@signet-registry/operator 0.0.0-stage → 0.1.3
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/LICENSE +28 -0
- package/README.md +191 -2
- package/dist/clients/api.js +245 -0
- package/dist/clients/mcp.js +118 -0
- package/dist/clients/verify.js +71 -0
- package/dist/config/env.js +42 -0
- package/dist/keyless.js +52 -0
- package/dist/main.js +7 -0
- package/dist/operator.js +1498 -0
- package/dist/transparency/sample-graph.js +203 -0
- package/dist/types.js +111 -0
- package/examples/bootstrap/agents/bootstrap-agent.md +5 -0
- package/examples/bootstrap/agents/bootstrap-ops-agent.md +8 -0
- package/examples/bootstrap/bootstrap.manifest.json +107 -0
- package/examples/bootstrap/skills/bootstrap-example.md +8 -0
- package/examples/bootstrap/skills/bootstrap-ops.md +8 -0
- package/examples/demo/agents/registry-agent.md +34 -0
- package/examples/demo/demo.manifest.json +90 -0
- package/examples/demo/skills/registry-mcp.md +74 -0
- package/examples/demo/skills/tame-llama.md +37 -0
- package/examples/signet-demo/agents/signet-demo-agent.md +39 -0
- package/examples/signet-demo/agents/signet-security-agent.md +36 -0
- package/examples/signet-demo/signet-demo.manifest.json +219 -0
- package/examples/signet-demo/skills/access-review.md +40 -0
- package/examples/signet-demo/skills/certification-workflow.md +39 -0
- package/examples/signet-demo/skills/governance-audit.md +39 -0
- package/examples/signet-demo/skills/graph-explorer.md +38 -0
- package/examples/signet-demo/skills/mcp-onboarding.md +39 -0
- package/examples/signet-demo/skills/policy-authoring.md +39 -0
- package/examples/signet-demo/skills/provenance-audit.md +39 -0
- package/examples/signet-demo/skills/registry-search.md +38 -0
- package/examples/signet-demo/skills/secrets-hygiene.md +39 -0
- package/examples/signet-demo/skills/skill-authoring.md +40 -0
- package/examples/transparency/README.md +39 -0
- package/examples/transparency/sample-graph.spec.json +16 -0
- package/package.json +52 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
function defaultRepoRoot() {
|
|
5
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
return path.resolve(here, '..', '..', '..', '..');
|
|
7
|
+
}
|
|
8
|
+
function defaultApiEnvFile() {
|
|
9
|
+
return path.join(defaultRepoRoot(), 'service', 'api', 'infra', '.env');
|
|
10
|
+
}
|
|
11
|
+
function defaultWebappEnvFile() {
|
|
12
|
+
return path.join(defaultRepoRoot(), 'service', 'webapp', 'knowledge-manager', 'infra', '.env');
|
|
13
|
+
}
|
|
14
|
+
function defaultMcpEnvFile() {
|
|
15
|
+
return path.join(defaultRepoRoot(), 'service', 'mcp', 'infra', '.env');
|
|
16
|
+
}
|
|
17
|
+
const EnvSchema = z.object({
|
|
18
|
+
API_ORIGIN: z.string().url().default('http://localhost:3100'),
|
|
19
|
+
MCP_ORIGIN: z.string().url().default('http://localhost:3000'),
|
|
20
|
+
WEBAPP_ORIGIN: z.string().url().default('http://localhost:3200'),
|
|
21
|
+
REPO_ROOT: z.string().default(defaultRepoRoot()),
|
|
22
|
+
API_ENV_FILE: z.string().default(defaultApiEnvFile()),
|
|
23
|
+
WEBAPP_ENV_FILE: z.string().default(defaultWebappEnvFile()),
|
|
24
|
+
MCP_ENV_FILE: z.string().default(defaultMcpEnvFile()),
|
|
25
|
+
// Cloudflare Access service-token headers for the deployed tunnels
|
|
26
|
+
// (machine clients outside the edge access layer). Both must be set to take effect.
|
|
27
|
+
SIGNET_CF_ACCESS_CLIENT_ID: z.string().optional(),
|
|
28
|
+
SIGNET_CF_ACCESS_CLIENT_SECRET: z.string().optional(),
|
|
29
|
+
});
|
|
30
|
+
export function loadEnv(input = process.env) {
|
|
31
|
+
return EnvSchema.parse(input);
|
|
32
|
+
}
|
|
33
|
+
/** Cloudflare Access headers for machine clients, when configured. */
|
|
34
|
+
export function cfAccessHeaders(env) {
|
|
35
|
+
if (env.SIGNET_CF_ACCESS_CLIENT_ID && env.SIGNET_CF_ACCESS_CLIENT_SECRET) {
|
|
36
|
+
return {
|
|
37
|
+
'CF-Access-Client-Id': env.SIGNET_CF_ACCESS_CLIENT_ID,
|
|
38
|
+
'CF-Access-Client-Secret': env.SIGNET_CF_ACCESS_CLIENT_SECRET,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {};
|
|
42
|
+
}
|
package/dist/keyless.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { bundleToJSON } from '@sigstore/bundle';
|
|
2
|
+
import { X509Certificate } from '@sigstore/core';
|
|
3
|
+
import { CIContextProvider, FulcioSigner, MessageSignatureBundleBuilder, RekorWitness } from '@sigstore/sign';
|
|
4
|
+
const OIDC_ISSUER_OID_V1 = '1.3.6.1.4.1.57264.1.1';
|
|
5
|
+
const OIDC_ISSUER_OID_V2 = '1.3.6.1.4.1.57264.1.8';
|
|
6
|
+
function oidcIssuerFromCertificate(cert) {
|
|
7
|
+
const v2 = cert.extension(OIDC_ISSUER_OID_V2);
|
|
8
|
+
if (v2) {
|
|
9
|
+
const value = v2.valueObj?.subs?.[0]?.value;
|
|
10
|
+
if (value)
|
|
11
|
+
return value.toString('ascii');
|
|
12
|
+
}
|
|
13
|
+
const v1 = cert.extension(OIDC_ISSUER_OID_V1);
|
|
14
|
+
return v1 ? v1.value.toString('ascii') : undefined;
|
|
15
|
+
}
|
|
16
|
+
function readBundleIdentity(bundle) {
|
|
17
|
+
const material = bundle['verificationMaterial'];
|
|
18
|
+
const chain = material?.['x509CertificateChain'];
|
|
19
|
+
const certificate = material?.['certificate'] ?? chain?.certificates?.[0];
|
|
20
|
+
const rawBytes = certificate?.['rawBytes'];
|
|
21
|
+
if (typeof rawBytes !== 'string') {
|
|
22
|
+
throw new Error('Fulcio bundle does not carry a signing certificate.');
|
|
23
|
+
}
|
|
24
|
+
const cert = X509Certificate.parse(Buffer.from(rawBytes, 'base64'));
|
|
25
|
+
const identity = cert.subjectAltName;
|
|
26
|
+
const issuer = oidcIssuerFromCertificate(cert);
|
|
27
|
+
if (!identity || !issuer) {
|
|
28
|
+
throw new Error('Signing certificate is missing its subject alternative name or OIDC issuer.');
|
|
29
|
+
}
|
|
30
|
+
return { identity, issuer };
|
|
31
|
+
}
|
|
32
|
+
// Keyless (sigstore) signing for CI: the OIDC identity (ambient in GitHub
|
|
33
|
+
// Actions via CIContextProvider, or an explicit token) is exchanged at Fulcio
|
|
34
|
+
// for a short-lived certificate, the payload bytes are signed with an
|
|
35
|
+
// ephemeral P-256 key, and the sigstore bundle is assembled (serialized JSON,
|
|
36
|
+
// the shape the registry verifies). Rekor upload is optional.
|
|
37
|
+
export async function buildKeylessBundle(input) {
|
|
38
|
+
const identityProvider = input.oidcToken
|
|
39
|
+
? { getToken: async () => input.oidcToken }
|
|
40
|
+
: new CIContextProvider();
|
|
41
|
+
const signer = new FulcioSigner({
|
|
42
|
+
identityProvider,
|
|
43
|
+
...(input.fulcioBaseURL ? { fulcioBaseURL: input.fulcioBaseURL } : {}),
|
|
44
|
+
});
|
|
45
|
+
const builder = new MessageSignatureBundleBuilder({
|
|
46
|
+
signer,
|
|
47
|
+
witnesses: input.rekorBaseURL ? [new RekorWitness({ rekorBaseURL: input.rekorBaseURL })] : [],
|
|
48
|
+
});
|
|
49
|
+
const bundle = await builder.create({ data: input.data });
|
|
50
|
+
const serialized = bundleToJSON(bundle);
|
|
51
|
+
return { bundle: serialized, ...readBundleIdentity(serialized) };
|
|
52
|
+
}
|