@nexus_js/vite-plugin-nexus 0.7.4
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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +378 -0
- package/dist/index.js.map +1 -0
- package/dist/security.d.ts +58 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +204 -0
- package/dist/security.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nexus Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @nexus_js/vite-plugin-nexus
|
|
2
|
+
|
|
3
|
+
Official Vite plugin for Nexus — transforms .nx files, HMR, island manifests, Server Actions.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
All guides, API reference, and examples live on **[nexusjs.dev](https://nexusjs.dev)**.
|
|
8
|
+
|
|
9
|
+
### Scoped CSS HMR (Vite dev)
|
|
10
|
+
|
|
11
|
+
When you save a `.nx` file that contains a `<style>` block, the plugin:
|
|
12
|
+
|
|
13
|
+
1. Recompiles on the server and emits a Vite custom event `nexus:style-update` with `{ hash, css, filepath }` — `hash` is `componentHash(filepath)` and matches `[data-nx="…"]` in the compiled template.
|
|
14
|
+
2. Injects a small client bridge (via `index.html` in dev) that listens on `import.meta.hot` and updates or appends `<style data-nx-style-scope="…">` so styles can refresh without a full page reload. Runes / island state stay warm when the rest of the pipeline cooperates.
|
|
15
|
+
|
|
16
|
+
Disable automatic injection with `nexus({ styleBridge: false })` and import `virtual:nexus-style-bridge` yourself if you prefer.
|
|
17
|
+
|
|
18
|
+
## Links
|
|
19
|
+
|
|
20
|
+
- **Website:** [https://nexusjs.dev](https://nexusjs.dev)
|
|
21
|
+
- **Install:** `pnpm add -D @nexus_js/vite-plugin-nexus` (published under the same `@nexus_js` scope as the rest of the framework).
|
|
22
|
+
- **Repository:** [github.com/bierfor/nexus](https://github.com/bierfor/nexus) (see `packages/vite-plugin-nexus/`)
|
|
23
|
+
- **Issues:** [github.com/bierfor/nexus/issues](https://github.com/bierfor/nexus/issues)
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
MIT © Nexus contributors
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-nexus — Official Vite integration for the Nexus Framework.
|
|
3
|
+
*
|
|
4
|
+
* What this plugin does:
|
|
5
|
+
* 1. Transforms .nx files through the Nexus compiler pipeline
|
|
6
|
+
* 2. Splits server/client code (virtual modules)
|
|
7
|
+
* 3. Handles HMR with surgical island updates (no full-page reload)
|
|
8
|
+
* 4. Generates and updates nexus-types.d.ts on every save
|
|
9
|
+
* 5. Emits island manifests for runtime hydration
|
|
10
|
+
* 6. Integrates with PostCSS/Sass via Vite's native pipeline
|
|
11
|
+
* 7. Handles /_nexus/action/* and /_nexus/image/* in dev server
|
|
12
|
+
* 8. Optimizes assets via Rollup in build mode
|
|
13
|
+
*/
|
|
14
|
+
import type { Plugin } from 'vite';
|
|
15
|
+
export interface NexusPluginOptions {
|
|
16
|
+
/** Root directory of the Nexus app (default: process.cwd()) */
|
|
17
|
+
root?: string;
|
|
18
|
+
/** Enable SSR mode */
|
|
19
|
+
ssr?: boolean;
|
|
20
|
+
/** Enable debug output */
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
/** Auto-generate types on save */
|
|
23
|
+
typeGen?: boolean;
|
|
24
|
+
/** Island hydration default strategy */
|
|
25
|
+
defaultHydration?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Inject `virtual:nexus-style-bridge` into `index.html` so scoped `.nx` CSS can hot-patch
|
|
28
|
+
* via WebSocket without full reload (islands / runes stay warm).
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
styleBridge?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function nexus(opts?: NexusPluginOptions): Plugin[];
|
|
34
|
+
export { nexusSecurity } from './security.js';
|
|
35
|
+
export type { NexusSecurityPluginOptions } from './security.js';
|
|
36
|
+
/**
|
|
37
|
+
* Convenience: creates a full Vite config for a Nexus project.
|
|
38
|
+
*/
|
|
39
|
+
export declare function defineNexusConfig(config?: Record<string, unknown>): {
|
|
40
|
+
plugins: Plugin<any>[][];
|
|
41
|
+
optimizeDeps: {
|
|
42
|
+
include: string[];
|
|
43
|
+
};
|
|
44
|
+
build: {
|
|
45
|
+
rollupOptions: {
|
|
46
|
+
external: string[];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAA6B,MAAM,MAAM,CAAC;AAM9D,MAAM,WAAW,kBAAkB;IACjC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAiBD,wBAAgB,KAAK,CAAC,IAAI,GAAE,kBAAuB,GAAG,MAAM,EAAE,CA8S7D;AA4DD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAEhE;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;;;;;;;;;;EAarE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-nexus — Official Vite integration for the Nexus Framework.
|
|
3
|
+
*
|
|
4
|
+
* What this plugin does:
|
|
5
|
+
* 1. Transforms .nx files through the Nexus compiler pipeline
|
|
6
|
+
* 2. Splits server/client code (virtual modules)
|
|
7
|
+
* 3. Handles HMR with surgical island updates (no full-page reload)
|
|
8
|
+
* 4. Generates and updates nexus-types.d.ts on every save
|
|
9
|
+
* 5. Emits island manifests for runtime hydration
|
|
10
|
+
* 6. Integrates with PostCSS/Sass via Vite's native pipeline
|
|
11
|
+
* 7. Handles /_nexus/action/* and /_nexus/image/* in dev server
|
|
12
|
+
* 8. Optimizes assets via Rollup in build mode
|
|
13
|
+
*/
|
|
14
|
+
import { compile, componentHash } from '@nexus_js/compiler';
|
|
15
|
+
import { generateTypes } from '@nexus_js/types';
|
|
16
|
+
import { readFile } from 'node:fs/promises';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
/** Virtual module IDs */
|
|
19
|
+
const VIRTUAL_SERVER = 'virtual:nexus-server/';
|
|
20
|
+
const VIRTUAL_CLIENT = 'virtual:nexus-client/';
|
|
21
|
+
const RESOLVED_SERVER = '\0' + VIRTUAL_SERVER;
|
|
22
|
+
const RESOLVED_CLIENT = '\0' + VIRTUAL_CLIENT;
|
|
23
|
+
/** Client HMR: applies `nexus:style-update` payloads to `<style data-nx-style-scope>`. */
|
|
24
|
+
const VIRTUAL_STYLE_BRIDGE = 'virtual:nexus-style-bridge';
|
|
25
|
+
const RESOLVED_STYLE_BRIDGE = '\0' + VIRTUAL_STYLE_BRIDGE;
|
|
26
|
+
const NX_FILE_RE = /\.nx(\?.*)?$/;
|
|
27
|
+
const ACTION_ROUTE_RE = /^\/_nexus\/action\//;
|
|
28
|
+
const IMAGE_ROUTE_RE = /^\/_nexus\/image/;
|
|
29
|
+
const SYNC_ROUTE_RE = /^\/_nexus\/sync\//;
|
|
30
|
+
export function nexus(opts = {}) {
|
|
31
|
+
const root = opts.root ?? process.cwd();
|
|
32
|
+
const typeGen = opts.typeGen ?? true;
|
|
33
|
+
const styleBridgeEnabled = opts.styleBridge !== false;
|
|
34
|
+
// Compiled cache: filepath → { serverCode, clientCode, css, manifest }
|
|
35
|
+
const compiledCache = new Map();
|
|
36
|
+
let devServer = null;
|
|
37
|
+
let typeGenDebounce = null;
|
|
38
|
+
// ── Type generation debouncer ──────────────────────────────────────────────
|
|
39
|
+
function scheduleTypeGen() {
|
|
40
|
+
if (!typeGen)
|
|
41
|
+
return;
|
|
42
|
+
if (typeGenDebounce)
|
|
43
|
+
clearTimeout(typeGenDebounce);
|
|
44
|
+
typeGenDebounce = setTimeout(async () => {
|
|
45
|
+
try {
|
|
46
|
+
await generateTypes({ root });
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
console.error('[vite-plugin-nexus] Type generation failed:', err);
|
|
50
|
+
}
|
|
51
|
+
}, 300);
|
|
52
|
+
}
|
|
53
|
+
// ── Main transform plugin ──────────────────────────────────────────────────
|
|
54
|
+
const transformPlugin = {
|
|
55
|
+
name: 'nexus:transform',
|
|
56
|
+
enforce: 'pre',
|
|
57
|
+
configResolved(config) {
|
|
58
|
+
if (opts.debug) {
|
|
59
|
+
console.log('[vite-plugin-nexus] Root:', root, 'SSR:', opts.ssr ?? config.build.ssr);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
configureServer(server) {
|
|
63
|
+
devServer = server;
|
|
64
|
+
// Intercept /_nexus/* routes in dev
|
|
65
|
+
server.middlewares.use(async (req, res, next) => {
|
|
66
|
+
const url = req.url ?? '';
|
|
67
|
+
// Server Actions endpoint
|
|
68
|
+
if (ACTION_ROUTE_RE.test(url)) {
|
|
69
|
+
const { handleActionRequest } = await import('@nexus_js/server/actions');
|
|
70
|
+
const webReq = nodeToWebRequest(req);
|
|
71
|
+
const webRes = await handleActionRequest(webReq);
|
|
72
|
+
await pipeResponse(webRes, res);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Image optimizer endpoint
|
|
76
|
+
if (IMAGE_ROUTE_RE.test(url)) {
|
|
77
|
+
const { handleImageRequest } = await import('@nexus_js/assets/image');
|
|
78
|
+
const webReq = nodeToWebRequest(req);
|
|
79
|
+
const publicDir = join(root, 'public');
|
|
80
|
+
const webRes = await handleImageRequest(webReq, { publicDir });
|
|
81
|
+
if (req.method === 'HEAD') {
|
|
82
|
+
res.statusCode = webRes.status;
|
|
83
|
+
webRes.headers.forEach((v, k) => res.setHeader(k, v));
|
|
84
|
+
res.end();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
await pipeResponse(webRes, res);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
next();
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
resolveId(id) {
|
|
94
|
+
if (id === VIRTUAL_STYLE_BRIDGE)
|
|
95
|
+
return RESOLVED_STYLE_BRIDGE;
|
|
96
|
+
if (id.startsWith(VIRTUAL_SERVER))
|
|
97
|
+
return RESOLVED_SERVER + id.slice(VIRTUAL_SERVER.length);
|
|
98
|
+
if (id.startsWith(VIRTUAL_CLIENT))
|
|
99
|
+
return RESOLVED_CLIENT + id.slice(VIRTUAL_CLIENT.length);
|
|
100
|
+
return undefined;
|
|
101
|
+
},
|
|
102
|
+
async load(id) {
|
|
103
|
+
if (id === RESOLVED_STYLE_BRIDGE) {
|
|
104
|
+
return styleBridgeClientCode();
|
|
105
|
+
}
|
|
106
|
+
if (id.startsWith(RESOLVED_SERVER)) {
|
|
107
|
+
const filepath = id.slice(RESOLVED_SERVER.length);
|
|
108
|
+
const compiled = compiledCache.get(filepath);
|
|
109
|
+
return compiled?.serverCode ?? null;
|
|
110
|
+
}
|
|
111
|
+
if (id.startsWith(RESOLVED_CLIENT)) {
|
|
112
|
+
const filepath = id.slice(RESOLVED_CLIENT.length);
|
|
113
|
+
const compiled = compiledCache.get(filepath);
|
|
114
|
+
return compiled?.clientCode ?? null;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
},
|
|
118
|
+
async transform(code, id, transformOpts) {
|
|
119
|
+
if (!NX_FILE_RE.test(id))
|
|
120
|
+
return null;
|
|
121
|
+
const filepath = id.split('?')[0] ?? id;
|
|
122
|
+
const isSSR = transformOpts?.ssr ?? false;
|
|
123
|
+
try {
|
|
124
|
+
const result = compile(code, filepath, {
|
|
125
|
+
mode: isSSR ? 'server' : 'client',
|
|
126
|
+
dev: true,
|
|
127
|
+
ssr: isSSR,
|
|
128
|
+
emitIslandManifest: true,
|
|
129
|
+
target: isSSR ? 'node' : 'browser',
|
|
130
|
+
});
|
|
131
|
+
compiledCache.set(filepath, result);
|
|
132
|
+
if (result.warnings?.length) {
|
|
133
|
+
for (const w of result.warnings) {
|
|
134
|
+
console.warn(`[nexus] ${w.message}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Inject island manifest as metadata
|
|
138
|
+
if (result.islandManifest) {
|
|
139
|
+
this.emitFile?.({
|
|
140
|
+
type: 'asset',
|
|
141
|
+
fileName: `islands/${sanitizePath(filepath)}.manifest.json`,
|
|
142
|
+
source: JSON.stringify(result.islandManifest, null, 2),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// Trigger type generation on save
|
|
146
|
+
scheduleTypeGen();
|
|
147
|
+
if (opts.debug) {
|
|
148
|
+
console.log(`[nexus] Compiled: ${filepath} (server=${isSSR}, islands=${result.islandManifest?.islands.length ?? 0})`);
|
|
149
|
+
}
|
|
150
|
+
// Return appropriate code for the context
|
|
151
|
+
return {
|
|
152
|
+
code: isSSR ? result.serverCode : (result.clientCode ?? result.serverCode),
|
|
153
|
+
map: result.map ?? null,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
this.error(`[nexus] Failed to compile ${filepath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
// ── HMR — scoped CSS stream & inject (matches [data-nx="<hash>"] from compiler) ──
|
|
162
|
+
async handleHotUpdate({ file, server, modules }) {
|
|
163
|
+
if (!NX_FILE_RE.test(file))
|
|
164
|
+
return;
|
|
165
|
+
console.log(` \x1b[33m[nexus HMR]\x1b[0m ${file.split('/').pop()}`);
|
|
166
|
+
let source;
|
|
167
|
+
try {
|
|
168
|
+
source = await readFile(file, 'utf-8');
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
let hotResult;
|
|
174
|
+
try {
|
|
175
|
+
hotResult = compile(source, file, {
|
|
176
|
+
mode: 'server',
|
|
177
|
+
dev: true,
|
|
178
|
+
ssr: true,
|
|
179
|
+
emitIslandManifest: false,
|
|
180
|
+
target: 'node',
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
server.ws.send({
|
|
185
|
+
type: 'custom',
|
|
186
|
+
event: 'nexus:compile-error',
|
|
187
|
+
data: {
|
|
188
|
+
file,
|
|
189
|
+
message: err instanceof Error ? err.message : String(err),
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (hotResult.css) {
|
|
195
|
+
server.ws.send({
|
|
196
|
+
type: 'custom',
|
|
197
|
+
event: 'nexus:style-update',
|
|
198
|
+
data: {
|
|
199
|
+
hash: componentHash(file),
|
|
200
|
+
css: hotResult.css,
|
|
201
|
+
filepath: file,
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
compiledCache.delete(file);
|
|
206
|
+
scheduleTypeGen();
|
|
207
|
+
const affected = new Set();
|
|
208
|
+
for (const mod of modules) {
|
|
209
|
+
affected.add(mod);
|
|
210
|
+
for (const importer of mod.importers) {
|
|
211
|
+
affected.add(importer);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
server.ws.send({
|
|
215
|
+
type: 'custom',
|
|
216
|
+
event: 'nexus:hmr',
|
|
217
|
+
data: {
|
|
218
|
+
file,
|
|
219
|
+
islandUpdate: true,
|
|
220
|
+
timestamp: Date.now(),
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
return [...affected];
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
// ── CSS handling plugin ────────────────────────────────────────────────────
|
|
227
|
+
const cssPlugin = {
|
|
228
|
+
name: 'nexus:css',
|
|
229
|
+
enforce: 'post',
|
|
230
|
+
transform(code, id) {
|
|
231
|
+
if (!NX_FILE_RE.test(id))
|
|
232
|
+
return null;
|
|
233
|
+
const compiled = compiledCache.get(id.split('?')[0] ?? id);
|
|
234
|
+
if (!compiled?.css)
|
|
235
|
+
return null;
|
|
236
|
+
// Inject scoped CSS as a virtual CSS module
|
|
237
|
+
return {
|
|
238
|
+
code: `${code}\nimport '${id}?nexus-css';`,
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
load(id) {
|
|
242
|
+
if (!id.includes('?nexus-css'))
|
|
243
|
+
return null;
|
|
244
|
+
const filepath = id.split('?')[0] ?? id;
|
|
245
|
+
const compiled = compiledCache.get(filepath);
|
|
246
|
+
return compiled?.css ?? null;
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
// ── Type generation plugin ─────────────────────────────────────────────────
|
|
250
|
+
const typesPlugin = {
|
|
251
|
+
name: 'nexus:types',
|
|
252
|
+
async buildStart() {
|
|
253
|
+
if (typeGen) {
|
|
254
|
+
await generateTypes({ root }).catch(console.error);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
// ── Islands manifest plugin (build only) ──────────────────────────────────
|
|
259
|
+
const manifestPlugin = {
|
|
260
|
+
name: 'nexus:manifest',
|
|
261
|
+
apply: 'build',
|
|
262
|
+
generateBundle(_opts, bundle) {
|
|
263
|
+
const allIslands = [];
|
|
264
|
+
for (const chunk of Object.values(bundle)) {
|
|
265
|
+
if (chunk.type !== 'asset')
|
|
266
|
+
continue;
|
|
267
|
+
if (!chunk.fileName.includes('.manifest.json'))
|
|
268
|
+
continue;
|
|
269
|
+
try {
|
|
270
|
+
const manifest = JSON.parse(chunk.source);
|
|
271
|
+
allIslands.push(...(manifest.islands ?? []));
|
|
272
|
+
}
|
|
273
|
+
catch { }
|
|
274
|
+
}
|
|
275
|
+
if (allIslands.length > 0) {
|
|
276
|
+
this.emitFile({
|
|
277
|
+
type: 'asset',
|
|
278
|
+
fileName: 'nexus-islands.json',
|
|
279
|
+
source: JSON.stringify({ islands: allIslands, generated: new Date().toISOString() }, null, 2),
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
const styleBridgeHtmlPlugin = {
|
|
285
|
+
name: 'nexus:style-bridge-html',
|
|
286
|
+
apply: 'serve',
|
|
287
|
+
transformIndexHtml(html) {
|
|
288
|
+
if (!styleBridgeEnabled)
|
|
289
|
+
return html;
|
|
290
|
+
if (!html.includes('</head>'))
|
|
291
|
+
return html;
|
|
292
|
+
if (html.includes('virtual:nexus-style-bridge') || html.includes('__x00__virtual:nexus-style-bridge')) {
|
|
293
|
+
return html;
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
html,
|
|
297
|
+
tags: [
|
|
298
|
+
{
|
|
299
|
+
tag: 'script',
|
|
300
|
+
attrs: { type: 'module', src: '/@id/__x00__virtual:nexus-style-bridge' },
|
|
301
|
+
injectTo: 'head',
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
};
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
return [transformPlugin, cssPlugin, typesPlugin, manifestPlugin, styleBridgeHtmlPlugin];
|
|
308
|
+
}
|
|
309
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
310
|
+
// Helpers
|
|
311
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
312
|
+
/**
|
|
313
|
+
* Dev-only client: listens for `nexus:style-update` and patches `<style data-nx-style-scope>`.
|
|
314
|
+
* Hash matches `componentHash(filepath)` → same as `data-nx` on scoped templates.
|
|
315
|
+
*/
|
|
316
|
+
function styleBridgeClientCode() {
|
|
317
|
+
return `/* nexus style bridge — hot-patch scoped .nx CSS (hash = componentHash(filepath)) */
|
|
318
|
+
if (import.meta.hot) {
|
|
319
|
+
import.meta.hot.on('nexus:style-update', (payload) => {
|
|
320
|
+
const o = payload && typeof payload === 'object' ? payload : {};
|
|
321
|
+
const h = 'hash' in o && o.hash != null ? String(o.hash) : '';
|
|
322
|
+
const css = 'css' in o && o.css != null ? String(o.css) : '';
|
|
323
|
+
if (!h || !css) return;
|
|
324
|
+
const sel = 'style[data-nx-style-scope="' + h + '"]';
|
|
325
|
+
let el = document.querySelector(sel);
|
|
326
|
+
if (el) {
|
|
327
|
+
el.textContent = css;
|
|
328
|
+
} else {
|
|
329
|
+
el = document.createElement('style');
|
|
330
|
+
el.setAttribute('data-nx-style-scope', h);
|
|
331
|
+
el.textContent = css;
|
|
332
|
+
document.head.appendChild(el);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
import.meta.hot.on('nexus:compile-error', (payload) => {
|
|
336
|
+
console.error('[nexus] .nx compile error:', payload);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
`;
|
|
340
|
+
}
|
|
341
|
+
function sanitizePath(p) {
|
|
342
|
+
return p.replace(/[^a-zA-Z0-9]/g, '_');
|
|
343
|
+
}
|
|
344
|
+
function nodeToWebRequest(req) {
|
|
345
|
+
const url = `http://localhost${req.url ?? '/'}`;
|
|
346
|
+
const headers = new Headers();
|
|
347
|
+
for (const [k, v] of Object.entries(req.headers)) {
|
|
348
|
+
if (v)
|
|
349
|
+
headers.set(k, Array.isArray(v) ? v.join(', ') : v);
|
|
350
|
+
}
|
|
351
|
+
return new Request(url, { method: req.method ?? 'GET', headers });
|
|
352
|
+
}
|
|
353
|
+
async function pipeResponse(webRes, res) {
|
|
354
|
+
res.statusCode = webRes.status;
|
|
355
|
+
webRes.headers.forEach((v, k) => res.setHeader(k, v));
|
|
356
|
+
const body = Buffer.from(await webRes.arrayBuffer());
|
|
357
|
+
res.end(body);
|
|
358
|
+
}
|
|
359
|
+
// Re-export security plugin
|
|
360
|
+
export { nexusSecurity } from './security.js';
|
|
361
|
+
/**
|
|
362
|
+
* Convenience: creates a full Vite config for a Nexus project.
|
|
363
|
+
*/
|
|
364
|
+
export function defineNexusConfig(config = {}) {
|
|
365
|
+
return {
|
|
366
|
+
plugins: [nexus()],
|
|
367
|
+
optimizeDeps: {
|
|
368
|
+
include: ['@nexus_js/runtime'],
|
|
369
|
+
},
|
|
370
|
+
build: {
|
|
371
|
+
rollupOptions: {
|
|
372
|
+
external: ['node:fs', 'node:path', 'node:http', 'node:crypto'],
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
...config,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAqBjC,yBAAyB;AACzB,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,eAAe,GAAG,IAAI,GAAG,cAAc,CAAC;AAC9C,MAAM,eAAe,GAAG,IAAI,GAAG,cAAc,CAAC;AAE9C,0FAA0F;AAC1F,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAC1D,MAAM,qBAAqB,GAAG,IAAI,GAAG,oBAAoB,CAAC;AAE1D,MAAM,UAAU,GAAG,cAAc,CAAC;AAClC,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAC9C,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAC1C,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C,MAAM,UAAU,KAAK,CAAC,OAA2B,EAAE;IACjD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC;IACrC,MAAM,kBAAkB,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AE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IACrD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,4BAA4B;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAkC,EAAE;IACpE,OAAO;QACL,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC;QAClB,YAAY,EAAE;YACZ,OAAO,EAAE,CAAC,mBAAmB,CAAC;SAC/B;QACD,KAAK,EAAE;YACL,aAAa,EAAE;gBACb,QAAQ,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC;aAC/D;SACF;QACD,GAAG,MAAM;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nexus Security Vite Plugin — Compiler-Level Dependency Blocking.
|
|
3
|
+
*
|
|
4
|
+
* Integrates the @nexus_js/audit engine directly into the Vite module resolution
|
|
5
|
+
* pipeline. When an import is resolved, the plugin checks the package against
|
|
6
|
+
* the OSV CVE database BEFORE the bundler processes the module.
|
|
7
|
+
*
|
|
8
|
+
* Two modes:
|
|
9
|
+
*
|
|
10
|
+
* WARN (default in dev):
|
|
11
|
+
* Logs a colored warning to the terminal. Build continues.
|
|
12
|
+
* Use for medium/high severity or when the developer is actively working.
|
|
13
|
+
*
|
|
14
|
+
* BLOCK (in hardened mode or for critical severity):
|
|
15
|
+
* Throws a build error with a detailed explanation.
|
|
16
|
+
* The dev server shows a full-page error overlay.
|
|
17
|
+
* The production build stops completely.
|
|
18
|
+
*
|
|
19
|
+
* The overlay in the browser shows:
|
|
20
|
+
* ┌─────────────────────────────────────────────────────────────────────┐
|
|
21
|
+
* │ 🛑 Nexus Security Blocked │
|
|
22
|
+
* │ Package "pdfkit@0.13.0" has a CRITICAL vulnerability │
|
|
23
|
+
* │ CVE-2024-29415 — Server-Side Request Forgery │
|
|
24
|
+
* │ Fix: pnpm update pdfkit@0.14.0 (patched) │
|
|
25
|
+
* │ Or: nexus fix — auto-update all vulnerable packages │
|
|
26
|
+
* └─────────────────────────────────────────────────────────────────────┘
|
|
27
|
+
*/
|
|
28
|
+
import type { Plugin } from 'vite';
|
|
29
|
+
export type AllowVulnerableConfig = Record<string, {
|
|
30
|
+
cve: string;
|
|
31
|
+
reason: string;
|
|
32
|
+
expires: string;
|
|
33
|
+
}>;
|
|
34
|
+
export interface NexusSecurityPluginOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Security mode.
|
|
37
|
+
* 'off' — no scanning
|
|
38
|
+
* 'warn' — log warnings, never block
|
|
39
|
+
* 'block' — block critical CVEs in build, warn for high/medium
|
|
40
|
+
* 'paranoid' — block critical + high, warn for medium
|
|
41
|
+
*/
|
|
42
|
+
mode?: 'off' | 'warn' | 'block' | 'paranoid';
|
|
43
|
+
/** Override exceptions (from nexus.config.ts security.allowVulnerable) */
|
|
44
|
+
allowVulnerable?: AllowVulnerableConfig;
|
|
45
|
+
/** Enable supply chain risk checks (default: true) */
|
|
46
|
+
supplyChain?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates the Nexus Security Vite plugin.
|
|
50
|
+
* Integrated automatically when `security.hardened: true` in nexus.config.ts.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // vite.config.ts
|
|
54
|
+
* import { nexus, nexusSecurity } from '@nexus_js/vite-plugin-nexus';
|
|
55
|
+
* export default { plugins: [nexus(), nexusSecurity({ mode: 'block' })] };
|
|
56
|
+
*/
|
|
57
|
+
export declare function nexusSecurity(opts?: NexusSecurityPluginOptions): Plugin;
|
|
58
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;IAC7C,0EAA0E;IAC1E,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,sDAAsD;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAkCD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,0BAA+B,GAAG,MAAM,CAmJ3E"}
|
package/dist/security.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nexus Security Vite Plugin — Compiler-Level Dependency Blocking.
|
|
3
|
+
*
|
|
4
|
+
* Integrates the @nexus_js/audit engine directly into the Vite module resolution
|
|
5
|
+
* pipeline. When an import is resolved, the plugin checks the package against
|
|
6
|
+
* the OSV CVE database BEFORE the bundler processes the module.
|
|
7
|
+
*
|
|
8
|
+
* Two modes:
|
|
9
|
+
*
|
|
10
|
+
* WARN (default in dev):
|
|
11
|
+
* Logs a colored warning to the terminal. Build continues.
|
|
12
|
+
* Use for medium/high severity or when the developer is actively working.
|
|
13
|
+
*
|
|
14
|
+
* BLOCK (in hardened mode or for critical severity):
|
|
15
|
+
* Throws a build error with a detailed explanation.
|
|
16
|
+
* The dev server shows a full-page error overlay.
|
|
17
|
+
* The production build stops completely.
|
|
18
|
+
*
|
|
19
|
+
* The overlay in the browser shows:
|
|
20
|
+
* ┌─────────────────────────────────────────────────────────────────────┐
|
|
21
|
+
* │ 🛑 Nexus Security Blocked │
|
|
22
|
+
* │ Package "pdfkit@0.13.0" has a CRITICAL vulnerability │
|
|
23
|
+
* │ CVE-2024-29415 — Server-Side Request Forgery │
|
|
24
|
+
* │ Fix: pnpm update pdfkit@0.14.0 (patched) │
|
|
25
|
+
* │ Or: nexus fix — auto-update all vulnerable packages │
|
|
26
|
+
* └─────────────────────────────────────────────────────────────────────┘
|
|
27
|
+
*/
|
|
28
|
+
// ── ANSI ──────────────────────────────────────────────────────────────────────
|
|
29
|
+
const c = {
|
|
30
|
+
reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m',
|
|
31
|
+
red: '\x1b[31m', yellow: '\x1b[33m', cyan: '\x1b[36m',
|
|
32
|
+
mag: '\x1b[35m', green: '\x1b[32m',
|
|
33
|
+
};
|
|
34
|
+
function sev(s) {
|
|
35
|
+
if (s === 'critical')
|
|
36
|
+
return `${c.red}${c.bold}CRITICAL${c.reset}`;
|
|
37
|
+
if (s === 'high')
|
|
38
|
+
return `${c.red}HIGH${c.reset}`;
|
|
39
|
+
if (s === 'medium')
|
|
40
|
+
return `${c.yellow}MEDIUM${c.reset}`;
|
|
41
|
+
return `${c.dim}${s.toUpperCase()}${c.reset}`;
|
|
42
|
+
}
|
|
43
|
+
// ── Package name extractor ────────────────────────────────────────────────────
|
|
44
|
+
// From: 'lodash/fp', '@types/node', 'react' → package name only
|
|
45
|
+
function extractPackageName(source) {
|
|
46
|
+
if (source.startsWith('.') || source.startsWith('/') || source.startsWith('\0'))
|
|
47
|
+
return null;
|
|
48
|
+
if (source.startsWith('virtual:') || source.startsWith('node:'))
|
|
49
|
+
return null;
|
|
50
|
+
// Handle scoped packages (@org/name)
|
|
51
|
+
if (source.startsWith('@')) {
|
|
52
|
+
const parts = source.split('/');
|
|
53
|
+
return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : null;
|
|
54
|
+
}
|
|
55
|
+
return source.split('/')[0] ?? null;
|
|
56
|
+
}
|
|
57
|
+
// In-process cache to avoid scanning the same package multiple times per build
|
|
58
|
+
const _scanned = new Map();
|
|
59
|
+
// ── Plugin factory ────────────────────────────────────────────────────────────
|
|
60
|
+
/**
|
|
61
|
+
* Creates the Nexus Security Vite plugin.
|
|
62
|
+
* Integrated automatically when `security.hardened: true` in nexus.config.ts.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // vite.config.ts
|
|
66
|
+
* import { nexus, nexusSecurity } from '@nexus_js/vite-plugin-nexus';
|
|
67
|
+
* export default { plugins: [nexus(), nexusSecurity({ mode: 'block' })] };
|
|
68
|
+
*/
|
|
69
|
+
export function nexusSecurity(opts = {}) {
|
|
70
|
+
const mode = opts.mode ?? 'warn';
|
|
71
|
+
const allowVulnerable = opts.allowVulnerable ?? {};
|
|
72
|
+
if (mode === 'off') {
|
|
73
|
+
return { name: 'nexus:security-disabled' };
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
name: 'nexus:dependency-audit',
|
|
77
|
+
/**
|
|
78
|
+
* buildStart — scan all dependencies once at startup (faster than per-import).
|
|
79
|
+
* resolveId — catch dynamic imports and workspace packages not in package.json.
|
|
80
|
+
*/
|
|
81
|
+
async buildStart() {
|
|
82
|
+
_scanned.clear();
|
|
83
|
+
// Lazy import to avoid loading @nexus_js/audit in non-security builds
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
let auditMod;
|
|
86
|
+
try {
|
|
87
|
+
auditMod = await import('@nexus_js/audit');
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
this.warn('[Nexus Security] @nexus_js/audit not installed. Run: pnpm add -D @nexus_js/audit');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
const scanProject = auditMod.scanProject;
|
|
95
|
+
const root = this.meta.env?.root
|
|
96
|
+
?? process.cwd();
|
|
97
|
+
try {
|
|
98
|
+
const result = await scanProject({
|
|
99
|
+
root,
|
|
100
|
+
includeDev: false,
|
|
101
|
+
supplyChain: opts.supplyChain !== false,
|
|
102
|
+
allowVulnerable,
|
|
103
|
+
failOnCritical: mode === 'block' || mode === 'paranoid',
|
|
104
|
+
minSeverity: mode === 'paranoid' ? 'medium' : 'high',
|
|
105
|
+
});
|
|
106
|
+
// Log vulnerable packages
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
+
for (const vuln of result.vulnerable) {
|
|
109
|
+
const topVuln = vuln.vulns[0];
|
|
110
|
+
if (!topVuln)
|
|
111
|
+
continue;
|
|
112
|
+
const msg = `\n ${c.mag}◆ Nexus Security${c.reset} ${sev(topVuln.severity)} in ${c.bold}"${vuln.package}"${c.reset}\n` +
|
|
113
|
+
` ${topVuln.id}: ${topVuln.summary}\n` +
|
|
114
|
+
(topVuln.fixedIn ? ` ${c.green}Fix: update to v${topVuln.fixedIn}${c.reset}\n` : '') +
|
|
115
|
+
` Run ${c.cyan}nexus fix${c.reset} to auto-update`;
|
|
116
|
+
if ((mode === 'block' || mode === 'paranoid') && topVuln.severity === 'critical') {
|
|
117
|
+
this.error(msg); // Stops the build
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this.warn(msg);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Supply chain warnings
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
+
for (const [pkg, sc] of result.supplyChain) {
|
|
126
|
+
if (sc.riskLevel === 'critical' || sc.riskLevel === 'high') {
|
|
127
|
+
const topFlag = sc.flags[0];
|
|
128
|
+
this.warn(`\n ${c.mag}◆ Nexus Supply Chain${c.reset} ${sev(sc.riskLevel)} risk: ${c.bold}"${pkg}"${c.reset}\n` +
|
|
129
|
+
(topFlag ? ` ${topFlag.title}: ${topFlag.description}\n` : '') +
|
|
130
|
+
` Risk score: ${sc.riskScore}/100`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Print override status
|
|
134
|
+
const { expiringSoon, expired } = result.overrideStatus;
|
|
135
|
+
for (const e of expiringSoon) {
|
|
136
|
+
this.warn(` ${c.yellow}[Nexus Security]${c.reset} Override expiring soon: ${e}`);
|
|
137
|
+
}
|
|
138
|
+
for (const e of expired) {
|
|
139
|
+
this.error(` ${c.red}[Nexus Security]${c.reset} Expired override: ${e} — update the dependency or renew the override`);
|
|
140
|
+
}
|
|
141
|
+
if (result.vulnerable.length === 0 && result.supplyChain.size === 0) {
|
|
142
|
+
console.log(` ${c.green}✔${c.reset} ${c.dim}Nexus Security: all dependencies clean${c.reset}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
if (err.code === 'NEXUS_SECURITY_BLOCK') {
|
|
147
|
+
this.error(err.message);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Don't fail the build for audit infrastructure errors
|
|
151
|
+
this.warn(`[Nexus Security] Audit failed: ${err.message}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
async resolveId(source) {
|
|
156
|
+
// Only check external packages (not relative imports or virtual)
|
|
157
|
+
const pkg = extractPackageName(source);
|
|
158
|
+
if (!pkg || _scanned.has(pkg))
|
|
159
|
+
return null;
|
|
160
|
+
_scanned.set(pkg, true);
|
|
161
|
+
// Only block in 'block' or 'paranoid' mode — warn is handled at buildStart
|
|
162
|
+
if (mode !== 'block' && mode !== 'paranoid')
|
|
163
|
+
return null;
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
+
let auditMod2;
|
|
166
|
+
try {
|
|
167
|
+
auditMod2 = await import('@nexus_js/audit');
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
|
+
const result = await auditMod2.auditPackage(pkg);
|
|
175
|
+
if (result.status !== 'vulnerable')
|
|
176
|
+
return null;
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
178
|
+
const criticalVuln = result.vulns.find((v) => v.severity === 'critical');
|
|
179
|
+
if (!criticalVuln)
|
|
180
|
+
return null;
|
|
181
|
+
// Check override
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
+
const overrideResult = auditMod2.findOverride(pkg, criticalVuln.id, allowVulnerable);
|
|
184
|
+
if (overrideResult?.valid)
|
|
185
|
+
return null; // Override active
|
|
186
|
+
const msg = `\n ${'─'.repeat(65)}\n` +
|
|
187
|
+
` ${c.red}${c.bold}🛑 NEXUS SECURITY — BUILD BLOCKED${c.reset}\n` +
|
|
188
|
+
` ${'─'.repeat(65)}\n` +
|
|
189
|
+
` Package : ${c.bold}"${pkg}"${c.reset}\n` +
|
|
190
|
+
` CVE : ${criticalVuln.id}\n` +
|
|
191
|
+
` Severity : ${sev(criticalVuln.severity)}\n` +
|
|
192
|
+
` Summary : ${criticalVuln.summary}\n` +
|
|
193
|
+
(criticalVuln.fixedIn ? ` Fix : Update to v${criticalVuln.fixedIn}\n` : '') +
|
|
194
|
+
` Command : ${c.cyan}nexus fix${c.reset}\n` +
|
|
195
|
+
` Override : Add to nexus.config.ts → security.allowVulnerable\n` +
|
|
196
|
+
` ${'─'.repeat(65)}`;
|
|
197
|
+
this.error(msg);
|
|
198
|
+
}
|
|
199
|
+
catch { /* audit failure is non-fatal */ }
|
|
200
|
+
return null;
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAyBH,iFAAiF;AACjF,MA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exus_js/vite-plugin-nexus",
|
|
3
|
+
"version": "0.7.4",
|
|
4
|
+
"description": "Official Vite plugin for Nexus — transforms .nx files, HMR, island manifests, Server Actions",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@nexus_js/assets": "0.7.4",
|
|
16
|
+
"@nexus_js/audit": "0.7.4",
|
|
17
|
+
"@nexus_js/types": "0.7.4",
|
|
18
|
+
"@nexus_js/compiler": "0.7.4"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"vite": ">=5.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^22.0.0",
|
|
25
|
+
"typescript": "^5.5.0",
|
|
26
|
+
"vite": "^5.0.0"
|
|
27
|
+
},
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"homepage": "https://nexusjs.dev",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/bierfor/nexus.git",
|
|
33
|
+
"directory": "packages/vite-plugin-nexus"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/bierfor/nexus/issues"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"nexus",
|
|
40
|
+
"framework",
|
|
41
|
+
"full-stack",
|
|
42
|
+
"svelte",
|
|
43
|
+
"islands",
|
|
44
|
+
"ssr",
|
|
45
|
+
"vite",
|
|
46
|
+
"server-actions"
|
|
47
|
+
],
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"README.md"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc -p tsconfig.json",
|
|
58
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
59
|
+
"clean": "rm -rf dist"
|
|
60
|
+
}
|
|
61
|
+
}
|