@decionis/agentsafe 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -20
- package/dist/Cli.js +20 -0
- package/dist/Cli.js.map +1 -1
- package/dist/Index.d.ts +22 -5
- package/dist/Index.d.ts.map +1 -1
- package/dist/Index.js +19 -2
- package/dist/Index.js.map +1 -1
- package/dist/TrustedExecutor.d.ts.map +1 -1
- package/dist/TrustedExecutor.js +1 -0
- package/dist/TrustedExecutor.js.map +1 -1
- package/dist/adapters/AdapterActionHandler.d.ts.map +1 -1
- package/dist/adapters/AdapterActionHandler.js +8 -4
- package/dist/adapters/AdapterActionHandler.js.map +1 -1
- package/dist/adapters/EffectAdapter.d.ts +6 -1
- package/dist/adapters/EffectAdapter.d.ts.map +1 -1
- package/dist/adapters/EffectAdapter.js +7 -1
- package/dist/adapters/EffectAdapter.js.map +1 -1
- package/dist/adapters/banking/CoreBankingHttpAdapter.d.ts.map +1 -1
- package/dist/adapters/banking/CoreBankingHttpAdapter.js +4 -4
- package/dist/adapters/banking/CoreBankingHttpAdapter.js.map +1 -1
- package/dist/adapters/cards/CardAuthorizationMatcher.d.ts +44 -0
- package/dist/adapters/cards/CardAuthorizationMatcher.d.ts.map +1 -0
- package/dist/adapters/cards/CardAuthorizationMatcher.js +39 -0
- package/dist/adapters/cards/CardAuthorizationMatcher.js.map +1 -0
- package/dist/adapters/cards/CardEffect.d.ts +52 -0
- package/dist/adapters/cards/CardEffect.d.ts.map +1 -0
- package/dist/adapters/cards/CardEffect.js +117 -0
- package/dist/adapters/cards/CardEffect.js.map +1 -0
- package/dist/adapters/cards/CardHandlers.d.ts +15 -0
- package/dist/adapters/cards/CardHandlers.d.ts.map +1 -0
- package/dist/adapters/cards/CardHandlers.js +26 -0
- package/dist/adapters/cards/CardHandlers.js.map +1 -0
- package/dist/adapters/cards/CardPurchase.d.ts +61 -0
- package/dist/adapters/cards/CardPurchase.d.ts.map +1 -0
- package/dist/adapters/cards/CardPurchase.js +116 -0
- package/dist/adapters/cards/CardPurchase.js.map +1 -0
- package/dist/adapters/cards/HeldCardGrants.d.ts +70 -0
- package/dist/adapters/cards/HeldCardGrants.d.ts.map +1 -0
- package/dist/adapters/cards/HeldCardGrants.js +79 -0
- package/dist/adapters/cards/HeldCardGrants.js.map +1 -0
- package/dist/adapters/cards/Pan.d.ts +17 -0
- package/dist/adapters/cards/Pan.d.ts.map +1 -0
- package/dist/adapters/cards/Pan.js +52 -0
- package/dist/adapters/cards/Pan.js.map +1 -0
- package/dist/adapters/mcp/McpGuard.d.ts +91 -0
- package/dist/adapters/mcp/McpGuard.d.ts.map +1 -0
- package/dist/adapters/mcp/McpGuard.js +147 -0
- package/dist/adapters/mcp/McpGuard.js.map +1 -0
- package/dist/adapters/mcp/McpIntentBinder.d.ts +54 -0
- package/dist/adapters/mcp/McpIntentBinder.d.ts.map +1 -0
- package/dist/adapters/mcp/McpIntentBinder.js +79 -0
- package/dist/adapters/mcp/McpIntentBinder.js.map +1 -0
- package/dist/adapters/mcp/McpInvocation.d.ts +55 -0
- package/dist/adapters/mcp/McpInvocation.d.ts.map +1 -0
- package/dist/adapters/mcp/McpInvocation.js +88 -0
- package/dist/adapters/mcp/McpInvocation.js.map +1 -0
- package/dist/audit/HashChain.d.ts +8 -2
- package/dist/audit/HashChain.d.ts.map +1 -1
- package/dist/audit/HashChain.js +14 -2
- package/dist/audit/HashChain.js.map +1 -1
- package/dist/boundary/BoundaryIdentity.d.ts +88 -0
- package/dist/boundary/BoundaryIdentity.d.ts.map +1 -0
- package/dist/boundary/BoundaryIdentity.js +126 -0
- package/dist/boundary/BoundaryIdentity.js.map +1 -0
- package/dist/cli/Commands.d.ts +1 -1
- package/dist/cli/Commands.d.ts.map +1 -1
- package/dist/cli/Commands.js +10 -0
- package/dist/cli/Commands.js.map +1 -1
- package/dist/cli/Edge.d.ts +4 -0
- package/dist/cli/Edge.d.ts.map +1 -0
- package/dist/cli/Edge.js +250 -0
- package/dist/cli/Edge.js.map +1 -0
- package/dist/cli/Help.d.ts.map +1 -1
- package/dist/cli/Help.js +9 -0
- package/dist/cli/Help.js.map +1 -1
- package/dist/cli/Host.d.ts +36 -0
- package/dist/cli/Host.d.ts.map +1 -0
- package/dist/cli/Host.js +247 -0
- package/dist/cli/Host.js.map +1 -0
- package/dist/cli/Identity.d.ts +47 -0
- package/dist/cli/Identity.d.ts.map +1 -0
- package/dist/cli/Identity.js +145 -0
- package/dist/cli/Identity.js.map +1 -0
- package/dist/cli/TcpBrokerCli.d.ts +4 -0
- package/dist/cli/TcpBrokerCli.d.ts.map +1 -0
- package/dist/cli/TcpBrokerCli.js +93 -0
- package/dist/cli/TcpBrokerCli.js.map +1 -0
- package/dist/cli/TcpClientCli.d.ts +16 -0
- package/dist/cli/TcpClientCli.d.ts.map +1 -0
- package/dist/cli/TcpClientCli.js +175 -0
- package/dist/cli/TcpClientCli.js.map +1 -0
- package/dist/cli/TestCommand.d.ts +8 -0
- package/dist/cli/TestCommand.d.ts.map +1 -1
- package/dist/cli/TestCommand.js +25 -5
- package/dist/cli/TestCommand.js.map +1 -1
- package/dist/config/ConfigKeys.d.ts +2 -2
- package/dist/config/ConfigKeys.d.ts.map +1 -1
- package/dist/config/ConfigKeys.js +19 -0
- package/dist/config/ConfigKeys.js.map +1 -1
- package/dist/config/ExecutorConfig.d.ts +62 -0
- package/dist/config/ExecutorConfig.d.ts.map +1 -1
- package/dist/config/ExecutorConfig.js +124 -0
- package/dist/config/ExecutorConfig.js.map +1 -1
- package/dist/edge/EdgeLicence.d.ts +25 -0
- package/dist/edge/EdgeLicence.d.ts.map +1 -0
- package/dist/edge/EdgeLicence.js +42 -0
- package/dist/edge/EdgeLicence.js.map +1 -0
- package/dist/edge/EdgeReplay.d.ts +45 -0
- package/dist/edge/EdgeReplay.d.ts.map +1 -0
- package/dist/edge/EdgeReplay.js +69 -0
- package/dist/edge/EdgeReplay.js.map +1 -0
- package/dist/edge/Entitlement.d.ts +57 -0
- package/dist/edge/Entitlement.d.ts.map +1 -0
- package/dist/edge/Entitlement.js +139 -0
- package/dist/edge/Entitlement.js.map +1 -0
- package/dist/edge/EntitlementEvaluation.d.ts +66 -0
- package/dist/edge/EntitlementEvaluation.d.ts.map +1 -0
- package/dist/edge/EntitlementEvaluation.js +74 -0
- package/dist/edge/EntitlementEvaluation.js.map +1 -0
- package/dist/edge/UsageCount.d.ts +40 -0
- package/dist/edge/UsageCount.d.ts.map +1 -0
- package/dist/edge/UsageCount.js +140 -0
- package/dist/edge/UsageCount.js.map +1 -0
- package/dist/edge/UsageKeyRegistration.d.ts +34 -0
- package/dist/edge/UsageKeyRegistration.d.ts.map +1 -0
- package/dist/edge/UsageKeyRegistration.js +74 -0
- package/dist/edge/UsageKeyRegistration.js.map +1 -0
- package/dist/edge/UsageMeter.d.ts +89 -0
- package/dist/edge/UsageMeter.d.ts.map +1 -0
- package/dist/edge/UsageMeter.js +275 -0
- package/dist/edge/UsageMeter.js.map +1 -0
- package/dist/edge/UsagePeriod.d.ts +23 -0
- package/dist/edge/UsagePeriod.d.ts.map +1 -0
- package/dist/edge/UsagePeriod.js +31 -0
- package/dist/edge/UsagePeriod.js.map +1 -0
- package/dist/edge/UsageReport.d.ts +92 -0
- package/dist/edge/UsageReport.d.ts.map +1 -0
- package/dist/edge/UsageReport.js +153 -0
- package/dist/edge/UsageReport.js.map +1 -0
- package/dist/edge/UsageTally.d.ts +63 -0
- package/dist/edge/UsageTally.d.ts.map +1 -0
- package/dist/edge/UsageTally.js +89 -0
- package/dist/edge/UsageTally.js.map +1 -0
- package/dist/egress/EgressError.d.ts +7 -1
- package/dist/egress/EgressError.d.ts.map +1 -1
- package/dist/egress/EgressError.js.map +1 -1
- package/dist/egress/EgressPolicy.d.ts +16 -3
- package/dist/egress/EgressPolicy.d.ts.map +1 -1
- package/dist/egress/EgressPolicy.js +33 -3
- package/dist/egress/EgressPolicy.js.map +1 -1
- package/dist/egress/GuardedFetch.d.ts +38 -1
- package/dist/egress/GuardedFetch.d.ts.map +1 -1
- package/dist/egress/GuardedFetch.js +52 -7
- package/dist/egress/GuardedFetch.js.map +1 -1
- package/dist/egress/TcpClient.d.ts +103 -0
- package/dist/egress/TcpClient.d.ts.map +1 -0
- package/dist/egress/TcpClient.js +490 -0
- package/dist/egress/TcpClient.js.map +1 -0
- package/dist/egress/TcpControlClient.d.ts +49 -0
- package/dist/egress/TcpControlClient.d.ts.map +1 -0
- package/dist/egress/TcpControlClient.js +186 -0
- package/dist/egress/TcpControlClient.js.map +1 -0
- package/dist/gateway/AuthorityAttacks.d.ts +39 -0
- package/dist/gateway/AuthorityAttacks.d.ts.map +1 -0
- package/dist/gateway/AuthorityAttacks.js +158 -0
- package/dist/gateway/AuthorityAttacks.js.map +1 -0
- package/dist/gateway/ForwardHandler.d.ts.map +1 -1
- package/dist/gateway/ForwardHandler.js +7 -4
- package/dist/gateway/ForwardHandler.js.map +1 -1
- package/dist/gateway/Gateway.d.ts +197 -10
- package/dist/gateway/Gateway.d.ts.map +1 -1
- package/dist/gateway/Gateway.js +524 -63
- package/dist/gateway/Gateway.js.map +1 -1
- package/dist/gateway/GatewayConfig.d.ts +78 -0
- package/dist/gateway/GatewayConfig.d.ts.map +1 -1
- package/dist/gateway/GatewayConfig.js +167 -2
- package/dist/gateway/GatewayConfig.js.map +1 -1
- package/dist/gateway/GatewayReport.d.ts +31 -1
- package/dist/gateway/GatewayReport.d.ts.map +1 -1
- package/dist/gateway/GatewayReport.js +12 -0
- package/dist/gateway/GatewayReport.js.map +1 -1
- package/dist/gateway/InterceptedRequest.d.ts +9 -2
- package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
- package/dist/gateway/InterceptedRequest.js +41 -9
- package/dist/gateway/InterceptedRequest.js.map +1 -1
- package/dist/gateway/RateLimit.d.ts +29 -0
- package/dist/gateway/RateLimit.d.ts.map +1 -0
- package/dist/gateway/RateLimit.js +33 -0
- package/dist/gateway/RateLimit.js.map +1 -0
- package/dist/gateway/RefusalSampler.d.ts +28 -0
- package/dist/gateway/RefusalSampler.d.ts.map +1 -0
- package/dist/gateway/RefusalSampler.js +52 -0
- package/dist/gateway/RefusalSampler.js.map +1 -0
- package/dist/gateway/RouteTable.d.ts +3 -0
- package/dist/gateway/RouteTable.d.ts.map +1 -1
- package/dist/gateway/RouteTable.js +44 -7
- package/dist/gateway/RouteTable.js.map +1 -1
- package/dist/gateway/Upstream.d.ts +26 -0
- package/dist/gateway/Upstream.d.ts.map +1 -1
- package/dist/gateway/Upstream.js +41 -2
- package/dist/gateway/Upstream.js.map +1 -1
- package/dist/gateway/UpstreamProof.d.ts +235 -0
- package/dist/gateway/UpstreamProof.d.ts.map +1 -0
- package/dist/gateway/UpstreamProof.js +375 -0
- package/dist/gateway/UpstreamProof.js.map +1 -0
- package/dist/handlers/ForwardRequestHandler.d.ts +5 -1
- package/dist/handlers/ForwardRequestHandler.d.ts.map +1 -1
- package/dist/handlers/ForwardRequestHandler.js +12 -2
- package/dist/handlers/ForwardRequestHandler.js.map +1 -1
- package/dist/hosted/TenantHost.d.ts +180 -0
- package/dist/hosted/TenantHost.d.ts.map +1 -0
- package/dist/hosted/TenantHost.js +432 -0
- package/dist/hosted/TenantHost.js.map +1 -0
- package/dist/hosted/TenantRegistry.d.ts +73 -0
- package/dist/hosted/TenantRegistry.d.ts.map +1 -0
- package/dist/hosted/TenantRegistry.js +123 -0
- package/dist/hosted/TenantRegistry.js.map +1 -0
- package/dist/http/ExecutorHttpServer.d.ts +7 -0
- package/dist/http/ExecutorHttpServer.d.ts.map +1 -1
- package/dist/http/ExecutorHttpServer.js +30 -5
- package/dist/http/ExecutorHttpServer.js.map +1 -1
- package/dist/http/GatewayHttpServer.d.ts +55 -3
- package/dist/http/GatewayHttpServer.d.ts.map +1 -1
- package/dist/http/GatewayHttpServer.js +157 -17
- package/dist/http/GatewayHttpServer.js.map +1 -1
- package/dist/http/RedirectServer.d.ts +26 -0
- package/dist/http/RedirectServer.d.ts.map +1 -0
- package/dist/http/RedirectServer.js +62 -0
- package/dist/http/RedirectServer.js.map +1 -0
- package/dist/http/Routes.d.ts +17 -0
- package/dist/http/Routes.d.ts.map +1 -1
- package/dist/http/Routes.js +21 -0
- package/dist/http/Routes.js.map +1 -1
- package/dist/http/TcpBroker.d.ts +57 -0
- package/dist/http/TcpBroker.d.ts.map +1 -0
- package/dist/http/TcpBroker.js +299 -0
- package/dist/http/TcpBroker.js.map +1 -0
- package/dist/http/TcpHostRelay.d.ts +24 -0
- package/dist/http/TcpHostRelay.d.ts.map +1 -0
- package/dist/http/TcpHostRelay.js +194 -0
- package/dist/http/TcpHostRelay.js.map +1 -0
- package/dist/http/TcpRelayStreams.d.ts +24 -0
- package/dist/http/TcpRelayStreams.d.ts.map +1 -0
- package/dist/http/TcpRelayStreams.js +128 -0
- package/dist/http/TcpRelayStreams.js.map +1 -0
- package/dist/http/TlsListener.d.ts +3 -1
- package/dist/http/TlsListener.d.ts.map +1 -1
- package/dist/http/TlsListener.js +7 -2
- package/dist/http/TlsListener.js.map +1 -1
- package/dist/identity/PrincipalsFile.d.ts +3 -1
- package/dist/identity/PrincipalsFile.d.ts.map +1 -1
- package/dist/identity/PrincipalsFile.js +1 -0
- package/dist/identity/PrincipalsFile.js.map +1 -1
- package/dist/incident/Metrics.d.ts +2 -0
- package/dist/incident/Metrics.d.ts.map +1 -1
- package/dist/incident/Metrics.js +10 -0
- package/dist/incident/Metrics.js.map +1 -1
- package/dist/incident/SecurityEvents.d.ts +89 -0
- package/dist/incident/SecurityEvents.d.ts.map +1 -1
- package/dist/incident/SecurityEvents.js +93 -2
- package/dist/incident/SecurityEvents.js.map +1 -1
- package/dist/journal/ExecutionJournal.d.ts +27 -0
- package/dist/journal/ExecutionJournal.d.ts.map +1 -1
- package/dist/journal/ExecutionJournal.js +28 -0
- package/dist/journal/ExecutionJournal.js.map +1 -1
- package/dist/journal/FileExecutionJournal.d.ts +2 -1
- package/dist/journal/FileExecutionJournal.d.ts.map +1 -1
- package/dist/journal/FileExecutionJournal.js +4 -1
- package/dist/journal/FileExecutionJournal.js.map +1 -1
- package/dist/journal/InMemoryExecutionJournal.d.ts +2 -1
- package/dist/journal/InMemoryExecutionJournal.d.ts.map +1 -1
- package/dist/journal/InMemoryExecutionJournal.js +4 -1
- package/dist/journal/InMemoryExecutionJournal.js.map +1 -1
- package/dist/provenance/DockerProvenanceProvider.d.ts +23 -0
- package/dist/provenance/DockerProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/DockerProvenanceProvider.js +24 -0
- package/dist/provenance/DockerProvenanceProvider.js.map +1 -0
- package/dist/provenance/KubernetesProvenanceProvider.d.ts +17 -0
- package/dist/provenance/KubernetesProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/KubernetesProvenanceProvider.js +18 -0
- package/dist/provenance/KubernetesProvenanceProvider.js.map +1 -0
- package/dist/provenance/NoneProvenanceProvider.d.ts +15 -0
- package/dist/provenance/NoneProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/NoneProvenanceProvider.js +16 -0
- package/dist/provenance/NoneProvenanceProvider.js.map +1 -0
- package/dist/provenance/ProvenanceProvider.d.ts +94 -0
- package/dist/provenance/ProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/ProvenanceProvider.js +118 -0
- package/dist/provenance/ProvenanceProvider.js.map +1 -0
- package/dist/provenance/StaticProvenanceProvider.d.ts +18 -0
- package/dist/provenance/StaticProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/StaticProvenanceProvider.js +25 -0
- package/dist/provenance/StaticProvenanceProvider.js.map +1 -0
- package/dist/service/AuthorityClients.d.ts +8 -1
- package/dist/service/AuthorityClients.d.ts.map +1 -1
- package/dist/service/AuthorityClients.js +33 -5
- package/dist/service/AuthorityClients.js.map +1 -1
- package/dist/service/EdgeRuntime.d.ts +73 -0
- package/dist/service/EdgeRuntime.d.ts.map +1 -0
- package/dist/service/EdgeRuntime.js +209 -0
- package/dist/service/EdgeRuntime.js.map +1 -0
- package/dist/service/EscalationResolver.d.ts +82 -2
- package/dist/service/EscalationResolver.d.ts.map +1 -1
- package/dist/service/EscalationResolver.js +39 -3
- package/dist/service/EscalationResolver.js.map +1 -1
- package/dist/service/Requests.d.ts +28 -2
- package/dist/service/Requests.d.ts.map +1 -1
- package/dist/service/TrustedExecutorService.d.ts +71 -1
- package/dist/service/TrustedExecutorService.d.ts.map +1 -1
- package/dist/service/TrustedExecutorService.js +461 -27
- package/dist/service/TrustedExecutorService.js.map +1 -1
- package/dist/tcp/TcpWire.d.ts +18 -0
- package/dist/tcp/TcpWire.d.ts.map +1 -0
- package/dist/tcp/TcpWire.js +114 -0
- package/dist/tcp/TcpWire.js.map +1 -0
- package/dist/verify/VerifyAuditChain.d.ts +5 -0
- package/dist/verify/VerifyAuditChain.d.ts.map +1 -1
- package/dist/verify/VerifyAuditChain.js +20 -4
- package/dist/verify/VerifyAuditChain.js.map +1 -1
- package/package.json +7 -3
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
import { CONSEQUENTIAL_METHODS, } from "./GatewayConfig.js";
|
|
2
2
|
const SEGMENT_WILDCARD = "*";
|
|
3
3
|
const TREE_WILDCARD = "**";
|
|
4
|
+
const SAFE_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
|
|
5
|
+
const AMBIGUOUS_PATH_CHARACTERS = new Set(["\\", "%", ";", "?", "#"]);
|
|
4
6
|
function segmentsOf(path) {
|
|
5
7
|
return path.split("/").filter((segment) => segment !== "");
|
|
6
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Match decoded literal characters without rewriting the forwarded path.
|
|
11
|
+
* Refuse encodings that change segment boundaries or admit another decoding
|
|
12
|
+
* or path-parameter interpretation at the upstream's router.
|
|
13
|
+
*/
|
|
14
|
+
function routingSegments(path) {
|
|
15
|
+
let decoded;
|
|
16
|
+
try {
|
|
17
|
+
decoded = decodeURIComponent(path);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (path.split("/").length !== decoded.split("/").length)
|
|
23
|
+
return null;
|
|
24
|
+
for (const character of decoded) {
|
|
25
|
+
const code = character.charCodeAt(0);
|
|
26
|
+
if (AMBIGUOUS_PATH_CHARACTERS.has(character) || code < 32 || code === 127)
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const segments = segmentsOf(decoded);
|
|
30
|
+
if (segments.some((segment) => segment === "." || segment === ".."))
|
|
31
|
+
return null;
|
|
32
|
+
return segments;
|
|
33
|
+
}
|
|
7
34
|
function matches(pattern, path) {
|
|
8
35
|
let index = 0;
|
|
9
36
|
for (; index < pattern.length; index += 1) {
|
|
@@ -37,11 +64,14 @@ export class RouteTable {
|
|
|
37
64
|
constructor(routes, unmatched, enabled = true) {
|
|
38
65
|
this.unmatched = unmatched;
|
|
39
66
|
this.enabled = enabled;
|
|
40
|
-
this.routes = routes.map((config) =>
|
|
41
|
-
config
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
this.routes = routes.map((config) => {
|
|
68
|
+
const segments = routingSegments(config.path);
|
|
69
|
+
// Pattern syntax is literal configuration. Encoded wildcards must not
|
|
70
|
+
// turn into routing operators as a side effect of decoding.
|
|
71
|
+
if (segments === null || config.path.includes("%"))
|
|
72
|
+
throw new Error("ROUTE_PATH_AMBIGUOUS");
|
|
73
|
+
return { config, segments, methods: new Set(config.methods) };
|
|
74
|
+
});
|
|
45
75
|
}
|
|
46
76
|
/** Every action name this table can produce, for the registry to be sealed over. */
|
|
47
77
|
actions() {
|
|
@@ -54,11 +84,18 @@ export class RouteTable {
|
|
|
54
84
|
if (!this.enabled)
|
|
55
85
|
return { kind: "PASSTHROUGH", reason: "DISABLED" };
|
|
56
86
|
const upper = method.toUpperCase();
|
|
57
|
-
if (
|
|
87
|
+
if (SAFE_METHODS.has(upper)) {
|
|
58
88
|
return { kind: "PASSTHROUGH", reason: "SAFE_METHOD" };
|
|
59
89
|
}
|
|
90
|
+
// WebDAV and extension methods can mutate state too. A method outside
|
|
91
|
+
// this execution contract cannot inherit the privilege of a safe read.
|
|
92
|
+
if (!CONSEQUENTIAL_METHODS.includes(upper)) {
|
|
93
|
+
return { kind: "REFUSE", code: "HTTP_METHOD_UNSUPPORTED" };
|
|
94
|
+
}
|
|
60
95
|
const consequential = upper;
|
|
61
|
-
const path =
|
|
96
|
+
const path = routingSegments(pathname);
|
|
97
|
+
if (path === null)
|
|
98
|
+
return { kind: "REFUSE", code: "HTTP_PATH_AMBIGUOUS" };
|
|
62
99
|
for (const route of this.routes) {
|
|
63
100
|
if (route.methods.has(consequential) && matches(route.segments, path)) {
|
|
64
101
|
return { kind: "GOVERN", action: route.config.action, route: route.config };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteTable.js","sourceRoot":"","sources":["../../src/gateway/RouteTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAItB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"RouteTable.js","sourceRoot":"","sources":["../../src/gateway/RouteTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAItB,MAAM,oBAAoB,CAAC;AAQ5B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAC9E,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAc3F,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,IAA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,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC/E,CAAC;CACF"}
|
|
@@ -15,7 +15,32 @@ export interface UpstreamOptions {
|
|
|
15
15
|
readonly timeoutMs: number;
|
|
16
16
|
readonly maxResponseBytes: number;
|
|
17
17
|
readonly fetch: FetchLike;
|
|
18
|
+
/** Releases what the transport holds open, such as a guarded egress's sockets. */
|
|
19
|
+
readonly close?: () => void;
|
|
20
|
+
/** Relay every cookie host-only, whatever `Domain` the upstream named (a hosted gateway). */
|
|
21
|
+
readonly hostOnlyCookies?: boolean;
|
|
22
|
+
/** Relay every response under a sandboxing content security policy (a hosted gateway). */
|
|
23
|
+
readonly sandboxed?: boolean;
|
|
18
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The policy a hosted gateway adds to every relayed response. A browser
|
|
27
|
+
* renders the response as a unique, opaque origin: no script runs, so a page
|
|
28
|
+
* one tenant's upstream serves cannot set a cookie for the shared domain
|
|
29
|
+
* from script (which no `Set-Cookie` rewrite would see), and nothing it
|
|
30
|
+
* renders is same-origin with its own host. It is added beside any policy the
|
|
31
|
+
* upstream sent, and a browser enforces every policy it is given, so the
|
|
32
|
+
* upstream's own can only narrow it further.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SANDBOX_POLICY = "sandbox";
|
|
35
|
+
/**
|
|
36
|
+
* A `Set-Cookie` value without its `Domain` attribute, so the client keeps
|
|
37
|
+
* the cookie for the exact host it came from. Behind a hosted gateway every
|
|
38
|
+
* tenant is a sibling host under one domain; a cookie one tenant's upstream
|
|
39
|
+
* set for the parent would otherwise be sent to every other tenant. The
|
|
40
|
+
* name and value are the first segment and are never touched, whatever they
|
|
41
|
+
* contain.
|
|
42
|
+
*/
|
|
43
|
+
export declare function hostOnlyCookie(value: string): string;
|
|
19
44
|
/**
|
|
20
45
|
* The one way the gateway reaches the upstream. It rebuilds the request
|
|
21
46
|
* from what it is given: the upstream origin from the configuration, the
|
|
@@ -40,6 +65,7 @@ export declare class Upstream {
|
|
|
40
65
|
send(method: string, path: string, search: string, headers: Readonly<Record<string, string>>, body: Buffer, signal: AbortSignal): Promise<UpstreamResult>;
|
|
41
66
|
/** The whole body, or a refusal once it passes the bound; never a partial relay. */
|
|
42
67
|
private static read;
|
|
68
|
+
close(): void;
|
|
43
69
|
/** The signal for one send: the configured ceiling, or a tighter budget the caller holds. */
|
|
44
70
|
signal(budgetMs?: number): AbortSignal;
|
|
45
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Upstream.d.ts","sourceRoot":"","sources":["../../src/gateway/Upstream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"Upstream.d.ts","sourceRoot":"","sources":["../../src/gateway/Upstream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,6FAA6F;AAC7F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,kFAAkF;AAClF,qBAAa,wBAAyB,SAAQ,KAAK;;CAKlD;AAiCD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,KAAK,CAAC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_HEADER } from "./GatewayConfig.js";
|
|
1
2
|
/** Thrown when the upstream's response body is longer than the gateway relays. */
|
|
2
3
|
export class UpstreamResponseTooLarge extends Error {
|
|
3
4
|
constructor() {
|
|
@@ -26,6 +27,8 @@ const REQUEST_OWNED = new Set([
|
|
|
26
27
|
"x-forwarded-proto",
|
|
27
28
|
"x-forwarded-host",
|
|
28
29
|
]);
|
|
30
|
+
/** The gateway's own credentials a client presents to it; they end at the gateway. */
|
|
31
|
+
const GATEWAY_CREDENTIALS = new Set([TENANT_KEY_HEADER]);
|
|
29
32
|
/** Response headers the relay recomputes, because it relays decoded bytes of a known length. */
|
|
30
33
|
const RESPONSE_OWNED = new Set(["content-length", "content-encoding"]);
|
|
31
34
|
const BODYLESS_METHODS = new Set(["GET", "HEAD"]);
|
|
@@ -33,6 +36,32 @@ const BODYLESS_METHODS = new Set(["GET", "HEAD"]);
|
|
|
33
36
|
const EVIDENCE_HEADER_PREFIX = "x-agent-safe-";
|
|
34
37
|
/** The headers the gateway sends the caller about the decision; an upstream may not set them. */
|
|
35
38
|
const RELAY_HEADER_PREFIX = "agentsafe-";
|
|
39
|
+
/**
|
|
40
|
+
* The policy a hosted gateway adds to every relayed response. A browser
|
|
41
|
+
* renders the response as a unique, opaque origin: no script runs, so a page
|
|
42
|
+
* one tenant's upstream serves cannot set a cookie for the shared domain
|
|
43
|
+
* from script (which no `Set-Cookie` rewrite would see), and nothing it
|
|
44
|
+
* renders is same-origin with its own host. It is added beside any policy the
|
|
45
|
+
* upstream sent, and a browser enforces every policy it is given, so the
|
|
46
|
+
* upstream's own can only narrow it further.
|
|
47
|
+
*/
|
|
48
|
+
export const SANDBOX_POLICY = "sandbox";
|
|
49
|
+
/**
|
|
50
|
+
* A `Set-Cookie` value without its `Domain` attribute, so the client keeps
|
|
51
|
+
* the cookie for the exact host it came from. Behind a hosted gateway every
|
|
52
|
+
* tenant is a sibling host under one domain; a cookie one tenant's upstream
|
|
53
|
+
* set for the parent would otherwise be sent to every other tenant. The
|
|
54
|
+
* name and value are the first segment and are never touched, whatever they
|
|
55
|
+
* contain.
|
|
56
|
+
*/
|
|
57
|
+
export function hostOnlyCookie(value) {
|
|
58
|
+
const [pair, ...attributes] = value.split(";");
|
|
59
|
+
const kept = attributes.filter((attribute) => {
|
|
60
|
+
const name = attribute.split("=", 1)[0]?.trim().toLowerCase();
|
|
61
|
+
return name !== "domain";
|
|
62
|
+
});
|
|
63
|
+
return [pair, ...kept].join(";");
|
|
64
|
+
}
|
|
36
65
|
/**
|
|
37
66
|
* The one way the gateway reaches the upstream. It rebuilds the request
|
|
38
67
|
* from what it is given: the upstream origin from the configuration, the
|
|
@@ -70,6 +99,7 @@ export class Upstream {
|
|
|
70
99
|
// a caller's spelling of one is dropped so it can never be mistaken for it.
|
|
71
100
|
if (HOP_BY_HOP.has(name) ||
|
|
72
101
|
REQUEST_OWNED.has(name) ||
|
|
102
|
+
GATEWAY_CREDENTIALS.has(name) ||
|
|
73
103
|
connectionNamed.has(name) ||
|
|
74
104
|
name.startsWith(EVIDENCE_HEADER_PREFIX)) {
|
|
75
105
|
continue;
|
|
@@ -117,8 +147,14 @@ export class Upstream {
|
|
|
117
147
|
}
|
|
118
148
|
relayed.push([name, value]);
|
|
119
149
|
}
|
|
120
|
-
for (const cookie of response.headers.getSetCookie())
|
|
121
|
-
relayed.push([
|
|
150
|
+
for (const cookie of response.headers.getSetCookie()) {
|
|
151
|
+
relayed.push([
|
|
152
|
+
"set-cookie",
|
|
153
|
+
this.options.hostOnlyCookies === true ? hostOnlyCookie(cookie) : cookie,
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
if (this.options.sandboxed === true)
|
|
157
|
+
relayed.push(["content-security-policy", SANDBOX_POLICY]);
|
|
122
158
|
return {
|
|
123
159
|
status: response.status,
|
|
124
160
|
headers: relayed,
|
|
@@ -150,6 +186,9 @@ export class Upstream {
|
|
|
150
186
|
}
|
|
151
187
|
return Buffer.concat(chunks);
|
|
152
188
|
}
|
|
189
|
+
close() {
|
|
190
|
+
this.options.close?.();
|
|
191
|
+
}
|
|
153
192
|
/** The signal for one send: the configured ceiling, or a tighter budget the caller holds. */
|
|
154
193
|
signal(budgetMs = this.options.timeoutMs) {
|
|
155
194
|
return AbortSignal.timeout(Math.max(Math.min(budgetMs, this.options.timeoutMs), 1));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Upstream.js","sourceRoot":"","sources":["../../src/gateway/Upstream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Upstream.js","sourceRoot":"","sources":["../../src/gateway/Upstream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAUvD,kFAAkF;AAClF,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD;QACE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IAC9C,YAAY;IACZ,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,kBAAkB;IAClB,IAAI;IACJ,SAAS;IACT,mBAAmB;IACnB,SAAS;CACV,CAAC,CAAC;AACH,6FAA6F;AAC7F,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC;IACjD,MAAM;IACN,gBAAgB;IAChB,QAAQ;IACR,iBAAiB;IACjB,mBAAmB;IACnB,kBAAkB;CACnB,CAAC,CAAC;AACH,sFAAsF;AACtF,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAC9E,gGAAgG;AAChG,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAC5F,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;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AE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAI,IAAI;oBAAE,MAAM;gBAChB,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC;gBACzB,IAAI,IAAI,GAAG,QAAQ;oBAAE,MAAM,IAAI,wBAAwB,EAAE,CAAC;gBAC1D,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,IAAI,GAAG,QAAQ;gBAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,6FAA6F;IACtF,MAAM,CAAC,WAAmB,IAAI,CAAC,OAAO,CAAC,SAAS;QACrD,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;CACF"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { type AddressResolver } from "../egress/GuardedFetch.js";
|
|
2
|
+
import type { FetchLike } from "../handlers/HandlerRegistration.js";
|
|
3
|
+
import { type SecurityEvent } from "../incident/SecurityEvents.js";
|
|
4
|
+
/**
|
|
5
|
+
* Where an upstream's origin serves its proof: one fixed path, so a token is
|
|
6
|
+
* never part of a URL and an origin that echoes its URL cannot serve one.
|
|
7
|
+
*/
|
|
8
|
+
export declare const UPSTREAM_PROOF_PATH = "/.well-known/agentsafe-upstream";
|
|
9
|
+
/** The label a TXT proof is published under, in front of the upstream's host name. */
|
|
10
|
+
export declare const UPSTREAM_PROOF_TXT_LABEL = "_agentsafe-challenge";
|
|
11
|
+
/** The header a forwarded answer carries while its upstream's proof is missing. */
|
|
12
|
+
export declare const UPSTREAM_PROOF_HEADER = "agentsafe-upstream-proof";
|
|
13
|
+
/** The most a proof file, or one TXT record, may be; anything longer is not a proof. */
|
|
14
|
+
export declare const MAX_PROOF_BYTES = 1024;
|
|
15
|
+
/** The TXT records read at the proof's name, in the order the resolver gives them. */
|
|
16
|
+
export declare const MAX_PROOF_RECORDS = 32;
|
|
17
|
+
export declare const PROOF_TIMEOUT_MS = 10000;
|
|
18
|
+
/** A proven upstream is checked again a day later, give or take the jitter. */
|
|
19
|
+
export declare const PROOF_RECHECK_MS: number;
|
|
20
|
+
export declare const PROOF_JITTER_MS: number;
|
|
21
|
+
/** While a proof is missing it is looked for every hour, and the gateway forwards for the grace. */
|
|
22
|
+
export declare const PROOF_MISSING_RECHECK_MS: number;
|
|
23
|
+
export declare const PROOF_GRACE_MS: number;
|
|
24
|
+
/** While the gateway forwards nothing, it looks every minute. */
|
|
25
|
+
export declare const PROOF_PENDING_RETRY_MS = 60000;
|
|
26
|
+
/**
|
|
27
|
+
* Whom a proof is for: the tenant's id, the Decionis organization it runs
|
|
28
|
+
* under, and the upstream's origin as the WHATWG URL spells it (lower-case
|
|
29
|
+
* host, no default port, no path). The base path is never part of it: the
|
|
30
|
+
* gateway is sealed to the whole origin, so the proof covers the whole origin.
|
|
31
|
+
*/
|
|
32
|
+
export interface ProofBinding {
|
|
33
|
+
readonly tenant: string;
|
|
34
|
+
readonly org: string;
|
|
35
|
+
readonly origin: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The token that proves an origin for a tenant and an organization, issued
|
|
39
|
+
* at a time in Unix seconds: `v1.<issued>.<base64url of the first 16 bytes
|
|
40
|
+
* of SHA-256("agentsafe-upstream\nv1\n" + tenant + "\n" + org + "\n" +
|
|
41
|
+
* origin + "\n" + issued)>`. There is no secret in it: whoever asks for a
|
|
42
|
+
* token is given it, and what proves control is that only the origin's
|
|
43
|
+
* controller can serve it there.
|
|
44
|
+
*/
|
|
45
|
+
export declare function proofToken(binding: ProofBinding, issued: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Whether any candidate, trimmed of white space at its ends and nothing
|
|
48
|
+
* else, is a token bound to this tenant, organization and origin, at any
|
|
49
|
+
* issue time: its age is onboarding's concern, never a recheck's.
|
|
50
|
+
*/
|
|
51
|
+
export declare function provesUpstream(candidates: readonly string[], binding: ProofBinding): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* A proof file's lines. A comment, a blank line and anything else that is not
|
|
54
|
+
* a token never proves anything, so nothing needs removing; a byte-order
|
|
55
|
+
* mark at the start is dropped and a line's carriage return is trimmed with
|
|
56
|
+
* its spaces. A body that is not UTF-8 has no lines at all, whatever one of
|
|
57
|
+
* them might hold: onboarding refuses such a file whole, and so does this.
|
|
58
|
+
*/
|
|
59
|
+
export declare function proofLines(body: Uint8Array): readonly string[];
|
|
60
|
+
export type ProofMethod = "file" | "dns";
|
|
61
|
+
/**
|
|
62
|
+
* What one check found. `missing` is definitive: the origin answered over
|
|
63
|
+
* verified TLS and served no token bound to the tenant. `unreachable` is no
|
|
64
|
+
* answer at all, which says nothing about the proof.
|
|
65
|
+
*/
|
|
66
|
+
export type ProofOutcome = {
|
|
67
|
+
readonly kind: "proven";
|
|
68
|
+
readonly method: ProofMethod;
|
|
69
|
+
} | {
|
|
70
|
+
readonly kind: "missing";
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: "unreachable";
|
|
73
|
+
readonly code: string;
|
|
74
|
+
};
|
|
75
|
+
/** TXT lookup as `dns.promises.resolveTxt` answers it: each record as its strings. */
|
|
76
|
+
export type TxtResolver = (name: string) => Promise<string[][]>;
|
|
77
|
+
export interface UpstreamProofCheckOptions {
|
|
78
|
+
readonly resolveTxt: TxtResolver;
|
|
79
|
+
/** Name resolution for the GET; the system resolver when absent. */
|
|
80
|
+
readonly resolve?: AddressResolver;
|
|
81
|
+
/** A transport under the guard, for a test; `node:https` when absent. */
|
|
82
|
+
readonly transport?: FetchLike;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* One look at whether an upstream's origin serves a token bound to its
|
|
86
|
+
* tenant. The GET goes through a guarded egress of the check's own, sealed
|
|
87
|
+
* to the origin and the proof's path: public addresses only, a loopback name
|
|
88
|
+
* refused, TLS verified against the public roots, redirects never followed,
|
|
89
|
+
* at most 1 KiB, and no header of the tenant's. When the origin answers
|
|
90
|
+
* without a token, a TXT record at `_agentsafe-challenge.<host>` may prove it
|
|
91
|
+
* instead; a record alone never does, because DNS is not authenticated and
|
|
92
|
+
* only an answer over verified TLS ties the name to the origin traffic
|
|
93
|
+
* reaches. Nothing it reads is kept or written anywhere: what it returns is
|
|
94
|
+
* an outcome and a code.
|
|
95
|
+
*/
|
|
96
|
+
export declare class UpstreamProofCheck {
|
|
97
|
+
private readonly binding;
|
|
98
|
+
private readonly guard;
|
|
99
|
+
private readonly resolveTxt;
|
|
100
|
+
constructor(binding: ProofBinding, options: UpstreamProofCheckOptions);
|
|
101
|
+
/** Looks once. Never rejects: every failure is an outcome. */
|
|
102
|
+
check(): Promise<ProofOutcome>;
|
|
103
|
+
close(): void;
|
|
104
|
+
/** The TXT record at the origin's name, once the origin has answered; an address has no name. */
|
|
105
|
+
private txt;
|
|
106
|
+
private static codeOf;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Where a tenant's proof stands in this process. `pending`: not yet seen;
|
|
110
|
+
* `verified`: seen, by file or by TXT; `missing`: gone since a time, and
|
|
111
|
+
* forwarded for the grace after it; `unverified`: not served when first
|
|
112
|
+
* looked for, or gone for longer than the grace.
|
|
113
|
+
*/
|
|
114
|
+
export type ProofState = {
|
|
115
|
+
readonly kind: "pending";
|
|
116
|
+
} | {
|
|
117
|
+
readonly kind: "verified";
|
|
118
|
+
readonly method: ProofMethod;
|
|
119
|
+
} | {
|
|
120
|
+
readonly kind: "missing";
|
|
121
|
+
readonly since: number;
|
|
122
|
+
} | {
|
|
123
|
+
readonly kind: "unverified";
|
|
124
|
+
};
|
|
125
|
+
/** What a change of state is reported as, on the tenant's security stream, before its origin. */
|
|
126
|
+
export type ProofEvent = {
|
|
127
|
+
readonly event: "UPSTREAM_PROOF_MISSING";
|
|
128
|
+
readonly stops_at: string;
|
|
129
|
+
} | {
|
|
130
|
+
readonly event: "UPSTREAM_UNVERIFIED";
|
|
131
|
+
readonly code: "UPSTREAM_PROOF_NOT_SERVED" | "UPSTREAM_PROOF_GRACE_ENDED";
|
|
132
|
+
} | {
|
|
133
|
+
readonly event: "UPSTREAM_PROOF_RESTORED";
|
|
134
|
+
readonly method: ProofMethod;
|
|
135
|
+
};
|
|
136
|
+
export interface ProofStep {
|
|
137
|
+
readonly state: ProofState;
|
|
138
|
+
readonly event: ProofEvent | null;
|
|
139
|
+
}
|
|
140
|
+
/** What a tenant's request gets: forwarded, forwarded and marked, or refused. */
|
|
141
|
+
export type ProofAdmission = "FORWARD" | "MISSING" | "REFUSE";
|
|
142
|
+
export declare const PENDING: ProofState;
|
|
143
|
+
/**
|
|
144
|
+
* The state after a check's outcome at a time. A proof seen is verified,
|
|
145
|
+
* and restores a tenant that had lost it. A grace that has run out ends in
|
|
146
|
+
* unverified, whatever the check found short of a proof. A miss starts the
|
|
147
|
+
* grace for a verified tenant, and makes a tenant never seen unverified. An
|
|
148
|
+
* origin that did not answer changes nothing.
|
|
149
|
+
*/
|
|
150
|
+
export declare function advance(state: ProofState, outcome: ProofOutcome, now: number): ProofStep;
|
|
151
|
+
/** What a request gets in a state at a time: the grace ends on the clock, not at the next check. */
|
|
152
|
+
export declare function admission(state: ProofState, now: number): ProofAdmission;
|
|
153
|
+
/**
|
|
154
|
+
* How long until the next check, with `random` in [0, 1): a day either side
|
|
155
|
+
* of an hour once verified, so a fleet's checks do not fall together; every
|
|
156
|
+
* hour while missing, and at the end of the grace; every minute otherwise.
|
|
157
|
+
*/
|
|
158
|
+
export declare function nextCheckIn(state: ProofState, now: number, random: number): number;
|
|
159
|
+
/** What the operator's status shows of a tenant's proof: its state and times, never its text. */
|
|
160
|
+
export interface ProofSnapshot {
|
|
161
|
+
readonly state: ProofState["kind"];
|
|
162
|
+
readonly method: ProofMethod | null;
|
|
163
|
+
readonly checked_at: string | null;
|
|
164
|
+
readonly stops_at: string | null;
|
|
165
|
+
/** Why the last check had no answer, when it had none. */
|
|
166
|
+
readonly code: string | null;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Whether a proof kept for one binding holds for another: the same tenant,
|
|
170
|
+
* organization and origin, all three. A gateway rebuilt with any of them
|
|
171
|
+
* changed looks from the start, so an edit to a registry entry never carries
|
|
172
|
+
* a proof over to a binding no origin has proved.
|
|
173
|
+
*/
|
|
174
|
+
export declare function sameBinding(kept: ProofBinding, binding: ProofBinding): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Where a tenant's proof stands, whole: its state, when it was last looked
|
|
177
|
+
* at and why that look had no answer, when the next look is due, and whether
|
|
178
|
+
* any look has ended. A gateway built to replace another takes it over as it
|
|
179
|
+
* stands at the swap, so a rebuild neither forgets the last look nor moves
|
|
180
|
+
* the next one.
|
|
181
|
+
*/
|
|
182
|
+
export interface ProofStanding {
|
|
183
|
+
readonly state: ProofState;
|
|
184
|
+
readonly checkedAt: number | null;
|
|
185
|
+
readonly code: string | null;
|
|
186
|
+
/** When the next look is due; null while one is in flight, so whoever takes over looks at once. */
|
|
187
|
+
readonly dueAt: number | null;
|
|
188
|
+
readonly settled: boolean;
|
|
189
|
+
}
|
|
190
|
+
export interface UpstreamProofMonitorOptions {
|
|
191
|
+
readonly origin: string;
|
|
192
|
+
/** One look; never rejects. */
|
|
193
|
+
readonly check: () => Promise<ProofOutcome>;
|
|
194
|
+
/** Puts a change of state on the tenant's security stream. */
|
|
195
|
+
readonly report: (event: SecurityEvent) => void;
|
|
196
|
+
readonly clock: () => number;
|
|
197
|
+
readonly random: () => number;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* A tenant's proof, kept: looked at once when nothing is known, or taken
|
|
201
|
+
* over from the monitor it replaces, then on the cadence its state sets, each
|
|
202
|
+
* change reported. It holds no socket and no timer that keeps a process alive.
|
|
203
|
+
*/
|
|
204
|
+
export declare class UpstreamProofMonitor {
|
|
205
|
+
private readonly options;
|
|
206
|
+
private state;
|
|
207
|
+
private settledOnce;
|
|
208
|
+
private checkedAt;
|
|
209
|
+
private lastCode;
|
|
210
|
+
private dueAt;
|
|
211
|
+
private timer;
|
|
212
|
+
private stopped;
|
|
213
|
+
constructor(options: UpstreamProofMonitorOptions);
|
|
214
|
+
/** Looks now: nothing is known yet. */
|
|
215
|
+
start(): void;
|
|
216
|
+
/**
|
|
217
|
+
* Takes up a proof where another monitor bound the same way left it: its
|
|
218
|
+
* state and last look as they were, and its next look when it was due, or
|
|
219
|
+
* at once when that monitor was stopped with a look in flight.
|
|
220
|
+
*/
|
|
221
|
+
resume(standing: ProofStanding): void;
|
|
222
|
+
/** Whether a look has finished, here or in the monitor this one took over from. */
|
|
223
|
+
get settled(): boolean;
|
|
224
|
+
get current(): ProofState;
|
|
225
|
+
/** Everything another monitor needs to go on from here; read it once this one is stopped. */
|
|
226
|
+
standing(): ProofStanding;
|
|
227
|
+
admits(): ProofAdmission;
|
|
228
|
+
snapshot(): ProofSnapshot;
|
|
229
|
+
/** No further look, and a look in flight changes nothing when it ends. */
|
|
230
|
+
stop(): void;
|
|
231
|
+
private run;
|
|
232
|
+
/** The next look, at a time; one already due runs at once. */
|
|
233
|
+
private schedule;
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=UpstreamProof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpstreamProof.d.ts","sourceRoot":"","sources":["../../src/gateway/UpstreamProof.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAA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