@disposabl/cli 2.0.0 → 2.0.1
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/index.js +4 -3
- package/dist/verify-metadata.mjs +64 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// auth.ts
|
|
4
4
|
import { lock } from "proper-lockfile";
|
|
5
5
|
// package.json
|
|
6
|
-
var version = "2.0.
|
|
6
|
+
var version = "2.0.1";
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@disposabl/cli",
|
|
9
9
|
version,
|
|
@@ -27,7 +27,8 @@ var package_default = {
|
|
|
27
27
|
build: "bun build.ts",
|
|
28
28
|
typecheck: "bun check",
|
|
29
29
|
lint: "bun check",
|
|
30
|
-
release: "semantic-release"
|
|
30
|
+
release: "semantic-release",
|
|
31
|
+
prepack: "node dist/verify-metadata.mjs"
|
|
31
32
|
},
|
|
32
33
|
dependencies: {
|
|
33
34
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
@@ -44,7 +45,7 @@ var package_default = {
|
|
|
44
45
|
},
|
|
45
46
|
repository: {
|
|
46
47
|
type: "git",
|
|
47
|
-
url: "https://
|
|
48
|
+
url: "git+https://github.com/disposabl-dev/create-disposabl-app.git",
|
|
48
49
|
directory: "packages/cli"
|
|
49
50
|
}
|
|
50
51
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
|
|
5
|
+
// Package metadata must never publish authenticated or signed URLs.
|
|
6
|
+
export function verifyMetadata(manifest) {
|
|
7
|
+
function inspect(value, field) {
|
|
8
|
+
if (typeof value === "string") {
|
|
9
|
+
const candidate = value
|
|
10
|
+
.trim()
|
|
11
|
+
.replace(/[\u0000-\u0020]/g, "")
|
|
12
|
+
.replace(/^git\+/i, "");
|
|
13
|
+
if (
|
|
14
|
+
/^[a-z][a-z\d+.-]*:/i.test(candidate) ||
|
|
15
|
+
/^[\\/]{2}/.test(candidate)
|
|
16
|
+
) {
|
|
17
|
+
let url;
|
|
18
|
+
try {
|
|
19
|
+
url = new URL(
|
|
20
|
+
candidate,
|
|
21
|
+
/^[\\/]{2}/.test(candidate)
|
|
22
|
+
? "https://metadata.invalid"
|
|
23
|
+
: undefined,
|
|
24
|
+
);
|
|
25
|
+
} catch {
|
|
26
|
+
throw new Error(`Invalid URL in package metadata: ${field}`);
|
|
27
|
+
}
|
|
28
|
+
if (url.username || url.password || url.search || url.hash)
|
|
29
|
+
throw new Error(`Unsafe URL in package metadata: ${field}`);
|
|
30
|
+
} else if (/^[^/]+@[^/]+:/.test(candidate)) {
|
|
31
|
+
throw new Error(`Unsafe URL in package metadata: ${field}`);
|
|
32
|
+
}
|
|
33
|
+
} else if (Array.isArray(value)) {
|
|
34
|
+
value.forEach((item) => inspect(item, field));
|
|
35
|
+
} else if (value && typeof value === "object") {
|
|
36
|
+
for (const item of Object.values(value)) inspect(item, field);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const field of [
|
|
40
|
+
"repository",
|
|
41
|
+
"homepage",
|
|
42
|
+
"bugs",
|
|
43
|
+
"funding",
|
|
44
|
+
"author",
|
|
45
|
+
"contributors",
|
|
46
|
+
"maintainers",
|
|
47
|
+
"publishConfig",
|
|
48
|
+
])
|
|
49
|
+
inspect(manifest[field], field);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
process.argv[1] &&
|
|
54
|
+
import.meta.url === pathToFileURL(realpathSync(resolve(process.argv[1]))).href
|
|
55
|
+
)
|
|
56
|
+
try {
|
|
57
|
+
verifyMetadata(
|
|
58
|
+
JSON.parse(readFileSync(process.argv[2] ?? "package.json", "utf8")),
|
|
59
|
+
);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof SyntaxError)
|
|
62
|
+
throw new Error("Invalid package metadata JSON");
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@disposabl/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Command-line access to your Disposabl app",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"build": "bun build.ts",
|
|
22
22
|
"typecheck": "bun check",
|
|
23
23
|
"lint": "bun check",
|
|
24
|
-
"release": "semantic-release"
|
|
24
|
+
"release": "semantic-release",
|
|
25
|
+
"prepack": "node dist/verify-metadata.mjs"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
},
|
|
39
40
|
"repository": {
|
|
40
41
|
"type": "git",
|
|
41
|
-
"url": "https://
|
|
42
|
+
"url": "git+https://github.com/disposabl-dev/create-disposabl-app.git",
|
|
42
43
|
"directory": "packages/cli"
|
|
43
44
|
}
|
|
44
45
|
}
|