create-astram-app 0.14.6 → 0.14.8
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
|
@@ -15,6 +15,10 @@ npx create-astram-app my-app --with-frontend # server/ + frontend/ (identity
|
|
|
15
15
|
`--with-frontend` may come before or after the name. The app name must be a single directory
|
|
16
16
|
name (letters, numbers, `.`, `_`, `-`; no leading dot).
|
|
17
17
|
|
|
18
|
+
The scaffolded app needs Node.js `^20.19.0 || >=22.12.0` (declared under `engines` in both
|
|
19
|
+
`package.json` files): on older Node 20 releases its test toolchain fails with `ERR_REQUIRE_ESM`
|
|
20
|
+
(GitHub #182).
|
|
21
|
+
|
|
18
22
|
```bash
|
|
19
23
|
cd my-app/server
|
|
20
24
|
npm install
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astram-app",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Scaffolder for a new Astram app — emits a running, framework-enforced NestJS server (deny-by-default, built-in auth/identity to switch on) and, with --with-frontend, a React admin/auth UI, over the immutable @astram/* framework packages.",
|
|
6
6
|
"type": "module",
|
package/template/README.md
CHANGED
|
@@ -13,6 +13,12 @@ identity UI). The API depends on the published, immutable framework packages
|
|
|
13
13
|
**deny-by-default** from the very first boot. You build features; the framework lives
|
|
14
14
|
read-only in `node_modules` and upgrades via `npm update` — you never edit it.
|
|
15
15
|
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
Node.js `^20.19.0 || >=22.12.0` (both `package.json` files declare it under `engines`). The test toolchain
|
|
19
|
+
(`unplugin-swc` → `unplugin`) loads ES modules through `require()`, which older Node 20 releases cannot do:
|
|
20
|
+
`npm test` then fails with `ERR_REQUIRE_ESM`.
|
|
21
|
+
|
|
16
22
|
## Layout
|
|
17
23
|
|
|
18
24
|
```
|
|
@@ -15,7 +15,7 @@ services:
|
|
|
15
15
|
astram-file-analyser:
|
|
16
16
|
build:
|
|
17
17
|
context: ./server/node_modules/@astram/file-analyser
|
|
18
|
-
image: astram-file-analyser:0.
|
|
18
|
+
image: astram-file-analyser:0.2.0
|
|
19
19
|
restart: unless-stopped
|
|
20
20
|
# No network at all, and no ports: the app reaches it only through the socket volume.
|
|
21
21
|
network_mode: none
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
8
|
+
},
|
|
6
9
|
"description": "The frontend (UI) half of an Astram consumer app — a professional web UI (login / auth / identity management) over the framework auth API. Built on shadcn/ui + Tailwind v4; shared auth/http logic comes from @astram/frontend-core and @astram/sdk. The API (../server) lives at http://localhost:3000 by default.",
|
|
7
10
|
"scripts": {
|
|
8
11
|
"dev": "vite",
|
|
@@ -12,7 +15,7 @@
|
|
|
12
15
|
"test": "node scripts/run-tests.mjs"
|
|
13
16
|
},
|
|
14
17
|
"dependencies": {
|
|
15
|
-
"@astram/frontend-core": "^0.
|
|
18
|
+
"@astram/frontend-core": "^0.15.0",
|
|
16
19
|
"@astram/sdk": "^0.2.1",
|
|
17
20
|
"@radix-ui/react-alert-dialog": "^1.1.19",
|
|
18
21
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// agentPlainText.test.mjs — personal-data-masking deviation (1e), QA iteration 5: the agent
|
|
2
|
+
// answer, claims, gaps, clarification questions (and option labels) and evidence render as
|
|
3
|
+
// PLAIN-TEXT nodes only: never through markdown, HTML injection or a linkifier.
|
|
4
|
+
//
|
|
5
|
+
// node --test src/platform/agentPlainText.test.mjs
|
|
6
|
+
//
|
|
7
|
+
// Why: `@astram/agent` swaps pseudonym tokens back to real values for the task's owner only when
|
|
8
|
+
// the server opts in with `AgentModule.forRoot({ masking: { ownerDisplay: 'plain-text' } })`, and
|
|
9
|
+
// that opt-in is the app's attestation of exactly this rendering. Model-written text could
|
|
10
|
+
// otherwise compose a link, image or URL around a real value. This template's server does not
|
|
11
|
+
// register AgentModule (so the swap is off); the guard still holds the agent UI to plain text, so
|
|
12
|
+
// an app that adds the agent and the opt-in keeps the attestation true.
|
|
13
|
+
//
|
|
14
|
+
// A static check (no React/DOM: this template has no DOM test harness and no agent answer
|
|
15
|
+
// component yet, so there is nothing to render): every source file under src/ that is agent UI
|
|
16
|
+
// (a file or folder named *agent*, or a file that mentions `agent` at all, which over-includes on
|
|
17
|
+
// purpose) must not use an HTML-injection API or import a markdown / HTML / linkify package, and
|
|
18
|
+
// the frontend's dependencies must hold none of those packages. A self-test proves each rule
|
|
19
|
+
// catches its violation.
|
|
20
|
+
import { test, describe } from 'node:test';
|
|
21
|
+
import assert from 'node:assert/strict';
|
|
22
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
23
|
+
import { basename, join, relative } from 'node:path';
|
|
24
|
+
import { fileURLToPath } from 'node:url';
|
|
25
|
+
|
|
26
|
+
const root = fileURLToPath(new URL('../..', import.meta.url));
|
|
27
|
+
const src = join(root, 'src');
|
|
28
|
+
|
|
29
|
+
/** HTML-injection APIs (React and DOM). */
|
|
30
|
+
const HTML_APIS = [
|
|
31
|
+
['dangerouslySetInnerHTML', /dangerouslySetInnerHTML/],
|
|
32
|
+
['innerHTML', /\binnerHTML\b/],
|
|
33
|
+
['outerHTML', /\bouterHTML\b/],
|
|
34
|
+
['insertAdjacentHTML', /\binsertAdjacentHTML\b/],
|
|
35
|
+
['document.write', /\bdocument\s*\.\s*write(?:ln)?\s*\(/],
|
|
36
|
+
['createContextualFragment', /\bcreateContextualFragment\b/],
|
|
37
|
+
['DOMParser', /\bDOMParser\b/],
|
|
38
|
+
['srcdoc', /\bsrcdoc\b/i],
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
/** Markdown, HTML-to-React and linkifier packages (and sanitizers, which imply rendered HTML). */
|
|
42
|
+
const RENDER_PACKAGE =
|
|
43
|
+
/^(?:react-markdown|marked|markdown-it(?:-.*)?|remark(?:-.*)?|rehype(?:-.*)?|micromark(?:-.*)?|mdast-.*|hast-.*|unified|showdown|commonmark|snarkdown|markdown-to-jsx|@mdx-js\/.*|@uiw\/react-md.*|linkifyjs|linkify-.*|react-linkify|autolinker|anchorme|html-react-parser|react-html-parser|htmr|dompurify|isomorphic-dompurify|sanitize-html|xss)(?:\/.*)?$/;
|
|
44
|
+
|
|
45
|
+
/** Every module specifier a source imports (static, dynamic, require, re-export). */
|
|
46
|
+
function specifiers(source) {
|
|
47
|
+
const out = [];
|
|
48
|
+
const patterns = [
|
|
49
|
+
/\bimport\s+(?:[^'"`;]*?\s+from\s+)?['"]([^'"]+)['"]/g,
|
|
50
|
+
/\bexport\s+[^'"`;]*?\s+from\s+['"]([^'"]+)['"]/g,
|
|
51
|
+
/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
|
|
52
|
+
/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
|
|
53
|
+
];
|
|
54
|
+
for (const p of patterns) for (const m of source.matchAll(p)) out.push(m[1]);
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The rule violations of one source text (empty when it renders plain text only). */
|
|
59
|
+
export function violations(source) {
|
|
60
|
+
const found = [];
|
|
61
|
+
for (const [name, re] of HTML_APIS) if (re.test(source)) found.push(`uses ${name}`);
|
|
62
|
+
for (const spec of specifiers(source)) {
|
|
63
|
+
if (RENDER_PACKAGE.test(spec)) found.push(`imports ${spec}`);
|
|
64
|
+
}
|
|
65
|
+
return found;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function sourceFiles(dir) {
|
|
69
|
+
const found = [];
|
|
70
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
71
|
+
const path = join(dir, entry.name);
|
|
72
|
+
if (entry.isDirectory()) found.push(...sourceFiles(path));
|
|
73
|
+
else if (/\.(?:jsx?|tsx?|mjs|cjs)$/.test(entry.name) && !entry.name.endsWith('.test.mjs')) {
|
|
74
|
+
found.push(path);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return found;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Agent UI: a file or folder named *agent*, or any file that mentions `agent` (over-includes). */
|
|
81
|
+
function agentUiFiles() {
|
|
82
|
+
return sourceFiles(src).filter((path) => {
|
|
83
|
+
const rel = relative(src, path);
|
|
84
|
+
return /agent/i.test(rel) || /\bagent\b/i.test(readFileSync(path, 'utf8'));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
describe('agent UI renders plain text only (personal-data-masking (1e))', () => {
|
|
89
|
+
test('the agent UI files are found (the guard is not vacuous)', () => {
|
|
90
|
+
const names = agentUiFiles().map((p) => basename(p));
|
|
91
|
+
assert.ok(names.includes('agentStreamTransport.js'), names.join(', '));
|
|
92
|
+
assert.ok(names.includes('AuthContext.jsx'), names.join(', '));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('no agent UI file uses an HTML-injection API or imports a markdown / HTML / linkify package', () => {
|
|
96
|
+
const bad = agentUiFiles()
|
|
97
|
+
.map((path) => [relative(root, path), violations(readFileSync(path, 'utf8'))])
|
|
98
|
+
.filter(([, v]) => v.length > 0)
|
|
99
|
+
.map(([path, v]) => `${path}: ${v.join(', ')}`);
|
|
100
|
+
assert.deepEqual(bad, []);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('the frontend depends on no markdown / HTML / linkify package', () => {
|
|
104
|
+
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
105
|
+
const deps = Object.keys({ ...pkg.dependencies, ...pkg.devDependencies });
|
|
106
|
+
assert.deepEqual(
|
|
107
|
+
deps.filter((d) => RENDER_PACKAGE.test(d)),
|
|
108
|
+
[],
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('VIOLATION CAUGHT: each rule flags its pattern', () => {
|
|
113
|
+
const cases = [
|
|
114
|
+
['<p dangerouslySetInnerHTML={{ __html: frame.answer }} />', 'uses dangerouslySetInnerHTML'],
|
|
115
|
+
['node.innerHTML = claim.text;', 'uses innerHTML'],
|
|
116
|
+
["el.insertAdjacentHTML('beforeend', gap);", 'uses insertAdjacentHTML'],
|
|
117
|
+
['document.write(answer)', 'uses document.write'],
|
|
118
|
+
["import ReactMarkdown from 'react-markdown';", 'imports react-markdown'],
|
|
119
|
+
["import { marked } from 'marked';", 'imports marked'],
|
|
120
|
+
["import MarkdownIt from 'markdown-it';", 'imports markdown-it'],
|
|
121
|
+
["import remarkGfm from 'remark-gfm';", 'imports remark-gfm'],
|
|
122
|
+
["import Linkify from 'linkify-react';", 'imports linkify-react'],
|
|
123
|
+
["const linkify = require('linkifyjs');", 'imports linkifyjs'],
|
|
124
|
+
["const md = await import('micromark');", 'imports micromark'],
|
|
125
|
+
["import parse from 'html-react-parser';", 'imports html-react-parser'],
|
|
126
|
+
["export { default } from 'dompurify';", 'imports dompurify'],
|
|
127
|
+
];
|
|
128
|
+
for (const [source, expected] of cases) {
|
|
129
|
+
assert.ok(violations(source).includes(expected), `${source} ⇒ ${violations(source)}`);
|
|
130
|
+
}
|
|
131
|
+
// Plain-text rendering passes.
|
|
132
|
+
assert.deepEqual(violations('<p className="whitespace-pre-wrap">{frame.answer}</p>'), []);
|
|
133
|
+
assert.deepEqual(violations("import { Button } from '@/components/ui/button';"), []);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
"description": "The server (API) half of an Astram consumer app. Depends on the immutable framework (@astram/core, @astram/guard, @astram/engine, @astram/sdk) and declares enforcement via ShieldModule.forRoot(). Features go in src/features/; the UI lives in ../frontend.",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "dist/main.js",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
10
|
+
},
|
|
8
11
|
"scripts": {
|
|
9
12
|
"prebuild": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
10
13
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -21,13 +24,13 @@
|
|
|
21
24
|
"postinstall": "node scripts/sync-astram-guide.mjs"
|
|
22
25
|
},
|
|
23
26
|
"dependencies": {
|
|
24
|
-
"@astram/core": "1.
|
|
25
|
-
"@astram/engine": "0.
|
|
26
|
-
"@astram/guard": "0.
|
|
27
|
+
"@astram/core": "1.19.0",
|
|
28
|
+
"@astram/engine": "0.19.0",
|
|
29
|
+
"@astram/guard": "0.32.0",
|
|
27
30
|
"@astram/guide": "^0.2.8",
|
|
28
|
-
"@astram/identity": "0.
|
|
29
|
-
"@astram/messaging": "0.1.
|
|
30
|
-
"@astram/migrate": "0.7.
|
|
31
|
+
"@astram/identity": "0.31.0",
|
|
32
|
+
"@astram/messaging": "0.1.20",
|
|
33
|
+
"@astram/migrate": "0.7.9",
|
|
31
34
|
"@astram/sdk": "^0.2.0",
|
|
32
35
|
"@nestjs/common": "^11.2.7",
|
|
33
36
|
"@nestjs/core": "^11.2.7",
|