@enactprotocol/shared 2.0.0 → 2.0.2
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/config.d.ts +164 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +386 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +17 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +26 -0
- package/dist/constants.js.map +1 -0
- package/dist/execution/command.d.ts +102 -0
- package/dist/execution/command.d.ts.map +1 -0
- package/dist/execution/command.js +262 -0
- package/dist/execution/command.js.map +1 -0
- package/dist/execution/index.d.ts +12 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +17 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/runtime.d.ts +82 -0
- package/dist/execution/runtime.d.ts.map +1 -0
- package/dist/execution/runtime.js +273 -0
- package/dist/execution/runtime.js.map +1 -0
- package/dist/execution/types.d.ts +306 -0
- package/dist/execution/types.d.ts.map +1 -0
- package/dist/execution/types.js +14 -0
- package/dist/execution/types.js.map +1 -0
- package/dist/execution/validation.d.ts +43 -0
- package/dist/execution/validation.d.ts.map +1 -0
- package/dist/execution/validation.js +430 -0
- package/dist/execution/validation.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest/index.d.ts +7 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +10 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/loader.d.ts +76 -0
- package/dist/manifest/loader.d.ts.map +1 -0
- package/dist/manifest/loader.js +146 -0
- package/dist/manifest/loader.js.map +1 -0
- package/dist/manifest/parser.d.ts +64 -0
- package/dist/manifest/parser.d.ts.map +1 -0
- package/dist/manifest/parser.js +135 -0
- package/dist/manifest/parser.js.map +1 -0
- package/dist/manifest/validator.d.ts +95 -0
- package/dist/manifest/validator.d.ts.map +1 -0
- package/dist/manifest/validator.js +258 -0
- package/dist/manifest/validator.js.map +1 -0
- package/dist/paths.d.ts +57 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +93 -0
- package/dist/paths.js.map +1 -0
- package/dist/registry.d.ts +73 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +147 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolver.d.ts +89 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +282 -0
- package/dist/resolver.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/manifest.d.ts +201 -0
- package/dist/types/manifest.d.ts.map +1 -0
- package/dist/types/manifest.js +13 -0
- package/dist/types/manifest.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fs.d.ts +105 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +233 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/logger.d.ts +112 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +232 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/version.d.ts +62 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +259 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +2 -2
- package/src/config.ts +36 -2
- package/src/index.ts +1 -0
- package/tests/config.test.ts +190 -1
- package/tsconfig.tsbuildinfo +1 -1
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration manager for Enact CLI
|
|
3
|
+
* Handles reading and writing ~/.enact/config.yaml
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Trust configuration for attestation verification
|
|
7
|
+
*
|
|
8
|
+
* Uses a unified model: all trust is based on cryptographic attestations.
|
|
9
|
+
* Publishers who want their tools trusted should self-sign them.
|
|
10
|
+
* Third-party reviewers can add additional attestations.
|
|
11
|
+
*/
|
|
12
|
+
export interface TrustConfig {
|
|
13
|
+
/**
|
|
14
|
+
* List of trusted auditor identities (provider:identity format, e.g., github:alice)
|
|
15
|
+
* Anyone who signs with these identities is trusted - whether they authored
|
|
16
|
+
* the tool (self-attestation) or reviewed it (third-party audit).
|
|
17
|
+
*/
|
|
18
|
+
auditors?: string[];
|
|
19
|
+
/** Trust policy: 'require_attestation' blocks without trust, 'prompt' asks user, 'allow' installs anyway */
|
|
20
|
+
policy?: "require_attestation" | "prompt" | "allow";
|
|
21
|
+
/** Minimum number of trusted attestations required */
|
|
22
|
+
minimum_attestations?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Cache configuration
|
|
26
|
+
*/
|
|
27
|
+
export interface CacheConfig {
|
|
28
|
+
/** Maximum cache size in megabytes */
|
|
29
|
+
maxSizeMb?: number;
|
|
30
|
+
/** Cache TTL in seconds */
|
|
31
|
+
ttlSeconds?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Execution configuration
|
|
35
|
+
*/
|
|
36
|
+
export interface ExecutionConfig {
|
|
37
|
+
/** Default timeout for tool execution (e.g., "30s", "5m") */
|
|
38
|
+
defaultTimeout?: string;
|
|
39
|
+
/** Whether to run in verbose mode */
|
|
40
|
+
verbose?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Registry configuration
|
|
44
|
+
*/
|
|
45
|
+
export interface RegistryConfig {
|
|
46
|
+
/** Default registry URL */
|
|
47
|
+
url?: string;
|
|
48
|
+
/** Authentication token for registry (stored reference, not actual token) */
|
|
49
|
+
authTokenRef?: string;
|
|
50
|
+
/** Direct authentication token (for local development) */
|
|
51
|
+
authToken?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Complete Enact configuration
|
|
55
|
+
*/
|
|
56
|
+
export interface EnactConfig {
|
|
57
|
+
/** Configuration file version */
|
|
58
|
+
version?: string;
|
|
59
|
+
/** Trust settings for verification */
|
|
60
|
+
trust?: TrustConfig;
|
|
61
|
+
/** Cache settings */
|
|
62
|
+
cache?: CacheConfig;
|
|
63
|
+
/** Execution defaults */
|
|
64
|
+
execution?: ExecutionConfig;
|
|
65
|
+
/** Registry settings */
|
|
66
|
+
registry?: RegistryConfig;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Default configuration values
|
|
70
|
+
*/
|
|
71
|
+
export declare const DEFAULT_CONFIG: EnactConfig;
|
|
72
|
+
/**
|
|
73
|
+
* Load configuration from ~/.enact/config.yaml
|
|
74
|
+
* Returns default config if file doesn't exist or is invalid
|
|
75
|
+
* @returns The loaded configuration merged with defaults
|
|
76
|
+
*/
|
|
77
|
+
export declare function loadConfig(): EnactConfig;
|
|
78
|
+
/**
|
|
79
|
+
* Save configuration to ~/.enact/config.yaml
|
|
80
|
+
* Creates the ~/.enact/ directory if it doesn't exist
|
|
81
|
+
* @param config - The configuration to save
|
|
82
|
+
*/
|
|
83
|
+
export declare function saveConfig(config: EnactConfig): void;
|
|
84
|
+
/**
|
|
85
|
+
* Get a configuration value by dot-notation key path
|
|
86
|
+
* @param key - Dot-notation path (e.g., "trust.policy", "cache.maxSizeMb")
|
|
87
|
+
* @param defaultValue - Default value if key doesn't exist
|
|
88
|
+
* @returns The configuration value or default
|
|
89
|
+
*/
|
|
90
|
+
export declare function getConfigValue<T>(key: string, defaultValue: T): T;
|
|
91
|
+
/**
|
|
92
|
+
* Set a configuration value by dot-notation key path and persist
|
|
93
|
+
* @param key - Dot-notation path (e.g., "trust.policy", "cache.maxSizeMb")
|
|
94
|
+
* @param value - The value to set
|
|
95
|
+
*/
|
|
96
|
+
export declare function setConfigValue<T>(key: string, value: T): void;
|
|
97
|
+
/**
|
|
98
|
+
* Reset configuration to defaults
|
|
99
|
+
* This will overwrite the existing config file
|
|
100
|
+
*/
|
|
101
|
+
export declare function resetConfig(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Check if a configuration file exists
|
|
104
|
+
* @returns true if ~/.enact/config.yaml exists
|
|
105
|
+
*/
|
|
106
|
+
export declare function configExists(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Ensure global setup is complete
|
|
109
|
+
* Creates ~/.enact/ directory structure and default config if they don't exist.
|
|
110
|
+
* This is a non-interactive initialization that runs silently.
|
|
111
|
+
* @returns true if setup was performed, false if already initialized
|
|
112
|
+
*/
|
|
113
|
+
export declare function ensureGlobalSetup(): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Get list of trusted identities from local config
|
|
116
|
+
* @returns Array of identities in provider:identity format
|
|
117
|
+
*/
|
|
118
|
+
export declare function getTrustedIdentities(): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Add an identity to the local trusted list
|
|
121
|
+
* @param identity - Identity in provider:identity format (e.g., github:alice)
|
|
122
|
+
* @returns true if added, false if already exists
|
|
123
|
+
*/
|
|
124
|
+
export declare function addTrustedIdentity(identity: string): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Remove an identity from the local trusted list
|
|
127
|
+
* @param identity - Identity in provider:identity format
|
|
128
|
+
* @returns true if removed, false if not found
|
|
129
|
+
*/
|
|
130
|
+
export declare function removeTrustedIdentity(identity: string): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Check if an identity is in the local trusted list
|
|
133
|
+
* Supports wildcards like github:my-org/* and *@company.com
|
|
134
|
+
* @param identity - Identity to check
|
|
135
|
+
* @returns true if trusted
|
|
136
|
+
*/
|
|
137
|
+
export declare function isIdentityTrusted(identity: string): boolean;
|
|
138
|
+
/** @deprecated Use getTrustedIdentities instead */
|
|
139
|
+
export declare const getTrustedAuditors: typeof getTrustedIdentities;
|
|
140
|
+
/** @deprecated Use addTrustedIdentity instead */
|
|
141
|
+
export declare const addTrustedAuditor: typeof addTrustedIdentity;
|
|
142
|
+
/** @deprecated Use removeTrustedIdentity instead */
|
|
143
|
+
export declare const removeTrustedAuditor: typeof removeTrustedIdentity;
|
|
144
|
+
/** @deprecated Use isIdentityTrusted instead */
|
|
145
|
+
export declare const isAuditorTrusted: typeof isIdentityTrusted;
|
|
146
|
+
/**
|
|
147
|
+
* Convert OIDC identity to provider:identity format
|
|
148
|
+
* @param email - Email from Sigstore certificate
|
|
149
|
+
* @param issuer - OIDC issuer URL (optional, improves accuracy)
|
|
150
|
+
* @param username - Provider username if known (optional)
|
|
151
|
+
* @returns Identity in provider:identity format (e.g., github:keithagroves)
|
|
152
|
+
*/
|
|
153
|
+
export declare function emailToProviderIdentity(email: string, issuer?: string, username?: string): string;
|
|
154
|
+
/**
|
|
155
|
+
* Get minimum required attestations from config
|
|
156
|
+
* @returns Minimum number of trusted attestations required
|
|
157
|
+
*/
|
|
158
|
+
export declare function getMinimumAttestations(): number;
|
|
159
|
+
/**
|
|
160
|
+
* Get trust policy from config
|
|
161
|
+
* @returns Trust policy: 'require_attestation', 'prompt', or 'allow'
|
|
162
|
+
*/
|
|
163
|
+
export declare function getTrustPolicy(): "require_attestation" | "prompt" | "allow";
|
|
164
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,4GAA4G;IAC5G,MAAM,CAAC,EAAE,qBAAqB,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,sDAAsD;IACtD,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MA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AAMD;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAG/C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAoB5D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAoB/D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA2B3D;AAGD,mDAAmD;AACnD,eAAO,MAAM,kBAAkB,6BAAuB,CAAC;AACvD,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,2BAAqB,CAAC;AACpD,oDAAoD;AACpD,eAAO,MAAM,oBAAoB,8BAAwB,CAAC;AAC1D,gDAAgD;AAChD,eAAO,MAAM,gBAAgB,0BAAoB,CAAC;AAElD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CA8DjG;AAaD;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,qBAAqB,GAAG,QAAQ,GAAG,OAAO,CAS3E"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration manager for Enact CLI
|
|
3
|
+
* Handles reading and writing ~/.enact/config.yaml
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import yaml from "js-yaml";
|
|
8
|
+
import { getConfigPath, getEnactHome } from "./paths";
|
|
9
|
+
/**
|
|
10
|
+
* Default configuration values
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_CONFIG = {
|
|
13
|
+
version: "1.0.0",
|
|
14
|
+
trust: {
|
|
15
|
+
auditors: [],
|
|
16
|
+
policy: "prompt",
|
|
17
|
+
minimum_attestations: 1,
|
|
18
|
+
},
|
|
19
|
+
cache: {
|
|
20
|
+
maxSizeMb: 1024, // 1GB
|
|
21
|
+
ttlSeconds: 86400 * 7, // 7 days
|
|
22
|
+
},
|
|
23
|
+
execution: {
|
|
24
|
+
defaultTimeout: "30s",
|
|
25
|
+
verbose: false,
|
|
26
|
+
},
|
|
27
|
+
registry: {
|
|
28
|
+
url: "https://siikwkfgsmouioodghho.supabase.co/functions/v1",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Deep merge two objects, with source values overwriting target values
|
|
33
|
+
*/
|
|
34
|
+
function deepMerge(target, source) {
|
|
35
|
+
const result = { ...target };
|
|
36
|
+
// Merge trust config
|
|
37
|
+
if (source.trust !== undefined) {
|
|
38
|
+
result.trust = { ...target.trust, ...source.trust };
|
|
39
|
+
}
|
|
40
|
+
// Merge cache config
|
|
41
|
+
if (source.cache !== undefined) {
|
|
42
|
+
result.cache = { ...target.cache, ...source.cache };
|
|
43
|
+
}
|
|
44
|
+
// Merge execution config
|
|
45
|
+
if (source.execution !== undefined) {
|
|
46
|
+
result.execution = { ...target.execution, ...source.execution };
|
|
47
|
+
}
|
|
48
|
+
// Merge registry config
|
|
49
|
+
if (source.registry !== undefined) {
|
|
50
|
+
result.registry = { ...target.registry, ...source.registry };
|
|
51
|
+
}
|
|
52
|
+
// Copy top-level primitives
|
|
53
|
+
if (source.version !== undefined) {
|
|
54
|
+
result.version = source.version;
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Load configuration from ~/.enact/config.yaml
|
|
60
|
+
* Returns default config if file doesn't exist or is invalid
|
|
61
|
+
* @returns The loaded configuration merged with defaults
|
|
62
|
+
*/
|
|
63
|
+
export function loadConfig() {
|
|
64
|
+
const configPath = getConfigPath();
|
|
65
|
+
if (!existsSync(configPath)) {
|
|
66
|
+
return { ...DEFAULT_CONFIG };
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const content = readFileSync(configPath, "utf-8");
|
|
70
|
+
const parsed = yaml.load(content);
|
|
71
|
+
if (!parsed || typeof parsed !== "object") {
|
|
72
|
+
return { ...DEFAULT_CONFIG };
|
|
73
|
+
}
|
|
74
|
+
// Merge with defaults to ensure all fields exist
|
|
75
|
+
return deepMerge(DEFAULT_CONFIG, parsed);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Return defaults on any error (parse error, read error, etc.)
|
|
79
|
+
return { ...DEFAULT_CONFIG };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Save configuration to ~/.enact/config.yaml
|
|
84
|
+
* Creates the ~/.enact/ directory if it doesn't exist
|
|
85
|
+
* @param config - The configuration to save
|
|
86
|
+
*/
|
|
87
|
+
export function saveConfig(config) {
|
|
88
|
+
const configPath = getConfigPath();
|
|
89
|
+
const enactHome = getEnactHome();
|
|
90
|
+
// Ensure ~/.enact/ directory exists
|
|
91
|
+
if (!existsSync(enactHome)) {
|
|
92
|
+
mkdirSync(enactHome, { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
// Ensure parent directory exists (should be ~/.enact/ but be safe)
|
|
95
|
+
const parentDir = dirname(configPath);
|
|
96
|
+
if (!existsSync(parentDir)) {
|
|
97
|
+
mkdirSync(parentDir, { recursive: true });
|
|
98
|
+
}
|
|
99
|
+
const yamlContent = yaml.dump(config, {
|
|
100
|
+
indent: 2,
|
|
101
|
+
lineWidth: 120,
|
|
102
|
+
noRefs: true,
|
|
103
|
+
});
|
|
104
|
+
writeFileSync(configPath, yamlContent, "utf-8");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get a configuration value by dot-notation key path
|
|
108
|
+
* @param key - Dot-notation path (e.g., "trust.policy", "cache.maxSizeMb")
|
|
109
|
+
* @param defaultValue - Default value if key doesn't exist
|
|
110
|
+
* @returns The configuration value or default
|
|
111
|
+
*/
|
|
112
|
+
export function getConfigValue(key, defaultValue) {
|
|
113
|
+
const config = loadConfig();
|
|
114
|
+
const keys = key.split(".");
|
|
115
|
+
let current = config;
|
|
116
|
+
for (const k of keys) {
|
|
117
|
+
if (current === null || current === undefined || typeof current !== "object") {
|
|
118
|
+
return defaultValue;
|
|
119
|
+
}
|
|
120
|
+
current = current[k];
|
|
121
|
+
}
|
|
122
|
+
return current === undefined ? defaultValue : current;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Set a configuration value by dot-notation key path and persist
|
|
126
|
+
* @param key - Dot-notation path (e.g., "trust.policy", "cache.maxSizeMb")
|
|
127
|
+
* @param value - The value to set
|
|
128
|
+
*/
|
|
129
|
+
export function setConfigValue(key, value) {
|
|
130
|
+
const config = loadConfig();
|
|
131
|
+
const keys = key.split(".");
|
|
132
|
+
const lastKey = keys.pop();
|
|
133
|
+
if (!lastKey) {
|
|
134
|
+
throw new Error("Invalid configuration key");
|
|
135
|
+
}
|
|
136
|
+
// Navigate to parent object, creating intermediate objects as needed
|
|
137
|
+
let current = config;
|
|
138
|
+
for (const k of keys) {
|
|
139
|
+
if (current[k] === undefined || current[k] === null || typeof current[k] !== "object") {
|
|
140
|
+
current[k] = {};
|
|
141
|
+
}
|
|
142
|
+
current = current[k];
|
|
143
|
+
}
|
|
144
|
+
// Set the value
|
|
145
|
+
current[lastKey] = value;
|
|
146
|
+
// Persist
|
|
147
|
+
saveConfig(config);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Reset configuration to defaults
|
|
151
|
+
* This will overwrite the existing config file
|
|
152
|
+
*/
|
|
153
|
+
export function resetConfig() {
|
|
154
|
+
saveConfig({ ...DEFAULT_CONFIG });
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Check if a configuration file exists
|
|
158
|
+
* @returns true if ~/.enact/config.yaml exists
|
|
159
|
+
*/
|
|
160
|
+
export function configExists() {
|
|
161
|
+
return existsSync(getConfigPath());
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Ensure global setup is complete
|
|
165
|
+
* Creates ~/.enact/ directory structure and default config if they don't exist.
|
|
166
|
+
* This is a non-interactive initialization that runs silently.
|
|
167
|
+
* @returns true if setup was performed, false if already initialized
|
|
168
|
+
*/
|
|
169
|
+
export function ensureGlobalSetup() {
|
|
170
|
+
const enactHome = getEnactHome();
|
|
171
|
+
const configPath = getConfigPath();
|
|
172
|
+
const cacheDir = join(enactHome, "cache");
|
|
173
|
+
let performedSetup = false;
|
|
174
|
+
// Ensure ~/.enact/ directory exists
|
|
175
|
+
if (!existsSync(enactHome)) {
|
|
176
|
+
mkdirSync(enactHome, { recursive: true });
|
|
177
|
+
performedSetup = true;
|
|
178
|
+
}
|
|
179
|
+
// Ensure ~/.enact/cache/ directory exists
|
|
180
|
+
if (!existsSync(cacheDir)) {
|
|
181
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
182
|
+
performedSetup = true;
|
|
183
|
+
}
|
|
184
|
+
// Create default config if it doesn't exist
|
|
185
|
+
if (!existsSync(configPath)) {
|
|
186
|
+
saveConfig({ ...DEFAULT_CONFIG });
|
|
187
|
+
performedSetup = true;
|
|
188
|
+
}
|
|
189
|
+
return performedSetup;
|
|
190
|
+
}
|
|
191
|
+
// =============================================================================
|
|
192
|
+
// Local Trust Management
|
|
193
|
+
// =============================================================================
|
|
194
|
+
/**
|
|
195
|
+
* Get list of trusted identities from local config
|
|
196
|
+
* @returns Array of identities in provider:identity format
|
|
197
|
+
*/
|
|
198
|
+
export function getTrustedIdentities() {
|
|
199
|
+
const config = loadConfig();
|
|
200
|
+
return config.trust?.auditors ?? [];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Add an identity to the local trusted list
|
|
204
|
+
* @param identity - Identity in provider:identity format (e.g., github:alice)
|
|
205
|
+
* @returns true if added, false if already exists
|
|
206
|
+
*/
|
|
207
|
+
export function addTrustedIdentity(identity) {
|
|
208
|
+
const config = loadConfig();
|
|
209
|
+
const auditors = config.trust?.auditors ?? [];
|
|
210
|
+
// Check if already exists
|
|
211
|
+
if (auditors.includes(identity)) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
// Add to list
|
|
215
|
+
auditors.push(identity);
|
|
216
|
+
// Update config
|
|
217
|
+
if (!config.trust) {
|
|
218
|
+
config.trust = { ...DEFAULT_CONFIG.trust };
|
|
219
|
+
}
|
|
220
|
+
config.trust.auditors = auditors;
|
|
221
|
+
saveConfig(config);
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Remove an identity from the local trusted list
|
|
226
|
+
* @param identity - Identity in provider:identity format
|
|
227
|
+
* @returns true if removed, false if not found
|
|
228
|
+
*/
|
|
229
|
+
export function removeTrustedIdentity(identity) {
|
|
230
|
+
const config = loadConfig();
|
|
231
|
+
const auditors = config.trust?.auditors ?? [];
|
|
232
|
+
const index = auditors.indexOf(identity);
|
|
233
|
+
if (index === -1) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
// Remove from list
|
|
237
|
+
auditors.splice(index, 1);
|
|
238
|
+
// Update config
|
|
239
|
+
if (!config.trust) {
|
|
240
|
+
config.trust = { ...DEFAULT_CONFIG.trust };
|
|
241
|
+
}
|
|
242
|
+
config.trust.auditors = auditors;
|
|
243
|
+
saveConfig(config);
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Check if an identity is in the local trusted list
|
|
248
|
+
* Supports wildcards like github:my-org/* and *@company.com
|
|
249
|
+
* @param identity - Identity to check
|
|
250
|
+
* @returns true if trusted
|
|
251
|
+
*/
|
|
252
|
+
export function isIdentityTrusted(identity) {
|
|
253
|
+
const trustedIdentities = getTrustedIdentities();
|
|
254
|
+
// Check exact match first
|
|
255
|
+
if (trustedIdentities.includes(identity)) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
// Check wildcard matches (e.g., github:my-org/* matches github:my-org/alice)
|
|
259
|
+
for (const trusted of trustedIdentities) {
|
|
260
|
+
if (trusted.endsWith("/*")) {
|
|
261
|
+
const prefix = trusted.slice(0, -2); // Remove /*
|
|
262
|
+
if (identity.startsWith(`${prefix}/`)) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Check email wildcards (e.g., *@company.com)
|
|
267
|
+
if (trusted.includes("*@")) {
|
|
268
|
+
const domainPart = trusted.split("*@")[1];
|
|
269
|
+
if (identity.endsWith(`@${domainPart}`)) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
// Legacy aliases for backward compatibility
|
|
277
|
+
/** @deprecated Use getTrustedIdentities instead */
|
|
278
|
+
export const getTrustedAuditors = getTrustedIdentities;
|
|
279
|
+
/** @deprecated Use addTrustedIdentity instead */
|
|
280
|
+
export const addTrustedAuditor = addTrustedIdentity;
|
|
281
|
+
/** @deprecated Use removeTrustedIdentity instead */
|
|
282
|
+
export const removeTrustedAuditor = removeTrustedIdentity;
|
|
283
|
+
/** @deprecated Use isIdentityTrusted instead */
|
|
284
|
+
export const isAuditorTrusted = isIdentityTrusted;
|
|
285
|
+
/**
|
|
286
|
+
* Convert OIDC identity to provider:identity format
|
|
287
|
+
* @param email - Email from Sigstore certificate
|
|
288
|
+
* @param issuer - OIDC issuer URL (optional, improves accuracy)
|
|
289
|
+
* @param username - Provider username if known (optional)
|
|
290
|
+
* @returns Identity in provider:identity format (e.g., github:keithagroves)
|
|
291
|
+
*/
|
|
292
|
+
export function emailToProviderIdentity(email, issuer, username) {
|
|
293
|
+
// If we have a username and can determine the provider, use that
|
|
294
|
+
if (username && issuer) {
|
|
295
|
+
const provider = issuerToProvider(issuer);
|
|
296
|
+
if (provider) {
|
|
297
|
+
return `${provider}:${username}`;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Determine provider from issuer URL if available
|
|
301
|
+
if (issuer) {
|
|
302
|
+
const provider = issuerToProvider(issuer);
|
|
303
|
+
if (provider) {
|
|
304
|
+
// Try to extract username from email for GitHub
|
|
305
|
+
if (provider === "github" && email.endsWith("@users.noreply.github.com")) {
|
|
306
|
+
// GitHub noreply format: "123456+username@users.noreply.github.com"
|
|
307
|
+
// or just "username@users.noreply.github.com"
|
|
308
|
+
const localPart = email.replace("@users.noreply.github.com", "");
|
|
309
|
+
const plusIndex = localPart.indexOf("+");
|
|
310
|
+
const extractedUsername = plusIndex >= 0 ? localPart.slice(plusIndex + 1) : localPart;
|
|
311
|
+
return `github:${extractedUsername}`;
|
|
312
|
+
}
|
|
313
|
+
// Use email as the identity since we don't have username
|
|
314
|
+
return `${provider}:${email}`;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// Common OIDC providers and their email domains (fallback)
|
|
318
|
+
const providerMap = {
|
|
319
|
+
"@users.noreply.github.com": "github",
|
|
320
|
+
"@github.com": "github",
|
|
321
|
+
"@gmail.com": "google",
|
|
322
|
+
"@googlemail.com": "google",
|
|
323
|
+
"@outlook.com": "microsoft",
|
|
324
|
+
"@hotmail.com": "microsoft",
|
|
325
|
+
"@live.com": "microsoft",
|
|
326
|
+
};
|
|
327
|
+
// Try to match provider by email domain
|
|
328
|
+
for (const [domain, provider] of Object.entries(providerMap)) {
|
|
329
|
+
if (email.endsWith(domain)) {
|
|
330
|
+
let extractedUsername = email.substring(0, email.length - domain.length);
|
|
331
|
+
// Handle GitHub noreply format: "123456+username@users.noreply.github.com"
|
|
332
|
+
if (provider === "github" && domain === "@users.noreply.github.com") {
|
|
333
|
+
const plusIndex = extractedUsername.indexOf("+");
|
|
334
|
+
if (plusIndex >= 0) {
|
|
335
|
+
extractedUsername = extractedUsername.slice(plusIndex + 1);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return `${provider}:${extractedUsername}`;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// If no match, check for GitHub workflow identity
|
|
342
|
+
// Format: https://github.com/{org}/{workflow}
|
|
343
|
+
if (email.startsWith("https://github.com/")) {
|
|
344
|
+
const path = email.replace("https://github.com/", "");
|
|
345
|
+
return `github:${path}`;
|
|
346
|
+
}
|
|
347
|
+
// Fall back to email as-is
|
|
348
|
+
return email;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Convert OIDC issuer URL to provider name
|
|
352
|
+
*/
|
|
353
|
+
function issuerToProvider(issuer) {
|
|
354
|
+
if (issuer.includes("github.com"))
|
|
355
|
+
return "github";
|
|
356
|
+
if (issuer.includes("accounts.google.com"))
|
|
357
|
+
return "google";
|
|
358
|
+
if (issuer.includes("login.microsoftonline.com"))
|
|
359
|
+
return "microsoft";
|
|
360
|
+
if (issuer.includes("gitlab.com"))
|
|
361
|
+
return "gitlab";
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Get minimum required attestations from config
|
|
366
|
+
* @returns Minimum number of trusted attestations required
|
|
367
|
+
*/
|
|
368
|
+
export function getMinimumAttestations() {
|
|
369
|
+
const config = loadConfig();
|
|
370
|
+
return config.trust?.minimum_attestations ?? 1;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Get trust policy from config
|
|
374
|
+
* @returns Trust policy: 'require_attestation', 'prompt', or 'allow'
|
|
375
|
+
*/
|
|
376
|
+
export function getTrustPolicy() {
|
|
377
|
+
const config = loadConfig();
|
|
378
|
+
// Handle legacy 'require_audit' value (cast to string for comparison)
|
|
379
|
+
const policy = config.trust?.policy;
|
|
380
|
+
if (policy === "require_audit") {
|
|
381
|
+
return "require_attestation";
|
|
382
|
+
}
|
|
383
|
+
// Default to require_attestation - trust must be explicit
|
|
384
|
+
return policy ?? "require_attestation";
|
|
385
|
+
}
|
|
386
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config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C;IAC/B,CAAC;IACD,0DAA0D;IAC1D,OAAQ,MAAqD,IAAI,qBAAqB,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enact Constants
|
|
3
|
+
*
|
|
4
|
+
* Centralized configuration for Enact URLs and identifiers.
|
|
5
|
+
* This ensures consistency across all packages.
|
|
6
|
+
*
|
|
7
|
+
* Note: Attestation type constants (ENACT_TOOL_TYPE, ENACT_AUDIT_TYPE, etc.)
|
|
8
|
+
* are defined in @enactprotocol/trust and re-exported here for convenience.
|
|
9
|
+
*/
|
|
10
|
+
export { ENACT_BASE_URL, ENACT_TOOL_TYPE, ENACT_AUDIT_TYPE, ENACT_BUILD_TYPE, INTOTO_STATEMENT_TYPE, SLSA_PROVENANCE_TYPE, } from "@enactprotocol/trust";
|
|
11
|
+
export declare const ENACT_API_URL: string;
|
|
12
|
+
/**
|
|
13
|
+
* The Enact web application URL
|
|
14
|
+
* Override with ENACT_WEB_URL environment variable
|
|
15
|
+
*/
|
|
16
|
+
export declare const ENACT_WEB_URL: string;
|
|
17
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAW9B,eAAO,MAAM,aAAa,QAAiD,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAwC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enact Constants
|
|
3
|
+
*
|
|
4
|
+
* Centralized configuration for Enact URLs and identifiers.
|
|
5
|
+
* This ensures consistency across all packages.
|
|
6
|
+
*
|
|
7
|
+
* Note: Attestation type constants (ENACT_TOOL_TYPE, ENACT_AUDIT_TYPE, etc.)
|
|
8
|
+
* are defined in @enactprotocol/trust and re-exported here for convenience.
|
|
9
|
+
*/
|
|
10
|
+
// Re-export attestation constants from trust package
|
|
11
|
+
export { ENACT_BASE_URL, ENACT_TOOL_TYPE, ENACT_AUDIT_TYPE, ENACT_BUILD_TYPE, INTOTO_STATEMENT_TYPE, SLSA_PROVENANCE_TYPE, } from "@enactprotocol/trust";
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Runtime URLs (can be overridden by environment)
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* The Enact API base URL (Supabase Edge Functions)
|
|
17
|
+
* Override with ENACT_API_URL environment variable
|
|
18
|
+
*/
|
|
19
|
+
import { ENACT_BASE_URL as BASE_URL } from "@enactprotocol/trust";
|
|
20
|
+
export const ENACT_API_URL = process.env.ENACT_API_URL || `${BASE_URL}/api`;
|
|
21
|
+
/**
|
|
22
|
+
* The Enact web application URL
|
|
23
|
+
* Override with ENACT_WEB_URL environment variable
|
|
24
|
+
*/
|
|
25
|
+
export const ENACT_WEB_URL = process.env.ENACT_WEB_URL || BASE_URL;
|
|
26
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,qDAAqD;AACrD,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAE9B,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAE/E;;;GAGG;AACH,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,GAAG,QAAQ,MAAM,CAAC;AAE5E;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,QAAQ,CAAC"}
|