2025-01-16 08:25:02 +01:00
|
|
|
import { doubleCsrf } from "csrf-csrf";
|
|
|
|
import sessionSecret from "../services/session_secret.js";
|
2025-01-17 09:23:00 +01:00
|
|
|
import { isElectron } from "../services/utils.js";
|
2025-01-16 08:25:02 +01:00
|
|
|
|
|
|
|
const doubleCsrfUtilities = doubleCsrf({
|
|
|
|
getSecret: () => sessionSecret,
|
|
|
|
cookieOptions: {
|
|
|
|
path: "", // empty, so cookie is valid only for the current path
|
|
|
|
secure: false,
|
2025-01-16 21:35:50 +01:00
|
|
|
sameSite: "strict",
|
2025-01-17 09:23:00 +01:00
|
|
|
httpOnly: !isElectron() // set to false for Electron, see https://github.com/TriliumNext/Notes/pull/966
|
2025-01-16 08:25:02 +01:00
|
|
|
},
|
|
|
|
cookieName: "_csrf"
|
|
|
|
});
|
|
|
|
|
2025-01-16 09:23:25 +01:00
|
|
|
export const { generateToken, doubleCsrfProtection } = doubleCsrfUtilities;
|