frakment 3.0.1 → 4.0.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 +3 -1
- package/dist/package.json +4 -3
- package/dist/src/commands/add.js +76 -2
- package/dist/src/commands/list.js +15 -2
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Frakment-authored CLI code is licensed under MIT, which permits commercial use,
|
|
|
9
9
|
|
|
10
10
|
## Requirements
|
|
11
11
|
|
|
12
|
-
- Node.js >= 22.
|
|
12
|
+
- Node.js >= 22.22.2
|
|
13
13
|
- Tailwind CSS v4 (`@import "tailwindcss";` in your `globals.css`)
|
|
14
14
|
|
|
15
15
|
## Package managers
|
|
@@ -84,6 +84,8 @@ The default registry URL is written to `components.json` during `init`. If the p
|
|
|
84
84
|
npx frakment@latest add badge --registry http://localhost:8765
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
The CLI verifies official registry payloads against a Sigstore-signed manifest published by the Frakment GitHub repository. Custom registry URLs are outside that signature policy and should only be used when trusted.
|
|
88
|
+
|
|
87
89
|
## Troubleshooting
|
|
88
90
|
|
|
89
91
|
### "Frakment requires Tailwind v4"
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frakment",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "MIT-licensed CLI and design system for the Frakment component registry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"commander": "^15.1.0",
|
|
35
35
|
"execa": "^10.2.1",
|
|
36
36
|
"ora": "^10.0.0",
|
|
37
|
-
"prompts": "^2.4.2"
|
|
37
|
+
"prompts": "^2.4.2",
|
|
38
|
+
"sigstore": "^5.0.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/prompts": "^2.4.9",
|
|
@@ -44,6 +45,6 @@
|
|
|
44
45
|
"tailwind-merge": "^3.7.1"
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|
|
47
|
-
"node": ">=22.
|
|
48
|
+
"node": ">=22.22.2"
|
|
48
49
|
}
|
|
49
50
|
}
|
package/dist/src/commands/add.js
CHANGED
|
@@ -24,7 +24,12 @@ export { assertSafePath };
|
|
|
24
24
|
const componentNamePattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
25
25
|
const dependencyPattern = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:@[0-9A-Za-z*~^<>=|.+_-]+)?$/u;
|
|
26
26
|
const maxRegistryPayloadBytes = 10 * 1024 * 1024;
|
|
27
|
+
const maxRegistryManifestBytes = 1024 * 1024;
|
|
27
28
|
const defaultWebRegistry = "https://www.arrafi.dev/frakment/r";
|
|
29
|
+
const registryManifestUrl = "https://github.com/frakment/ui/releases/download/registry/manifest.json";
|
|
30
|
+
const registrySignatureUrl = "https://github.com/frakment/ui/releases/download/registry/manifest.sigstore.json";
|
|
31
|
+
const registrySignerIdentity = "^https://github\\.com/frakment/ui/\\.github/workflows/registry-sign\\.yml@refs/heads/main$";
|
|
32
|
+
const sigstoreIssuer = "https://token.actions.githubusercontent.com";
|
|
28
33
|
const defaultAliases = {
|
|
29
34
|
components: "@/components",
|
|
30
35
|
ui: "@/components/ui",
|
|
@@ -66,6 +71,59 @@ const canonicalize = (value) => {
|
|
|
66
71
|
const createIntegrity = (payload) => `sha256:${createHash("sha256")
|
|
67
72
|
.update(canonicalize(payload), "utf8")
|
|
68
73
|
.digest("hex")}`;
|
|
74
|
+
async function fetchRegistryText(url, maxBytes) {
|
|
75
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(10000) });
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(`HTTP ${response.status} from ${url}`);
|
|
78
|
+
}
|
|
79
|
+
const contentLength = Number(response.headers.get("content-length"));
|
|
80
|
+
if (Number.isFinite(contentLength) && contentLength > maxBytes) {
|
|
81
|
+
throw new Error(`Response from ${url} is too large`);
|
|
82
|
+
}
|
|
83
|
+
const raw = await response.text();
|
|
84
|
+
if (Buffer.byteLength(raw, "utf8") > maxBytes) {
|
|
85
|
+
throw new Error(`Response from ${url} is too large`);
|
|
86
|
+
}
|
|
87
|
+
return raw;
|
|
88
|
+
}
|
|
89
|
+
export async function fetchSignedRegistryManifest() {
|
|
90
|
+
const [manifestRaw, signatureRaw] = await Promise.all([
|
|
91
|
+
fetchRegistryText(registryManifestUrl, maxRegistryManifestBytes),
|
|
92
|
+
fetchRegistryText(registrySignatureUrl, maxRegistryManifestBytes),
|
|
93
|
+
]);
|
|
94
|
+
const manifest = JSON.parse(manifestRaw);
|
|
95
|
+
const signature = JSON.parse(signatureRaw);
|
|
96
|
+
const sigstore = await import("sigstore");
|
|
97
|
+
await sigstore.verify(signature, Buffer.from(manifestRaw, "utf8"), {
|
|
98
|
+
certificateIdentityURI: registrySignerIdentity,
|
|
99
|
+
certificateIssuer: sigstoreIssuer,
|
|
100
|
+
});
|
|
101
|
+
if (!isRecord(manifest) ||
|
|
102
|
+
manifest.version !== 1 ||
|
|
103
|
+
!isRecord(manifest.files)) {
|
|
104
|
+
throw new Error("Signed registry manifest has an invalid format");
|
|
105
|
+
}
|
|
106
|
+
const files = {};
|
|
107
|
+
for (const [name, digest] of Object.entries(manifest.files)) {
|
|
108
|
+
if (!/^(?:index|[a-z0-9]+(?:-[a-z0-9]+)*)\.json$/u.test(name) ||
|
|
109
|
+
typeof digest !== "string" ||
|
|
110
|
+
!/^sha256:[a-f0-9]{64}$/u.test(digest)) {
|
|
111
|
+
throw new Error("Signed registry manifest has an invalid file entry");
|
|
112
|
+
}
|
|
113
|
+
files[name] = digest;
|
|
114
|
+
}
|
|
115
|
+
return { files, version: 1 };
|
|
116
|
+
}
|
|
117
|
+
export function verifySignedRegistryFile(name, raw, manifest) {
|
|
118
|
+
const expectedDigest = manifest.files[name];
|
|
119
|
+
const actualDigest = `sha256:${createHash("sha256")
|
|
120
|
+
.update(raw, "utf8")
|
|
121
|
+
.digest("hex")}`;
|
|
122
|
+
if (!expectedDigest || expectedDigest !== actualDigest) {
|
|
123
|
+
throw new Error(`Registry file ${name} does not match the signed manifest`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export const isOfficialRegistryUrl = (url) => url === defaultWebRegistry;
|
|
69
127
|
function assertComponentName(name) {
|
|
70
128
|
if (typeof name !== "string" || !componentNamePattern.test(name)) {
|
|
71
129
|
throw new Error(`Invalid component name: ${String(name)}`);
|
|
@@ -161,7 +219,7 @@ export function resolveRegistryUrl(config, options = {}) {
|
|
|
161
219
|
const configured = (_a = registry !== null && registry !== void 0 ? registry : web) !== null && _a !== void 0 ? _a : defaultWebRegistry;
|
|
162
220
|
return getRegistryUrl((_b = options.registry) !== null && _b !== void 0 ? _b : configured);
|
|
163
221
|
}
|
|
164
|
-
async function fetchComponent(name, registryUrl, spinner) {
|
|
222
|
+
async function fetchComponent(name, registryUrl, spinner, manifest) {
|
|
165
223
|
try {
|
|
166
224
|
const res = await fetch(`${registryUrl}/${name}.json`, {
|
|
167
225
|
signal: AbortSignal.timeout(30000),
|
|
@@ -177,6 +235,9 @@ async function fetchComponent(name, registryUrl, spinner) {
|
|
|
177
235
|
if (Buffer.byteLength(raw, "utf8") > maxRegistryPayloadBytes) {
|
|
178
236
|
throw new Error("Registry response is too large");
|
|
179
237
|
}
|
|
238
|
+
if (manifest) {
|
|
239
|
+
verifySignedRegistryFile(`${name}.json`, raw, manifest);
|
|
240
|
+
}
|
|
180
241
|
const payload = validateRegistryPayload(JSON.parse(raw), name);
|
|
181
242
|
spinner.text = `Fetching ${name}...`;
|
|
182
243
|
return payload;
|
|
@@ -248,6 +309,19 @@ export async function add(componentNamesInput, options = {}) {
|
|
|
248
309
|
process.exit(1);
|
|
249
310
|
}
|
|
250
311
|
const registrySpinner = ora("Checking registry").start();
|
|
312
|
+
let signedManifest;
|
|
313
|
+
if (registryUrl === defaultWebRegistry) {
|
|
314
|
+
try {
|
|
315
|
+
signedManifest = await fetchSignedRegistryManifest();
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
registrySpinner.fail(`Registry signature verification failed: ${error instanceof Error ? error.message : "unknown error"}`);
|
|
319
|
+
process.exit(1);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
logger.warn("Custom registry is not covered by Frakment's Sigstore signature.");
|
|
324
|
+
}
|
|
251
325
|
const roots = new Set(componentNames);
|
|
252
326
|
const queue = [...roots];
|
|
253
327
|
const fetched = new Map();
|
|
@@ -260,7 +334,7 @@ export async function add(componentNamesInput, options = {}) {
|
|
|
260
334
|
if (fetched.has(name)) {
|
|
261
335
|
continue;
|
|
262
336
|
}
|
|
263
|
-
const payload = await fetchComponent(name, registryUrl, registrySpinner);
|
|
337
|
+
const payload = await fetchComponent(name, registryUrl, registrySpinner, signedManifest);
|
|
264
338
|
fetched.set(name, payload);
|
|
265
339
|
for (const d of (_a = payload.dependencies) !== null && _a !== void 0 ? _a : []) {
|
|
266
340
|
const packageName = getDependencyName(d);
|
|
@@ -5,7 +5,7 @@ import chalk from "chalk";
|
|
|
5
5
|
import ora from "ora";
|
|
6
6
|
import { findProjectRoot } from "../utils/detect.js";
|
|
7
7
|
import { logger } from "../utils/logger.js";
|
|
8
|
-
import { resolveRegistryUrl } from "./add.js";
|
|
8
|
+
import { fetchSignedRegistryManifest, isOfficialRegistryUrl, resolveRegistryUrl, verifySignedRegistryFile, } from "./add.js";
|
|
9
9
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
10
|
export const isRegistryIndex = (value) => isRecord(value) &&
|
|
11
11
|
Array.isArray(value.components) &&
|
|
@@ -45,13 +45,26 @@ export async function list(options) {
|
|
|
45
45
|
const s = ora("Fetching components").start();
|
|
46
46
|
let index;
|
|
47
47
|
try {
|
|
48
|
+
const manifest = isOfficialRegistryUrl(registryUrl)
|
|
49
|
+
? await fetchSignedRegistryManifest()
|
|
50
|
+
: undefined;
|
|
51
|
+
if (!manifest) {
|
|
52
|
+
logger.warn("Custom registry is not covered by Frakment's Sigstore signature.");
|
|
53
|
+
}
|
|
48
54
|
const res = await fetch(`${registryUrl}/index.json`, {
|
|
49
55
|
signal: AbortSignal.timeout(30000),
|
|
50
56
|
});
|
|
51
57
|
if (!res.ok) {
|
|
52
58
|
throw new Error(`HTTP ${res.status}`);
|
|
53
59
|
}
|
|
54
|
-
const
|
|
60
|
+
const raw = await res.text();
|
|
61
|
+
if (Buffer.byteLength(raw, "utf8") > 10 * 1024 * 1024) {
|
|
62
|
+
throw new Error("Registry index response is too large");
|
|
63
|
+
}
|
|
64
|
+
if (manifest) {
|
|
65
|
+
verifySignedRegistryFile("index.json", raw, manifest);
|
|
66
|
+
}
|
|
67
|
+
const response = JSON.parse(raw);
|
|
55
68
|
if (!isRegistryIndex(response)) {
|
|
56
69
|
throw new Error("Registry index has an invalid shape");
|
|
57
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frakment",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "MIT-licensed CLI and design system for the Frakment component registry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"commander": "^15.1.0",
|
|
30
30
|
"execa": "^10.2.1",
|
|
31
31
|
"ora": "^10.0.0",
|
|
32
|
-
"prompts": "^2.4.2"
|
|
32
|
+
"prompts": "^2.4.2",
|
|
33
|
+
"sigstore": "^5.0.1"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/prompts": "^2.4.9",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"tailwind-merge": "^3.7.1"
|
|
40
41
|
},
|
|
41
42
|
"engines": {
|
|
42
|
-
"node": ">=22.
|
|
43
|
+
"node": ">=22.22.2"
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
46
|
"build": "tsc -p tsconfig.build.json && node ../../scripts/copy-runtime-package.ts",
|