@0xmaxma/claude-gateway 2.1.7 → 2.1.8
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"packageVersion": "2.1.
|
|
4
|
-
"builtAt": "2026-10-
|
|
5
|
-
"commit": "
|
|
6
|
-
"tag": "v2.1.
|
|
3
|
+
"packageVersion": "2.1.8",
|
|
4
|
+
"builtAt": "2026-10-21T10:48:12.725Z",
|
|
5
|
+
"commit": "ef2cae00f05c298ef3b3085643e5e3a548f401a4",
|
|
6
|
+
"tag": "v2.1.8",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-path.d.ts","sourceRoot":"","sources":["../../src/orchestration/share-path.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"share-path.d.ts","sourceRoot":"","sources":["../../src/orchestration/share-path.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxF"}
|
|
@@ -9,32 +9,57 @@ const crypto_1 = require("crypto");
|
|
|
9
9
|
const types_1 = require("./types");
|
|
10
10
|
/** Keep task-authorized files in the API's session root without attachment ingestion. */
|
|
11
11
|
async function prepareSharePath(source, mediaDir) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
try {
|
|
13
|
+
return await prepareSharePathInternal(source, mediaDir);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error instanceof types_1.OrchestrationError)
|
|
17
|
+
throw error;
|
|
18
|
+
throw new types_1.OrchestrationError('SHARE_PREPARATION_FAILED');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function prepareSharePathInternal(source, mediaDir) {
|
|
15
22
|
const agentRoot = await (0, promises_1.realpath)((0, path_1.join)(mediaDir, '..', '..'));
|
|
23
|
+
// Validate the media parent before creating the session directory.
|
|
24
|
+
await (0, promises_1.mkdir)((0, path_1.join)(mediaDir, '..'), { recursive: true, mode: 0o700 });
|
|
25
|
+
const root = await (0, promises_1.realpath)((0, path_1.join)(mediaDir, '..'));
|
|
26
|
+
if (root !== (0, path_1.join)(agentRoot, 'media'))
|
|
27
|
+
throw new types_1.OrchestrationError('ARTIFACT_PATH_DENIED');
|
|
28
|
+
await (0, promises_1.mkdir)(mediaDir, { recursive: true, mode: 0o700 });
|
|
16
29
|
const directory = await (0, promises_1.realpath)(mediaDir);
|
|
17
|
-
if (
|
|
30
|
+
if (directory !== (0, path_1.join)(root, (0, path_1.basename)(mediaDir)))
|
|
18
31
|
throw new types_1.OrchestrationError('ARTIFACT_PATH_DENIED');
|
|
19
32
|
const ref = (0, path_1.relative)(directory, source);
|
|
20
|
-
|
|
21
|
-
return source;
|
|
22
|
-
const suffix = (0, path_1.extname)(source).slice(0, 12).replace(/[^a-zA-Z0-9.]/g, '');
|
|
23
|
-
const name = `share-${(0, crypto_1.createHash)('sha256').update(source).digest('hex')}${suffix}`;
|
|
24
|
-
const destination = (0, path_1.join)(directory, name);
|
|
25
|
-
const temporary = (0, path_1.join)(directory, `.share-${(0, crypto_1.randomUUID)()}`);
|
|
33
|
+
let input;
|
|
26
34
|
try {
|
|
35
|
+
input = await (0, promises_1.open)(source, fs_1.constants.O_RDONLY | fs_1.constants.O_NOFOLLOW);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const code = error.code;
|
|
39
|
+
if (code === 'EACCES' || code === 'EPERM' || code === 'ENOENT')
|
|
40
|
+
throw new types_1.OrchestrationError('SHARE_SOURCE_UNREADABLE');
|
|
41
|
+
if (code === 'ELOOP')
|
|
42
|
+
throw new types_1.OrchestrationError('ARTIFACT_PATH_DENIED');
|
|
43
|
+
throw new types_1.OrchestrationError('SHARE_PREPARATION_FAILED');
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const sourceStat = await input.stat();
|
|
47
|
+
if (!sourceStat.isFile())
|
|
48
|
+
throw new types_1.OrchestrationError('ARTIFACT_PATH_DENIED');
|
|
49
|
+
if (ref && !ref.startsWith('..') && !(0, path_1.isAbsolute)(ref))
|
|
50
|
+
return source;
|
|
51
|
+
const suffix = (0, path_1.extname)(source).slice(0, 12).replace(/[^a-zA-Z0-9.]/g, '');
|
|
52
|
+
const name = `share-${(0, crypto_1.createHash)('sha256').update(source).digest('hex')}${suffix}`;
|
|
53
|
+
const destination = (0, path_1.join)(directory, name);
|
|
54
|
+
const temporary = (0, path_1.join)(directory, `.share-${(0, crypto_1.randomUUID)()}`);
|
|
27
55
|
try {
|
|
28
|
-
await (0, promises_1.link)(source, temporary);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (error.code !== 'EXDEV')
|
|
32
|
-
throw error;
|
|
33
|
-
// Separate mounts cannot hard-link. Stream from a no-follow descriptor instead.
|
|
34
|
-
const input = await (0, promises_1.open)(source, fs_1.constants.O_RDONLY | fs_1.constants.O_NOFOLLOW);
|
|
35
56
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
await (0, promises_1.link)(source, temporary);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (!['EXDEV', 'EPERM'].includes(String(error.code)))
|
|
61
|
+
throw error;
|
|
62
|
+
// Separate mounts and protected hard links need a bounded-memory copy.
|
|
38
63
|
const output = await (0, promises_1.open)(temporary, 'wx', 0o600);
|
|
39
64
|
try {
|
|
40
65
|
await (0, promises_2.pipeline)(input.createReadStream(), output.createWriteStream());
|
|
@@ -43,24 +68,25 @@ async function prepareSharePath(source, mediaDir) {
|
|
|
43
68
|
await output.close();
|
|
44
69
|
}
|
|
45
70
|
}
|
|
46
|
-
|
|
47
|
-
|
|
71
|
+
const preparedStat = await (0, promises_1.lstat)(temporary);
|
|
72
|
+
if (!preparedStat.isFile() || (preparedStat.nlink > 1 && (preparedStat.dev !== sourceStat.dev || preparedStat.ino !== sourceStat.ino)))
|
|
73
|
+
throw new types_1.OrchestrationError('ARTIFACT_PATH_DENIED');
|
|
74
|
+
await (0, promises_1.rename)(temporary, destination);
|
|
75
|
+
return destination;
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
// POSIX rename is a no-op when both names already refer to the same inode.
|
|
79
|
+
try {
|
|
80
|
+
await (0, promises_1.unlink)(temporary);
|
|
81
|
+
}
|
|
82
|
+
catch (cleanup) {
|
|
83
|
+
if (cleanup.code !== 'ENOENT')
|
|
84
|
+
throw cleanup;
|
|
48
85
|
}
|
|
49
86
|
}
|
|
50
|
-
if (!(await (0, promises_1.lstat)(temporary)).isFile())
|
|
51
|
-
throw new types_1.OrchestrationError('ARTIFACT_PATH_DENIED');
|
|
52
|
-
await (0, promises_1.rename)(temporary, destination);
|
|
53
|
-
return destination;
|
|
54
87
|
}
|
|
55
88
|
finally {
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
await (0, promises_1.unlink)(temporary);
|
|
59
|
-
}
|
|
60
|
-
catch (cleanup) {
|
|
61
|
-
if (cleanup.code !== 'ENOENT')
|
|
62
|
-
throw cleanup;
|
|
63
|
-
}
|
|
89
|
+
await input.close();
|
|
64
90
|
}
|
|
65
91
|
}
|
|
66
92
|
//# sourceMappingURL=share-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-path.js","sourceRoot":"","sources":["../../src/orchestration/share-path.ts"],"names":[],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"share-path.js","sourceRoot":"","sources":["../../src/orchestration/share-path.ts"],"names":[],"mappings":";;AAQA,4CAMC;AAdD,2BAA+B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