@antelopejs/dms-frontend 0.2.0 → 0.2.1
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 +7 -5
- package/dist/commands/build.js +2 -0
- package/dist/commands/dev.js +2 -0
- package/dist/commands/start.js +2 -0
- package/dist/config.js +13 -0
- package/dist/index.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -163,11 +163,13 @@ started by `dev`, and the production server started by `start`, because those
|
|
|
163
163
|
child processes inherit the environment. A missing file is not an error; an
|
|
164
164
|
unreadable one is reported and skipped.
|
|
165
165
|
|
|
166
|
-
`
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
`ajs dms dev` generates a fresh ephemeral 32-byte secret when
|
|
167
|
+
`DMS_SESSION_SECRET` is absent; all sessions are invalidated when that dev
|
|
168
|
+
server restarts. An explicit value is preserved, but empty or shorter than 32
|
|
169
|
+
characters is rejected. `build` and `start` require a configured secret and
|
|
170
|
+
never generate one, which is required for production so sessions survive
|
|
171
|
+
restarts. The generated server also validates the value as a safety net.
|
|
172
|
+
Generate one with `openssl rand -hex 32`.
|
|
171
173
|
|
|
172
174
|
### Opening a session from a module flow
|
|
173
175
|
|
package/dist/commands/build.js
CHANGED
|
@@ -21,6 +21,7 @@ function cmdBuild() {
|
|
|
21
21
|
(0, cli_ui_1.error)("Backend URL is required. Use -b <url> or set DMS_API_BASE_URL.");
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
|
+
const sessionSecret = (0, common_1.resolveSessionSecret)("build");
|
|
24
25
|
const spinner = new cli_ui_1.Spinner("Setting up workspace...");
|
|
25
26
|
await spinner.start();
|
|
26
27
|
try {
|
|
@@ -44,6 +45,7 @@ function cmdBuild() {
|
|
|
44
45
|
cwd: workspaceDir,
|
|
45
46
|
env: {
|
|
46
47
|
...process.env,
|
|
48
|
+
DMS_SESSION_SECRET: sessionSecret,
|
|
47
49
|
NODE_OPTIONS: "--max-old-space-size=4096",
|
|
48
50
|
NODE_PATH: nodeModulesDir,
|
|
49
51
|
},
|
package/dist/commands/dev.js
CHANGED
|
@@ -44,6 +44,7 @@ function cmdDev() {
|
|
|
44
44
|
.action(async (options) => {
|
|
45
45
|
const { backendUrl, workspaceKey } = resolveBackend(options);
|
|
46
46
|
const bootstrapSecret = (0, common_1.resolveBootstrapSecret)(options.bootstrapSecret, backendUrl);
|
|
47
|
+
const sessionSecret = (0, common_1.resolveSessionSecret)("dev");
|
|
47
48
|
const requestedPort = Number.parseInt(options.port, 10);
|
|
48
49
|
if (Number.isNaN(requestedPort)) {
|
|
49
50
|
(0, cli_ui_1.error)(`Invalid port: ${options.port}`);
|
|
@@ -101,6 +102,7 @@ function cmdDev() {
|
|
|
101
102
|
DMS_COOKIE_SECURE: process.env.DMS_COOKIE_SECURE ?? "false",
|
|
102
103
|
DMS_API_BASE_URL: backendUrl,
|
|
103
104
|
DMS_BOOTSTRAP_SECRET: bootstrapSecret,
|
|
105
|
+
DMS_SESSION_SECRET: sessionSecret,
|
|
104
106
|
NODE_OPTIONS: "--max-old-space-size=4096",
|
|
105
107
|
NODE_PATH: nodeModulesDir,
|
|
106
108
|
},
|
package/dist/commands/start.js
CHANGED
|
@@ -20,6 +20,7 @@ function cmdStart() {
|
|
|
20
20
|
(0, cli_ui_1.error)("Backend URL is required. Use -b <url> or set DMS_API_BASE_URL.");
|
|
21
21
|
process.exit(1);
|
|
22
22
|
}
|
|
23
|
+
const sessionSecret = (0, common_1.resolveSessionSecret)("start");
|
|
23
24
|
const workspaceDir = (0, common_1.getWorkspaceDir)(options.backendUrl);
|
|
24
25
|
const serverPath = (0, node_path_1.join)(workspaceDir, "server.mjs");
|
|
25
26
|
const clientPath = (0, node_path_1.join)(workspaceDir, "dist", "client", "index.html");
|
|
@@ -41,6 +42,7 @@ function cmdStart() {
|
|
|
41
42
|
...process.env,
|
|
42
43
|
PORT: options.port,
|
|
43
44
|
DMS_API_BASE_URL: options.backendUrl,
|
|
45
|
+
DMS_SESSION_SECRET: sessionSecret,
|
|
44
46
|
DMS_COOKIE_SECURE: process.env.DMS_COOKIE_SECURE ?? "true",
|
|
45
47
|
},
|
|
46
48
|
});
|
package/dist/config.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Options = exports.TAILWIND_SOURCE_GLOB = exports.PNPM_LIFECYCLE_SCRIPTS = exports.layerCopyIgnore = exports.LAYER_COPY_BLOCKLIST = exports.AUTH_ESTABLISH_FILE = exports.FRONTEND_MODULE_ENTRY = exports.LAYERS_SUBDIR = exports.TEMPLATE_FILES = exports.WORKSPACE_DIR_MODE = exports.DEPS_HASH_FILE = exports.DMS_FRONTEND_HOME = void 0;
|
|
7
7
|
exports.writeSecretBearingFile = writeSecretBearingFile;
|
|
8
8
|
exports.normalizeBootstrapSecret = normalizeBootstrapSecret;
|
|
9
|
+
exports.resolveSessionSecret = resolveSessionSecret;
|
|
9
10
|
exports.resolveBootstrapSecret = resolveBootstrapSecret;
|
|
10
11
|
exports.sha256Hex = sha256Hex;
|
|
11
12
|
exports.canonicalizeBackendUrl = canonicalizeBackendUrl;
|
|
@@ -109,6 +110,18 @@ function normalizeBootstrapSecret(value, source = DEFAULT_CREDENTIAL_SOURCE) {
|
|
|
109
110
|
}
|
|
110
111
|
return trimmed;
|
|
111
112
|
}
|
|
113
|
+
function resolveSessionSecret(mode, value = process.env.DMS_SESSION_SECRET) {
|
|
114
|
+
if (value === undefined && mode === "dev") {
|
|
115
|
+
return (0, node_crypto_1.randomBytes)(32).toString("hex");
|
|
116
|
+
}
|
|
117
|
+
if (value === undefined || value.length < 32) {
|
|
118
|
+
throw new Error("DMS_SESSION_SECRET must contain at least 32 characters; " +
|
|
119
|
+
(mode === "dev"
|
|
120
|
+
? "set it explicitly or omit it to generate an ephemeral dev secret"
|
|
121
|
+
: "set it explicitly for build and start"));
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
112
125
|
function resolveBootstrapSecret(explicit, backendUrl, options = {}) {
|
|
113
126
|
const normalized = normalizeBootstrapSecret(explicit);
|
|
114
127
|
if (normalized)
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,9 @@ Environment:
|
|
|
38
38
|
the other variables below can live in the project's .env. A variable already
|
|
39
39
|
set in the environment always wins over a file, and .env.local wins over .env.
|
|
40
40
|
The generated workspace never loads a .env of its own.
|
|
41
|
+
'dev' generates an ephemeral 32-byte DMS_SESSION_SECRET when it is absent;
|
|
42
|
+
restarting dev invalidates its sessions. 'build' and 'start' require a
|
|
43
|
+
configured secret of at least 32 characters.
|
|
41
44
|
|
|
42
45
|
Workspaces:
|
|
43
46
|
Each canonical backend URL gets its own workspace under
|