tina4-nodejs 3.13.142 → 3.13.143
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/CLAUDE.md +28 -2
- package/package.json +1 -1
- package/packages/cli/dist/bin.js +379 -85
- package/packages/cli/src/commands/generate.ts +7 -2
- package/packages/cli/src/commands/init.ts +18 -8
- package/packages/core/dist/index.js +377 -78
- package/packages/core/gallery/auth/src/routes/gallery/auth/get.ts +27 -11
- package/packages/core/gallery/queue/src/routes/gallery/queue/get.ts +20 -7
- package/packages/core/gallery/templates/src/templates/gallery_page.twig +34 -15
- package/packages/core/src/csp.ts +138 -0
- package/packages/core/src/errorOverlay.ts +80 -37
- package/packages/core/src/index.ts +10 -0
- package/packages/core/src/middleware.ts +20 -6
- package/packages/core/src/response.ts +14 -3
- package/packages/core/src/server.ts +52 -15
- package/packages/core/src/session.ts +154 -7
- package/packages/core/src/sso.ts +1 -1
- package/packages/core/src/types.ts +8 -0
- package/packages/core/templates/errors/302.twig +1 -1
- package/packages/core/templates/errors/401.twig +2 -2
- package/packages/core/templates/errors/403.twig +1 -1
- package/packages/core/templates/errors/404.twig +1 -1
- package/packages/core/templates/errors/500.twig +1 -1
- package/packages/core/templates/errors/502.twig +2 -2
- package/packages/core/templates/errors/503.twig +2 -2
- package/packages/core/templates/errors/base.twig +4 -1
- package/packages/frond/dist/index.js +2 -0
- package/packages/frond/src/engine.ts +23 -0
- package/packages/orm/dist/index.js +378 -87
- package/packages/swagger/dist/index.js +4 -4
- package/packages/swagger/src/ui.ts +7 -4
- package/types/core/src/csp.d.ts +42 -0
- package/types/core/src/index.d.ts +1 -0
- package/types/core/src/middleware.d.ts +6 -0
- package/types/core/src/session.d.ts +62 -2
- package/types/core/src/types.d.ts +8 -0
- package/types/frond/src/engine.d.ts +7 -0
|
@@ -1785,6 +1785,21 @@ export function setFormTokenSessionId(sessionId: string): void {
|
|
|
1785
1785
|
_formTokenSessionId = sessionId || "";
|
|
1786
1786
|
}
|
|
1787
1787
|
|
|
1788
|
+
// CSP nonce provider (ADR-0088). Frond never imports @tina4/core (that would be
|
|
1789
|
+
// circular — core depends on frond), so core injects the per-response nonce
|
|
1790
|
+
// source through this setter. Default returns "" for standalone Frond use.
|
|
1791
|
+
let _cspNonceProvider: () => string = () => "";
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* Register the function that backs the `{{ csp_nonce() }}` template global.
|
|
1795
|
+
* @tina4/core calls this once with its request-scoped nonce source so every
|
|
1796
|
+
* Frond instance (framework templates AND the app's) resolves the same nonce
|
|
1797
|
+
* the Content-Security-Policy header names.
|
|
1798
|
+
*/
|
|
1799
|
+
export function setCspNonceProvider(fn: () => string): void {
|
|
1800
|
+
_cspNonceProvider = fn;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1788
1803
|
function _buildFormTokenJwt(descriptor: string = ""): string {
|
|
1789
1804
|
// Fail-closed, IDENTICAL to the validator (auth.ts validToken:
|
|
1790
1805
|
// `secret ?? process.env.TINA4_SECRET ?? ""`). With TINA4_SECRET unset the
|
|
@@ -2014,6 +2029,14 @@ export class Frond {
|
|
|
2014
2029
|
// {{ user|dump }} and {{ dump(user) }}
|
|
2015
2030
|
this.globals.dump = (value: unknown) => renderDump(value);
|
|
2016
2031
|
|
|
2032
|
+
// CSP nonce (ADR-0088): {{ csp_nonce() }} returns the current response's
|
|
2033
|
+
// nonce so a template can serve an inline <style>/<script> under the strict
|
|
2034
|
+
// default Content-Security-Policy — <style nonce="{{ csp_nonce() }}">. The
|
|
2035
|
+
// value matches the 'nonce-X' the security middleware puts in the CSP header.
|
|
2036
|
+
// Frond stays zero-dependency: @tina4/core injects the provider (it never
|
|
2037
|
+
// imports core); standalone Frond returns "".
|
|
2038
|
+
this.globals.csp_nonce = () => _cspNonceProvider();
|
|
2039
|
+
|
|
2017
2040
|
// Drain the class-level registry. This is the key to surviving
|
|
2018
2041
|
// hot-reloads AND the static-facade pattern: app.ts calls
|
|
2019
2042
|
// Frond.addFilter("money", fn) once, the class remembers it,
|