@getstrata/core 2.2.44 → 2.2.46
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/CHANGELOG.md +10 -0
- package/dist/core/runtime/frontendMode.d.ts +3 -1
- package/dist/entries/http/csrfMiddleware.js +4 -2
- package/dist/entries/http/memoryThrottleMiddleware.js +7 -1
- package/dist/entries/http/requireAbilityMiddleware.js +7 -1
- package/dist/entries/http/scimThrottleMiddleware.js +7 -1
- package/dist/entries/http/throttleMiddleware.js +7 -1
- package/dist/entries/runtime/frontendMode.js +9 -2
- package/dist/index.js +11 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @getstrata/core changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.46
|
|
4
|
+
|
|
5
|
+
- Preserve GuestGuard credential identity through named guards; resolve development tenancy without account tables and permit non-cookie writes only for actual, explicitly enabled development identities. Keep anonymous, session-CSRF and staging/production refusal intact.
|
|
6
|
+
|
|
7
|
+
- Add `validateSpaPrefix` for canonical, dedicated SPA URL namespaces; reject API, asset and platform-probe collisions while preserving existing prefix normalization.
|
|
8
|
+
|
|
9
|
+
## 2.2.45
|
|
10
|
+
|
|
11
|
+
Offer optional Adminer consistently in Docker and Mix wizard modes when the selected database is in Compose. Generate debug-profile startup commands and complete database login instructions; correct noninteractive Docker documentation while preserving existing flag behavior. Add prompt/CLI regressions and real isolated MySQL/Postgres Adminer profile and login acceptance tests without removing assertions.
|
|
12
|
+
|
|
3
13
|
## 2.2.44
|
|
4
14
|
|
|
5
15
|
Generate JSON registration, verification/resend, reset and password-confirmed MFA for API/SPA cookie starters; share guarded MFA persistence with HTML, reject malformed TOTP secrets, and extend installed-app SMTP, replay, revocation and compiler coverage without changing HTML contracts.
|
|
@@ -9,6 +9,8 @@ declare function isSpaMode(mode: FrontendMode): boolean;
|
|
|
9
9
|
declare function isViewsEnabled(): boolean;
|
|
10
10
|
declare function isSpaEnabled(): boolean;
|
|
11
11
|
declare function normalizeSpaPrefix(value: string | undefined): string;
|
|
12
|
+
/** A dedicated, canonical URL namespace; API and platform probes cannot serve SPA assets. */
|
|
13
|
+
declare function validateSpaPrefix(value: string | undefined): string;
|
|
12
14
|
declare function readSpaPrefix(): string;
|
|
13
15
|
export type { FrontendMode };
|
|
14
|
-
export { DEFAULT_SPA_PREFIX, FRONTEND_MODE_PATTERN, FRONTEND_MODES, isSpaEnabled, isSpaMode, isViewsEnabled, isViewsMode, normalizeSpaPrefix, parseFrontendMode, readFrontendMode, readSpaPrefix, };
|
|
16
|
+
export { DEFAULT_SPA_PREFIX, FRONTEND_MODE_PATTERN, FRONTEND_MODES, isSpaEnabled, isSpaMode, isViewsEnabled, isViewsMode, normalizeSpaPrefix, parseFrontendMode, readFrontendMode, readSpaPrefix, validateSpaPrefix, };
|
|
@@ -27,8 +27,9 @@ function createAsyncContextStore(key) {
|
|
|
27
27
|
var init_asyncContextStore = () => {};
|
|
28
28
|
|
|
29
29
|
// ../../src/core/http/csrfMiddleware.ts
|
|
30
|
-
import { currentCredentialSource } from "@getstrata/core/auth/authContext";
|
|
30
|
+
import { currentAuthUser, currentCredentialSource } from "@getstrata/core/auth/authContext";
|
|
31
31
|
import { ForbiddenError } from "@getstrata/core/errors/http";
|
|
32
|
+
import { envFlagEnabled as envFlagEnabled2, isProductionEnv as isProductionEnv2 } from "@getstrata/core/runtime/appEnv";
|
|
32
33
|
|
|
33
34
|
// ../../src/core/http/csrfToken.ts
|
|
34
35
|
import { timingSafeEqual } from "crypto";
|
|
@@ -274,7 +275,8 @@ function appendSetCookie(response, cookie) {
|
|
|
274
275
|
function createCsrfMiddleware() {
|
|
275
276
|
return async (request, next) => {
|
|
276
277
|
const credentialSource = currentCredentialSource();
|
|
277
|
-
|
|
278
|
+
const developmentHeaderProof = credentialSource === "guest" && currentAuthUser() !== null && envFlagEnabled2(process.env.AUTH_DEV_HEADERS) && !isProductionEnv2();
|
|
279
|
+
if (credentialSource === "bearer" || credentialSource === "basic" || developmentHeaderProof) {
|
|
278
280
|
return await next();
|
|
279
281
|
}
|
|
280
282
|
const pathname = new URL(request.url).pathname;
|
|
@@ -259,8 +259,14 @@ function normalizeSpaPrefix(value) {
|
|
|
259
259
|
}
|
|
260
260
|
return trimmed;
|
|
261
261
|
}
|
|
262
|
+
function validateSpaPrefix(value) {
|
|
263
|
+
const prefix = normalizeSpaPrefix(value);
|
|
264
|
+
if (!/^\/[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*$/.test(prefix) || prefix.split("/").some((part) => part === "." || part === "..") || prefix === "/api" || prefix.startsWith("/api/") || prefix === "/assets" || prefix.startsWith("/assets/") || ["/health", "/ready", "/metrics"].includes(prefix))
|
|
265
|
+
throw new Error("SPA_PREFIX must be a dedicated URL path outside API, assets and health/metrics routes.");
|
|
266
|
+
return prefix;
|
|
267
|
+
}
|
|
262
268
|
function readSpaPrefix() {
|
|
263
|
-
return
|
|
269
|
+
return validateSpaPrefix(process.env.SPA_PREFIX);
|
|
264
270
|
}
|
|
265
271
|
|
|
266
272
|
// ../../src/core/view/webErrorView.ts
|
|
@@ -39,8 +39,14 @@ function normalizeSpaPrefix(value) {
|
|
|
39
39
|
}
|
|
40
40
|
return trimmed;
|
|
41
41
|
}
|
|
42
|
+
function validateSpaPrefix(value) {
|
|
43
|
+
const prefix = normalizeSpaPrefix(value);
|
|
44
|
+
if (!/^\/[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*$/.test(prefix) || prefix.split("/").some((part) => part === "." || part === "..") || prefix === "/api" || prefix.startsWith("/api/") || prefix === "/assets" || prefix.startsWith("/assets/") || ["/health", "/ready", "/metrics"].includes(prefix))
|
|
45
|
+
throw new Error("SPA_PREFIX must be a dedicated URL path outside API, assets and health/metrics routes.");
|
|
46
|
+
return prefix;
|
|
47
|
+
}
|
|
42
48
|
function readSpaPrefix() {
|
|
43
|
-
return
|
|
49
|
+
return validateSpaPrefix(process.env.SPA_PREFIX);
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
// ../../src/core/http/contentNegotiation.ts
|
|
@@ -313,8 +313,14 @@ function normalizeSpaPrefix(value) {
|
|
|
313
313
|
}
|
|
314
314
|
return trimmed;
|
|
315
315
|
}
|
|
316
|
+
function validateSpaPrefix(value) {
|
|
317
|
+
const prefix = normalizeSpaPrefix(value);
|
|
318
|
+
if (!/^\/[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*$/.test(prefix) || prefix.split("/").some((part) => part === "." || part === "..") || prefix === "/api" || prefix.startsWith("/api/") || prefix === "/assets" || prefix.startsWith("/assets/") || ["/health", "/ready", "/metrics"].includes(prefix))
|
|
319
|
+
throw new Error("SPA_PREFIX must be a dedicated URL path outside API, assets and health/metrics routes.");
|
|
320
|
+
return prefix;
|
|
321
|
+
}
|
|
316
322
|
function readSpaPrefix() {
|
|
317
|
-
return
|
|
323
|
+
return validateSpaPrefix(process.env.SPA_PREFIX);
|
|
318
324
|
}
|
|
319
325
|
|
|
320
326
|
// ../../src/core/view/webErrorView.ts
|
|
@@ -198,8 +198,14 @@ function normalizeSpaPrefix(value) {
|
|
|
198
198
|
}
|
|
199
199
|
return trimmed;
|
|
200
200
|
}
|
|
201
|
+
function validateSpaPrefix(value) {
|
|
202
|
+
const prefix = normalizeSpaPrefix(value);
|
|
203
|
+
if (!/^\/[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*$/.test(prefix) || prefix.split("/").some((part) => part === "." || part === "..") || prefix === "/api" || prefix.startsWith("/api/") || prefix === "/assets" || prefix.startsWith("/assets/") || ["/health", "/ready", "/metrics"].includes(prefix))
|
|
204
|
+
throw new Error("SPA_PREFIX must be a dedicated URL path outside API, assets and health/metrics routes.");
|
|
205
|
+
return prefix;
|
|
206
|
+
}
|
|
201
207
|
function readSpaPrefix() {
|
|
202
|
-
return
|
|
208
|
+
return validateSpaPrefix(process.env.SPA_PREFIX);
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
// ../../src/core/view/webErrorView.ts
|
|
@@ -34,8 +34,14 @@ function normalizeSpaPrefix(value) {
|
|
|
34
34
|
}
|
|
35
35
|
return trimmed;
|
|
36
36
|
}
|
|
37
|
+
function validateSpaPrefix(value) {
|
|
38
|
+
const prefix = normalizeSpaPrefix(value);
|
|
39
|
+
if (!/^\/[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*$/.test(prefix) || prefix.split("/").some((part) => part === "." || part === "..") || prefix === "/api" || prefix.startsWith("/api/") || prefix === "/assets" || prefix.startsWith("/assets/") || ["/health", "/ready", "/metrics"].includes(prefix))
|
|
40
|
+
throw new Error("SPA_PREFIX must be a dedicated URL path outside API, assets and health/metrics routes.");
|
|
41
|
+
return prefix;
|
|
42
|
+
}
|
|
37
43
|
function readSpaPrefix() {
|
|
38
|
-
return
|
|
44
|
+
return validateSpaPrefix(process.env.SPA_PREFIX);
|
|
39
45
|
}
|
|
40
46
|
export {
|
|
41
47
|
DEFAULT_SPA_PREFIX,
|
|
@@ -48,5 +54,6 @@ export {
|
|
|
48
54
|
normalizeSpaPrefix,
|
|
49
55
|
parseFrontendMode,
|
|
50
56
|
readFrontendMode,
|
|
51
|
-
readSpaPrefix
|
|
57
|
+
readSpaPrefix,
|
|
58
|
+
validateSpaPrefix
|
|
52
59
|
};
|
package/dist/index.js
CHANGED
|
@@ -2285,9 +2285,9 @@ class AuthManager {
|
|
|
2285
2285
|
async authenticateRequest(request) {
|
|
2286
2286
|
const scheme = authorizationScheme(request);
|
|
2287
2287
|
if (scheme === "bearer") {
|
|
2288
|
-
const fromNamed = await this.tryNamedGuards(request, BEARER_GUARD_NAMES);
|
|
2288
|
+
const fromNamed = await this.tryNamedGuards(request, BEARER_GUARD_NAMES, "bearer");
|
|
2289
2289
|
if (fromNamed) {
|
|
2290
|
-
return
|
|
2290
|
+
return fromNamed;
|
|
2291
2291
|
}
|
|
2292
2292
|
if (isBearerCapableGuard(this.guard)) {
|
|
2293
2293
|
const fromDefault = await this.resolveGuard(this.guard, request);
|
|
@@ -2296,9 +2296,9 @@ class AuthManager {
|
|
|
2296
2296
|
return { user: null, credentialSource: null };
|
|
2297
2297
|
}
|
|
2298
2298
|
if (scheme === "basic") {
|
|
2299
|
-
const fromNamed = await this.tryNamedGuards(request, BASIC_GUARD_NAMES);
|
|
2299
|
+
const fromNamed = await this.tryNamedGuards(request, BASIC_GUARD_NAMES, "basic");
|
|
2300
2300
|
if (fromNamed) {
|
|
2301
|
-
return
|
|
2301
|
+
return fromNamed;
|
|
2302
2302
|
}
|
|
2303
2303
|
if (this.guard instanceof BasicAuthGuard) {
|
|
2304
2304
|
const fromDefault = await this.resolveGuard(this.guard, request);
|
|
@@ -2306,9 +2306,9 @@ class AuthManager {
|
|
|
2306
2306
|
}
|
|
2307
2307
|
return { user: null, credentialSource: null };
|
|
2308
2308
|
}
|
|
2309
|
-
const fromSession = await this.tryNamedGuards(request, SESSION_GUARD_NAMES);
|
|
2309
|
+
const fromSession = await this.tryNamedGuards(request, SESSION_GUARD_NAMES, "session");
|
|
2310
2310
|
if (fromSession) {
|
|
2311
|
-
return
|
|
2311
|
+
return fromSession;
|
|
2312
2312
|
}
|
|
2313
2313
|
const fromDefault = await this.resolveGuard(this.guard, request);
|
|
2314
2314
|
if (!fromDefault) {
|
|
@@ -2317,7 +2317,7 @@ class AuthManager {
|
|
|
2317
2317
|
const source = this.guard instanceof GuestGuard ? "guest" : "session";
|
|
2318
2318
|
return { user: fromDefault, credentialSource: source };
|
|
2319
2319
|
}
|
|
2320
|
-
async tryNamedGuards(request, names) {
|
|
2320
|
+
async tryNamedGuards(request, names, source) {
|
|
2321
2321
|
const seen = new Set;
|
|
2322
2322
|
for (const name of names) {
|
|
2323
2323
|
const named = this.namedGuards.get(name);
|
|
@@ -2327,7 +2327,7 @@ class AuthManager {
|
|
|
2327
2327
|
seen.add(named);
|
|
2328
2328
|
const user = await this.resolveGuard(named, request);
|
|
2329
2329
|
if (user) {
|
|
2330
|
-
return user;
|
|
2330
|
+
return { user, credentialSource: named instanceof GuestGuard ? "guest" : source };
|
|
2331
2331
|
}
|
|
2332
2332
|
}
|
|
2333
2333
|
return null;
|
|
@@ -12517,7 +12517,8 @@ function appendSetCookie(response, cookie) {
|
|
|
12517
12517
|
function createCsrfMiddleware() {
|
|
12518
12518
|
return async (request, next) => {
|
|
12519
12519
|
const credentialSource = currentCredentialSource();
|
|
12520
|
-
|
|
12520
|
+
const developmentHeaderProof = credentialSource === "guest" && currentAuthUser() !== null && envFlagEnabled(process.env.AUTH_DEV_HEADERS) && !isProductionEnv();
|
|
12521
|
+
if (credentialSource === "bearer" || credentialSource === "basic" || developmentHeaderProof) {
|
|
12521
12522
|
return await next();
|
|
12522
12523
|
}
|
|
12523
12524
|
const pathname = new URL(request.url).pathname;
|
|
@@ -16218,7 +16219,7 @@ async function resolveTenantForRequest(request, resolver, selectPublicTenant) {
|
|
|
16218
16219
|
const user = currentAuthUser();
|
|
16219
16220
|
const headerValue = request.headers.get("x-tenant-id")?.trim();
|
|
16220
16221
|
const parsedHeader = headerValue !== undefined && headerValue.length > 0 ? Number(headerValue) : Number.NaN;
|
|
16221
|
-
if (user) {
|
|
16222
|
+
if (user && currentCredentialSource() !== "guest") {
|
|
16222
16223
|
const userId = typeof user.id === "number" ? user.id : Number.parseInt(String(user.id), 10);
|
|
16223
16224
|
if (Number.isInteger(userId) && userId > 0) {
|
|
16224
16225
|
const userTenantId = await resolveUserTenantId(userId);
|