Compare commits

..

3 Commits

Author SHA1 Message Date
Fabian Stamm
6bcda75634 Fix TOTP space bug, caused by space inserted by cleavejs 2023-04-15 00:06:06 +02:00
Fabian Stamm
dd39ece408 Make birthday optional 2023-04-14 15:46:00 +02:00
Fabian Stamm
cc1696a429 Adjust frontend build script to allow aggressive caching 2023-04-14 15:43:08 +02:00
10 changed files with 69 additions and 17 deletions

View File

@ -18,7 +18,7 @@ export default class AccountService extends Server.AccountService<SessionContext
id: ctx.user.uid,
username: ctx.user.username,
name: ctx.user.name,
birthday: ctx.user.birthday.valueOf(),
birthday: ctx.user.birthday?.valueOf(),
gender: ctx.user.gender as number as Gender,
}
}

View File

@ -26,6 +26,7 @@ export default class Web {
constructor(config: WebConfig) {
this.server = express();
this.server.set("trust proxy", 1);
this.port = Number(config.port);
this.registerMiddleware();
this.registerUserSession();

View File

@ -19,6 +19,7 @@
"postcss-url": "^10.1.3",
"rollup": "^3.20.2",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-hash": "^1.3.0",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-sizes": "^1.0.5",

View File

@ -2,6 +2,6 @@ module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
cssnano: {},
// cssnano: {},
},
};

View File

@ -9,6 +9,7 @@ import postcss from "rollup-plugin-postcss";
import livereload from "rollup-plugin-livereload";
import sveltePreprocess from "svelte-preprocess";
import commonjs from "@rollup/plugin-commonjs";
import hash from "rollup-plugin-hash";
const VIEWS = ["home", "login", "popup", "user"];
@ -27,9 +28,14 @@ const htmlTemplate = ({ attributes, meta, files, publicPath, title }) => {
""
);
};
let bundle_name = "";
const scripts = (files.js || [])
.map(({ fileName }) => {
const attrs = makeHtmlAttributes(attributes.script);
if (fileName.startsWith("bundle.")) {
bundle_name = fileName;
}
return `<script src="${publicPath}${fileName}"${attrs}></script>`;
})
.join("\n");
@ -54,8 +60,7 @@ const htmlTemplate = ({ attributes, meta, files, publicPath, title }) => {
<head>
${metas}
<title>${title}</title>
<link rel="stylesheet" href="bundle.css"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto"/>
<link rel="stylesheet" href="${bundle_name.slice(0, -2)}css"/>
${links}
</head>
<body>
@ -66,14 +71,13 @@ const htmlTemplate = ({ attributes, meta, files, publicPath, title }) => {
export default VIEWS.map((view) => ({
input: `src/pages/${view}/main.ts`,
output: [
{
file: `build/${view}/bundle.min.js`,
output: {
dir: `build/${view}`,
entryFileNames: `bundle.[hash].min.js`,
format: "es",
sourcemap: true,
name: view,
},
],
plugins: [
svelte({
emitCss: true,
@ -106,9 +110,12 @@ export default VIEWS.map((view) => ({
title: `Rullup bundle for ${view}`,
}),
postcss({
extract: `bundle.css`, //TODO: Check if it should be enabled
extract: true, // `bundle.css`, //TODO: Check if it should be enabled
// inject: true,
}),
hash({
dest: "bundle.[hash].min.js",
}),
// dev && livereload(),
],
}));

View File

@ -9,7 +9,7 @@
let code: string = "";
function send() {
loginState.useTOTP(id, code);
loginState.useTOTP(id, code.replace(/\s+/g, ""));
}
</script>

View File

@ -31,7 +31,7 @@
verifingTOTP = true;
verifyError = undefined;
try {
await InternalAPI.TwoFactor.VerifyTOTP(totp.id, code);
await InternalAPI.TwoFactor.VerifyTOTP(totp.id, code.replace(/\s/g, ""));
stage = "done";
dispatch("reload");
} catch (err) {

View File

@ -9,7 +9,7 @@ type Profile {
id: string;
name: string;
username: string;
birthday: int;
birthday?: int;
gender: Gender;
}

View File

@ -1,6 +1,6 @@
{
"name": "@hibas123/openauth",
"version": "1.3.0",
"version": "1.3.2",
"author": "Fabian Stamm <dev@fabianstamm.de>",
"private": true,
"scripts": {

View File

@ -581,6 +581,7 @@ __metadata:
postcss-url: ^10.1.3
rollup: ^3.20.2
rollup-plugin-esbuild: ^5.0.0
rollup-plugin-hash: ^1.3.0
rollup-plugin-livereload: ^2.0.5
rollup-plugin-postcss: ^4.0.2
rollup-plugin-sizes: ^1.0.5
@ -4385,6 +4386,16 @@ __metadata:
languageName: node
linkType: hard
"hasha@npm:^2.2.0":
version: 2.2.0
resolution: "hasha@npm:2.2.0"
dependencies:
is-stream: ^1.0.1
pinkie-promise: ^2.0.0
checksum: 1855680c0e8a1b92686f816f2f224e184e5f2422f2ddef4f05184ea57bf954cecc017598af08b84c6aa723ccc38353469d4f143869ecfafedf1c50aec0e7ed4e
languageName: node
linkType: hard
"he@npm:^1.2.0":
version: 1.2.0
resolution: "he@npm:1.2.0"
@ -4858,6 +4869,13 @@ __metadata:
languageName: node
linkType: hard
"is-stream@npm:^1.0.1":
version: 1.1.0
resolution: "is-stream@npm:1.1.0"
checksum: 063c6bec9d5647aa6d42108d4c59723d2bd4ae42135a2d4db6eadbd49b7ea05b750fd69d279e5c7c45cf9da753ad2c00d8978be354d65aa9f6bb434969c6a2ae
languageName: node
linkType: hard
"is-stream@npm:^2.0.0":
version: 2.0.1
resolution: "is-stream@npm:2.0.1"
@ -6207,6 +6225,22 @@ __metadata:
languageName: node
linkType: hard
"pinkie-promise@npm:^2.0.0":
version: 2.0.1
resolution: "pinkie-promise@npm:2.0.1"
dependencies:
pinkie: ^2.0.0
checksum: b53a4a2e73bf56b6f421eef711e7bdcb693d6abb474d57c5c413b809f654ba5ee750c6a96dd7225052d4b96c4d053cdcb34b708a86fceed4663303abee52fcca
languageName: node
linkType: hard
"pinkie@npm:^2.0.0":
version: 2.0.4
resolution: "pinkie@npm:2.0.4"
checksum: b12b10afea1177595aab036fc220785488f67b4b0fc49e7a27979472592e971614fa1c728e63ad3e7eb748b4ec3c3dbd780819331dad6f7d635c77c10537b9db
languageName: node
linkType: hard
"pirates@npm:^4.0.1":
version: 4.0.5
resolution: "pirates@npm:4.0.5"
@ -7364,6 +7398,15 @@ __metadata:
languageName: node
linkType: hard
"rollup-plugin-hash@npm:^1.3.0":
version: 1.3.0
resolution: "rollup-plugin-hash@npm:1.3.0"
dependencies:
hasha: ^2.2.0
checksum: ecb39f6d296664377436ab42defdc6250a4b7bd906b53aea4cb7026969a5c55a874d57c11561c98dc89c29e8b89f9dc0058ad13d7e3f5aef6247962fdf80d2bb
languageName: node
linkType: hard
"rollup-plugin-includepaths@npm:^0.2.4":
version: 0.2.4
resolution: "rollup-plugin-includepaths@npm:0.2.4"