Ensure safe cookies

This commit is contained in:
Florine W. Dekker 2020-05-12 13:04:45 +02:00
parent db064ad7f0
commit 091c5bcf88
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
4 changed files with 30 additions and 40 deletions

View File

@ -7,12 +7,12 @@ module.exports = grunt => {
default: ["dist/"], default: ["dist/"],
}, },
copy: { copy: {
html: {
files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "dist/"}]
},
css: { css: {
files: [{expand: true, cwd: "src/main/", src: "**/*.css", dest: "dist/"}] files: [{expand: true, cwd: "src/main/", src: "**/*.css", dest: "dist/"}]
}, },
html: {
files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "dist/"}]
},
}, },
focus: { focus: {
dev: { dev: {
@ -41,6 +41,24 @@ module.exports = grunt => {
overwrite: true overwrite: true
}, },
}, },
watch: {
css: {
files: ["src/main/**/*.css"],
tasks: ["copy:css"],
},
html: {
files: ["src/main/**/*.html"],
tasks: ["copy:html"],
},
js: {
files: ["src/main/**/*.js"],
tasks: ["webpack:dev", "replace:dev"],
},
link: {
files: ["node_modules/@fwdekker/*/dist/**"],
tasks: ["webpack:dev", "replace:dev"],
},
},
webpack: { webpack: {
options: { options: {
entry: "./src/main/js/Main.js", entry: "./src/main/js/Main.js",
@ -68,24 +86,6 @@ module.exports = grunt => {
mode: "production", mode: "production",
}, },
}, },
watch: {
css: {
files: ["src/main/**/*.css"],
tasks: ["copy:css"],
},
html: {
files: ["src/main/**/*.html"],
tasks: ["copy:html"],
},
js: {
files: ["src/main/**/*.js"],
tasks: ["webpack:dev", "replace:dev"],
},
link: {
files: ["node_modules/@fwdekker/*/dist/**"],
tasks: ["webpack:dev", "replace:dev"],
},
},
}); });
grunt.loadNpmTasks("grunt-contrib-clean"); grunt.loadNpmTasks("grunt-contrib-clean");
@ -99,24 +99,22 @@ module.exports = grunt => {
// Pre // Pre
"clean", "clean",
// Copy files // Copy files
"copy:html",
"copy:css", "copy:css",
// Compile "copy:html",
// Compile JS
"webpack:dev", "webpack:dev",
// Post "replace:dev",
"replace:dev"
]); ]);
grunt.registerTask("dev:server", ["dev", "focus:dev"]); grunt.registerTask("dev:server", ["dev", "focus:dev"]);
grunt.registerTask("deploy", [ grunt.registerTask("deploy", [
// Pre // Pre
"clean", "clean",
// Copy files // Copy files
"copy:html",
"copy:css", "copy:css",
"copy:html",
// Compile JS // Compile JS
"webpack:deploy", "webpack:deploy",
// Post "replace:deploy",
"replace:deploy"
]); ]);
grunt.registerTask("default", ["dev"]); grunt.registerTask("default", ["dev"]);

View File

@ -35,18 +35,10 @@ $> npm ci
### Building ### Building
```shell script ```shell script
# Build the template in `dist/` for development # Build the tool in `dist/` for development
$> npm run dev $> npm run dev
# Same as above, but automatically rerun it whenever files are changed # Same as above, but automatically rerun it whenever files are changed
$> npm run dev:server $> npm run dev:server
# Build the template in `dist/` for deployment # Build the tool in `dist/` for deployment
$> npm run deploy $> npm run deploy
``` ```
### Publishing
```shell script
# Log in to npm
$> npm login
# Push to npm
$> npm publish --access public
```

View File

@ -1,6 +1,6 @@
{ {
"name": "interlanguage-checker", "name": "interlanguage-checker",
"version": "1.10.8", "version": "1.10.9",
"description": "Check the consistency of MediaWiki interlanguage links in a simple overview.", "description": "Check the consistency of MediaWiki interlanguage links in a simple overview.",
"author": "Felix W. Dekker", "author": "Felix W. Dekker",
"browser": "dist/bundle.js", "browser": "dist/bundle.js",

View File

@ -57,7 +57,7 @@ doAfterLoad(async () => {
let mwm = undefined; let mwm = undefined;
const submit = async () => { const submit = async () => {
Cookies.set("api-url", urlInput.getValue(), {expires: 10 * 365}); Cookies.set("api-url", urlInput.getValue(), {expires: 10 * 365, secure: true, sameSite: "lax"});
// Clean up // Clean up
urlInput.showBlank(); urlInput.showBlank();