@ailuntz/resource-agent 1.1.0 → 1.1.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/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Authenticated short-lived S3 download links, with health-aware Cloudflare Tunnel selection and elastic connector workers. Clients receive one link; object data travels through the selected tunnel, without passing through the application backend.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
npm install @ailuntz/resource-agent@1.1.
|
|
6
|
+
npm install @ailuntz/resource-agent@1.1.1
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
Backend integration:
|
|
@@ -23,7 +23,7 @@ Authenticate the user and check resource access on your backend **before** makin
|
|
|
23
23
|
|
|
24
24
|
## Runtime
|
|
25
25
|
|
|
26
|
-
Run `
|
|
26
|
+
Run `resource-agent serve --runtime /runtime` and `resource-agent channels --runtime /runtime` as separate supervised services. There is no native service installer.
|
|
27
27
|
|
|
28
28
|
- `secrets/agent.json`: S3 read-only signing credentials and per-client shared secrets/bucket allowlists.
|
|
29
29
|
- `channels.json`: four pre-provisioned tunnel definitions; first channel id `primary`.
|
|
@@ -46,4 +46,4 @@ The primary tunnel and control tunnel run separately. The channel manager starts
|
|
|
46
46
|
|
|
47
47
|
Scaling preserves existing transfers: stop issuing links, wait at least 150 seconds, and require zero observed in-flight requests before stopping a worker. Missing metrics never permit draining. New requests try healthy lanes after a failure; an interrupted download needs a new URL and a client that supports Range resumption. Multiple tunnels share the same physical uplink.
|
|
48
48
|
|
|
49
|
-
The package contains code only: no deployment credentials, tunnel tokens, customer objects or production host configuration. The Docker image `ailuntz/
|
|
49
|
+
The package contains code only: no deployment credentials, tunnel tokens, customer objects or production host configuration. The Docker image `ailuntz/resource-agent:1.1.1` installs this exact npm release and a pinned official cloudflared binary.
|
|
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
const command = process.argv[2], index = process.argv.indexOf('--runtime');
|
|
6
|
-
const runtime = path.resolve(index >= 0 ? process.argv[index + 1] : process.env.AILUNTZ_RUNTIME || path.join(os.homedir(), '.
|
|
6
|
+
const runtime = path.resolve(index >= 0 ? process.argv[index + 1] : process.env.AILUNTZ_RUNTIME || path.join(os.homedir(), '.resource-agent'));
|
|
7
7
|
process.env.AILUNTZ_RUNTIME = runtime;
|
|
8
8
|
try {
|
|
9
9
|
if (command === 'serve') await (await import('../src/server.mjs')).serve(runtime);
|
|
@@ -13,7 +13,7 @@ try {
|
|
|
13
13
|
const agent = JSON.parse(fs.readFileSync(runtime + '/state/agent.json'));
|
|
14
14
|
console.log(JSON.stringify({agent, policy: state.policy, checkedAt: state.checkedAt, channels: state.channels}, null, 2));
|
|
15
15
|
if (Date.now() - Date.parse(agent.checkedAt) > 15000 || Date.now() - Date.parse(state.checkedAt) > 15000) process.exitCode = 1;
|
|
16
|
-
} else console.log('
|
|
16
|
+
} else console.log('resource-agent <serve|channels|status> [--runtime directory]');
|
|
17
17
|
} catch {
|
|
18
18
|
console.error('Download service could not complete the operation; check local configuration and service status.');
|
|
19
19
|
process.exitCode = 1;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ailuntz/resource-agent",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Authenticated S3 download links and elastic Cloudflare tunnel workers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=22"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"
|
|
10
|
+
"resource-agent": "bin/resource-agent.mjs"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
"./client": "./src/client.mjs",
|
|
@@ -25,5 +25,15 @@
|
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public",
|
|
27
27
|
"registry": "https://registry.npmjs.org/"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"check": "node tools/check.mjs",
|
|
31
|
+
"import": "node tools/import.mjs",
|
|
32
|
+
"backup": "node tools/backup.mjs"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@aws-sdk/client-s3": "3.1133.0",
|
|
36
|
+
"@aws-sdk/lib-storage": "3.1133.0",
|
|
37
|
+
"dotenv": "17.4.2"
|
|
28
38
|
}
|
|
29
39
|
}
|
package/src/server.mjs
CHANGED
|
@@ -38,7 +38,7 @@ export async function serve(runtime) {
|
|
|
38
38
|
server.maxConnections = 64;
|
|
39
39
|
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(19081, '127.0.0.1', resolve); });
|
|
40
40
|
const writeStatus = () => {
|
|
41
|
-
const data = {version: '1.1.
|
|
41
|
+
const data = {version: '1.1.1', pid: process.pid, checkedAt: new Date().toISOString(), ...service.status()};
|
|
42
42
|
const tmp = runtime + '/state/agent.json.tmp';
|
|
43
43
|
fs.writeFileSync(tmp, JSON.stringify(data, null, 2) + '\n', {mode: 0o600});
|
|
44
44
|
fs.renameSync(tmp, runtime + '/state/agent.json');
|