@taujs/server 0.3.6 → 0.4.0
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 +1 -1
- package/README.md +5 -3
- package/dist/{build.d.ts → Build.d.ts} +5 -7
- package/dist/{config.js → Build.js} +122 -40
- package/dist/Config-CjwAJCfZ.d.ts +245 -0
- package/dist/Config.d.ts +3 -0
- package/dist/Config.js +27 -0
- package/dist/index.d.ts +54 -4
- package/dist/index.js +1636 -348
- package/dist/types.d.ts +3 -0
- package/dist/types.js +0 -0
- package/package.json +18 -21
- package/dist/SSRServer-DPZped7n.d.ts +0 -153
- package/dist/build.js +0 -804
- package/dist/config.d.ts +0 -37
- package/dist/security/csp.d.ts +0 -4
- package/dist/security/csp.js +0 -67
package/dist/config.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { PluginOption } from 'vite';
|
|
2
|
-
import { R as Route, a as RouteParams, b as RouteAttributes } from './SSRServer-DPZped7n.js';
|
|
3
|
-
import 'node:http';
|
|
4
|
-
import 'fastify';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* taujs [ τjs ] Orchestration System
|
|
8
|
-
* (c) 2024-present Aoede Ltd
|
|
9
|
-
* Author: John Smith
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the MIT License — attribution appreciated.
|
|
12
|
-
* Part of the taujs [ τjs ] system for declarative, build-time orchestration of microfrontend applications,
|
|
13
|
-
* including CSR, SSR, streaming, and middleware composition.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
type AppRoute = Omit<Route<RouteParams>, 'appId'> & {
|
|
17
|
-
attr?: RouteAttributes;
|
|
18
|
-
};
|
|
19
|
-
type AppConfig = {
|
|
20
|
-
appId: string;
|
|
21
|
-
entryPoint: string;
|
|
22
|
-
plugins?: PluginOption[];
|
|
23
|
-
routes?: AppRoute[];
|
|
24
|
-
};
|
|
25
|
-
type TaujsConfig = {
|
|
26
|
-
apps: AppConfig[];
|
|
27
|
-
};
|
|
28
|
-
declare const extractBuildConfigs: (config: {
|
|
29
|
-
apps: {
|
|
30
|
-
appId: string;
|
|
31
|
-
entryPoint: string;
|
|
32
|
-
plugins?: PluginOption[];
|
|
33
|
-
}[];
|
|
34
|
-
}) => AppConfig[];
|
|
35
|
-
declare const extractRoutes: (taujsConfig: TaujsConfig) => Route<RouteParams>[];
|
|
36
|
-
|
|
37
|
-
export { type AppConfig, type AppRoute, type TaujsConfig, extractBuildConfigs, extractRoutes };
|
package/dist/security/csp.d.ts
DELETED
package/dist/security/csp.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// src/security/csp.ts
|
|
2
|
-
import crypto from "crypto";
|
|
3
|
-
|
|
4
|
-
// src/constants.ts
|
|
5
|
-
var DEV_CSP_DIRECTIVES = {
|
|
6
|
-
"default-src": ["'self'"],
|
|
7
|
-
"connect-src": ["'self'", "ws:", "http:"],
|
|
8
|
-
"style-src": ["'self'", "'unsafe-inline'"],
|
|
9
|
-
"img-src": ["'self'", "data:"]
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/utils/Utils.ts
|
|
13
|
-
import { dirname, join } from "path";
|
|
14
|
-
import "path";
|
|
15
|
-
import { fileURLToPath } from "url";
|
|
16
|
-
import { match } from "path-to-regexp";
|
|
17
|
-
var isDevelopment = process.env.NODE_ENV === "development";
|
|
18
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
19
|
-
var __dirname = join(dirname(__filename), !isDevelopment ? "./" : "..");
|
|
20
|
-
|
|
21
|
-
// src/security/csp.ts
|
|
22
|
-
var defaultGenerateCSP = (directives, nonce) => {
|
|
23
|
-
const merged = { ...directives };
|
|
24
|
-
merged["script-src"] = merged["script-src"] || ["'self'"];
|
|
25
|
-
if (!merged["script-src"].some((v) => v.startsWith("'nonce-"))) merged["script-src"].push(`'nonce-${nonce}'`);
|
|
26
|
-
if (isDevelopment) {
|
|
27
|
-
const connect = merged["connect-src"] || ["'self'"];
|
|
28
|
-
if (!connect.includes("ws:")) connect.push("ws:");
|
|
29
|
-
if (!connect.includes("http:")) connect.push("http:");
|
|
30
|
-
merged["connect-src"] = connect;
|
|
31
|
-
const style = merged["style-src"] || ["'self'"];
|
|
32
|
-
if (!style.includes("'unsafe-inline'")) style.push("'unsafe-inline'");
|
|
33
|
-
merged["style-src"] = style;
|
|
34
|
-
}
|
|
35
|
-
return Object.entries(merged).map(([key, values]) => `${key} ${values.join(" ")}`).join("; ");
|
|
36
|
-
};
|
|
37
|
-
var generateNonce = () => crypto.randomBytes(16).toString("base64");
|
|
38
|
-
var createCSPHook = (options = {}) => (req, reply, done) => {
|
|
39
|
-
const nonce = generateNonce();
|
|
40
|
-
const directives = options.directives ?? DEV_CSP_DIRECTIVES;
|
|
41
|
-
const generate = options.generateCSP ?? defaultGenerateCSP;
|
|
42
|
-
const cspHeader = generate(directives, nonce);
|
|
43
|
-
reply.header("Content-Security-Policy", cspHeader);
|
|
44
|
-
if (typeof options.exposeNonce === "function") {
|
|
45
|
-
options.exposeNonce(req, nonce);
|
|
46
|
-
} else {
|
|
47
|
-
req.nonce = nonce;
|
|
48
|
-
}
|
|
49
|
-
done();
|
|
50
|
-
};
|
|
51
|
-
var getRequestNonce = (req) => req.nonce;
|
|
52
|
-
var applyCSP = (security, reply) => {
|
|
53
|
-
const nonce = generateNonce();
|
|
54
|
-
const directives = security?.csp?.directives ?? DEV_CSP_DIRECTIVES;
|
|
55
|
-
const generate = security?.csp?.generateCSP ?? defaultGenerateCSP;
|
|
56
|
-
const header = generate(directives, nonce);
|
|
57
|
-
reply.header("Content-Security-Policy", header);
|
|
58
|
-
reply.request.nonce = nonce;
|
|
59
|
-
return nonce;
|
|
60
|
-
};
|
|
61
|
-
export {
|
|
62
|
-
applyCSP,
|
|
63
|
-
createCSPHook,
|
|
64
|
-
defaultGenerateCSP,
|
|
65
|
-
generateNonce,
|
|
66
|
-
getRequestNonce
|
|
67
|
-
};
|