@softure-ai/files 0.4.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ Newest first. Each version lists what changed for an app that uses `@softure-ai/
4
4
  in production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
5
5
  "Definition of done").
6
6
 
7
+ ## 0.4.1
8
+
9
+ - Fix: the browser upload page sends the file again from an app's minified production build. The page inlined
10
+ `sendUpload.toString()` and then called `sendUpload(...)`, but a minifier renames the function (`async function
11
+ l(...)`), so pressing Upload threw `ReferenceError: sendUpload is not defined` and nothing was sent. The page now
12
+ binds the inlined source to its own name (`const sendUpload = (...)`). Tests bundle and minify the page module with
13
+ esbuild and run its script in a `vm` context and in Chromium against the upload route.
14
+ - Migration: none; bump the package.
15
+
7
16
  ## 0.4.0
8
17
 
9
18
  - The `files.prune` job logs every run (#1192): one line `files.prune finished` with `removed`, `freedBytes`,
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ export const FILES_RATE_LIMIT_BUCKETS = {
22
22
  export const files = defineModule({
23
23
  manifest: {
24
24
  id: MODULE_ID,
25
- version: "0.4.0",
25
+ version: "0.4.1",
26
26
  dependsOn: { jobs: "^0.1.6?", security: "^0.2.5?" },
27
27
  dbSchema: "files",
28
28
  tables: ["files", "uploads"],
@@ -1 +1 @@
1
- {"version":3,"file":"upload-page.d.ts","sourceRoot":"","sources":["../../src/server/upload-page.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAiCjD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,GAAG,QAAQ,CA0ClG"}
1
+ {"version":3,"file":"upload-page.d.ts","sourceRoot":"","sources":["../../src/server/upload-page.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAmCjD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,GAAG,QAAQ,CA0ClG"}
@@ -11,8 +11,10 @@ const STYLE = `body{font:16px/1.5 system-ui,sans-serif;max-width:32rem;margin:2r
11
11
  button,input{font:inherit}button{margin-top:1rem;padding:.5rem 1rem}progress{width:100%;margin-top:1rem}
12
12
  p[role=status]{min-height:1.5em}`;
13
13
  // The page's script: the client's own `sendUpload`, inlined from its source, then the few lines that wire it to the
14
- // form. `sendUpload` references nothing outside its body (see `client/send-upload.ts`).
15
- const SCRIPT = `${sendUpload.toString()}
14
+ // form. `sendUpload` references nothing outside its body (see `client/send-upload.ts`). The source is bound to a name
15
+ // of its own as an expression: an app's minifier renames the declaration (`async function l(...)`), so the page must
16
+ // never rely on the name `toString()` returns.
17
+ const SCRIPT = `const sendUpload = (${sendUpload.toString()});
16
18
  const config = JSON.parse(document.getElementById("upload-config").textContent);
17
19
  const input = document.getElementById("file");
18
20
  const button = document.getElementById("start");
@@ -1 +1 @@
1
- {"version":3,"file":"upload-page.js","sourceRoot":"","sources":["../../src/server/upload-page.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,iHAAiH;AACjH,kHAAkH;AAClH,qHAAqH;AACrH,mDAAmD;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,KAAK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B,MAAM;QACJ,CAAC,CAAC,oBAAoB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;QACjD,CAAC,CAAC,qBAAqB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;;uCAEX,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;oCACzB,MAAM,CAAC,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC;;qDAEzB,YAAY,CAAC,MAAM,CAAC;iBACxD,KAAK,KAAK,MAAM,WACjC;;QAEQ,CAAC;IACP,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;QACxB,MAAM,EAAE,GAAG;QACX,OAAO,EAAE;YACP,cAAc,EAAE,0BAA0B;YAC1C,eAAe,EAAE,mBAAmB;YACpC,wBAAwB,EAAE,SAAS;YACnC,iBAAiB,EAAE,aAAa;YAChC,yBAAyB,EAAE,yCAAyC,KAAK,uBAAuB,KAAK,oFAAoF;SAC1L;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACjF,CAAC;AAED,kEAAkE;AAClE,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACxD,CAAC"}
package/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "files",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "dependsOn": { "jobs": "^0.1.6?", "security": "^0.2.5?" },
5
5
  "dbSchema": "files",
6
6
  "tables": ["files", "uploads"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/files",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "SOFTURE AI files module: an app's stored files (content hash, size, type, owner, kind, expiry, a per-owner quota, opt-in dedupe) on a storage driver (local disk with atomic writes, S3-compatible with SigV4 and multipart uploads, in memory for tests), streamed and never buffered, public links that expire (HMAC-signed, checked before any database read, revocable per file, a rotating keyring) served by a Next.js route with byte ranges and one 404 for every dead link, the same answer for the signed-in owner by id without a link, resumable chunked uploads through signed URLs (with a browser client, an upload list, a browser page and MCP upload tools), a prune job, a privacy contributor and a health check.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -85,5 +85,9 @@
85
85
  "@softure-ai/jobs": {
86
86
  "optional": true
87
87
  }
88
+ },
89
+ "devDependencies": {
90
+ "@playwright/test": "^1.64.1",
91
+ "esbuild": "^0.28.2"
88
92
  }
89
93
  }
package/src/index.ts CHANGED
@@ -26,7 +26,7 @@ export const FILES_RATE_LIMIT_BUCKETS = {
26
26
  export const files = defineModule({
27
27
  manifest: {
28
28
  id: MODULE_ID,
29
- version: "0.4.0",
29
+ version: "0.4.1",
30
30
  dependsOn: { jobs: "^0.1.6?", security: "^0.2.5?" },
31
31
  dbSchema: "files",
32
32
  tables: ["files", "uploads"],
@@ -16,8 +16,10 @@ button,input{font:inherit}button{margin-top:1rem;padding:.5rem 1rem}progress{wid
16
16
  p[role=status]{min-height:1.5em}`;
17
17
 
18
18
  // The page's script: the client's own `sendUpload`, inlined from its source, then the few lines that wire it to the
19
- // form. `sendUpload` references nothing outside its body (see `client/send-upload.ts`).
20
- const SCRIPT = `${sendUpload.toString()}
19
+ // form. `sendUpload` references nothing outside its body (see `client/send-upload.ts`). The source is bound to a name
20
+ // of its own as an expression: an app's minifier renames the declaration (`async function l(...)`), so the page must
21
+ // never rely on the name `toString()` returns.
22
+ const SCRIPT = `const sendUpload = (${sendUpload.toString()});
21
23
  const config = JSON.parse(document.getElementById("upload-config").textContent);
22
24
  const input = document.getElementById("file");
23
25
  const button = document.getElementById("start");