@sealant/api-contracts-next 0.40.0-next.934 → 0.40.0-next.935
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/core-api/control-plane.d.ts +3896 -3758
- package/dist/core-api/workspaces.d.ts +477 -22
- package/dist/core-api/workspaces.js +224 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/network-policy.d.ts +113 -0
- package/dist/network-policy.js +292 -0
- package/package.json +6 -2
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
3
|
+
import { canonicalRevocationHost, brokeredSecretsProblems, brokeredSecretValuesProblems, networkPolicyProblems, } from "../network-policy.js";
|
|
3
4
|
import { boatFailureSchema } from "./boat-failures.js";
|
|
4
5
|
import { BudgetExceededError } from "./budgets.js";
|
|
5
6
|
import { connectedAccountProviderSchema } from "./connected-accounts.js";
|
|
6
7
|
import { EndpointUrl } from "./endpoint-url.js";
|
|
7
8
|
import { PersonId } from "./person-id.js";
|
|
9
|
+
import { refusalWords } from "./refusal-words.js";
|
|
8
10
|
import { runCommandSchema, runSchema } from "./runs.js";
|
|
9
11
|
import { workspaceProcessUserSchema } from "./sessions.js";
|
|
10
12
|
const NonEmptyString = Schema.String.check(Schema.isNonEmpty(), Schema.isTrimmed());
|
|
@@ -26,7 +28,71 @@ export const workspaceStatusSchema = Schema.Literals([
|
|
|
26
28
|
"retained",
|
|
27
29
|
]);
|
|
28
30
|
/** Request families. A deployment registers only the adapters it can actually launch. */
|
|
29
|
-
export const runtimeAdapterIds = [
|
|
31
|
+
export const runtimeAdapterIds = [
|
|
32
|
+
"docker",
|
|
33
|
+
"k8s",
|
|
34
|
+
"k3s",
|
|
35
|
+
"cloudflare",
|
|
36
|
+
"microvm",
|
|
37
|
+
"boat",
|
|
38
|
+
"host-vm",
|
|
39
|
+
];
|
|
40
|
+
/** Policy and secret refusals name the field they are about; they never hold a secret's value. */
|
|
41
|
+
const policyRefusalWords = refusalWords(/^(networkPolicy|brokeredSecrets|brokeredSecretValues|revocation)\b.*$/);
|
|
42
|
+
const PortNumber = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65_535 }));
|
|
43
|
+
const networkPolicyStructSchema = Schema.Struct({
|
|
44
|
+
mode: Schema.Literals(["standard", "restricted"]),
|
|
45
|
+
policyHash: NonEmptyString,
|
|
46
|
+
sourcePolicyId: Schema.optional(NonEmptyString),
|
|
47
|
+
sourcePolicyRevision: Schema.optional(Schema.Int),
|
|
48
|
+
requireVmIsolation: Schema.optional(Schema.Boolean),
|
|
49
|
+
allowHosts: Schema.optional(Schema.Array(Schema.Struct({
|
|
50
|
+
host: NonEmptyString,
|
|
51
|
+
ports: Schema.optional(Schema.Array(PortNumber)),
|
|
52
|
+
inspectTls: Schema.optional(Schema.Boolean),
|
|
53
|
+
methods: Schema.optional(Schema.Array(NonEmptyString)),
|
|
54
|
+
pathPrefixes: Schema.optional(Schema.Array(NonEmptyString)),
|
|
55
|
+
}))),
|
|
56
|
+
allowMirrors: Schema.optional(Schema.Array(Schema.Struct({
|
|
57
|
+
name: Schema.Literals(["npm", "docker"]),
|
|
58
|
+
host: NonEmptyString,
|
|
59
|
+
port: PortNumber,
|
|
60
|
+
}))),
|
|
61
|
+
allowResources: Schema.optional(Schema.Array(Schema.Struct({
|
|
62
|
+
name: NonEmptyString,
|
|
63
|
+
host: NonEmptyString,
|
|
64
|
+
port: PortNumber,
|
|
65
|
+
guestIp: NonEmptyString,
|
|
66
|
+
}))),
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* A workspace's network policy (`spec.networkPolicy`, workspace isolation architecture §8.4).
|
|
70
|
+
* `standard`: public internet less private, metadata and host addresses. `restricted`: only the
|
|
71
|
+
* hosts, mirrors and resources it lists. A Docker workspace with a `restricted` policy, or with
|
|
72
|
+
* any brokered secret, runs behind its own egress proxy. The rules are `networkPolicyProblems`'.
|
|
73
|
+
*/
|
|
74
|
+
export const networkPolicySchema = networkPolicyStructSchema.check(Schema.makeFilter((policy) => [...networkPolicyProblems(policy)], policyRefusalWords));
|
|
75
|
+
/**
|
|
76
|
+
* Project secrets the workspace never holds (`spec.brokeredSecrets`): it reads `placeholder` from
|
|
77
|
+
* `name`, and its egress proxy swaps in the real value, only inside `headerName` and only on
|
|
78
|
+
* HTTPS to one of `bindHosts`. The rules are `brokeredSecretsProblems`'.
|
|
79
|
+
*/
|
|
80
|
+
export const brokeredSecretsSchema = Schema.Array(Schema.Struct({
|
|
81
|
+
secretId: NonEmptyString,
|
|
82
|
+
name: NonEmptyString,
|
|
83
|
+
placeholder: NonEmptyString,
|
|
84
|
+
secretRef: NonEmptyString,
|
|
85
|
+
headerName: NonEmptyString,
|
|
86
|
+
bindHosts: Schema.Array(NonEmptyString),
|
|
87
|
+
methods: Schema.optional(Schema.Array(NonEmptyString)),
|
|
88
|
+
pathPrefixes: Schema.optional(Schema.Array(NonEmptyString)),
|
|
89
|
+
})).check(Schema.makeFilter((secrets) => [...brokeredSecretsProblems(secrets)], policyRefusalWords));
|
|
90
|
+
/**
|
|
91
|
+
* The values of a request's brokered secrets, keyed by each secret's `secretRef`. Sealed with the
|
|
92
|
+
* credential key at rest, handed only to the workspace's egress proxy, and never part of the spec,
|
|
93
|
+
* the workspace's environment or any read response.
|
|
94
|
+
*/
|
|
95
|
+
export const brokeredSecretValuesSchema = Schema.Record(Schema.String, Schema.String);
|
|
30
96
|
export const workspaceRuntimeSchema = Schema.Struct({
|
|
31
97
|
adapter: Schema.Literals(runtimeAdapterIds),
|
|
32
98
|
/**
|
|
@@ -248,6 +314,13 @@ export const createWorkspaceRequestSchema = Schema.Struct({
|
|
|
248
314
|
// reaching the daemon's boot secret file as `SEALANT_CAPTURE_TOKEN`; never the spec, the attempt
|
|
249
315
|
// snapshot, or any read response. Not retained: a capture workspace cannot be restarted in place.
|
|
250
316
|
captureToken: Schema.optional(NonEmptyString),
|
|
317
|
+
/**
|
|
318
|
+
* The values of the spec's `brokeredSecrets`, keyed by `secretRef`: required for each one, and
|
|
319
|
+
* refused without them. Sealed like `secretEnv`, but never delivered to the workspace: only its
|
|
320
|
+
* egress proxy receives them. Kept sealed for the workspace's life, so a restart and a restarted
|
|
321
|
+
* proxy get them again.
|
|
322
|
+
*/
|
|
323
|
+
brokeredSecretValues: Schema.optional(brokeredSecretValuesSchema),
|
|
251
324
|
// Per-create TTL override in seconds; when omitted the server default TTL (if configured)
|
|
252
325
|
// applies. The reaper stops the workspace once the TTL elapses.
|
|
253
326
|
ttlSeconds: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
@@ -817,6 +890,21 @@ export const runtimeSupportSchema = Schema.Struct({
|
|
|
817
890
|
]),
|
|
818
891
|
/** Whether a workspace that sits idle costs money, and the sentence that says so. */
|
|
819
892
|
idleCost: Schema.Struct({ charged: Schema.Boolean, message: NonEmptyString }),
|
|
893
|
+
/**
|
|
894
|
+
* What the runtime enforces of a network policy (`spec.networkPolicy`, `spec.brokeredSecrets`). A
|
|
895
|
+
* create that asks for an unsupported item is refused, never run with less. Absent from control
|
|
896
|
+
* planes that predate network policies.
|
|
897
|
+
*/
|
|
898
|
+
networkPolicy: Schema.optional(Schema.Struct({
|
|
899
|
+
/** The workspace in its own VM (`networkPolicy.requireVmIsolation`). */
|
|
900
|
+
vmIsolation: runtimeCapabilitySchema,
|
|
901
|
+
/** `networkPolicy.mode: "restricted"`. */
|
|
902
|
+
restricted: runtimeCapabilitySchema,
|
|
903
|
+
/** `restricted` together with Docker inside the workspace. */
|
|
904
|
+
restrictedWithDocker: runtimeCapabilitySchema,
|
|
905
|
+
/** Any `brokeredSecrets`, whatever the mode. */
|
|
906
|
+
brokeredSecrets: runtimeCapabilitySchema,
|
|
907
|
+
})),
|
|
820
908
|
});
|
|
821
909
|
/**
|
|
822
910
|
* The runtimes this install launches workspaces on, and what each supports. `default` is the one
|
|
@@ -1357,6 +1445,103 @@ export const workspaceGatewayHeadersSchema = Schema.Struct({
|
|
|
1357
1445
|
// removing a key ends what connections opened with it can still open.
|
|
1358
1446
|
"x-sealant-ssh-key-fingerprint": Schema.optional(NonEmptyString),
|
|
1359
1447
|
});
|
|
1448
|
+
/**
|
|
1449
|
+
* Apply an updated network policy to a workspace ("Apply updated policy", §7.3): its pinned policy
|
|
1450
|
+
* and brokered secrets are replaced, and a running egress proxy takes them at once. Revocations
|
|
1451
|
+
* always win: a secret id or host revoked earlier stays refused whatever this policy lists, so a
|
|
1452
|
+
* secret is granted again only under a new `secretId`. `brokeredSecretValues` carries a value for
|
|
1453
|
+
* every `secretRef` the new secrets name (values already held are not sent again only when no
|
|
1454
|
+
* secret is listed).
|
|
1455
|
+
*/
|
|
1456
|
+
export const applyWorkspaceNetworkPolicyRequestSchema = Schema.Struct({
|
|
1457
|
+
ownerUserId: PersonId,
|
|
1458
|
+
networkPolicy: networkPolicySchema,
|
|
1459
|
+
brokeredSecrets: Schema.optional(brokeredSecretsSchema),
|
|
1460
|
+
brokeredSecretValues: Schema.optional(brokeredSecretValuesSchema),
|
|
1461
|
+
}).check(Schema.makeFilter((request) => [
|
|
1462
|
+
...brokeredSecretValuesProblems(request.brokeredSecrets ?? [], request.brokeredSecretValues ?? {}),
|
|
1463
|
+
], policyRefusalWords));
|
|
1464
|
+
/**
|
|
1465
|
+
* What became of a policy update or a revocation on the workspace's running executor:
|
|
1466
|
+
*
|
|
1467
|
+
* - `enforced`: its egress proxy confirmed it (a revocation: after closing every matching stream).
|
|
1468
|
+
* - `pending`: it is stored, and the proxy has not confirmed it yet (it could not be reached). The
|
|
1469
|
+
* worker keeps pushing it; a revocation's unreachable proxy is killed, so nothing it revoked
|
|
1470
|
+
* stays reachable.
|
|
1471
|
+
* - `next-start`: it is stored, and no egress proxy runs for the workspace now (not running, or
|
|
1472
|
+
* running without one): it applies when the workspace next starts.
|
|
1473
|
+
*/
|
|
1474
|
+
export const workspaceNetworkPolicyEnforcementSchema = Schema.Literals([
|
|
1475
|
+
"enforced",
|
|
1476
|
+
"pending",
|
|
1477
|
+
"next-start",
|
|
1478
|
+
]);
|
|
1479
|
+
export const applyWorkspaceNetworkPolicyResponseSchema = Schema.Struct({
|
|
1480
|
+
workspaceId: NonEmptyString,
|
|
1481
|
+
policyHash: NonEmptyString,
|
|
1482
|
+
/** The workspace's revocation watermark: every revocation up to it holds. */
|
|
1483
|
+
revocationWatermark: Schema.Int,
|
|
1484
|
+
enforcement: workspaceNetworkPolicyEnforcementSchema,
|
|
1485
|
+
/** Streams the proxy closed because the new policy no longer allows them (`enforced` only). */
|
|
1486
|
+
closed: Schema.optional(Schema.Int),
|
|
1487
|
+
});
|
|
1488
|
+
/**
|
|
1489
|
+
* Revoke access on a workspace, durably: brokered secrets by id, hosts, or `all` grants. The
|
|
1490
|
+
* revocation is stored first, under a new revocation watermark, and holds for the workspace's life,
|
|
1491
|
+
* restarts included; a running egress proxy drops it and closes every matching stream before this
|
|
1492
|
+
* answers `enforced`. At least one of `secretIds`, `hosts` and `all`.
|
|
1493
|
+
*/
|
|
1494
|
+
export const revokeWorkspaceAccessRequestSchema = Schema.Struct({
|
|
1495
|
+
ownerUserId: PersonId,
|
|
1496
|
+
secretIds: Schema.optional(Schema.Array(NonEmptyString)),
|
|
1497
|
+
hosts: Schema.optional(Schema.Array(NonEmptyString)),
|
|
1498
|
+
all: Schema.optional(Schema.Boolean),
|
|
1499
|
+
}).check(Schema.makeFilter((request) => (request.secretIds?.length ?? 0) === 0 &&
|
|
1500
|
+
(request.hosts?.length ?? 0) === 0 &&
|
|
1501
|
+
request.all !== true
|
|
1502
|
+
? "revocation: name secretIds, hosts or all"
|
|
1503
|
+
: // A tombstone the proxy cannot read would refuse every later policy: refused here.
|
|
1504
|
+
(request.hosts ?? [])
|
|
1505
|
+
.filter((host) => canonicalRevocationHost(host) === undefined)
|
|
1506
|
+
.map((host) => `revocation: \`${host}\` is not a host a policy can name`), policyRefusalWords));
|
|
1507
|
+
export const revokeWorkspaceAccessResponseSchema = Schema.Struct({
|
|
1508
|
+
workspaceId: NonEmptyString,
|
|
1509
|
+
/** The watermark this revocation is stored under. */
|
|
1510
|
+
revocationWatermark: Schema.Int,
|
|
1511
|
+
enforcement: workspaceNetworkPolicyEnforcementSchema,
|
|
1512
|
+
/** Streams the proxy closed (`enforced` only). */
|
|
1513
|
+
closed: Schema.optional(Schema.Int),
|
|
1514
|
+
});
|
|
1515
|
+
export const getWorkspaceNetworkPolicyQuerySchema = Schema.Struct({
|
|
1516
|
+
ownerUserId: PersonId,
|
|
1517
|
+
});
|
|
1518
|
+
/** One stored revocation. */
|
|
1519
|
+
export const workspaceAccessRevocationSchema = Schema.Struct({
|
|
1520
|
+
revocationWatermark: Schema.Int,
|
|
1521
|
+
kind: Schema.Literals(["secret", "host", "all"]),
|
|
1522
|
+
/** The secret id or host; absent for `all`. */
|
|
1523
|
+
target: Schema.optional(NonEmptyString),
|
|
1524
|
+
revokedAt: NonEmptyString,
|
|
1525
|
+
});
|
|
1526
|
+
/**
|
|
1527
|
+
* A workspace's pinned network policy, its brokered secrets (never their values), every revocation
|
|
1528
|
+
* it holds, and what its running egress proxy last confirmed. `networkPolicy` is absent for a
|
|
1529
|
+
* workspace created without one.
|
|
1530
|
+
*/
|
|
1531
|
+
export const workspaceNetworkPolicySchema = Schema.Struct({
|
|
1532
|
+
workspaceId: NonEmptyString,
|
|
1533
|
+
networkPolicy: Schema.optional(networkPolicySchema),
|
|
1534
|
+
brokeredSecrets: brokeredSecretsSchema,
|
|
1535
|
+
revocationWatermark: Schema.Int,
|
|
1536
|
+
revocations: Schema.Array(workspaceAccessRevocationSchema),
|
|
1537
|
+
/** The current run's egress proxy; absent when the workspace has none. */
|
|
1538
|
+
proxy: Schema.optional(Schema.Struct({
|
|
1539
|
+
runId: NonEmptyString,
|
|
1540
|
+
/** The policy hash and watermark the proxy last confirmed; absent before its first. */
|
|
1541
|
+
confirmedPolicyHash: Schema.optional(NonEmptyString),
|
|
1542
|
+
confirmedRevocationWatermark: Schema.optional(Schema.Int),
|
|
1543
|
+
})),
|
|
1544
|
+
});
|
|
1360
1545
|
export class WorkspaceBadRequestError extends Schema.TaggedError()("WorkspaceBadRequestError", {
|
|
1361
1546
|
message: Schema.String,
|
|
1362
1547
|
}, { httpApiStatus: 400 }) {
|
|
@@ -1662,6 +1847,44 @@ HttpApiEndpoint.post("restartWorkspace", "/:workspaceId/restart", {
|
|
|
1662
1847
|
],
|
|
1663
1848
|
}))
|
|
1664
1849
|
.add(
|
|
1850
|
+
// Synchronous: stored, then pushed to the running egress proxy before this answers.
|
|
1851
|
+
HttpApiEndpoint.put("applyWorkspaceNetworkPolicy", "/:workspaceId/network-policy", {
|
|
1852
|
+
params: workspaceIdParams,
|
|
1853
|
+
payload: applyWorkspaceNetworkPolicyRequestSchema,
|
|
1854
|
+
success: applyWorkspaceNetworkPolicyResponseSchema,
|
|
1855
|
+
error: [
|
|
1856
|
+
WorkspaceBadRequestError,
|
|
1857
|
+
WorkspaceNotFoundError,
|
|
1858
|
+
// The runtime the workspace runs on cannot enforce the policy (a brokered secret where no
|
|
1859
|
+
// proxy runs, VM isolation on a container runtime).
|
|
1860
|
+
WorkspaceRuntimeRequirementUnsupportedError,
|
|
1861
|
+
// SEALANT_CREDENTIALS_KEY is not configured, so brokered values cannot be sealed.
|
|
1862
|
+
WorkspaceServiceUnavailableError,
|
|
1863
|
+
WorkspaceInternalServerError,
|
|
1864
|
+
],
|
|
1865
|
+
}))
|
|
1866
|
+
.add(
|
|
1867
|
+
// Synchronous: the revocation is stored first, then the proxy closes matching streams.
|
|
1868
|
+
HttpApiEndpoint.post("revokeWorkspaceAccess", "/:workspaceId/network-policy/revocations", {
|
|
1869
|
+
params: workspaceIdParams,
|
|
1870
|
+
payload: revokeWorkspaceAccessRequestSchema,
|
|
1871
|
+
success: revokeWorkspaceAccessResponseSchema,
|
|
1872
|
+
error: [
|
|
1873
|
+
WorkspaceBadRequestError,
|
|
1874
|
+
WorkspaceNotFoundError,
|
|
1875
|
+
// A host revocation on a runtime that runs no egress proxy, which alone refuses a host.
|
|
1876
|
+
WorkspaceRuntimeRequirementUnsupportedError,
|
|
1877
|
+
WorkspaceServiceUnavailableError,
|
|
1878
|
+
WorkspaceInternalServerError,
|
|
1879
|
+
],
|
|
1880
|
+
}))
|
|
1881
|
+
.add(HttpApiEndpoint.get("getWorkspaceNetworkPolicy", "/:workspaceId/network-policy", {
|
|
1882
|
+
params: workspaceIdParams,
|
|
1883
|
+
query: getWorkspaceNetworkPolicyQuerySchema,
|
|
1884
|
+
success: workspaceNetworkPolicySchema,
|
|
1885
|
+
error: [WorkspaceNotFoundError, WorkspaceInternalServerError],
|
|
1886
|
+
}))
|
|
1887
|
+
.add(
|
|
1665
1888
|
// A read, before any create: the runtimes this install launches and what each supports.
|
|
1666
1889
|
HttpApiEndpoint.get("listWorkspaceRuntimes", "/runtimes", {
|
|
1667
1890
|
success: workspaceRuntimesResponseSchema,
|
package/dist/index.d.ts
CHANGED
|
@@ -27,5 +27,6 @@ export * from "./core-api/boat-failures.js";
|
|
|
27
27
|
export * from "./workspace-environment.js";
|
|
28
28
|
export * from "./capture-owner-map.js";
|
|
29
29
|
export * from "./connected-account-selector.js";
|
|
30
|
+
export * from "./network-policy.js";
|
|
30
31
|
export { resourceDomainOwnerKindSchema, ResourceDomainOwnerDiffersError, type ResourceDomainOwnerKind, } from "./core-api/resource-domains.js";
|
|
31
32
|
export { resourceCallerReachSchema, resourceInstanceSecretEnvSchema, ResourceInstanceBusyError, ResourceInstanceBudgetError, RESOURCE_INSTANCE_BACKUP, type ResourceCallerReach, } from "./core-api/resource-instances.js";
|
package/dist/index.js
CHANGED
|
@@ -27,5 +27,6 @@ export * from "./core-api/boat-failures.js";
|
|
|
27
27
|
export * from "./workspace-environment.js";
|
|
28
28
|
export * from "./capture-owner-map.js";
|
|
29
29
|
export * from "./connected-account-selector.js";
|
|
30
|
+
export * from "./network-policy.js";
|
|
30
31
|
export { resourceDomainOwnerKindSchema, ResourceDomainOwnerDiffersError, } from "./core-api/resource-domains.js";
|
|
31
32
|
export { resourceCallerReachSchema, resourceInstanceSecretEnvSchema, ResourceInstanceBusyError, ResourceInstanceBudgetError, RESOURCE_INSTANCE_BACKUP, } from "./core-api/resource-instances.js";
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** `standard`: public internet less the blocked ranges. `restricted`: only what the policy lists. */
|
|
2
|
+
export type NetworkPolicyMode = "standard" | "restricted";
|
|
3
|
+
export interface NetworkPolicyAllowHost {
|
|
4
|
+
/** An exact host name or IP literal. Never a wildcard. */
|
|
5
|
+
readonly host: string;
|
|
6
|
+
/** The ports allowed on the host; default `[443]`. */
|
|
7
|
+
readonly ports?: readonly number[] | undefined;
|
|
8
|
+
/** Terminate and inspect TLS to this host (always so for a brokered secret's bind host). */
|
|
9
|
+
readonly inspectTls?: boolean | undefined;
|
|
10
|
+
/** HTTP methods allowed; inspected hosts only. */
|
|
11
|
+
readonly methods?: readonly string[] | undefined;
|
|
12
|
+
/** Path prefixes allowed, each starting with `/`; inspected hosts only. */
|
|
13
|
+
readonly pathPrefixes?: readonly string[] | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface NetworkPolicyMirror {
|
|
16
|
+
readonly name: "npm" | "docker";
|
|
17
|
+
readonly host: string;
|
|
18
|
+
readonly port: number;
|
|
19
|
+
}
|
|
20
|
+
export interface NetworkPolicyResource {
|
|
21
|
+
/** The name the workspace resolves (`db`, `cache`). */
|
|
22
|
+
readonly name: string;
|
|
23
|
+
/** Where the proxy relays it, on the worktree's reach network. */
|
|
24
|
+
readonly host: string;
|
|
25
|
+
readonly port: number;
|
|
26
|
+
/** The synthetic address the workspace sees, in `10.201.0.0/16`. */
|
|
27
|
+
readonly guestIp: string;
|
|
28
|
+
}
|
|
29
|
+
export interface NetworkPolicy {
|
|
30
|
+
readonly mode: NetworkPolicyMode;
|
|
31
|
+
/** The caller's canonical hash of the policy snapshot this workspace is pinned to. */
|
|
32
|
+
readonly policyHash: string;
|
|
33
|
+
readonly sourcePolicyId?: string | undefined;
|
|
34
|
+
readonly sourcePolicyRevision?: number | undefined;
|
|
35
|
+
/** The workspace must run in its own VM: a container runtime refuses it. */
|
|
36
|
+
readonly requireVmIsolation?: boolean | undefined;
|
|
37
|
+
readonly allowHosts?: readonly NetworkPolicyAllowHost[] | undefined;
|
|
38
|
+
readonly allowMirrors?: readonly NetworkPolicyMirror[] | undefined;
|
|
39
|
+
readonly allowResources?: readonly NetworkPolicyResource[] | undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A project secret the workspace never holds: it gets `placeholder` in `name`, and the proxy puts
|
|
43
|
+
* the real value in `headerName` only on HTTPS requests to one of `bindHosts`.
|
|
44
|
+
*/
|
|
45
|
+
export interface BrokeredSecret {
|
|
46
|
+
readonly secretId: string;
|
|
47
|
+
/**
|
|
48
|
+
* The environment variable the workspace reads the placeholder from. Delivered like a
|
|
49
|
+
* `secretEnv` entry (so `VERCEL_TOKEN` arrives), and reserved like one: platform and
|
|
50
|
+
* connected-account names (`GITHUB_TOKEN`, `HTTP_PROXY`, `SEALANT_*`) are refused.
|
|
51
|
+
*/
|
|
52
|
+
readonly name: string;
|
|
53
|
+
/** Opaque, at least 8 visible ASCII characters. */
|
|
54
|
+
readonly placeholder: string;
|
|
55
|
+
/** The key of the secret's value in the request's `brokeredSecretValues`. */
|
|
56
|
+
readonly secretRef: string;
|
|
57
|
+
readonly headerName: string;
|
|
58
|
+
readonly bindHosts: readonly string[];
|
|
59
|
+
readonly methods?: readonly string[] | undefined;
|
|
60
|
+
readonly pathPrefixes?: readonly string[] | undefined;
|
|
61
|
+
}
|
|
62
|
+
/** The lease the proxy holds traffic open for without hearing from sealant (§7.3). */
|
|
63
|
+
export declare const EGRESS_PROXY_LEASE_TTL_SECONDS = 120;
|
|
64
|
+
/** Synthetic addresses worktree resources are answered from. */
|
|
65
|
+
export declare const SYNTHETIC_RESOURCE_CIDR = "10.201.0.0/16";
|
|
66
|
+
export declare const NETWORK_POLICY_MAX_ALLOW_HOSTS = 256;
|
|
67
|
+
export declare const NETWORK_POLICY_MAX_RESOURCES = 64;
|
|
68
|
+
export declare const BROKERED_SECRETS_MAX = 64;
|
|
69
|
+
/** A brokered secret's value is one header value: bounded like one. */
|
|
70
|
+
export declare const BROKERED_SECRET_VALUE_MAX_LENGTH: number;
|
|
71
|
+
/**
|
|
72
|
+
* Header names that frame, route or authenticate the request to the proxy itself. A secret in
|
|
73
|
+
* one could change where the request goes or how it is read, so none may carry one. The same list
|
|
74
|
+
* as the proxy's `FORBIDDEN_SECRET_HEADERS`.
|
|
75
|
+
*/
|
|
76
|
+
export declare const FORBIDDEN_BROKERED_HEADER_NAMES: readonly string[];
|
|
77
|
+
/** Whether `name` is one HTTP header name (an RFC 9110 token). */
|
|
78
|
+
export declare const isHttpHeaderName: (name: string) => boolean;
|
|
79
|
+
/** Whether a secret in header `name` is refused: not one name, or one that frames or routes. */
|
|
80
|
+
export declare const brokeredHeaderNameProblem: (name: string) => string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Why `host` is not an exact policy host name, or `undefined` when it is one: lowercase DNS labels
|
|
83
|
+
* (letters, digits, `-`, `_`), or an IP literal when `allowIp`. Never a wildcard, a port, a path or
|
|
84
|
+
* a query: a policy names hosts, not URLs.
|
|
85
|
+
*/
|
|
86
|
+
export declare const policyHostProblem: (host: string, options: {
|
|
87
|
+
readonly allowIp: boolean;
|
|
88
|
+
}) => string | undefined;
|
|
89
|
+
/** Every rule `policy` breaks, in the words a create's refusal uses; empty when it breaks none. */
|
|
90
|
+
export declare const networkPolicyProblems: (policy: NetworkPolicy) => readonly string[];
|
|
91
|
+
/** Every rule `secrets` break; empty when they break none. Values are never read here. */
|
|
92
|
+
export declare const brokeredSecretsProblems: (secrets: readonly BrokeredSecret[]) => readonly string[];
|
|
93
|
+
/**
|
|
94
|
+
* The problems with the values a request sends for its brokered secrets: each `secretRef` needs a
|
|
95
|
+
* value, each value is one non-empty header value (no line breaks or control characters), and no
|
|
96
|
+
* value goes unused. Never echoes a value.
|
|
97
|
+
*/
|
|
98
|
+
export declare const brokeredSecretValuesProblems: (secrets: readonly BrokeredSecret[], values: Readonly<Record<string, string>>) => readonly string[];
|
|
99
|
+
/** Whether a workspace with this policy and these secrets runs behind its own egress proxy. */
|
|
100
|
+
export declare const needsEgressProxy: (input: {
|
|
101
|
+
readonly networkPolicy?: NetworkPolicy | undefined;
|
|
102
|
+
readonly brokeredSecrets?: readonly BrokeredSecret[] | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Hosts the workspace holds a durable revocation of: only a proxy refuses a host, so a workspace
|
|
105
|
+
* with one runs behind its proxy from then on, whatever its mode.
|
|
106
|
+
*/
|
|
107
|
+
readonly revokedHosts?: readonly string[] | undefined;
|
|
108
|
+
}) => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* A host as a revocation stores it: lowercase, no trailing dot, so a tombstone matches the host the
|
|
111
|
+
* proxy compares it with. `undefined` when it is not a host a policy could name.
|
|
112
|
+
*/
|
|
113
|
+
export declare const canonicalRevocationHost: (host: string) => string | undefined;
|