@fusionkit/plane 0.1.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/dist/auth.d.ts +18 -0
- package/dist/auth.js +46 -0
- package/dist/claim-token-service.d.ts +23 -0
- package/dist/claim-token-service.js +54 -0
- package/dist/contract-service.d.ts +14 -0
- package/dist/contract-service.js +39 -0
- package/dist/domain-errors.d.ts +13 -0
- package/dist/domain-errors.js +31 -0
- package/dist/idp.d.ts +26 -0
- package/dist/idp.js +24 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +21 -0
- package/dist/keys.d.ts +60 -0
- package/dist/keys.js +132 -0
- package/dist/logging.d.ts +21 -0
- package/dist/logging.js +42 -0
- package/dist/plane.d.ts +167 -0
- package/dist/plane.js +606 -0
- package/dist/policy.d.ts +23 -0
- package/dist/policy.js +92 -0
- package/dist/ratelimit.d.ts +40 -0
- package/dist/ratelimit.js +94 -0
- package/dist/receipt-service.d.ts +16 -0
- package/dist/receipt-service.js +17 -0
- package/dist/retention.d.ts +33 -0
- package/dist/retention.js +123 -0
- package/dist/run-lifecycle.d.ts +2 -0
- package/dist/run-lifecycle.js +19 -0
- package/dist/secrets.d.ts +25 -0
- package/dist/secrets.js +73 -0
- package/dist/server.d.ts +38 -0
- package/dist/server.js +418 -0
- package/dist/sqlite-store.d.ts +53 -0
- package/dist/sqlite-store.js +401 -0
- package/dist/store.d.ts +107 -0
- package/dist/store.js +9 -0
- package/dist/test/api.test.d.ts +1 -0
- package/dist/test/api.test.js +179 -0
- package/dist/test/hardening.test.d.ts +1 -0
- package/dist/test/hardening.test.js +259 -0
- package/dist/test/policy.test.d.ts +1 -0
- package/dist/test/policy.test.js +78 -0
- package/dist/test/server-hardening.test.d.ts +1 -0
- package/dist/test/server-hardening.test.js +192 -0
- package/dist/test/ui-parity.test.d.ts +1 -0
- package/dist/test/ui-parity.test.js +28 -0
- package/dist/validation.d.ts +326 -0
- package/dist/validation.js +178 -0
- package/package.json +34 -0
- package/ui/app.css +276 -0
- package/ui/app.js +483 -0
- package/ui/index.html +65 -0
package/dist/plane.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { ActorRef, ChainedEvent, ClaimResult, DisclosureReport, Policy, PolicyDecision, Receipt, ReceiptBundle, RunnerSummary, RunSummary } from "@fusionkit/protocol";
|
|
2
|
+
import type { Capability, Principal } from "./auth.js";
|
|
3
|
+
import type { IdpVerifier } from "./idp.js";
|
|
4
|
+
import { Metrics } from "./logging.js";
|
|
5
|
+
import type { Logger } from "./logging.js";
|
|
6
|
+
import { RetentionSweeper } from "./retention.js";
|
|
7
|
+
import { SecretStore } from "./secrets.js";
|
|
8
|
+
import type { PlaneStore, PrincipalRole, RunRecord, RunRequest } from "./store.js";
|
|
9
|
+
export type PlaneConfig = {
|
|
10
|
+
dataDir: string;
|
|
11
|
+
policy: Policy;
|
|
12
|
+
planePrivateKeyPem: string;
|
|
13
|
+
planePublicKeyPem: string;
|
|
14
|
+
/** Bootstrap admin principal token. */
|
|
15
|
+
adminToken: string;
|
|
16
|
+
/** Bootstrap reusable enroller credential (also accepts single-use tokens). */
|
|
17
|
+
enrollToken: string;
|
|
18
|
+
secretStore: SecretStore;
|
|
19
|
+
/** Inject a store (tests); defaults to SQLite at <dataDir>/<sqliteFilename>. */
|
|
20
|
+
store?: PlaneStore;
|
|
21
|
+
/** Verifier for IdP-issued approval assertions, when configured. */
|
|
22
|
+
idp?: IdpVerifier;
|
|
23
|
+
logger?: Logger;
|
|
24
|
+
metrics?: Metrics;
|
|
25
|
+
/** Start the background retention sweeper. Defaults to false. */
|
|
26
|
+
startRetention?: boolean;
|
|
27
|
+
/** Timeouts, sizes, and names; sensible defaults below. */
|
|
28
|
+
tuning?: Partial<PlaneTuning>;
|
|
29
|
+
};
|
|
30
|
+
/** Tunable plane parameters. Defaults are in DEFAULT_PLANE_TUNING. */
|
|
31
|
+
export type PlaneTuning = {
|
|
32
|
+
/** Validity of a runner claim token. */
|
|
33
|
+
claimTokenTtlMs: number;
|
|
34
|
+
/** Validity of an issued run contract. */
|
|
35
|
+
contractTtlMs: number;
|
|
36
|
+
/** How long a completion nonce is retained past claim-token expiry. */
|
|
37
|
+
nonceTtlMs: number;
|
|
38
|
+
/** Default validity of a minted single-use enroll token. */
|
|
39
|
+
enrollTokenTtlMs: number;
|
|
40
|
+
/** Random bytes of entropy in issued principal/runner/enroll tokens. */
|
|
41
|
+
tokenBytes: number;
|
|
42
|
+
/** SQLite database filename under dataDir. */
|
|
43
|
+
sqliteFilename: string;
|
|
44
|
+
/** Bootstrap principal names. */
|
|
45
|
+
bootstrapAdminName: string;
|
|
46
|
+
bootstrapEnrollerName: string;
|
|
47
|
+
};
|
|
48
|
+
export declare const DEFAULT_PLANE_TUNING: PlaneTuning;
|
|
49
|
+
export type { ClaimResult, DisclosureReport, PolicyDecision };
|
|
50
|
+
export type IssuedPrincipal = {
|
|
51
|
+
principalId: string;
|
|
52
|
+
name: string;
|
|
53
|
+
role: PrincipalRole;
|
|
54
|
+
token: string;
|
|
55
|
+
};
|
|
56
|
+
export declare class Plane {
|
|
57
|
+
private readonly config;
|
|
58
|
+
private readonly store;
|
|
59
|
+
private readonly policyHash;
|
|
60
|
+
private readonly receipts;
|
|
61
|
+
private readonly claimTokens;
|
|
62
|
+
private readonly contracts;
|
|
63
|
+
private readonly logger;
|
|
64
|
+
private readonly idp?;
|
|
65
|
+
readonly metrics: Metrics;
|
|
66
|
+
private readonly sweeper;
|
|
67
|
+
private readonly tuning;
|
|
68
|
+
constructor(config: PlaneConfig);
|
|
69
|
+
/** Ensure the bootstrap admin and enroller principals match the config. */
|
|
70
|
+
private seedBootstrapPrincipals;
|
|
71
|
+
/** Mint a fresh bearer token with the configured entropy. */
|
|
72
|
+
private newToken;
|
|
73
|
+
private upsertPrincipal;
|
|
74
|
+
close(): void;
|
|
75
|
+
get blobs(): PlaneStore;
|
|
76
|
+
get policySnapshot(): {
|
|
77
|
+
policy: Policy;
|
|
78
|
+
policyHash: string;
|
|
79
|
+
};
|
|
80
|
+
get log(): Logger;
|
|
81
|
+
/** Run one retention pass synchronously (also used by tests). */
|
|
82
|
+
sweepRetention(): ReturnType<RetentionSweeper["sweepOnce"]>;
|
|
83
|
+
/** Resolve a bearer token to a principal, or undefined if invalid/revoked. */
|
|
84
|
+
authenticate(token: string | undefined): Principal | undefined;
|
|
85
|
+
authorize(token: string | undefined, capability: Capability): Principal | undefined;
|
|
86
|
+
/** Backward-compatible admin check used by older callers. */
|
|
87
|
+
checkAdminToken(token: string | undefined): boolean;
|
|
88
|
+
issuePrincipal(name: string, role: PrincipalRole): IssuedPrincipal;
|
|
89
|
+
rotatePrincipal(name: string): {
|
|
90
|
+
token: string;
|
|
91
|
+
};
|
|
92
|
+
revokePrincipal(name: string): boolean;
|
|
93
|
+
listPrincipals(): {
|
|
94
|
+
name: string;
|
|
95
|
+
role: PrincipalRole;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
revoked: boolean;
|
|
98
|
+
}[];
|
|
99
|
+
/** Mint a single-use, expiring runner enrollment token. */
|
|
100
|
+
issueEnrollToken(options?: {
|
|
101
|
+
pool?: string;
|
|
102
|
+
ttlMs?: number;
|
|
103
|
+
}): {
|
|
104
|
+
token: string;
|
|
105
|
+
expiresAt: string;
|
|
106
|
+
};
|
|
107
|
+
enrollRunner(input: {
|
|
108
|
+
enrollToken: string;
|
|
109
|
+
publicKeyPem: string;
|
|
110
|
+
pool: string;
|
|
111
|
+
}): {
|
|
112
|
+
runnerId: string;
|
|
113
|
+
runnerToken: string;
|
|
114
|
+
};
|
|
115
|
+
listRunners(): RunnerSummary[];
|
|
116
|
+
listRuns(): RunSummary[];
|
|
117
|
+
private authRunner;
|
|
118
|
+
private buildSecretClaims;
|
|
119
|
+
private evaluateRequest;
|
|
120
|
+
dryRun(request: Omit<RunRequest, "runId">): DisclosureReport;
|
|
121
|
+
requestRun(request: Omit<RunRequest, "runId">): RunRecord;
|
|
122
|
+
private continuationEvents;
|
|
123
|
+
approve(runId: string, actor: ActorRef, verified?: {
|
|
124
|
+
idpSubject: string;
|
|
125
|
+
idpIssuer: string;
|
|
126
|
+
}): RunRecord;
|
|
127
|
+
cancel(runId: string, actor: ActorRef): RunRecord;
|
|
128
|
+
private issueContract;
|
|
129
|
+
private appendPlaneEvents;
|
|
130
|
+
claim(input: {
|
|
131
|
+
runnerToken: string;
|
|
132
|
+
pool: string;
|
|
133
|
+
}): ClaimResult | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Single decoder for claim tokens: verifies the plane signature, validates
|
|
136
|
+
* every payload field is present and well-formed, and checks expiry.
|
|
137
|
+
* Throws on any defect; both public verifiers below build on this.
|
|
138
|
+
*/
|
|
139
|
+
private parseClaimToken;
|
|
140
|
+
/**
|
|
141
|
+
* Verify a claim token's plane signature, payload shape, and expiry, plus
|
|
142
|
+
* that the named run is actually claimed by the named runner. Used to
|
|
143
|
+
* authorize artifact blob uploads from a runner holding an active claim;
|
|
144
|
+
* unlike verifyClaimToken it does not require the caller to know the run
|
|
145
|
+
* id ahead of time, but it still enforces the token's own run binding.
|
|
146
|
+
*/
|
|
147
|
+
verifyClaimTokenSignature(token: string): boolean;
|
|
148
|
+
private verifyClaimToken;
|
|
149
|
+
appendRunnerEvents(runId: string, claimToken: string, events: ChainedEvent[]): void;
|
|
150
|
+
complete(runId: string, claimToken: string, receipt: Receipt): Receipt;
|
|
151
|
+
getRun(runId: string): RunRecord | undefined;
|
|
152
|
+
getEvents(runId: string): ChainedEvent[];
|
|
153
|
+
getBundle(runId: string): ReceiptBundle | undefined;
|
|
154
|
+
exportJsonl(sinceIso?: string): string;
|
|
155
|
+
/**
|
|
156
|
+
* Readiness: store reachable and the signing keypair actually usable —
|
|
157
|
+
* the private key must parse and its public half must match the
|
|
158
|
+
* configured public key, so a plane with mismatched key material reports
|
|
159
|
+
* not-ready instead of issuing unverifiable contracts.
|
|
160
|
+
*/
|
|
161
|
+
ready(): boolean;
|
|
162
|
+
verifyIdpToken(token: string): Promise<{
|
|
163
|
+
idpSubject: string;
|
|
164
|
+
idpIssuer: string;
|
|
165
|
+
}>;
|
|
166
|
+
private mustGetRun;
|
|
167
|
+
}
|