javascript-solid-server 0.0.184 → 0.0.186
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/.claude/settings.local.json +5 -188
- package/.github/CODEOWNERS +27 -0
- package/CONTRIBUTING.md +98 -0
- package/LICENSING.md +30 -0
- package/README.md +2 -1
- package/package.json +1 -1
- package/src/handlers/container.js +24 -16
- package/src/rdf/turtle.js +0 -0
- package/src/server.js +44 -9
- package/src/wac/parser.js +50 -9
- package/test/error-handler.test.js +82 -0
- package/test/turtle.test.js +89 -0
- package/test/wac.test.js +234 -1
- package/.claude/scheduled_tasks.lock +0 -1
|
@@ -141,6 +141,7 @@
|
|
|
141
141
|
"Bash(DATA_ROOT=/tmp/jss-git-test/data node:*)",
|
|
142
142
|
"Bash(git remote set-url:*)",
|
|
143
143
|
"Bash(for:*)",
|
|
144
|
+
"Bash(^/**\" | head -1 | sed ''''s/.*\\* //'''')\")",
|
|
144
145
|
"Bash(if [ ! -d \"node-solid-server\" ])",
|
|
145
146
|
"Bash(then git clone --depth 1 https://github.com/nodeSolidServer/node-solid-server.git)",
|
|
146
147
|
"Bash(node test-local-nss2.js:*)",
|
|
@@ -225,195 +226,11 @@
|
|
|
225
226
|
"Bash(gh api:*)",
|
|
226
227
|
"Bash(gh pr comment:*)",
|
|
227
228
|
"Bash(git pull:*)",
|
|
228
|
-
"Bash(
|
|
229
|
+
"Bash(NODE_OPTIONS=\"--test-name-pattern='should allow any authenticated'\" npm test:*)",
|
|
229
230
|
"Bash(node --test:*)",
|
|
230
|
-
"Bash(
|
|
231
|
-
"Bash(
|
|
232
|
-
"Bash(timeout
|
|
233
|
-
"Bash(timeout 90 bash -c:*)",
|
|
234
|
-
"Bash(git commit -m \"$\\(cat <<''EOF''\nsecurity: add ACL check on WebSocket subscription requests\n\nCheck WAC read permission before allowing subscription to prevent\ninformation leakage via notifications. Unauthorized subscriptions\nnow receive ''err <url> forbidden'' response.\n\nSecurity improvements:\n- Check ACL read access before allowing subscription\n- Validate URLs are on this server \\(prevents SSRF-like probing\\)\n- Add subscription limit and URL length validation\n\nFixes #62\nEOF\n\\)\")",
|
|
235
|
-
"Bash(gh repo fork:*)",
|
|
236
|
-
"Bash(timeout 180 npm test:*)",
|
|
237
|
-
"Bash(git show:*)",
|
|
238
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server log --oneline -30 -- \"test/integration/acl-tls-test.mjs\" \"test-esm/integration/acl-tls-test.js\")",
|
|
239
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server log --oneline --follow -30 -- \"test/integration/acl-tls-test.mjs\")",
|
|
240
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server show 778095ad --stat)",
|
|
241
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server show 778095ad)",
|
|
242
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server show b183c7a0)",
|
|
243
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server log --oneline --before=\"2019-10-29\" --after=\"2019-10-01\" -20)",
|
|
244
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server show 1a92a912 --stat)",
|
|
245
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server log --oneline --all --grep=jaxoncreed)",
|
|
246
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server log --oneline --author=\"jaxoncreed\" -30)",
|
|
247
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server log --oneline --author=\"[Dd]mitri\" -20)",
|
|
248
|
-
"Bash(git -C /home/melvin/remote/github.com/nodeSolidServer/node-solid-server log --oneline --all --grep=\"oidc\" -20)",
|
|
249
|
-
"Bash(npm install)",
|
|
250
|
-
"Bash(timeout 60 npx mocha:*)",
|
|
251
|
-
"Bash(timeout 120 npx mocha:*)",
|
|
252
|
-
"Bash(timeout 30 npx mocha:*)",
|
|
253
|
-
"Bash(openssl x509:*)",
|
|
254
|
-
"Bash(gh pr checks:*)",
|
|
255
|
-
"Bash(gh run view:*)",
|
|
256
|
-
"Bash(gh pr edit:*)",
|
|
257
|
-
"WebFetch(domain:patch-diff.githubusercontent.com)",
|
|
258
|
-
"Bash(git rebase:*)",
|
|
259
|
-
"Bash(timeout 10 npm start)",
|
|
260
|
-
"Bash(node bin/jss.js start:*)",
|
|
261
|
-
"Bash(ssh solid.social \"cd /var/www/jss && git pull && pm2 restart jss\")",
|
|
262
|
-
"Bash(ssh solid.social:*)",
|
|
263
|
-
"Bash(git -C /tmp/lws-server log --oneline --all -20)",
|
|
264
|
-
"Bash(git -C /tmp/lws-server branch -a)",
|
|
265
|
-
"Bash(git -C /tmp/lws-server show-branch -a)",
|
|
266
|
-
"WebFetch(domain:web-platform-tests.org)",
|
|
267
|
-
"Bash(file:*)",
|
|
268
|
-
"WebFetch(domain:karate.apache.org)",
|
|
269
|
-
"WebFetch(domain:restfulapi.net)",
|
|
270
|
-
"Bash(npm run test:jss:*)",
|
|
271
|
-
"Bash(node /home/melvin/remote/github.com/JavaScriptSolidServer/JavaScriptSolidServer/bin/jss.js start:*)",
|
|
272
|
-
"Bash(VERBOSE=true npm run test:jss:*)",
|
|
273
|
-
"Bash(npm whoami:*)",
|
|
274
|
-
"Bash(node bin/lws-test.js:*)",
|
|
275
|
-
"Bash(timeout 2 node:*)",
|
|
276
|
-
"Bash(node index.js:*)",
|
|
277
|
-
"Bash(timeout 3 npx lws-server@0.0.3:*)",
|
|
278
|
-
"Bash(npx lws-server@0.0.3)",
|
|
279
|
-
"Bash(node /tmp/jssd/verify-spacing.js:*)",
|
|
280
|
-
"Bash(gh run list:*)",
|
|
281
|
-
"Bash(pm2 startup:*)",
|
|
282
|
-
"Bash(npm run build:*)",
|
|
283
|
-
"Bash(npx esbuild:*)",
|
|
284
|
-
"Bash(gzip:*)",
|
|
285
|
-
"Bash(sort:*)",
|
|
286
|
-
"Bash(echo __NEW_LINE_496cf3994d374e5c__ echo '1. jsonld \\(277 KB\\) - used by:' grep -r \"from ['''']jsonld\" src/ --include=*.ts --include=*.js 2)",
|
|
287
|
-
"Bash(/dev/null __NEW_LINE_496cf3994d374e5c__ echo echo '2. readable-stream \\(180 KB\\) - used by:' grep -r readable-stream node_modules/n3/package.json node_modules/jsonld/package.json)",
|
|
288
|
-
"Bash(head -3 __NEW_LINE_496cf3994d374e5c__ echo echo '3. n3 \\(156 KB\\) - used by:' grep -r \"from ['''']n3\" src/ --include=*.ts --include=*.js 2)",
|
|
289
|
-
"Bash(/dev/null __NEW_LINE_496cf3994d374e5c__ echo echo '4. @xmldom/xmldom \\(136 KB\\) - used by:' grep -r xmldom src/ --include=*.ts --include=*.js 2)",
|
|
290
|
-
"Bash(/dev/null __NEW_LINE_496cf3994d374e5c__ echo echo '5. @frogcat/ttl2jsonld \\(135 KB\\) - used by:' grep -r ttl2jsonld src/ --include=*.ts --include=*.js)",
|
|
291
|
-
"Bash(echo \"\" __NEW_LINE_b9f7c85f1ada8a30__ echo \"1. jsonld \\(277 KB\\):\" grep -rn \"jsonld\" src/ --include=\"*.ts\" --include=\"*.js\")",
|
|
292
|
-
"Bash(head -5 __NEW_LINE_b9f7c85f1ada8a30__ echo \"\" echo \"2. n3 \\(156 KB\\):\" grep -rn \"from ''''n3''''\" src/ --include=\"*.ts\" --include=\"*.js\")",
|
|
293
|
-
"Bash(head -5 __NEW_LINE_b9f7c85f1ada8a30__ echo \"\" echo \"3. @xmldom \\(136 KB\\):\" grep -rn \"xmldom\" src/ --include=\"*.ts\" --include=\"*.js\")",
|
|
294
|
-
"Bash(head -5 __NEW_LINE_b9f7c85f1ada8a30__ echo \"\" echo \"4. @frogcat/ttl2jsonld \\(135 KB\\):\" grep -rn \"ttl2jsonld\" src/ --include=\"*.ts\" --include=\"*.js\")",
|
|
295
|
-
"Bash(head -5 __NEW_LINE_b9f7c85f1ada8a30__ echo \"\" echo \"5. cross-fetch \\(20 KB\\):\" grep -rn \"cross-fetch\" src/ --include=\"*.ts\" --include=\"*.js\")",
|
|
296
|
-
"Bash(head -5 __NEW_LINE_b9f7c85f1ada8a30__ echo \"\" echo \"6. solid-namespace \\(3 KB\\):\" grep -rn \"solid-namespace\" src/ --include=\"*.ts\" --include=\"*.js\")",
|
|
297
|
-
"Bash(echo __NEW_LINE_fbfd1802fc51eb60__ echo '1. jsonld \\(277 KB\\):' grep -n jsonld src/*.ts src/*.js)",
|
|
298
|
-
"Bash(grep -E \"import|require\" __NEW_LINE_fbfd1802fc51eb60__ echo echo '2. n3 \\(156 KB\\):' grep -n ''n3'' src/*.ts src/*.js)",
|
|
299
|
-
"Bash(grep -E \"import|require\" __NEW_LINE_fbfd1802fc51eb60__ echo echo '3. @xmldom \\(136 KB\\):' grep -n xmldom src/*.ts src/*.js)",
|
|
300
|
-
"Bash(grep -E \"import|require\" __NEW_LINE_fbfd1802fc51eb60__ echo echo '4. @frogcat/ttl2jsonld \\(135 KB\\):' grep -n ttl2jsonld src/*.ts src/*.js)",
|
|
301
|
-
"Bash(grep -E \"import|require\" __NEW_LINE_fbfd1802fc51eb60__ echo echo '5. cross-fetch \\(20 KB\\):' grep -n cross-fetch src/*.ts src/*.js)",
|
|
302
|
-
"Bash(grep -E \"import|require\" __NEW_LINE_fbfd1802fc51eb60__ echo echo '6. solid-namespace \\(3 KB\\):' grep -n solid-namespace src/*.ts src/*.js)",
|
|
303
|
-
"Bash(npm run build:all:*)",
|
|
304
|
-
"Bash(git status:*)",
|
|
305
|
-
"Bash(npm run lint-fix:*)",
|
|
306
|
-
"Bash(npm uninstall:*)",
|
|
307
|
-
"Bash(npm search:*)",
|
|
308
|
-
"Bash(npm run lint:*)",
|
|
309
|
-
"Bash(npm run typecheck:*)",
|
|
310
|
-
"Bash(du:*)",
|
|
311
|
-
"Bash(for pkg in activitystreams-pane chat-pane contacts-pane folder-pane issue-pane meeting-pane profile-pane source-pane pane-registry)",
|
|
312
|
-
"Bash(do du -sh node_modules/$pkg)",
|
|
313
|
-
"Bash(for pkg in solid-ui solid-logic react react-dom lodash core-js @inrupt marked dompurify)",
|
|
314
|
-
"Bash(npm why:*)",
|
|
315
|
-
"Bash(for pkg in activitystreams-pane chat-pane contacts-pane folder-pane issue-pane meeting-pane profile-pane source-pane)",
|
|
316
|
-
"Bash(wc -l echo 'Brings: mime-types \\(we already removed this pattern\\)' echo echo '=== profile-pane unique deps ===')",
|
|
317
|
-
"Bash(npm run build-prod:*)",
|
|
318
|
-
"Bash(ln:*)",
|
|
319
|
-
"WebFetch(domain:remotestorage.io)",
|
|
320
|
-
"Bash(gh issue create --title \"Feature: --public flag to skip WAC and allow open access\" --body \"$\\(cat << ''ENDOFFILE''\n## Summary\n\nAdd a `--public` flag that disables WAC \\(Web Access Control\\) checks, allowing unauthenticated read/write access to all resources. This enables JSS to be used as a simple file server similar to `npx serve`, but with REST write capabilities.\n\n**Difficulty**: 15/100 \n**Estimated Effort**: 2-4 hours \n**Dependencies**: None\n\n---\n\n## Motivation\n\nCurrently, JSS requires either:\n1. ACL files to grant access, or\n2. Authentication via Solid-OIDC\n\nThis makes it impossible to use JSS as a simple \"just serve this folder\" tool like `npx serve`. The `--public` flag would enable:\n\n1. **Quick local development** - No auth setup needed\n2. **Simple file sharing** - LAN file server with write support\n3. **jsserve wrapper** - Foundation for `npx jsserve` \\(see future issue\\)\n4. **WebDAV alternative** - Simple REST-based file server\n5. **Testing/demos** - Quick Solid server without auth complexity\n\n---\n\n## Proposed Implementation\n\n### CLI Flag\n\n```bash\njss start --public # Open read/write, no auth\njss start --public --read-only # Open read, no writes \\(like npx serve\\)\n```\n\n### Environment Variable\n\n```bash\nJSS_PUBLIC=true jss start\n```\n\n### Config File\n\n```json\n{\n \"public\": true\n}\n```\n\n---\n\n## Implementation Details\n\n### 1. Add flag to CLI \\(`bin/jss.js`\\)\n\n```javascript\n.option\\(''--public'', ''Allow unauthenticated access to all resources \\(disables WAC\\)''\\)\n.option\\(''--read-only'', ''Disable PUT/DELETE methods \\(read-only mode\\)''\\)\n```\n\n### 2. Add to config \\(`src/config.js`\\)\n\n```javascript\nconst DEFAULTS = {\n // ... existing ...\n public: false,\n readOnly: false,\n};\n\n// Environment variable mapping\nif \\(process.env.JSS_PUBLIC\\) {\n config.public = process.env.JSS_PUBLIC === ''true'';\n}\nif \\(process.env.JSS_READ_ONLY\\) {\n config.readOnly = process.env.JSS_READ_ONLY === ''true'';\n}\n```\n\n### 3. Skip WAC when public \\(`src/auth/middleware.js`\\)\n\n```javascript\nexport async function authorize\\(request, reply\\) {\n // Public mode - skip all auth/WAC checks\n if \\(request.config?.public\\) {\n return; // Allow request to proceed\n }\n \n // ... existing WAC logic ...\n}\n```\n\n### 4. Block writes when read-only \\(`src/handlers/resource.js`, `src/handlers/container.js`\\)\n\n```javascript\n// At start of PUT/DELETE handlers\nif \\(request.config?.readOnly\\) {\n return reply.code\\(405\\).send\\({ \n error: ''Method Not Allowed'',\n message: ''Server is in read-only mode''\n }\\);\n}\n```\n\n---\n\n## Behavior Matrix\n\n| Flag Combination | GET | PUT/DELETE | Auth Required |\n|------------------|-----|------------|---------------|\n| \\(default\\) | ACL | ACL | Yes \\(if ACL requires\\) |\n| `--public` | ✅ Allow | ✅ Allow | No |\n| `--public --read-only` | ✅ Allow | ❌ Block | No |\n| `--read-only` \\(no public\\) | ACL | ❌ Block | Yes |\n\n---\n\n## Security Considerations\n\n### Warning on Startup\n\nWhen `--public` is enabled, show a clear warning:\n\n```\n⚠️ WARNING: Server running in PUBLIC mode\n All files are readable and writable without authentication.\n Do not use in production or expose to the internet.\n```\n\n### Binding to localhost by default?\n\nConsider: When `--public` is set, should the default host be `localhost` instead of `0.0.0.0`?\n\n```javascript\nif \\(config.public && !explicitHostSet\\) {\n config.host = ''localhost''; // Safer default for public mode\n}\n```\n\nUser can override with `--public --host 0.0.0.0` if they explicitly want network access.\n\n---\n\n## Examples\n\n### Local Development\n```bash\n# Quick Solid-compatible file server for development\njss start --public --port 3000 --root ./test-data\n```\n\n### Read-Only File Sharing\n```bash\n# Share files on LAN, no writes allowed\njss start --public --read-only --host 0.0.0.0 --root ~/shared\n```\n\n### Testing Solid Apps\n```bash\n# Test app without auth complexity\njss start --public --root ./fixtures\nnpm test\n```\n\n---\n\n## Files to Modify\n\n| File | Changes |\n|------|---------|\n| `bin/jss.js` | Add `--public` and `--read-only` options \\(~5 LOC\\) |\n| `src/config.js` | Add defaults and env var mapping \\(~10 LOC\\) |\n| `src/auth/middleware.js` | Skip WAC when public \\(~5 LOC\\) |\n| `src/handlers/resource.js` | Block writes when read-only \\(~5 LOC\\) |\n| `src/handlers/container.js` | Block writes when read-only \\(~5 LOC\\) |\n| **Total** | **~30 LOC** |\n\n---\n\n## Testing\n\n```javascript\ndescribe\\(''--public flag'', \\(\\) => {\n it\\(''should allow unauthenticated GET'', async \\(\\) => {\n const server = await createServer\\({ public: true, root: tmpDir }\\);\n const res = await request\\(server\\).get\\(''/file.txt''\\);\n expect\\(res.status\\).toBe\\(200\\);\n }\\);\n\n it\\(''should allow unauthenticated PUT'', async \\(\\) => {\n const server = await createServer\\({ public: true, root: tmpDir }\\);\n const res = await request\\(server\\)\n .put\\(''/new-file.txt''\\)\n .send\\(''content''\\);\n expect\\(res.status\\).toBe\\(201\\);\n }\\);\n\n it\\(''should block PUT when read-only'', async \\(\\) => {\n const server = await createServer\\({ public: true, readOnly: true, root: tmpDir }\\);\n const res = await request\\(server\\)\n .put\\(''/new-file.txt''\\)\n .send\\(''content''\\);\n expect\\(res.status\\).toBe\\(405\\);\n }\\);\n}\\);\n```\n\n---\n\n## Related Issues\n\n- Future: `jsserve` package \\(thin wrapper using this flag\\)\n- #100 - Production Readiness \\(this is a dev/convenience feature\\)\n\n---\n\n## Open Questions\n\n1. Should `--public` default to `localhost` binding for safety?\n2. Should there be a `--public-read` \\(read-only public\\) shorthand?\n3. Should `--public` disable IdP/login UI entirely, or just make it optional?\nENDOFFILE\n\\)\")",
|
|
321
|
-
"Bash(npx serve --help:*)",
|
|
322
|
-
"Bash(npm exec serve:*)",
|
|
323
|
-
"Bash(npm link)",
|
|
324
|
-
"Bash(npm link:*)",
|
|
325
|
-
"Bash(git push)",
|
|
326
|
-
"Bash(ulimit:*)",
|
|
327
|
-
"Bash(gh label:*)",
|
|
328
|
-
"Bash(mongosh --eval \"db.runCommand\\({ ping: 1 }\\)\" 2>&1 | head -5)",
|
|
329
|
-
"Bash(which jss && jss --version 2>&1)",
|
|
330
|
-
"Bash(jss start --help 2>&1 | grep -i mongo)",
|
|
331
|
-
"Bash(grep -A5 '\"\"files\"\"' package.json)",
|
|
332
|
-
"Bash(mkdir -p /tmp/wt-check)",
|
|
333
|
-
"Bash(npm init:*)",
|
|
334
|
-
"WebFetch(domain:webtorrent.io)",
|
|
335
|
-
"Bash(TORRENT=/home/melvin/.claude/projects/-home-melvin-remote-github-com-JavaScriptSolidServer-JavaScriptSolidServer/a05da419-92b7-4056-93b8-e97b2035d4ae/tool-results/webfetch-1774004425803-fce7mx.bin npx -y parse-torrent $TORRENT)",
|
|
336
|
-
"Bash(gh issue:*)",
|
|
337
|
-
"Bash(sed -i 's|Settings/|settings/|g' src/server.js src/handlers/container.js src/webid/profile.js)",
|
|
338
|
-
"Bash(sed -i 's|// Settings folder|// settings folder|' src/handlers/container.js)",
|
|
339
|
-
"WebFetch(domain:www.x402.org)",
|
|
340
|
-
"Bash(jss start:*)",
|
|
341
|
-
"Read(//tmp/**)",
|
|
342
|
-
"Bash(sed -i 's/\"currency\": \"sats\"/\"currency\": \"tbtc4\"/g' /home/melvin/articles/solid-402.html /home/melvin/articles/solid-pay.html /home/melvin/articles/solid-balance.html)",
|
|
343
|
-
"Bash(sed -i 's/\"currency\":\"sats\"/\"currency\":\"tbtc4\"/g' /home/melvin/articles/solid-402.html /home/melvin/articles/solid-pay.html /home/melvin/articles/solid-balance.html)",
|
|
344
|
-
"WebFetch(domain:lists.w3.org)",
|
|
345
|
-
"Bash(git:*)",
|
|
346
|
-
"Bash(npm publish:*)",
|
|
347
|
-
"WebFetch(domain:git-mark.com)",
|
|
348
|
-
"WebFetch(domain:w3id.org)",
|
|
349
|
-
"WebFetch(domain:webledgers.github.io)",
|
|
350
|
-
"Bash(\\\\\"git config:*)",
|
|
351
|
-
"Read(//usr/local/lib/node_modules/gitmark-test/**)",
|
|
352
|
-
"WebFetch(domain:nip98.com)",
|
|
353
|
-
"WebFetch(domain:htmlpreview.github.io)",
|
|
354
|
-
"WebFetch(domain:timbl.solidcommunity.net)",
|
|
355
|
-
"Read(//home/melvin/remote/github.com/solid-helper/core/**)",
|
|
356
|
-
"Bash(curl -s https://www.gnu.org/licenses/agpl-3.0.txt)",
|
|
357
|
-
"Bash(cat LICENSE.full)",
|
|
358
|
-
"Bash(rm LICENSE.full)",
|
|
359
|
-
"Bash(awk -F: '{print $1,$2}')",
|
|
360
|
-
"Bash(awk -F: '{print $1}')",
|
|
361
|
-
"WebFetch(domain:www.gitfork.app)",
|
|
362
|
-
"Bash(JSS_SINGLE_USER_PASSWORD=hunter2 timeout 3 node bin/jss.js start --port 4581 --root /tmp/jss-103 --single-user --single-user-name alice --idp)",
|
|
363
|
-
"Bash(JSS_SINGLE_USER_PASSWORD=hunter2 timeout 2 node bin/jss.js start --port 4581 --root /tmp/jss-103 --single-user-name alice --idp)",
|
|
364
|
-
"Bash(JSS_SINGLE_USER_PASSWORD=hunter2 timeout 3 node bin/jss.js start --port 4581 --root /tmp/jss-103-sanity --single-user-name alice --single-user --idp)",
|
|
365
|
-
"Bash(pm2 jlist *)",
|
|
366
|
-
"Bash(jss --version)",
|
|
367
|
-
"Bash(cp -a ~/main/me ~/main/me.backup-pre-348)",
|
|
368
|
-
"Bash(cp -a ~/main/.idp/accounts ~/main/.idp/accounts.backup-pre-348)",
|
|
369
|
-
"Bash(mv ~/main/me.backup-pre-348 ~/main.backup-me-pre-348)",
|
|
370
|
-
"Bash(mv ~/main/.idp/accounts.backup-pre-348 ~/main.backup-accounts-pre-348)",
|
|
371
|
-
"Bash(shopt -s dotglob)",
|
|
372
|
-
"Bash(mv ~/main/me/* ~/main/)",
|
|
373
|
-
"Bash(shopt -u dotglob)",
|
|
374
|
-
"Bash(rmdir ~/main/me)",
|
|
375
|
-
"Bash(rm /tmp/dup-issue.md)",
|
|
376
|
-
"Bash(rm -rf /tmp/losos-fix)",
|
|
377
|
-
"Bash(terser losos/shell.js -m -c)",
|
|
378
|
-
"Bash(terser losos/html.js -m -c)",
|
|
379
|
-
"Bash(terser losos/store.js -m -c)",
|
|
380
|
-
"Bash(terser losos/registry.js -m -c)",
|
|
381
|
-
"Bash(terser losos/losos.js -m -c)",
|
|
382
|
-
"Bash(DATA_ROOT=/tmp/whatever node --test test/url.test.js)",
|
|
383
|
-
"Bash(gh run *)",
|
|
384
|
-
"Bash(command -v flutter)",
|
|
385
|
-
"Bash(flutter --version)",
|
|
386
|
-
"Bash(command -v adb)",
|
|
387
|
-
"Bash(command -v node)",
|
|
388
|
-
"Bash(rm -rf /tmp/jss-mobile-test)",
|
|
389
|
-
"Bash(mkdir -p /tmp/jss-mobile-test)",
|
|
390
|
-
"Bash(JSS_SINGLE_USER_PASSWORD=test1234 node bin/jss.js start --single-user --port 4444 --root /tmp/jss-mobile-test --idp)",
|
|
391
|
-
"Bash(./scripts/bundle-jss.sh 0.0.169)",
|
|
392
|
-
"Bash(JSS_SINGLE_USER_PASSWORD=test1234 node assets/nodejs-project/bin/jss.js start --single-user --port 4446 --host 127.0.0.1 --root /tmp/jss-bundle-smoke --idp)",
|
|
393
|
-
"Bash(flutter create *)",
|
|
394
|
-
"Bash(flutter pub *)",
|
|
395
|
-
"WebFetch(domain:pub.dev)",
|
|
396
|
-
"WebFetch(domain:nodejs-mobile.github.io)",
|
|
397
|
-
"WebFetch(domain:bare.pears.com)",
|
|
398
|
-
"Bash(command -v gradle)",
|
|
399
|
-
"Bash(gradle --version)",
|
|
400
|
-
"Bash(java -version)",
|
|
401
|
-
"Bash(./gradlew --version)",
|
|
402
|
-
"Bash(./gradlew :app:tasks --no-daemon --warning-mode=none)",
|
|
403
|
-
"Bash(ANDROID_HOME=/home/melvin/Android/Sdk ANDROID_SDK_ROOT=/home/melvin/Android/Sdk ./gradlew :app:tasks --no-daemon)",
|
|
404
|
-
"Bash(ANDROID_HOME=/home/melvin/Android/Sdk ANDROID_SDK_ROOT=/home/melvin/Android/Sdk ./gradlew :app:processDebugResources --no-daemon)",
|
|
405
|
-
"Bash(ANDROID_HOME=/home/melvin/Android/Sdk ANDROID_SDK_ROOT=/home/melvin/Android/Sdk ./gradlew :app:compileDebugKotlin --no-daemon)",
|
|
406
|
-
"Bash(./scripts/fetch-libnode.sh v18.20.4)",
|
|
407
|
-
"Bash(ANDROID_HOME=/home/melvin/Android/Sdk ANDROID_SDK_ROOT=/home/melvin/Android/Sdk ./gradlew :app:assembleDebug --no-daemon)",
|
|
408
|
-
"Bash(/home/melvin/Android/Sdk/platform-tools/adb devices *)",
|
|
409
|
-
"Bash(command -v chromium chromium-browser google-chrome firefox playwright)",
|
|
410
|
-
"Bash(/usr/bin/chromium-browser --headless --no-sandbox --disable-gpu --hide-scrollbars --window-size=480,800 --screenshot=/tmp/consent-preview.png file:///tmp/consent-preview.html)",
|
|
411
|
-
"Bash(cp /tmp/consent-preview.html ~/consent-preview.html)",
|
|
412
|
-
"Read(//home/melvin/**)",
|
|
413
|
-
"Bash(/usr/bin/chromium-browser --headless --no-sandbox --disable-gpu --hide-scrollbars --window-size=520,900 --screenshot=consent.png file:///home/melvin/consent-preview.html)",
|
|
414
|
-
"Bash(sed -i '0,/\"version\": \"0.0.181\"/{s/\"version\": \"0.0.181\"/\"version\": \"0.0.182\"/}' package-lock.json)",
|
|
415
|
-
"WebFetch(domain:losos.org)",
|
|
416
|
-
"Bash(sed -i '0,/\"version\": \"0.0.183\"/{s/\"version\": \"0.0.183\"/\"version\": \"0.0.184\"/}' package-lock.json)"
|
|
231
|
+
"Bash(git commit -m \"$\\(cat <<''EOF''\ntest: add coverage for acl:AuthenticatedAgent\n\nAdd test to verify that acl:AuthenticatedAgent works correctly:\n- Denies anonymous/unauthenticated access\n- Allows the resource owner\n- Allows ANY authenticated user \\(key distinction from private ACLs\\)\n\nFixes #58\nEOF\n\\)\")",
|
|
232
|
+
"Bash(timeout 60 node --test:*)",
|
|
233
|
+
"Bash(timeout 45 node --test:*)"
|
|
417
234
|
]
|
|
418
235
|
}
|
|
419
236
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# CODEOWNERS — paths that auto-request review from the listed owners.
|
|
2
|
+
#
|
|
3
|
+
# GitHub matches paths in order. The most specific match for a given
|
|
4
|
+
# file wins. The catch-all `*` pattern at the top covers everything
|
|
5
|
+
# else; the path-specific entries below document review responsibility
|
|
6
|
+
# for security-sensitive surfaces explicitly.
|
|
7
|
+
#
|
|
8
|
+
# Format reference:
|
|
9
|
+
# https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
|
|
10
|
+
|
|
11
|
+
# Default — all files
|
|
12
|
+
* @melvincarvalho
|
|
13
|
+
|
|
14
|
+
# Auth / security-sensitive paths
|
|
15
|
+
/src/auth/ @melvincarvalho
|
|
16
|
+
/src/idp/ @melvincarvalho
|
|
17
|
+
/src/utils/ssrf.js @melvincarvalho
|
|
18
|
+
|
|
19
|
+
# CLI and release surface
|
|
20
|
+
/bin/ @melvincarvalho
|
|
21
|
+
/package.json @melvincarvalho
|
|
22
|
+
/package-lock.json @melvincarvalho
|
|
23
|
+
|
|
24
|
+
# Legal / policy substrate
|
|
25
|
+
/LICENSE @melvincarvalho
|
|
26
|
+
/CONTRIBUTING.md @melvincarvalho
|
|
27
|
+
/.github/ @melvincarvalho
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Contributing to JSS
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing to JavaScript Solid Server (JSS).
|
|
4
|
+
This document covers the conventions the project already follows. Aim is
|
|
5
|
+
*reference card*, not tutorial — one screen, scannable.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/JavaScriptSolidServer/JavaScriptSolidServer
|
|
11
|
+
cd JavaScriptSolidServer
|
|
12
|
+
npm install
|
|
13
|
+
npm test # ~40s, 780+ tests
|
|
14
|
+
node bin/jss.js # run a local pod
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
The project follows a strict **issue → branch → PR → merge → pull** sequence.
|
|
20
|
+
No direct commits to `gh-pages` (the default branch).
|
|
21
|
+
|
|
22
|
+
1. Open an issue describing the change (or pick an existing one)
|
|
23
|
+
2. Branch: `git checkout -b issue-<number>-short-slug`
|
|
24
|
+
3. Commit with a descriptive title + multi-paragraph body explaining the *why*
|
|
25
|
+
(see existing history for the cadence)
|
|
26
|
+
4. Open a PR linked to the issue
|
|
27
|
+
5. Address Copilot review iteratively until clean (the project leans heavily
|
|
28
|
+
on automated review passes)
|
|
29
|
+
6. Squash-merge, delete branch, `git pull`
|
|
30
|
+
|
|
31
|
+
## Code style
|
|
32
|
+
|
|
33
|
+
- **ESM only**, Node ≥ 22 LTS
|
|
34
|
+
- **No native modules** — runs unmodified on Termux, postmarketOS,
|
|
35
|
+
Cloudflare Workers
|
|
36
|
+
- **JSDoc** on public exports; inline `//` comments explain *why*, not *what*
|
|
37
|
+
- **Tests via `node --test`** — no test framework dependency
|
|
38
|
+
- **No build step** — the source you read is the source that runs
|
|
39
|
+
|
|
40
|
+
## AI-assistance disclosure
|
|
41
|
+
|
|
42
|
+
JSS welcomes thoughtfully-prepared contributions, including those drafted
|
|
43
|
+
with AI assistance. To keep provenance clear:
|
|
44
|
+
|
|
45
|
+
- **Disclose AI assistance** in the PR description. Indicate one of:
|
|
46
|
+
- hand-authored
|
|
47
|
+
- AI-assisted with substantive human review
|
|
48
|
+
- substantially AI-generated
|
|
49
|
+
- **Share prompts** for substantial AI-generated portions (in the PR
|
|
50
|
+
description or a linked artifact) so reviewers can assess scope.
|
|
51
|
+
- **Authorship responsibility** — code review, follow-up, and licence
|
|
52
|
+
obligations stay with the contributor regardless of AI involvement.
|
|
53
|
+
- **Per-contributor flexibility** — established contributors with a
|
|
54
|
+
consistent disclosure history may agree streamlined arrangements
|
|
55
|
+
with the maintainer.
|
|
56
|
+
|
|
57
|
+
This is consistent with [NLnet's generative-AI policy for funded
|
|
58
|
+
projects](https://nlnet.nl/foundation/policies/generativeAI/) and
|
|
59
|
+
general open-source provenance best practice; it is not a JSS-specific
|
|
60
|
+
imposition.
|
|
61
|
+
|
|
62
|
+
A PR template (`.github/pull_request_template.md`) carries the same
|
|
63
|
+
checklist so every PR captures the disclosure inline.
|
|
64
|
+
|
|
65
|
+
## Forks and downstream distribution
|
|
66
|
+
|
|
67
|
+
JSS is AGPL-3.0. Forks are welcome.
|
|
68
|
+
|
|
69
|
+
The licence terms set the boundary: **§5(a)** requires a prominent
|
|
70
|
+
modification notice on conveyed (deployed, published, or distributed)
|
|
71
|
+
modified versions, with a relevant date. Forks operating a public
|
|
72
|
+
deployment are encouraged to surface this notice on the deployment
|
|
73
|
+
itself — about page, footer, response headers, or equivalent — so
|
|
74
|
+
downstream users have visible provenance.
|
|
75
|
+
|
|
76
|
+
If you are forking and want to ensure §5(a) compliance, please open an
|
|
77
|
+
issue or ping the maintainer; happy to advise on how to apply the
|
|
78
|
+
notice cleanly.
|
|
79
|
+
|
|
80
|
+
## Licence and CLA
|
|
81
|
+
|
|
82
|
+
JSS is licensed under AGPL-3.0 (see `LICENSE`). All contributions are
|
|
83
|
+
accepted under the same licence by default.
|
|
84
|
+
|
|
85
|
+
A Contributor Licence Agreement is being drafted and will be required
|
|
86
|
+
for substantial contributions ahead of the `0.1` release; details and
|
|
87
|
+
process will be published as part of that milestone work. Until then,
|
|
88
|
+
the GitHub commit-via-PR flow constitutes acceptance of the project
|
|
89
|
+
licence for the contributed change.
|
|
90
|
+
|
|
91
|
+
## Where to ask
|
|
92
|
+
|
|
93
|
+
- **Bugs / feature requests:** the GitHub issue tracker
|
|
94
|
+
- **Security issues:** see `SECURITY.md` (forthcoming) for the
|
|
95
|
+
responsible-disclosure path
|
|
96
|
+
- **General questions:** ping the maintainer via the project's issue
|
|
97
|
+
tracker; conversational venues are intentionally not listed here so
|
|
98
|
+
the canonical record stays on GitHub
|
package/LICENSING.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Licensing
|
|
2
|
+
|
|
3
|
+
JSS is distributed under the GNU Affero General Public License v3.0
|
|
4
|
+
(AGPL-3.0) — see [LICENSE](./LICENSE) for the full text.
|
|
5
|
+
|
|
6
|
+
The AGPL-3.0 is appropriate for most use cases, including
|
|
7
|
+
network-deployed Solid servers (single-user, multi-user, agentic),
|
|
8
|
+
community projects, research deployments, and commercial deployments
|
|
9
|
+
compatible with AGPL terms (including §13 source-availability
|
|
10
|
+
obligations on network-deployed modified versions, and §5(a)
|
|
11
|
+
modification notice requirements).
|
|
12
|
+
|
|
13
|
+
## Commercial licensing
|
|
14
|
+
|
|
15
|
+
Commercial licensing is also available for organisations whose
|
|
16
|
+
deployment requirements are incompatible with AGPL-3.0 — for example:
|
|
17
|
+
|
|
18
|
+
- Organisations whose internal policies forbid AGPL substrate
|
|
19
|
+
- Network-deployed services where source-availability obligations
|
|
20
|
+
(AGPL §13) cannot be satisfied
|
|
21
|
+
- Embedded or OEM redistribution in proprietary products
|
|
22
|
+
- Integration with proprietary stacks where copyleft contamination
|
|
23
|
+
is a concern
|
|
24
|
+
|
|
25
|
+
Custom-licensed deployments are negotiable per-case. Terms typically
|
|
26
|
+
include an annual or multi-year license fee, defined deployment scope
|
|
27
|
+
(per server / per organisation / per use case), and a patent grant.
|
|
28
|
+
|
|
29
|
+
To inquire about commercial licensing, contact
|
|
30
|
+
`melvincarvalho@gmail.com` with subject prefix `[JSS LICENSING]`.
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { initializeQuota, checkQuota, updateQuotaUsage } from '../storage/quota.
|
|
|
3
3
|
import { getAllHeaders } from '../ldp/headers.js';
|
|
4
4
|
import { isContainer, getEffectiveUrlPath, getPodName } from '../utils/url.js';
|
|
5
5
|
import { generateProfile, generatePreferences, generateTypeIndex, serialize } from '../webid/profile.js';
|
|
6
|
-
import { generateOwnerAcl, generatePrivateAcl, generateInboxAcl, generatePublicFolderAcl, serializeAcl } from '../wac/parser.js';
|
|
6
|
+
import { generateOwnerAcl, generatePrivateAcl, generateInboxAcl, generatePublicFolderAcl, serializeAcl, relativizeOwnerWebId } from '../wac/parser.js';
|
|
7
7
|
import { createToken } from '../auth/token.js';
|
|
8
8
|
import { canAcceptInput, toJsonLd, RDF_TYPES } from '../rdf/conneg.js';
|
|
9
9
|
import { emitChange } from '../notifications/events.js';
|
|
@@ -193,34 +193,42 @@ export async function createPodStructure(name, webId, podUri, issuer, defaultQuo
|
|
|
193
193
|
const privateTypeIndex = generateTypeIndex(`${podUri}settings/privateTypeIndex.jsonld`, { listed: false });
|
|
194
194
|
await storage.write(`${podPath}settings/privateTypeIndex.jsonld`, serialize(privateTypeIndex));
|
|
195
195
|
|
|
196
|
-
// Create default ACL files
|
|
197
|
-
//
|
|
198
|
-
|
|
196
|
+
// Create default ACL files. Each .acl is written inside the container it
|
|
197
|
+
// protects, so `acl:accessTo` is always './' (resolved against the .acl's
|
|
198
|
+
// own URL by the parser — see #428).
|
|
199
|
+
//
|
|
200
|
+
// The owner WebID is also written relatively (#430), derived from the
|
|
201
|
+
// absolute `webId` and the .acl's location within the pod by
|
|
202
|
+
// `relativizeOwnerWebId`. This works for any profile layout (modern
|
|
203
|
+
// `profile/card.jsonld#me`, legacy `profile/card#me`, custom shapes) and
|
|
204
|
+
// falls back to the absolute WebID for foreign owners. Together this
|
|
205
|
+
// keeps the on-disk pod portable across hostnames.
|
|
206
|
+
const owner = aclBase => relativizeOwnerWebId(webId, podUri, aclBase);
|
|
207
|
+
|
|
208
|
+
const rootAcl = generateOwnerAcl('./', owner(''), true);
|
|
199
209
|
await storage.write(`${podPath}.acl`, serializeAcl(rootAcl));
|
|
200
210
|
|
|
201
|
-
|
|
202
|
-
const privateAcl = generatePrivateAcl(`${podUri}private/`, webId);
|
|
211
|
+
const privateAcl = generatePrivateAcl('./', owner('private/'));
|
|
203
212
|
await storage.write(`${podPath}private/.acl`, serializeAcl(privateAcl));
|
|
204
213
|
|
|
205
|
-
|
|
206
|
-
const settingsAcl = generatePrivateAcl(`${podUri}settings/`, webId);
|
|
214
|
+
const settingsAcl = generatePrivateAcl('./', owner('settings/'));
|
|
207
215
|
await storage.write(`${podPath}settings/.acl`, serializeAcl(settingsAcl));
|
|
208
216
|
|
|
209
|
-
// publicTypeIndex: public read, overrides the private default inherited
|
|
210
|
-
|
|
217
|
+
// publicTypeIndex: public read, overrides the private default inherited
|
|
218
|
+
// from /settings/. This is a resource ACL (lives at .../publicTypeIndex.jsonld.acl),
|
|
219
|
+
// whose base URL is /settings/ — same depth as `settings/.acl` for the
|
|
220
|
+
// owner reference.
|
|
221
|
+
const publicTypeIndexAcl = generateOwnerAcl('./publicTypeIndex.jsonld', owner('settings/'), false);
|
|
211
222
|
await storage.write(`${podPath}settings/publicTypeIndex.jsonld.acl`, serializeAcl(publicTypeIndexAcl));
|
|
212
223
|
|
|
213
|
-
|
|
214
|
-
const inboxAcl = generateInboxAcl(`${podUri}inbox/`, webId);
|
|
224
|
+
const inboxAcl = generateInboxAcl('./', owner('inbox/'));
|
|
215
225
|
await storage.write(`${podPath}inbox/.acl`, serializeAcl(inboxAcl));
|
|
216
226
|
|
|
217
|
-
|
|
218
|
-
const publicAcl = generatePublicFolderAcl(`${podUri}public/`, webId);
|
|
227
|
+
const publicAcl = generatePublicFolderAcl('./', owner('public/'));
|
|
219
228
|
await storage.write(`${podPath}public/.acl`, serializeAcl(publicAcl));
|
|
220
229
|
|
|
221
|
-
// Profile folder: owner full, public read (with inheritance)
|
|
222
230
|
// Profile documents must be publicly readable for WebID verification
|
|
223
|
-
const profileAcl = generatePublicFolderAcl(
|
|
231
|
+
const profileAcl = generatePublicFolderAcl('./', owner('profile/'));
|
|
224
232
|
await storage.write(`${podPath}profile/.acl`, serializeAcl(profileAcl));
|
|
225
233
|
|
|
226
234
|
// Initialize storage quota if configured
|
package/src/rdf/turtle.js
CHANGED
|
Binary file
|
package/src/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Fastify from 'fastify';
|
|
2
2
|
import rateLimit from '@fastify/rate-limit';
|
|
3
3
|
import { readFile } from 'fs/promises';
|
|
4
|
+
import { STATUS_CODES } from 'node:http';
|
|
4
5
|
import { join, dirname } from 'path';
|
|
5
6
|
import { fileURLToPath } from 'url';
|
|
6
7
|
import { handleGet, handleHead, handlePut, handleDelete, handleOptions, handlePatch } from './handlers/resource.js';
|
|
@@ -169,6 +170,32 @@ export function createServer(options = {}) {
|
|
|
169
170
|
}
|
|
170
171
|
// Default Fastify behavior for other client errors
|
|
171
172
|
socket.destroy(err);
|
|
173
|
+
},
|
|
174
|
+
// Catch Fastify-internal errors that fire BEFORE any user hook
|
|
175
|
+
// runs — notably FST_ERR_BAD_URL on malformed percent-encoding
|
|
176
|
+
// (`%g1`, truncated `%E0%`, invalid UTF-8). Without this, Fastify
|
|
177
|
+
// writes the 400 response directly via `res.writeHead` and the
|
|
178
|
+
// browser sees a CORS error (no Access-Control-Allow-*) instead
|
|
179
|
+
// of the real status. #376.
|
|
180
|
+
frameworkErrors: (err, request, reply) => {
|
|
181
|
+
// ALWAYS apply CORS headers — matches the rest of the server's
|
|
182
|
+
// behavior (every successful response sets CORS via the global
|
|
183
|
+
// onRequest hook). getCorsHeaders defaults Allow-Origin to `*`
|
|
184
|
+
// when the request didn't send an Origin header.
|
|
185
|
+
const cors = getCorsHeaders(request.headers?.origin);
|
|
186
|
+
for (const [k, v] of Object.entries(cors)) reply.header(k, v);
|
|
187
|
+
const statusCode = err.statusCode ?? 400;
|
|
188
|
+
reply.code(statusCode).type('application/json').send({
|
|
189
|
+
// Use the HTTP status text (e.g. "Bad Request" for 400)
|
|
190
|
+
// rather than err.name (which for FastifyError is the
|
|
191
|
+
// unhelpful string "FastifyError"). Matches Fastify's
|
|
192
|
+
// default error-body shape that pre-fix clients were
|
|
193
|
+
// parsing.
|
|
194
|
+
error: STATUS_CODES[statusCode] || 'Error',
|
|
195
|
+
code: err.code,
|
|
196
|
+
message: err.message,
|
|
197
|
+
statusCode,
|
|
198
|
+
});
|
|
172
199
|
}
|
|
173
200
|
};
|
|
174
201
|
|
|
@@ -914,7 +941,7 @@ export function createServer(options = {}) {
|
|
|
914
941
|
*/
|
|
915
942
|
async function createRootPodStructure(webId, podUri, issuer, displayName) {
|
|
916
943
|
const { generateProfile, generatePreferences, generateTypeIndex, serialize } = await import('./webid/profile.js');
|
|
917
|
-
const { generateOwnerAcl, generatePrivateAcl, generateInboxAcl, generatePublicFolderAcl, serializeAcl } = await import('./wac/parser.js');
|
|
944
|
+
const { generateOwnerAcl, generatePrivateAcl, generateInboxAcl, generatePublicFolderAcl, serializeAcl, relativizeOwnerWebId } = await import('./wac/parser.js');
|
|
918
945
|
|
|
919
946
|
// Create directories at root
|
|
920
947
|
await storage.createContainer('/inbox/');
|
|
@@ -937,27 +964,35 @@ export function createServer(options = {}) {
|
|
|
937
964
|
const privateTypeIndex = generateTypeIndex(`${podUri}settings/privateTypeIndex.jsonld`, { listed: false });
|
|
938
965
|
await storage.write('/settings/privateTypeIndex.jsonld', serialize(privateTypeIndex));
|
|
939
966
|
|
|
940
|
-
// ACL files
|
|
941
|
-
|
|
967
|
+
// ACL files. Both `accessTo` (#428) and `acl:agent` (#430) are written
|
|
968
|
+
// relatively so the on-disk pod isn't host-locked to whichever interface
|
|
969
|
+
// the server happened to bind on first start. The owner WebID is
|
|
970
|
+
// derived from the absolute `webId` and each .acl's location by
|
|
971
|
+
// `relativizeOwnerWebId`, so any current or future profile layout
|
|
972
|
+
// (modern `profile/card.jsonld#me`, legacy `profile/card#me`, etc.)
|
|
973
|
+
// produces the correct relative IRI without hardcoding.
|
|
974
|
+
const owner = aclBase => relativizeOwnerWebId(webId, podUri, aclBase);
|
|
975
|
+
|
|
976
|
+
const rootAcl = generateOwnerAcl('./', owner(''), true);
|
|
942
977
|
await storage.write('/.acl', serializeAcl(rootAcl));
|
|
943
978
|
|
|
944
|
-
const privateAcl = generatePrivateAcl(
|
|
979
|
+
const privateAcl = generatePrivateAcl('./', owner('private/'));
|
|
945
980
|
await storage.write('/private/.acl', serializeAcl(privateAcl));
|
|
946
981
|
|
|
947
|
-
const settingsAcl = generatePrivateAcl(
|
|
982
|
+
const settingsAcl = generatePrivateAcl('./', owner('settings/'));
|
|
948
983
|
await storage.write('/settings/.acl', serializeAcl(settingsAcl));
|
|
949
984
|
|
|
950
985
|
// publicTypeIndex: public read, overrides the private default inherited from /settings/
|
|
951
|
-
const publicTypeIndexAcl = generateOwnerAcl(
|
|
986
|
+
const publicTypeIndexAcl = generateOwnerAcl('./publicTypeIndex.jsonld', owner('settings/'), false);
|
|
952
987
|
await storage.write('/settings/publicTypeIndex.jsonld.acl', serializeAcl(publicTypeIndexAcl));
|
|
953
988
|
|
|
954
|
-
const inboxAcl = generateInboxAcl(
|
|
989
|
+
const inboxAcl = generateInboxAcl('./', owner('inbox/'));
|
|
955
990
|
await storage.write('/inbox/.acl', serializeAcl(inboxAcl));
|
|
956
991
|
|
|
957
|
-
const publicAcl = generatePublicFolderAcl(
|
|
992
|
+
const publicAcl = generatePublicFolderAcl('./', owner('public/'));
|
|
958
993
|
await storage.write('/public/.acl', serializeAcl(publicAcl));
|
|
959
994
|
|
|
960
|
-
const profileAcl = generatePublicFolderAcl(
|
|
995
|
+
const profileAcl = generatePublicFolderAcl('./', owner('profile/'));
|
|
961
996
|
await storage.write('/profile/.acl', serializeAcl(profileAcl));
|
|
962
997
|
|
|
963
998
|
// Note: Quota not initialized for root-level pods (no user directory)
|
package/src/wac/parser.js
CHANGED
|
@@ -210,9 +210,44 @@ function normalizeMode(mode) {
|
|
|
210
210
|
return modeMap[mode] || mode;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Express an absolute owner WebID as a path relative to a given .acl
|
|
215
|
+
* file's container, so the in-ACL `acl:agent` reference is host-portable.
|
|
216
|
+
* The parser resolves the relative IRI against the .acl URL at check
|
|
217
|
+
* time. See #430.
|
|
218
|
+
*
|
|
219
|
+
* If the WebID isn't hosted under this pod (foreign owner), the absolute
|
|
220
|
+
* URI is returned unchanged — there's no in-pod path to resolve to. This
|
|
221
|
+
* also means the helper degrades gracefully for any current or future
|
|
222
|
+
* profile layout (modern `profile/card.jsonld#me`, legacy `profile/card#me`,
|
|
223
|
+
* single-file `me#me`, etc.) — whatever path the WebID actually has under
|
|
224
|
+
* the pod is what gets emitted.
|
|
225
|
+
*
|
|
226
|
+
* @param {string} webId - Owner WebID, typically absolute.
|
|
227
|
+
* @param {string} podUri - Pod root URI (must end with `/`).
|
|
228
|
+
* @param {string} aclBaseInPod - The .acl file's container, expressed
|
|
229
|
+
* relative to the pod root, e.g. `''` for `<pod>/.acl`, `'private/'`
|
|
230
|
+
* for `<pod>/private/.acl`, `'settings/'` for the resource ACL
|
|
231
|
+
* `<pod>/settings/publicTypeIndex.jsonld.acl`.
|
|
232
|
+
* @returns {string} Relative IRI for use as `acl:agent`, or the original
|
|
233
|
+
* absolute WebID if it isn't hosted under `podUri`.
|
|
234
|
+
*/
|
|
235
|
+
export function relativizeOwnerWebId(webId, podUri, aclBaseInPod = '') {
|
|
236
|
+
if (typeof webId !== 'string' || !webId) return webId;
|
|
237
|
+
if (typeof podUri !== 'string' || !podUri) return webId;
|
|
238
|
+
if (!webId.startsWith(podUri)) return webId;
|
|
239
|
+
const tail = webId.slice(podUri.length);
|
|
240
|
+
const depth = aclBaseInPod ? aclBaseInPod.split('/').filter(Boolean).length : 0;
|
|
241
|
+
const ups = depth === 0 ? './' : '../'.repeat(depth);
|
|
242
|
+
return ups + tail;
|
|
243
|
+
}
|
|
244
|
+
|
|
213
245
|
/**
|
|
214
246
|
* Generate a default public read ACL
|
|
215
|
-
* @param {string} resourceUrl - URL of the resource
|
|
247
|
+
* @param {string} resourceUrl - URL of the resource. May be relative (e.g.
|
|
248
|
+
* './' for the .acl's own container) — the parser resolves it against
|
|
249
|
+
* the .acl's URL at check time, which keeps the document portable across
|
|
250
|
+
* hostnames. See #428.
|
|
216
251
|
* @returns {object} JSON-LD ACL document
|
|
217
252
|
*/
|
|
218
253
|
export function generatePublicReadAcl(resourceUrl) {
|
|
@@ -237,8 +272,12 @@ export function generatePublicReadAcl(resourceUrl) {
|
|
|
237
272
|
|
|
238
273
|
/**
|
|
239
274
|
* Generate a full owner ACL (owner has full control, public read)
|
|
240
|
-
* @param {string} resourceUrl - URL of the resource
|
|
241
|
-
*
|
|
275
|
+
* @param {string} resourceUrl - URL of the resource. May be relative (see
|
|
276
|
+
* `generatePublicReadAcl`).
|
|
277
|
+
* @param {string} ownerWebId - WebID of the owner. May also be relative
|
|
278
|
+
* (e.g. './profile/card.jsonld#me' for an in-pod owner) — the parser
|
|
279
|
+
* resolves it against the .acl URL at check time. The profile document
|
|
280
|
+
* itself still publishes the absolute WebID. See #430.
|
|
242
281
|
* @param {boolean} isContainer - Whether this is a container
|
|
243
282
|
* @returns {object} JSON-LD ACL document
|
|
244
283
|
*/
|
|
@@ -285,8 +324,10 @@ export function generateOwnerAcl(resourceUrl, ownerWebId, isContainer = false) {
|
|
|
285
324
|
|
|
286
325
|
/**
|
|
287
326
|
* Generate a private ACL (owner only, no public access)
|
|
288
|
-
* @param {string} resourceUrl - URL of the resource
|
|
289
|
-
*
|
|
327
|
+
* @param {string} resourceUrl - URL of the resource (may be relative — see
|
|
328
|
+
* `generatePublicReadAcl`).
|
|
329
|
+
* @param {string} ownerWebId - WebID of the owner (may be relative — see
|
|
330
|
+
* `generateOwnerAcl`).
|
|
290
331
|
* @param {boolean} isContainer - Whether this is a container
|
|
291
332
|
* @returns {object} JSON-LD ACL document
|
|
292
333
|
*/
|
|
@@ -318,8 +359,8 @@ export function generatePrivateAcl(resourceUrl, ownerWebId, isContainer = true)
|
|
|
318
359
|
|
|
319
360
|
/**
|
|
320
361
|
* Generate an inbox ACL (owner full control, public append)
|
|
321
|
-
* @param {string} resourceUrl - URL of the inbox
|
|
322
|
-
* @param {string} ownerWebId - WebID of the owner
|
|
362
|
+
* @param {string} resourceUrl - URL of the inbox (may be relative).
|
|
363
|
+
* @param {string} ownerWebId - WebID of the owner (may be relative).
|
|
323
364
|
* @returns {object} JSON-LD ACL document
|
|
324
365
|
*/
|
|
325
366
|
export function generateInboxAcl(resourceUrl, ownerWebId) {
|
|
@@ -358,8 +399,8 @@ export function generateInboxAcl(resourceUrl, ownerWebId) {
|
|
|
358
399
|
/**
|
|
359
400
|
* Generate a public folder ACL (owner full control, public read with inheritance)
|
|
360
401
|
* Used for /public/ folders where content should be publicly readable
|
|
361
|
-
* @param {string} resourceUrl - URL of the folder
|
|
362
|
-
* @param {string} ownerWebId - WebID of the owner
|
|
402
|
+
* @param {string} resourceUrl - URL of the folder (may be relative).
|
|
403
|
+
* @param {string} ownerWebId - WebID of the owner (may be relative).
|
|
363
404
|
* @returns {object} JSON-LD ACL document
|
|
364
405
|
*/
|
|
365
406
|
export function generatePublicFolderAcl(resourceUrl, ownerWebId) {
|
|
@@ -81,3 +81,85 @@ describe('registerErrorHandler (#312)', () => {
|
|
|
81
81
|
assert.strictEqual(unhandled.length, 0, '4xx must not produce a 5xx stack log');
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
|
+
|
|
85
|
+
// #376: Fastify-internal errors that fire BEFORE any user hook
|
|
86
|
+
// runs (notably FST_ERR_BAD_URL on malformed percent-encoding)
|
|
87
|
+
// previously bypassed every CORS-injecting handler in JSS, leaving
|
|
88
|
+
// the 400 response with no Access-Control-Allow-* headers — browsers
|
|
89
|
+
// surfaced the response as a CORS error instead of the real status.
|
|
90
|
+
// The fix uses Fastify's `frameworkErrors` option in createServer
|
|
91
|
+
// to attach the full CORS header set on EVERY framework-error
|
|
92
|
+
// response (matching the rest of the server, where the global
|
|
93
|
+
// onRequest hook sets CORS unconditionally). Allow-Origin mirrors
|
|
94
|
+
// the request's `Origin` if present, otherwise defaults to `*`.
|
|
95
|
+
describe('frameworkErrors injects CORS headers on FST_ERR_BAD_URL (#376)', () => {
|
|
96
|
+
let server;
|
|
97
|
+
let baseUrl;
|
|
98
|
+
|
|
99
|
+
before(async () => {
|
|
100
|
+
const { createServer } = await import('../src/server.js');
|
|
101
|
+
server = createServer({ logger: false, forceCloseConnections: true });
|
|
102
|
+
await server.listen({ port: 0, host: '127.0.0.1' });
|
|
103
|
+
const addr = server.server.address();
|
|
104
|
+
baseUrl = `http://127.0.0.1:${addr.port}`;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
after(async () => {
|
|
108
|
+
await server.close();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('returns 400 with full CORS headers for a malformed-percent URL + Origin', async () => {
|
|
112
|
+
// `%g1` is the canonical FST_ERR_BAD_URL trigger — `g` isn't a
|
|
113
|
+
// valid hex digit, so the percent-decode bails before any route
|
|
114
|
+
// handler is even resolved.
|
|
115
|
+
const r = await fetch(`${baseUrl}/foo%g1`, {
|
|
116
|
+
headers: { Origin: 'https://example.com' },
|
|
117
|
+
});
|
|
118
|
+
assert.strictEqual(r.status, 400);
|
|
119
|
+
// CORS headers are what was missing pre-fix. ACAO should mirror
|
|
120
|
+
// the request Origin (not `*`), since the request explicitly
|
|
121
|
+
// sent one — that's what getCorsHeaders does.
|
|
122
|
+
assert.strictEqual(r.headers.get('access-control-allow-origin'), 'https://example.com');
|
|
123
|
+
assert.match(r.headers.get('access-control-allow-methods') || '', /GET/);
|
|
124
|
+
assert.ok(r.headers.get('access-control-allow-headers'), 'ACAH must be set');
|
|
125
|
+
assert.ok(r.headers.get('access-control-expose-headers'), 'ACEH must be set');
|
|
126
|
+
// Body uses HTTP status text ("Bad Request"), not err.name
|
|
127
|
+
// ("FastifyError") — matches Fastify's default body shape so
|
|
128
|
+
// any pre-fix client parsing `error` keeps working.
|
|
129
|
+
const body = await r.json();
|
|
130
|
+
assert.strictEqual(body.error, 'Bad Request');
|
|
131
|
+
assert.strictEqual(body.code, 'FST_ERR_BAD_URL');
|
|
132
|
+
assert.strictEqual(body.statusCode, 400);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('returns CORS headers (ACAO=*) and well-shaped JSON for the same bad URL without an Origin', async () => {
|
|
136
|
+
// Non-browser clients without an Origin still receive the full
|
|
137
|
+
// CORS header set — consistent with the rest of the server,
|
|
138
|
+
// where the global onRequest hook always sets CORS. ACAO
|
|
139
|
+
// defaults to `*` when no Origin was sent (per getCorsHeaders).
|
|
140
|
+
const r = await fetch(`${baseUrl}/foo%g1`);
|
|
141
|
+
assert.strictEqual(r.status, 400);
|
|
142
|
+
assert.strictEqual(r.headers.get('access-control-allow-origin'), '*');
|
|
143
|
+
assert.match(r.headers.get('access-control-allow-methods') || '', /GET/);
|
|
144
|
+
assert.ok(r.headers.get('access-control-allow-headers'), 'ACAH must be set');
|
|
145
|
+
const body = await r.json();
|
|
146
|
+
assert.strictEqual(body.error, 'Bad Request');
|
|
147
|
+
assert.strictEqual(body.code, 'FST_ERR_BAD_URL');
|
|
148
|
+
assert.strictEqual(body.statusCode, 400);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('does NOT regress: a normal 404 still carries CORS via the wildcard handler', async () => {
|
|
152
|
+
// Belt-and-suspenders: the frameworkErrors hook shouldn't have
|
|
153
|
+
// displaced any existing CORS behavior on responses that go
|
|
154
|
+
// through the wildcard handler. Ask for a path that hits the
|
|
155
|
+
// LDP wildcard and 404s (no such resource), confirm CORS.
|
|
156
|
+
const r = await fetch(`${baseUrl}/nonexistent/deep/path`, {
|
|
157
|
+
headers: { Origin: 'https://example.com' },
|
|
158
|
+
});
|
|
159
|
+
// Could be 401 or 404 depending on auth defaults; in either case
|
|
160
|
+
// CORS must be present.
|
|
161
|
+
assert.ok([401, 404].includes(r.status), `expected 401 or 404, got ${r.status}`);
|
|
162
|
+
assert.ok(r.headers.get('access-control-allow-origin'),
|
|
163
|
+
'ACAO must be set on the normal-handler error path too');
|
|
164
|
+
});
|
|
165
|
+
});
|
package/test/turtle.test.js
CHANGED
|
@@ -153,6 +153,95 @@ describe('turtle converter — unit (#320 follow-ups)', () => {
|
|
|
153
153
|
`node n3 should appear:\n${content}`);
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
+
it('emits a space before `;` and `.` terminators (#419)', async () => {
|
|
157
|
+
// The de-facto convention in W3C spec examples and Apache Jena
|
|
158
|
+
// RIOT is to separate the statement-terminator from the previous
|
|
159
|
+
// token by a space. n3.js packs them; JSS post-processes the
|
|
160
|
+
// output to add the space.
|
|
161
|
+
//
|
|
162
|
+
// Use TWO predicates on the same subject so n3.js emits a `;`
|
|
163
|
+
// continuation (multiple triples on one subject). If a future
|
|
164
|
+
// N3 upgrade ever switched to "one triple per statement" style
|
|
165
|
+
// and dropped `;` entirely, this test would otherwise pass
|
|
166
|
+
// vacuously. The presence-of-terminator assertions below pin
|
|
167
|
+
// that behavior.
|
|
168
|
+
const doc = {
|
|
169
|
+
'@context': { 'foaf': 'http://xmlns.com/foaf/0.1/' },
|
|
170
|
+
'@id': 'https://example.test/alice',
|
|
171
|
+
'foaf:name': 'Alice',
|
|
172
|
+
'foaf:age': 30,
|
|
173
|
+
};
|
|
174
|
+
const { content } = await fromJsonLd(doc, 'text/turtle', 'https://example.test/', true);
|
|
175
|
+
// Pin "at least one ` ;` and one ` .` exists" with a literal
|
|
176
|
+
// SPACE — not just any whitespace. The intended output style
|
|
177
|
+
// (matching W3C Turtle 1.1 spec examples) is a single space
|
|
178
|
+
// separator: `value ;` / `value .`. Allowing `\n;` or `\t;`
|
|
179
|
+
// would let the test pass on visually-different output.
|
|
180
|
+
assert.match(content, / ;/, `output must contain at least one " ;" terminator (space-prefixed), got:\n${content}`);
|
|
181
|
+
assert.match(content, / \.(?:\s|$)/, `output must contain at least one " ." terminator (space-prefixed), got:\n${content}`);
|
|
182
|
+
// Every `;` must be preceded by a literal space. Same for `.`
|
|
183
|
+
// at end-of-statement. Reject anything else (newline, tab,
|
|
184
|
+
// packed-against-token).
|
|
185
|
+
const offendingSemi = /[^ ];/.test(content);
|
|
186
|
+
const offendingDot = /[^ ]\.\s*$/m.test(content) || /[^ ]\.\n/.test(content);
|
|
187
|
+
assert.ok(!offendingSemi, `every ; must be preceded by a single space, got:\n${content}`);
|
|
188
|
+
assert.ok(!offendingDot, `every . at line/doc end must be preceded by a single space, got:\n${content}`);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('does NOT add a space inside literals containing `;` or `.` (#419 safety)', async () => {
|
|
192
|
+
// Critical correctness test: the post-pass must NOT corrupt
|
|
193
|
+
// literal values. A literal "foo;bar" with the post-pass naïvely
|
|
194
|
+
// applied would become "foo ;bar" — silent data corruption.
|
|
195
|
+
//
|
|
196
|
+
// Assert by VALUE, not by lexical form. A quote-agnostic parser
|
|
197
|
+
// round-trip survives any future N3 writer style change
|
|
198
|
+
// (single vs double quotes, long-string `"""..."""`, etc.).
|
|
199
|
+
const doc = {
|
|
200
|
+
'@context': { 'ex': 'https://example.test/ns#' },
|
|
201
|
+
'@id': 'https://example.test/s',
|
|
202
|
+
'ex:semicolonInside': 'foo;bar',
|
|
203
|
+
'ex:dotInside': 'has.dot',
|
|
204
|
+
'ex:both': 'a;b.c',
|
|
205
|
+
};
|
|
206
|
+
const { content } = await fromJsonLd(doc, 'text/turtle', 'https://example.test/', true);
|
|
207
|
+
// Round-trip: parse the emitted Turtle, walk the quads, assert
|
|
208
|
+
// the literal values came back exactly as authored.
|
|
209
|
+
const { Parser } = await import('n3');
|
|
210
|
+
const parser = new Parser({ baseIRI: 'https://example.test/' });
|
|
211
|
+
const quads = parser.parse(content);
|
|
212
|
+
const objectsByPredicate = new Map();
|
|
213
|
+
for (const q of quads) {
|
|
214
|
+
if (q.object.termType !== 'Literal') continue;
|
|
215
|
+
objectsByPredicate.set(q.predicate.value, q.object.value);
|
|
216
|
+
}
|
|
217
|
+
assert.strictEqual(objectsByPredicate.get('https://example.test/ns#semicolonInside'), 'foo;bar',
|
|
218
|
+
`literal value for ex:semicolonInside must be "foo;bar"`);
|
|
219
|
+
assert.strictEqual(objectsByPredicate.get('https://example.test/ns#dotInside'), 'has.dot',
|
|
220
|
+
`literal value for ex:dotInside must be "has.dot"`);
|
|
221
|
+
assert.strictEqual(objectsByPredicate.get('https://example.test/ns#both'), 'a;b.c',
|
|
222
|
+
`literal value for ex:both must be "a;b.c"`);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('does NOT add a space inside an IRI containing `;` (#419 safety)', async () => {
|
|
226
|
+
// An IRI's content is bracketed by `<...>` — the post-pass
|
|
227
|
+
// shouldn't touch what's inside. Assert by value via parser
|
|
228
|
+
// round-trip so we don't depend on N3 writer formatting.
|
|
229
|
+
const doc = {
|
|
230
|
+
'@context': { 'ex': 'https://example.test/ns#' },
|
|
231
|
+
'@id': 'https://example.test/s',
|
|
232
|
+
'ex:rel': { '@id': 'https://example.test/path;with;semis' },
|
|
233
|
+
};
|
|
234
|
+
const { content } = await fromJsonLd(doc, 'text/turtle', 'https://example.test/', true);
|
|
235
|
+
const { Parser } = await import('n3');
|
|
236
|
+
const parser = new Parser({ baseIRI: 'https://example.test/' });
|
|
237
|
+
const quads = parser.parse(content);
|
|
238
|
+
const rels = quads
|
|
239
|
+
.filter(q => q.predicate.value === 'https://example.test/ns#rel')
|
|
240
|
+
.map(q => q.object.value);
|
|
241
|
+
assert.deepStrictEqual(rels, ['https://example.test/path;with;semis'],
|
|
242
|
+
`IRI value must round-trip with internal ; intact`);
|
|
243
|
+
});
|
|
244
|
+
|
|
156
245
|
it('cyclical nested node reference does not hang', async () => {
|
|
157
246
|
// Two nested nodes reference each other. BFS must not loop.
|
|
158
247
|
const a = { '@id': 'https://example.test/a', 'ex:knows': null };
|
package/test/wac.test.js
CHANGED
|
@@ -13,7 +13,17 @@ import {
|
|
|
13
13
|
assertHeader,
|
|
14
14
|
getBaseUrl
|
|
15
15
|
} from './helpers.js';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
parseAcl,
|
|
18
|
+
AccessMode,
|
|
19
|
+
generateOwnerAcl,
|
|
20
|
+
generatePrivateAcl,
|
|
21
|
+
generateInboxAcl,
|
|
22
|
+
generatePublicFolderAcl,
|
|
23
|
+
generatePublicReadAcl,
|
|
24
|
+
serializeAcl,
|
|
25
|
+
relativizeOwnerWebId
|
|
26
|
+
} from '../src/wac/parser.js';
|
|
17
27
|
import { checkAccess, getRequiredMode } from '../src/wac/checker.js';
|
|
18
28
|
|
|
19
29
|
describe('WAC Parser', () => {
|
|
@@ -238,6 +248,208 @@ describe('WAC Parser', () => {
|
|
|
238
248
|
assert.ok(publicAuth);
|
|
239
249
|
});
|
|
240
250
|
});
|
|
251
|
+
|
|
252
|
+
// Phase 1 of #427 (#428): generators should preserve relative resourceUrls
|
|
253
|
+
// verbatim so callers can emit host-portable ACLs. The parser already
|
|
254
|
+
// resolves them at check time against the .acl's URL.
|
|
255
|
+
describe('relative resourceUrl portability (#428)', () => {
|
|
256
|
+
const webId = 'https://alice.example/profile/card.jsonld#me';
|
|
257
|
+
|
|
258
|
+
it('generateOwnerAcl preserves "./" in accessTo and default', () => {
|
|
259
|
+
const acl = generateOwnerAcl('./', webId, true);
|
|
260
|
+
const owner = acl['@graph'].find(a => a['@id'] === '#owner');
|
|
261
|
+
const pub = acl['@graph'].find(a => a['@id'] === '#public');
|
|
262
|
+
assert.strictEqual(owner['acl:accessTo']['@id'], './');
|
|
263
|
+
assert.strictEqual(owner['acl:default']['@id'], './');
|
|
264
|
+
assert.strictEqual(pub['acl:accessTo']['@id'], './');
|
|
265
|
+
// #public intentionally has no default — child resources require auth
|
|
266
|
+
assert.strictEqual(pub['acl:default'], undefined);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('generatePrivateAcl preserves "./"', () => {
|
|
270
|
+
const acl = generatePrivateAcl('./', webId);
|
|
271
|
+
const owner = acl['@graph'][0];
|
|
272
|
+
assert.strictEqual(owner['acl:accessTo']['@id'], './');
|
|
273
|
+
assert.strictEqual(owner['acl:default']['@id'], './');
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('generateInboxAcl preserves "./"', () => {
|
|
277
|
+
const acl = generateInboxAcl('./', webId);
|
|
278
|
+
for (const auth of acl['@graph']) {
|
|
279
|
+
assert.strictEqual(auth['acl:accessTo']['@id'], './');
|
|
280
|
+
assert.strictEqual(auth['acl:default']['@id'], './');
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it('generatePublicFolderAcl preserves "./"', () => {
|
|
285
|
+
const acl = generatePublicFolderAcl('./', webId);
|
|
286
|
+
for (const auth of acl['@graph']) {
|
|
287
|
+
assert.strictEqual(auth['acl:accessTo']['@id'], './');
|
|
288
|
+
assert.strictEqual(auth['acl:default']['@id'], './');
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('generatePublicReadAcl preserves a relative resource basename', () => {
|
|
293
|
+
const acl = generatePublicReadAcl('./publicTypeIndex.jsonld');
|
|
294
|
+
assert.strictEqual(
|
|
295
|
+
acl['@graph'][0]['acl:accessTo']['@id'],
|
|
296
|
+
'./publicTypeIndex.jsonld'
|
|
297
|
+
);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// Phase 2 of #427 (#430): generators should also preserve a relative
|
|
301
|
+
// ownerWebId verbatim, so the on-disk pod is host-portable for the
|
|
302
|
+
// owner half of the rule too. The parser already resolves relative
|
|
303
|
+
// agents (PR #65 / #64) — this just exercises the writer side.
|
|
304
|
+
it('generateOwnerAcl preserves a relative ownerWebId (#430)', () => {
|
|
305
|
+
const acl = generateOwnerAcl('./', './profile/card.jsonld#me', true);
|
|
306
|
+
const owner = acl['@graph'].find(a => a['@id'] === '#owner');
|
|
307
|
+
assert.strictEqual(owner['acl:agent']['@id'], './profile/card.jsonld#me');
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('generatePrivateAcl preserves a relative ownerWebId (#430)', () => {
|
|
311
|
+
const acl = generatePrivateAcl('./', '../profile/card.jsonld#me');
|
|
312
|
+
assert.strictEqual(acl['@graph'][0]['acl:agent']['@id'], '../profile/card.jsonld#me');
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('generateInboxAcl preserves a relative ownerWebId (#430)', () => {
|
|
316
|
+
const acl = generateInboxAcl('./', '../profile/card.jsonld#me');
|
|
317
|
+
const owner = acl['@graph'].find(a => a['@id'] === '#owner');
|
|
318
|
+
assert.strictEqual(owner['acl:agent']['@id'], '../profile/card.jsonld#me');
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('generatePublicFolderAcl preserves a relative ownerWebId (#430)', () => {
|
|
322
|
+
const acl = generatePublicFolderAcl('./', './card.jsonld#me');
|
|
323
|
+
const owner = acl['@graph'].find(a => a['@id'] === '#owner');
|
|
324
|
+
assert.strictEqual(owner['acl:agent']['@id'], './card.jsonld#me');
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('round-trip: relative ownerWebId resolves to .acl base URL on parse (#430)', async () => {
|
|
328
|
+
// Same ACL document, two hosts — agent should resolve to whichever
|
|
329
|
+
// host asked, just like accessTo. This is what makes the on-disk
|
|
330
|
+
// pod portable for the owner half.
|
|
331
|
+
const generated = generateOwnerAcl('./', './profile/card.jsonld#me', true);
|
|
332
|
+
const wire = serializeAcl(generated);
|
|
333
|
+
const auths1 = await parseAcl(wire, 'http://localhost:4444/.acl');
|
|
334
|
+
const auths2 = await parseAcl(wire, 'http://0.0.0.0:4444/.acl');
|
|
335
|
+
const owner1 = auths1.find(a => a.id === '#owner');
|
|
336
|
+
const owner2 = auths2.find(a => a.id === '#owner');
|
|
337
|
+
assert.ok(owner1.agents.includes('http://localhost:4444/profile/card.jsonld#me'),
|
|
338
|
+
`Expected localhost agent, got: ${JSON.stringify(owner1.agents)}`);
|
|
339
|
+
assert.ok(owner2.agents.includes('http://0.0.0.0:4444/profile/card.jsonld#me'),
|
|
340
|
+
`Expected 0.0.0.0 agent, got: ${JSON.stringify(owner2.agents)}`);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// The relativizeOwnerWebId helper drives the Phase 2 callers. Cover
|
|
344
|
+
// the layouts Copilot asked about so callers don't need to hardcode.
|
|
345
|
+
describe('relativizeOwnerWebId helper', () => {
|
|
346
|
+
const podUri = 'http://h/alice/';
|
|
347
|
+
|
|
348
|
+
it('emits "./<tail>" from the pod root', () => {
|
|
349
|
+
assert.strictEqual(
|
|
350
|
+
relativizeOwnerWebId(`${podUri}profile/card.jsonld#me`, podUri, ''),
|
|
351
|
+
'./profile/card.jsonld#me'
|
|
352
|
+
);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('emits "../<tail>" from an immediate child folder', () => {
|
|
356
|
+
assert.strictEqual(
|
|
357
|
+
relativizeOwnerWebId(`${podUri}profile/card.jsonld#me`, podUri, 'private/'),
|
|
358
|
+
'../profile/card.jsonld#me'
|
|
359
|
+
);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('handles legacy /profile/card#me layout', () => {
|
|
363
|
+
// Pre-#282 pods used extensionless `profile/card`. The helper just
|
|
364
|
+
// slices the tail, so any layout works.
|
|
365
|
+
assert.strictEqual(
|
|
366
|
+
relativizeOwnerWebId(`${podUri}profile/card#me`, podUri, ''),
|
|
367
|
+
'./profile/card#me'
|
|
368
|
+
);
|
|
369
|
+
assert.strictEqual(
|
|
370
|
+
relativizeOwnerWebId(`${podUri}profile/card#me`, podUri, 'private/'),
|
|
371
|
+
'../profile/card#me'
|
|
372
|
+
);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('handles a custom (non-profile/) WebID shape', () => {
|
|
376
|
+
assert.strictEqual(
|
|
377
|
+
relativizeOwnerWebId(`${podUri}me#me`, podUri, ''),
|
|
378
|
+
'./me#me'
|
|
379
|
+
);
|
|
380
|
+
assert.strictEqual(
|
|
381
|
+
relativizeOwnerWebId(`${podUri}me#me`, podUri, 'public/'),
|
|
382
|
+
'../me#me'
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('returns the absolute WebID unchanged for foreign owners', () => {
|
|
387
|
+
const foreign = 'https://other.example/profile/card.jsonld#me';
|
|
388
|
+
assert.strictEqual(
|
|
389
|
+
relativizeOwnerWebId(foreign, podUri, ''),
|
|
390
|
+
foreign
|
|
391
|
+
);
|
|
392
|
+
assert.strictEqual(
|
|
393
|
+
relativizeOwnerWebId(foreign, podUri, 'private/'),
|
|
394
|
+
foreign
|
|
395
|
+
);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('round-trips through the parser back to the absolute WebID', async () => {
|
|
399
|
+
// Helper output is correct iff parsing it under the same pod URI
|
|
400
|
+
// yields the original absolute WebID. Covers both modern and
|
|
401
|
+
// legacy layouts, from root and from a child folder.
|
|
402
|
+
const cases = [
|
|
403
|
+
{ web: `${podUri}profile/card.jsonld#me`, base: '', acl: `${podUri}.acl` },
|
|
404
|
+
{ web: `${podUri}profile/card.jsonld#me`, base: 'private/', acl: `${podUri}private/.acl` },
|
|
405
|
+
{ web: `${podUri}profile/card#me`, base: '', acl: `${podUri}.acl` },
|
|
406
|
+
{ web: `${podUri}profile/card#me`, base: 'private/', acl: `${podUri}private/.acl` },
|
|
407
|
+
{ web: `${podUri}me#me`, base: 'public/', acl: `${podUri}public/.acl` }
|
|
408
|
+
];
|
|
409
|
+
for (const { web, base, acl } of cases) {
|
|
410
|
+
const rel = relativizeOwnerWebId(web, podUri, base);
|
|
411
|
+
const generated = generateOwnerAcl('./', rel, true);
|
|
412
|
+
const wire = serializeAcl(generated);
|
|
413
|
+
const auths = await parseAcl(wire, acl);
|
|
414
|
+
const owner = auths.find(a => a.id === '#owner');
|
|
415
|
+
assert.ok(
|
|
416
|
+
owner.agents.includes(web),
|
|
417
|
+
`Round-trip failed for ${web} from ${base}: relative=${rel}, resolved=${JSON.stringify(owner.agents)}`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('round-trip: relative ownerWebId from a child folder resolves correctly (#430)', async () => {
|
|
424
|
+
// /pod/private/.acl with agent '../profile/card.jsonld#me'
|
|
425
|
+
// should resolve to /pod/profile/card.jsonld#me, not into the
|
|
426
|
+
// pod root or escape it.
|
|
427
|
+
const generated = generatePrivateAcl('./', '../profile/card.jsonld#me');
|
|
428
|
+
const wire = serializeAcl(generated);
|
|
429
|
+
const auths = await parseAcl(wire, 'http://localhost:4444/alice/private/.acl');
|
|
430
|
+
const owner = auths.find(a => a.id === '#owner');
|
|
431
|
+
assert.ok(owner.agents.includes('http://localhost:4444/alice/profile/card.jsonld#me'),
|
|
432
|
+
`Expected resolution to /alice/profile/card.jsonld#me, got: ${JSON.stringify(owner.agents)}`);
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('round-trip: relative "./" resolves to the .acl base URL on parse', async () => {
|
|
436
|
+
const generated = generateOwnerAcl('./', webId, true);
|
|
437
|
+
const wire = serializeAcl(generated);
|
|
438
|
+
|
|
439
|
+
// Parse the same .acl document under two different host URLs and
|
|
440
|
+
// assert accessTo resolves to whichever host asked. This is what
|
|
441
|
+
// makes the on-disk pod portable across interfaces.
|
|
442
|
+
const auths1 = await parseAcl(wire, 'http://localhost:4444/.acl');
|
|
443
|
+
const auths2 = await parseAcl(wire, 'http://0.0.0.0:4444/.acl');
|
|
444
|
+
|
|
445
|
+
const pub1 = auths1.find(a => a.agentClasses.includes('foaf:Agent'));
|
|
446
|
+
const pub2 = auths2.find(a => a.agentClasses.includes('foaf:Agent'));
|
|
447
|
+
assert.ok(pub1.accessTo.includes('http://localhost:4444/'),
|
|
448
|
+
`Expected localhost resolution, got: ${JSON.stringify(pub1.accessTo)}`);
|
|
449
|
+
assert.ok(pub2.accessTo.includes('http://0.0.0.0:4444/'),
|
|
450
|
+
`Expected 0.0.0.0 resolution, got: ${JSON.stringify(pub2.accessTo)}`);
|
|
451
|
+
});
|
|
452
|
+
});
|
|
241
453
|
});
|
|
242
454
|
|
|
243
455
|
describe('WAC Checker', () => {
|
|
@@ -325,6 +537,27 @@ describe('WAC Integration', () => {
|
|
|
325
537
|
});
|
|
326
538
|
});
|
|
327
539
|
|
|
540
|
+
describe('Cross-host ACL portability (#428)', () => {
|
|
541
|
+
// The .acl is written with a relative `./` so the public-read rule
|
|
542
|
+
// matches whichever host the request comes in on. Before #428, the
|
|
543
|
+
// .acl baked the bind-time host into accessTo and any other host
|
|
544
|
+
// returned 401. We exercise this by varying the Host: header.
|
|
545
|
+
it('serves public-read resources regardless of Host header', async () => {
|
|
546
|
+
// Profile is public-read by default (#427 Phase 1).
|
|
547
|
+
const baseHost = new URL(getBaseUrl()).host;
|
|
548
|
+
const profileUrl = `${getBaseUrl()}/wactest/profile/`;
|
|
549
|
+
const hostsToTry = [baseHost, 'localhost:9999', 'pod.example:443', 'pod.invalid'];
|
|
550
|
+
|
|
551
|
+
for (const host of hostsToTry) {
|
|
552
|
+
const res = await fetch(profileUrl, { headers: { Host: host } });
|
|
553
|
+
assert.strictEqual(
|
|
554
|
+
res.status, 200,
|
|
555
|
+
`Public-read should succeed for Host: ${host} (got ${res.status})`
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
|
|
328
561
|
describe('WAC-Allow Header', () => {
|
|
329
562
|
it('should return WAC-Allow header for public container', async () => {
|
|
330
563
|
const res = await request('/wactest/public/');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"sessionId":"a05da419-92b7-4056-93b8-e97b2035d4ae","pid":3932382,"procStart":"114094236","acquiredAt":1778317500161}
|