@camstack/server 1.2.145 → 1.2.146
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/dist/auth/session-cookie.js +12 -4
- package/dist/main.js +23 -7
- package/dist/manual-boot.js +7 -1
- package/package.json +5 -5
|
@@ -12,18 +12,26 @@ exports.isSessionGradeJwtPayload = isSessionGradeJwtPayload;
|
|
|
12
12
|
* after a tRPC login; read by the addon-route catch-all for `authenticated`
|
|
13
13
|
* routes hit by a plain browser navigation. */
|
|
14
14
|
exports.SESSION_COOKIE = 'camstack_session';
|
|
15
|
-
function buildSessionCookie(token, ttlSec) {
|
|
15
|
+
function buildSessionCookie(token, ttlSec, opts = {}) {
|
|
16
16
|
return {
|
|
17
17
|
name: exports.SESSION_COOKIE,
|
|
18
18
|
value: token,
|
|
19
|
-
options: {
|
|
19
|
+
options: {
|
|
20
|
+
httpOnly: true,
|
|
21
|
+
sameSite: 'lax',
|
|
22
|
+
// Secure cookies are invisible on the LAN HTTP sibling (plain http://).
|
|
23
|
+
// Default stays true so HTTPS callers do not regress.
|
|
24
|
+
secure: opts.secure ?? true,
|
|
25
|
+
path: '/',
|
|
26
|
+
maxAge: ttlSec,
|
|
27
|
+
},
|
|
20
28
|
};
|
|
21
29
|
}
|
|
22
|
-
function clearSessionCookie() {
|
|
30
|
+
function clearSessionCookie(opts = {}) {
|
|
23
31
|
return {
|
|
24
32
|
name: exports.SESSION_COOKIE,
|
|
25
33
|
value: '',
|
|
26
|
-
options: { httpOnly: true, sameSite: 'lax', secure: true, path: '/', maxAge: 0 },
|
|
34
|
+
options: { httpOnly: true, sameSite: 'lax', secure: opts.secure ?? true, path: '/', maxAge: 0 },
|
|
27
35
|
};
|
|
28
36
|
}
|
|
29
37
|
/**
|
package/dist/main.js
CHANGED
|
@@ -790,13 +790,13 @@ async function bootstrap() {
|
|
|
790
790
|
catch {
|
|
791
791
|
return reply.status(401).send({ error: 'invalid token' });
|
|
792
792
|
}
|
|
793
|
-
const c = (0, session_cookie_js_1.buildSessionCookie)(token, ttlSec);
|
|
793
|
+
const c = (0, session_cookie_js_1.buildSessionCookie)(token, ttlSec, { secure: request.protocol === 'https' });
|
|
794
794
|
reply.setCookie(c.name, c.value, c.options);
|
|
795
795
|
return reply.send({ ok: true });
|
|
796
796
|
});
|
|
797
797
|
// DELETE /api/auth/session — clear the cookie on logout.
|
|
798
|
-
fastify.delete('/api/auth/session', async (
|
|
799
|
-
const c = (0, session_cookie_js_1.clearSessionCookie)();
|
|
798
|
+
fastify.delete('/api/auth/session', async (request, reply) => {
|
|
799
|
+
const c = (0, session_cookie_js_1.clearSessionCookie)({ secure: request.protocol === 'https' });
|
|
800
800
|
reply.setCookie(c.name, c.value, c.options);
|
|
801
801
|
return reply.send({ ok: true });
|
|
802
802
|
});
|
|
@@ -826,7 +826,7 @@ async function bootstrap() {
|
|
|
826
826
|
catch {
|
|
827
827
|
return reply.status(401).send({ error: 'invalid token' });
|
|
828
828
|
}
|
|
829
|
-
const c = (0, session_cookie_js_1.buildSessionCookie)(token, ttlSec);
|
|
829
|
+
const c = (0, session_cookie_js_1.buildSessionCookie)(token, ttlSec, { secure: request.protocol === 'https' });
|
|
830
830
|
reply.setCookie(c.name, c.value, c.options);
|
|
831
831
|
return reply.redirect(next);
|
|
832
832
|
});
|
|
@@ -1301,7 +1301,18 @@ async function bootstrap() {
|
|
|
1301
1301
|
}
|
|
1302
1302
|
};
|
|
1303
1303
|
try {
|
|
1304
|
-
|
|
1304
|
+
const listenHost = (0, system_1.allFamiliesListenHost)(host).host;
|
|
1305
|
+
try {
|
|
1306
|
+
await app.listen(port, listenHost);
|
|
1307
|
+
}
|
|
1308
|
+
catch (listenErr) {
|
|
1309
|
+
if (listenHost === '::' && host !== '::') {
|
|
1310
|
+
await app.listen(port, '0.0.0.0');
|
|
1311
|
+
}
|
|
1312
|
+
else {
|
|
1313
|
+
throw listenErr;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1305
1316
|
}
|
|
1306
1317
|
catch (listenErr) {
|
|
1307
1318
|
if (listenErr !== null &&
|
|
@@ -1319,8 +1330,13 @@ async function bootstrap() {
|
|
|
1319
1330
|
// LAN HTTP sibling — same Fastify request graph, dedicated port. Handler
|
|
1320
1331
|
// is registered as soon as we have the instance; bind happens after HTTPS
|
|
1321
1332
|
// is up so a failed HTTPS listen does not leave HTTP serving alone.
|
|
1322
|
-
(0, system_1.registerLanHttpHandler)(
|
|
1323
|
-
|
|
1333
|
+
(0, system_1.registerLanHttpHandler)({
|
|
1334
|
+
onRequest: (req, res) => {
|
|
1335
|
+
fastify.server.emit('request', req, res);
|
|
1336
|
+
},
|
|
1337
|
+
onUpgrade: (req, socket, head) => {
|
|
1338
|
+
fastify.server.emit('upgrade', req, socket, head);
|
|
1339
|
+
},
|
|
1324
1340
|
});
|
|
1325
1341
|
try {
|
|
1326
1342
|
const lanHttp = await (0, system_1.bindPendingLanHttp)();
|
package/dist/manual-boot.js
CHANGED
|
@@ -414,7 +414,13 @@ async function bootManual(opts) {
|
|
|
414
414
|
});
|
|
415
415
|
},
|
|
416
416
|
async listen(port, host) {
|
|
417
|
-
await fastify.listen({
|
|
417
|
+
await fastify.listen({
|
|
418
|
+
port,
|
|
419
|
+
host,
|
|
420
|
+
// Dual-stack when binding `::`. Positional listen() drops this and
|
|
421
|
+
// on macOS/BSD `IPV6_V6ONLY` defaults to 1 — IPv4 clients die.
|
|
422
|
+
ipv6Only: host === '::' ? false : undefined,
|
|
423
|
+
});
|
|
418
424
|
},
|
|
419
425
|
close,
|
|
420
426
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.146",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@camstack/addon-admin-ui": "1.2.
|
|
36
|
+
"@camstack/addon-admin-ui": "1.2.89",
|
|
37
37
|
"@camstack/addon-agent-ui": "1.2.27",
|
|
38
38
|
"@camstack/addon-auth": "1.2.29",
|
|
39
39
|
"@camstack/addon-decoder-nodeav": "1.2.25",
|
|
40
40
|
"@camstack/addon-notifiers": "1.2.30",
|
|
41
41
|
"@camstack/addon-pipeline": "1.2.107",
|
|
42
|
-
"@camstack/addon-pipeline-orchestrator": "1.2.
|
|
42
|
+
"@camstack/addon-pipeline-orchestrator": "1.2.91",
|
|
43
43
|
"@camstack/addon-post-analysis": "1.2.109",
|
|
44
44
|
"@camstack/sdk": "1.2.29",
|
|
45
|
-
"@camstack/system": "1.2.
|
|
46
|
-
"@camstack/types": "1.2.
|
|
45
|
+
"@camstack/system": "1.2.117",
|
|
46
|
+
"@camstack/types": "1.2.98",
|
|
47
47
|
"@camstack/ui-library": "1.2.67",
|
|
48
48
|
"@fastify/compress": "^9.0.0",
|
|
49
49
|
"@fastify/cookie": "^11.0.2",
|