@stacksjs/defaults 0.70.276 → 0.70.278
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/app/Middleware/Csrf.ts
CHANGED
|
@@ -77,7 +77,9 @@ export function generateCsrfToken(): string {
|
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Seed the CSRF cookie on the outgoing response if the incoming request
|
|
80
|
-
* didn't already carry one
|
|
80
|
+
* didn't already carry one, or with the token the router minted before
|
|
81
|
+
* rendering (`minted`) so a server-rendered page's forms and the browser's
|
|
82
|
+
* cookie hold the same string. Used by the router as a post-response step
|
|
81
83
|
* on safe-method (GET/HEAD/OPTIONS) responses so SPAs get a usable
|
|
82
84
|
* cookie value before they ever submit an unsafe request.
|
|
83
85
|
*
|
|
@@ -95,13 +97,19 @@ export function generateCsrfToken(): string {
|
|
|
95
97
|
* - 2-hour `Max-Age` — short enough to limit replay if leaked, long
|
|
96
98
|
* enough that idle tabs don't constantly re-fetch tokens
|
|
97
99
|
*/
|
|
98
|
-
export function seedCsrfCookieIfMissing(req: Request, response: Response): Response {
|
|
100
|
+
export function seedCsrfCookieIfMissing(req: Request, response: Response, minted?: string): Response {
|
|
99
101
|
const cookieHeader = req.headers.get('cookie') || ''
|
|
100
|
-
|
|
102
|
+
|
|
103
|
+
// A token the router minted before rendering wins over "the header already
|
|
104
|
+
// has one", because it put that value in the header itself - and the page
|
|
105
|
+
// has already embedded it in every form it drew. Generating a second token
|
|
106
|
+
// here would store one string in the browser while the page carries another,
|
|
107
|
+
// which fails in a way indistinguishable from having no token at all.
|
|
108
|
+
if (!minted && (cookieHeader.includes(`${CSRF_COOKIE_NAME}=`) || cookieHeader.includes('csrf-token='))) {
|
|
101
109
|
return response
|
|
102
110
|
}
|
|
103
111
|
|
|
104
|
-
const token = generateCsrfToken()
|
|
112
|
+
const token = minted || generateCsrfToken()
|
|
105
113
|
const isSecure = req.url.startsWith('https://')
|
|
106
114
|
const cookie = [
|
|
107
115
|
`${CSRF_COOKIE_NAME}=${token}`,
|
|
@@ -32,6 +32,7 @@ export default defineModel({
|
|
|
32
32
|
},
|
|
33
33
|
|
|
34
34
|
channel: {
|
|
35
|
+
type: 'string',
|
|
35
36
|
required: true,
|
|
36
37
|
fillable: true,
|
|
37
38
|
validation: {
|
|
@@ -64,6 +65,7 @@ export default defineModel({
|
|
|
64
65
|
},
|
|
65
66
|
|
|
66
67
|
status: {
|
|
68
|
+
type: 'string',
|
|
67
69
|
required: true,
|
|
68
70
|
fillable: true,
|
|
69
71
|
default: 'pending',
|
|
@@ -81,6 +83,7 @@ export default defineModel({
|
|
|
81
83
|
},
|
|
82
84
|
|
|
83
85
|
metadata: {
|
|
86
|
+
type: 'text',
|
|
84
87
|
required: false,
|
|
85
88
|
fillable: true,
|
|
86
89
|
validation: {
|
package/ide/vscode/package.json
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/defaults",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.278",
|
|
6
6
|
"description": "The complete managed Stacks application scaffold, including runtime defaults, AI guidance, editor metadata, and npm-backed project support files.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|