maven-proxy 1.0.1 → 1.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/package.json CHANGED
@@ -1,54 +1,54 @@
1
- {
2
- "name": "maven-proxy",
3
- "version": "1.0.1",
4
- "description": "Maven proxy with cache, HTTPS MITM for selected domains, and local repo publishing",
5
- "main": "src/index.js",
6
- "bin": {
7
- "maven-proxy": "bin/maven-proxy.js"
8
- },
9
- "files": [
10
- "bin/",
11
- "src/",
12
- "scripts/",
13
- "README.md"
14
- ],
15
- "scripts": {
16
- "start": "node src/index.js",
17
- "start:cli": "node bin/maven-proxy.js",
18
- "cli:help": "node bin/maven-proxy.js --help",
19
- "cli:start": "node bin/maven-proxy.js start --mode development",
20
- "cli:doctor": "node bin/maven-proxy.js doctor --mode development",
21
- "cli:truststore:print": "node bin/maven-proxy.js truststore print --mode development",
22
- "cli:truststore:init": "node bin/maven-proxy.js truststore init --mode development",
23
- "cli:truststore:merge": "node bin/maven-proxy.js truststore merge --mode development",
24
- "truststore:print": "node scripts/truststore.js print",
25
- "truststore:init": "node scripts/truststore.js init",
26
- "truststore:merge": "node scripts/truststore.js merge",
27
- "npm:registry:get": "npm config get registry",
28
- "npm:registry:set": "npm config set registry https://registry.npmjs.org",
29
- "npm:login": "npm login",
30
- "npm:pack:dry-run": "npm pack --dry-run",
31
- "npm:publish:dry-run": "npm publish --dry-run",
32
- "npm:publish": "npm publish",
33
- "npm:version:patch": "npm version patch",
34
- "npm:view:version": "npm view maven-proxy version",
35
- "npm:view:dist-tags": "npm view maven-proxy dist-tags",
36
- "test": "node -e \"console.log('No tests yet')\""
37
- },
38
- "keywords": [],
39
- "author": "",
40
- "license": "ISC",
41
- "type": "module",
42
- "dependencies": {
43
- "dotenv": "^16.6.1",
44
- "node-forge": "^1.3.1",
45
- "proxy-agent": "^6.5.0"
46
- },
47
- "devDependencies": {
48
- "@types/node": "^25.9.1"
49
- },
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/yizems/maven-proxy.git"
53
- }
54
- }
1
+ {
2
+ "name": "maven-proxy",
3
+ "version": "1.0.2",
4
+ "description": "Maven proxy with cache, HTTPS MITM for selected domains, and local repo publishing",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "maven-proxy": "bin/maven-proxy.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "src/",
12
+ "scripts/",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "start": "node src/index.js",
17
+ "start:cli": "node bin/maven-proxy.js",
18
+ "cli:help": "node bin/maven-proxy.js --help",
19
+ "cli:start": "node bin/maven-proxy.js start --mode development",
20
+ "cli:doctor": "node bin/maven-proxy.js doctor --mode development",
21
+ "cli:truststore:print": "node bin/maven-proxy.js truststore print --mode development",
22
+ "cli:truststore:init": "node bin/maven-proxy.js truststore init --mode development",
23
+ "cli:truststore:merge": "node bin/maven-proxy.js truststore merge --mode development",
24
+ "truststore:print": "node scripts/truststore.js print",
25
+ "truststore:init": "node scripts/truststore.js init",
26
+ "truststore:merge": "node scripts/truststore.js merge",
27
+ "npm:registry:get": "npm config get registry",
28
+ "npm:registry:set": "npm config set registry https://registry.npmjs.org",
29
+ "npm:login": "npm login",
30
+ "npm:pack:dry-run": "npm pack --dry-run",
31
+ "npm:publish:dry-run": "npm publish --dry-run",
32
+ "npm:publish": "npm publish",
33
+ "npm:version:patch": "npm version patch",
34
+ "npm:view:version": "npm view maven-proxy version",
35
+ "npm:view:dist-tags": "npm view maven-proxy dist-tags",
36
+ "test": "node -e \"console.log('No tests yet')\""
37
+ },
38
+ "keywords": [],
39
+ "author": "",
40
+ "license": "ISC",
41
+ "type": "module",
42
+ "dependencies": {
43
+ "dotenv": "^16.6.1",
44
+ "node-forge": "^1.3.1",
45
+ "proxy-agent": "^6.5.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^25.9.1"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/yizems/maven-proxy.git"
53
+ }
54
+ }
@@ -1,96 +1,96 @@
1
- import { config } from "../src/config/config.js";
2
- import {
3
- getTrustStoreCommands,
4
- initTrustStore,
5
- mergeTrustStores,
6
- } from "../src/cert/truststore-utils.js";
7
-
8
- function printUsage() {
9
- console.log("Usage:");
10
- console.log(" node scripts/truststore.js print");
11
- console.log(" node scripts/truststore.js init");
12
- console.log(
13
- " node scripts/truststore.js merge --source <path> --target <path> [--source-pass <pwd>] [--target-pass <pwd>] [--source-type <JKS|PKCS12>] [--target-type <JKS|PKCS12>] [--on-conflict <fail|overwrite>] [--dry-run]",
14
- );
15
- }
16
-
17
- function parseCliOptions(args) {
18
- const options = {};
19
-
20
- for (let i = 0; i < args.length; i += 1) {
21
- const token = args[i];
22
- if (!token.startsWith("--")) {
23
- continue;
24
- }
25
-
26
- const key = token.slice(2);
27
-
28
- if (key === "dry-run") {
29
- options[key] = true;
30
- continue;
31
- }
32
-
33
- const value = args[i + 1];
34
- if (!value || value.startsWith("--")) {
35
- throw new Error(`Missing value for option: --${key}`);
36
- }
37
-
38
- options[key] = value;
39
- i += 1;
40
- }
41
-
42
- return options;
43
- }
44
-
45
- const action = process.argv[2] || "print";
46
-
47
- try {
48
- if (action === "init") {
49
- initTrustStore(config);
50
- process.exit(0);
51
- }
52
-
53
- if (action === "merge") {
54
- if (process.argv.slice(3).includes("--help")) {
55
- printUsage();
56
- process.exit(0);
57
- }
58
-
59
- const opts = parseCliOptions(process.argv.slice(3));
60
- if (!opts.source || !opts.target) {
61
- throw new Error("merge requires --source and --target");
62
- }
63
-
64
- const mergeResult = mergeTrustStores({
65
- sourcePath: opts.source,
66
- targetPath: opts.target,
67
- sourcePassword: opts["source-pass"] || config.trustStorePassword,
68
- targetPassword: opts["target-pass"] || config.trustStorePassword,
69
- sourceType: (opts["source-type"] || "JKS").toUpperCase(),
70
- targetType: (opts["target-type"] || "JKS").toUpperCase(),
71
- onConflict: (opts["on-conflict"] || "fail").toLowerCase(),
72
- dryRun: Boolean(opts["dry-run"]),
73
- });
74
-
75
- if (mergeResult?.dryRun) {
76
- console.log("Dry run passed: merge validation completed, no changes were made.");
77
- } else {
78
- console.log("Trust stores merged successfully.");
79
- }
80
- process.exit(0);
81
- }
82
-
83
- if (action !== "print") {
84
- printUsage();
85
- throw new Error(`Unknown action: ${action}`);
86
- }
87
-
88
- const commands = getTrustStoreCommands(config);
89
- console.log("Trust store commands:");
90
- console.log(commands.copyCmd);
91
- console.log(commands.importCmd);
92
- console.log(commands.listCmd);
93
- } catch (error) {
94
- console.error(`[truststore] ${error.message}`);
95
- process.exit(1);
96
- }
1
+ import { config } from "../src/config/config.js";
2
+ import {
3
+ getTrustStoreCommands,
4
+ initTrustStore,
5
+ mergeTrustStores,
6
+ } from "../src/cert/truststore-utils.js";
7
+
8
+ function printUsage() {
9
+ console.log("Usage:");
10
+ console.log(" node scripts/truststore.js print");
11
+ console.log(" node scripts/truststore.js init");
12
+ console.log(
13
+ " node scripts/truststore.js merge --source <path> --target <path> [--source-pass <pwd>] [--target-pass <pwd>] [--source-type <JKS|PKCS12>] [--target-type <JKS|PKCS12>] [--on-conflict <fail|overwrite>] [--dry-run]",
14
+ );
15
+ }
16
+
17
+ function parseCliOptions(args) {
18
+ const options = {};
19
+
20
+ for (let i = 0; i < args.length; i += 1) {
21
+ const token = args[i];
22
+ if (!token.startsWith("--")) {
23
+ continue;
24
+ }
25
+
26
+ const key = token.slice(2);
27
+
28
+ if (key === "dry-run") {
29
+ options[key] = true;
30
+ continue;
31
+ }
32
+
33
+ const value = args[i + 1];
34
+ if (!value || value.startsWith("--")) {
35
+ throw new Error(`Missing value for option: --${key}`);
36
+ }
37
+
38
+ options[key] = value;
39
+ i += 1;
40
+ }
41
+
42
+ return options;
43
+ }
44
+
45
+ const action = process.argv[2] || "print";
46
+
47
+ try {
48
+ if (action === "init") {
49
+ initTrustStore(config);
50
+ process.exit(0);
51
+ }
52
+
53
+ if (action === "merge") {
54
+ if (process.argv.slice(3).includes("--help")) {
55
+ printUsage();
56
+ process.exit(0);
57
+ }
58
+
59
+ const opts = parseCliOptions(process.argv.slice(3));
60
+ if (!opts.source || !opts.target) {
61
+ throw new Error("merge requires --source and --target");
62
+ }
63
+
64
+ const mergeResult = mergeTrustStores({
65
+ sourcePath: opts.source,
66
+ targetPath: opts.target,
67
+ sourcePassword: opts["source-pass"] || config.trustStorePassword,
68
+ targetPassword: opts["target-pass"] || config.trustStorePassword,
69
+ sourceType: (opts["source-type"] || "JKS").toUpperCase(),
70
+ targetType: (opts["target-type"] || "JKS").toUpperCase(),
71
+ onConflict: (opts["on-conflict"] || "fail").toLowerCase(),
72
+ dryRun: Boolean(opts["dry-run"]),
73
+ });
74
+
75
+ if (mergeResult?.dryRun) {
76
+ console.log("Dry run passed: merge validation completed, no changes were made.");
77
+ } else {
78
+ console.log("Trust stores merged successfully.");
79
+ }
80
+ process.exit(0);
81
+ }
82
+
83
+ if (action !== "print") {
84
+ printUsage();
85
+ throw new Error(`Unknown action: ${action}`);
86
+ }
87
+
88
+ const commands = getTrustStoreCommands(config);
89
+ console.log("Trust store commands:");
90
+ console.log(commands.copyCmd);
91
+ console.log(commands.importCmd);
92
+ console.log(commands.listCmd);
93
+ } catch (error) {
94
+ console.error(`[truststore] ${error.message}`);
95
+ process.exit(1);
96
+ }
@@ -1,50 +1,50 @@
1
- import path from "node:path";
2
-
3
- function sanitizeSegment(segment) {
4
- return segment.replace(/[<>:\\"|?*]/g, "_");
5
- }
6
-
7
- function safeDecode(pathname) {
8
- try {
9
- return decodeURIComponent(pathname || "/");
10
- } catch {
11
- return pathname || "/";
12
- }
13
- }
14
-
15
- export function getCacheFilePath(cacheDir, urlObj, options = {}) {
16
- const ecosystem = sanitizeSegment(String(options.ecosystem || "generic").toLowerCase());
17
- const includeHost = options.includeHost ?? ecosystem !== "maven";
18
-
19
- const rawPathname = safeDecode(urlObj.pathname || "/");
20
- const normalized = rawPathname.replace(/\\/g, "/");
21
- const lowerNormalized = normalized.toLowerCase();
22
- const parts = normalized.split("/").filter(Boolean);
23
-
24
- if (parts.some((part) => part === "..")) {
25
- throw new Error(`Invalid path traversal attempt: ${rawPathname}`);
26
- }
27
-
28
- if (parts.length === 0) {
29
- parts.push("index");
30
- }
31
-
32
- const safeParts = parts.map((part) => sanitizeSegment(part));
33
-
34
- if (includeHost) {
35
- safeParts.unshift(sanitizeSegment(String(urlObj.hostname || "unknown").toLowerCase()));
36
- }
37
-
38
- const npmTarballPath = /\/-\/.+\.tgz$/i.test(lowerNormalized);
39
- if (ecosystem === "npm" && !npmTarballPath) {
40
- safeParts.push("__meta__.json");
41
- }
42
-
43
- if (urlObj.search && urlObj.search.length > 1) {
44
- const lastIndex = safeParts.length - 1;
45
- const encodedQuery = encodeURIComponent(urlObj.search.slice(1));
46
- safeParts[lastIndex] = `${safeParts[lastIndex]}__q__${encodedQuery}`;
47
- }
48
-
49
- return path.join(cacheDir, ecosystem, ...safeParts);
50
- }
1
+ import path from "node:path";
2
+
3
+ function sanitizeSegment(segment) {
4
+ return segment.replace(/[<>:\\"|?*]/g, "_");
5
+ }
6
+
7
+ function safeDecode(pathname) {
8
+ try {
9
+ return decodeURIComponent(pathname || "/");
10
+ } catch {
11
+ return pathname || "/";
12
+ }
13
+ }
14
+
15
+ export function getCacheFilePath(cacheDir, urlObj, options = {}) {
16
+ const ecosystem = sanitizeSegment(String(options.ecosystem || "generic").toLowerCase());
17
+ const includeHost = options.includeHost ?? ecosystem !== "maven";
18
+
19
+ const rawPathname = safeDecode(urlObj.pathname || "/");
20
+ const normalized = rawPathname.replace(/\\/g, "/");
21
+ const lowerNormalized = normalized.toLowerCase();
22
+ const parts = normalized.split("/").filter(Boolean);
23
+
24
+ if (parts.some((part) => part === "..")) {
25
+ throw new Error(`Invalid path traversal attempt: ${rawPathname}`);
26
+ }
27
+
28
+ if (parts.length === 0) {
29
+ parts.push("index");
30
+ }
31
+
32
+ const safeParts = parts.map((part) => sanitizeSegment(part));
33
+
34
+ if (includeHost) {
35
+ safeParts.unshift(sanitizeSegment(String(urlObj.hostname || "unknown").toLowerCase()));
36
+ }
37
+
38
+ const npmTarballPath = /\/-\/.+\.tgz$/i.test(lowerNormalized);
39
+ if (ecosystem === "npm" && !npmTarballPath) {
40
+ safeParts.push("__meta__.json");
41
+ }
42
+
43
+ if (urlObj.search && urlObj.search.length > 1) {
44
+ const lastIndex = safeParts.length - 1;
45
+ const encodedQuery = encodeURIComponent(urlObj.search.slice(1));
46
+ safeParts[lastIndex] = `${safeParts[lastIndex]}__q__${encodedQuery}`;
47
+ }
48
+
49
+ return path.join(cacheDir, ecosystem, ...safeParts);
50
+ }