diff --git a/deploy/cloudflare-worker/src/index.js b/deploy/cloudflare-worker/src/index.js index 7f090d6..36c2172 100644 --- a/deploy/cloudflare-worker/src/index.js +++ b/deploy/cloudflare-worker/src/index.js @@ -3059,7 +3059,7 @@ function readLimits(env) { maxShareBytes: envInt(env, "MAX_SHARE_BYTES", maxBlobBytes + maxManifestBytes), maxTitleChars: envInt(env, "MAX_TITLE_CHARS", 180), maxThreadIDChars: envInt(env, "MAX_THREAD_ID_CHARS", 128), - maxTtlSeconds: envInt(env, "MAX_TTL_SECONDS", 24 * 60 * 60), + maxTtlSeconds: envInt(env, "MAX_TTL_SECONDS", 7 * 24 * 60 * 60), maxDownloadsPerShare: envInt(env, "MAX_DOWNLOADS_PER_SHARE", 10), liveBytesLimit: envInt(env, "LIVE_BYTES_LIMIT", 4 * GB), monthlyGbDaysLimit: envInt(env, "MONTHLY_GB_DAYS_LIMIT", 120), diff --git a/deploy/cloudflare-worker/test/index.test.js b/deploy/cloudflare-worker/test/index.test.js index f45f3eb..a791b2b 100644 --- a/deploy/cloudflare-worker/test/index.test.js +++ b/deploy/cloudflare-worker/test/index.test.js @@ -5,17 +5,22 @@ import worker, { BudgetGate } from "../src/index.js"; const BASE_URL = "https://capsule.example"; const DEFAULT_INSTALL_COMMAND = "curl -fsSL https://raw.githubusercontent.com/z2z23n0/agent-capsule/main/install.sh | sh"; +const DEFAULT_TTL_SECONDS = 7 * 24 * 60 * 60; test("anonymous upload/download happy path", async () => { const env = fakeEnv(); const blob = new Blob([new Uint8Array([1, 2, 3])], { type: "application/octet-stream" }); + const uploadStartedAt = Date.now(); const upload = await worker.fetch(new Request(BASE_URL + "/v1/shares", { method: "POST", body: shareForm(blob) }), env); + const uploadFinishedAt = Date.now(); assert.equal(upload.status, 201); const created = await upload.json(); assert.match(created.share_url, /^https:\/\/capsule\.example\/s\//); + assert.ok(Date.parse(created.expires_at) >= uploadStartedAt + DEFAULT_TTL_SECONDS * 1000); + assert.ok(Date.parse(created.expires_at) <= uploadFinishedAt + DEFAULT_TTL_SECONDS * 1000); const shareID = new URL(created.share_url).pathname.split("/").pop(); assert.match(shareID, /^[A-Za-z0-9_-]{16}$/); assert.equal(created.manifest_url, BASE_URL + "/v1/shares/" + shareID); @@ -33,7 +38,9 @@ test("anonymous upload/download happy path", async () => { const caps = await worker.fetch(new Request(BASE_URL + "/v1/capabilities"), env); assert.equal(caps.status, 200); - assert.equal((await caps.json()).max_blob_bytes, 32 * 1024 * 1024); + const capabilities = await caps.json(); + assert.equal(capabilities.max_blob_bytes, 32 * 1024 * 1024); + assert.equal(capabilities.max_ttl_seconds, DEFAULT_TTL_SECONDS); }); test("configured BYO token gates uploads but not public reads", async () => { diff --git a/deploy/cloudflare-worker/wrangler.production.toml b/deploy/cloudflare-worker/wrangler.production.toml index 27c9fc6..2a38b1e 100644 --- a/deploy/cloudflare-worker/wrangler.production.toml +++ b/deploy/cloudflare-worker/wrangler.production.toml @@ -22,7 +22,7 @@ MAX_BLOB_BYTES = "33554432" MAX_MANIFEST_BYTES = "8388608" MAX_PREVIEW_PAYLOAD_BYTES = "6291456" MAX_REQUEST_BYTES = "42008576" -MAX_TTL_SECONDS = "86400" +MAX_TTL_SECONDS = "604800" MAX_DOWNLOADS_PER_SHARE = "10" LIVE_BYTES_LIMIT = "4294967296" MONTHLY_GB_DAYS_LIMIT = "120" diff --git a/deploy/cloudflare-worker/wrangler.toml.example b/deploy/cloudflare-worker/wrangler.toml.example index 7560d32..1b0ece7 100644 --- a/deploy/cloudflare-worker/wrangler.toml.example +++ b/deploy/cloudflare-worker/wrangler.toml.example @@ -22,7 +22,7 @@ MAX_BLOB_BYTES = "33554432" MAX_MANIFEST_BYTES = "8388608" MAX_PREVIEW_PAYLOAD_BYTES = "6291456" MAX_REQUEST_BYTES = "42008576" -MAX_TTL_SECONDS = "86400" +MAX_TTL_SECONDS = "604800" MAX_DOWNLOADS_PER_SHARE = "10" LIVE_BYTES_LIMIT = "4294967296" MONTHLY_GB_DAYS_LIMIT = "120"