clavarium 0.2.2-next.1 → 0.2.2
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/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/files.mjs +21 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.2
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.2
|
|
9
|
+
"version": "0.2.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
13
13
|
"@xterm/xterm": "^6.0.0",
|
|
14
|
-
"clavarium-parley": "0.10.
|
|
14
|
+
"clavarium-parley": "0.10.1",
|
|
15
15
|
"mermaid": "11.17.2",
|
|
16
16
|
"node-pty": "^1.1.0",
|
|
17
17
|
"pdfjs-dist": "6.4.299",
|
|
@@ -686,9 +686,9 @@
|
|
|
686
686
|
}
|
|
687
687
|
},
|
|
688
688
|
"node_modules/clavarium-parley": {
|
|
689
|
-
"version": "0.10.
|
|
690
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.10.
|
|
691
|
-
"integrity": "sha512-
|
|
689
|
+
"version": "0.10.1",
|
|
690
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.10.1.tgz",
|
|
691
|
+
"integrity": "sha512-oXHwsLraHHv4oXhS2W6rK+i7g7N2UdtdZ6mmgcY5Ti8bmmWo4xSNsXkpr6nFxTA5P0Iq/c9Z2PyGV9/apbV+IQ==",
|
|
692
692
|
"license": "MIT",
|
|
693
693
|
"bin": {
|
|
694
694
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.2
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@xterm/addon-fit": "^0.11.0",
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
|
-
"clavarium-parley": "0.10.
|
|
47
|
+
"clavarium-parley": "0.10.1",
|
|
48
48
|
"mermaid": "11.17.2",
|
|
49
49
|
"node-pty": "^1.1.0",
|
|
50
50
|
"pdfjs-dist": "6.4.299",
|
package/server/files.mjs
CHANGED
|
@@ -428,11 +428,31 @@ export async function picture(root, relative) {
|
|
|
428
428
|
* the caller's own rules (who may write where) are in it. The caller has
|
|
429
429
|
* already checked that a POST comes from this site.
|
|
430
430
|
* Answers [status, body], or { picture }, or undefined: not one of these. */
|
|
431
|
+
/* WHAT THE PERSON ATTACHES IN A CHAT is kept in its bridge folder, hidden on purpose (Parley's
|
|
432
|
+
.parley/files/<id>/<name>): no listing ever shows it, but its picture is shown in the message it
|
|
433
|
+
came with. Only that shape, walked from that folder, each step looked at: never a link. */
|
|
434
|
+
const ATTACHED_PICTURE = /^\.parley\/files\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/([^/]+)$/;
|
|
435
|
+
async function bridgeFiles(root) {
|
|
436
|
+
let here = await realpath(root);
|
|
437
|
+
for (const part of ['.parley', 'files']) {
|
|
438
|
+
const next = join(here, part);
|
|
439
|
+
const info = await lstat(next).catch(() => undefined);
|
|
440
|
+
if (!info || info.isSymbolicLink() || !info.isDirectory()) throw new Refusal(404, 'No such file.');
|
|
441
|
+
here = next;
|
|
442
|
+
}
|
|
443
|
+
return here;
|
|
444
|
+
}
|
|
445
|
+
|
|
431
446
|
export const CHANGE_ROUTES = ['/files/thumb', '/files/text', '/files/save', '/files/make', '/files/rename', '/files/move', '/files/remove', '/files/taken'];
|
|
432
447
|
export async function changeRoute(method, route, params, request, folder) {
|
|
433
448
|
if (!CHANGE_ROUTES.includes(route)) return undefined;
|
|
434
449
|
const p = params.get('p') ?? '';
|
|
435
|
-
if (method === 'GET' && route === '/files/thumb')
|
|
450
|
+
if (method === 'GET' && route === '/files/thumb') {
|
|
451
|
+
/* A picture the person attached in its chat: shown in their own message too, by that one shape. */
|
|
452
|
+
const attached = ATTACHED_PICTURE.exec(p);
|
|
453
|
+
if (attached) return { picture: await picture(await bridgeFiles(folder()), `${attached[1]}/${attached[2]}`) };
|
|
454
|
+
return { picture: await picture(folder(), p) };
|
|
455
|
+
}
|
|
436
456
|
if (method === 'GET' && route === '/files/text') return [200, await readText(folder(), p)];
|
|
437
457
|
if (method !== 'POST') return [405, { error: 'Not this way.' }];
|
|
438
458
|
const type = String(request.headers['content-type'] ?? '');
|