@mantiq/core 0.5.10 → 0.5.11
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/package.json
CHANGED
|
@@ -43,7 +43,9 @@ export class EncryptCookies implements Middleware {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
try {
|
|
46
|
-
|
|
46
|
+
// Cookie values may be URL-encoded (= → %3D) — decode before decrypting
|
|
47
|
+
const decoded = decodeURIComponent(value)
|
|
48
|
+
decrypted[name] = await this.encrypter.decrypt(decoded)
|
|
47
49
|
} catch {
|
|
48
50
|
// Can't decrypt — skip this cookie (expired key, tampered, etc.)
|
|
49
51
|
decrypted[name] = value
|
|
@@ -74,16 +74,12 @@ export class VerifyCsrfToken implements Middleware {
|
|
|
74
74
|
const csrfHeader = request.header('x-csrf-token')
|
|
75
75
|
if (csrfHeader) return csrfHeader
|
|
76
76
|
|
|
77
|
-
// 3. Check X-XSRF-TOKEN header (
|
|
77
|
+
// 3. Check X-XSRF-TOKEN header (plain token from XSRF-TOKEN cookie)
|
|
78
|
+
// XSRF-TOKEN cookie is excluded from EncryptCookies so JS can read it.
|
|
79
|
+
// The value is the raw session token — no decryption needed.
|
|
78
80
|
const xsrfHeader = request.header('x-xsrf-token')
|
|
79
81
|
if (xsrfHeader) {
|
|
80
|
-
|
|
81
|
-
// Cookie values may be URL-encoded — decode before decrypting
|
|
82
|
-
const decoded = decodeURIComponent(xsrfHeader)
|
|
83
|
-
return await this.encrypter.decrypt(decoded)
|
|
84
|
-
} catch {
|
|
85
|
-
return null
|
|
86
|
-
}
|
|
82
|
+
return decodeURIComponent(xsrfHeader)
|
|
87
83
|
}
|
|
88
84
|
|
|
89
85
|
return null
|