Restructuring the Project

Updating dependencies
This commit is contained in:
Fabian Stamm
2023-04-07 19:54:47 +02:00
parent 532107c479
commit 0453e461c9
121 changed files with 16380 additions and 6701 deletions

171
FrontendLegacy/build.js Normal file
View File

@ -0,0 +1,171 @@
const {
lstatSync,
readdirSync,
mkdirSync,
copyFileSync,
writeFileSync,
readFileSync,
exists,
} = require("fs");
const { join, basename, dirname } = require("path");
const isDirectory = (source) => lstatSync(source).isDirectory();
const getDirectories = (source) =>
readdirSync(source)
.map((name) => join(source, name))
.filter(isDirectory);
function ensureDir(folder) {
try {
if (!isDirectory(folder)) mkdirSync(folder);
} catch (e) {
mkdirSync(folder);
}
}
const fileExists = (filename) =>
new Promise((yes, no) => exists(filename, (exi) => yes(exi)));
ensureDir("./out");
const sass = require("sass");
function findHead(elm) {
if (elm.tagName === "head") return elm;
for (let i = 0; i < elm.childNodes.length; i++) {
let res = findHead(elm.childNodes[i]);
if (res) return res;
}
return undefined;
}
const rollup = require("rollup");
const includepaths = require("rollup-plugin-includepaths");
const typescript = require("rollup-plugin-typescript2");
const resolve = require("rollup-plugin-node-resolve");
const minify = require("html-minifier").minify;
const gzipSize = require("gzip-size");
async function file_name(folder, name, exts) {
for (let ext of exts) {
let basefile = `${folder}/${name}.${ext}`;
if (await fileExists(basefile)) return basefile;
}
return null;
}
async function buildPage(folder) {
const pagename = basename(folder);
const outpath = "./out/" + pagename;
ensureDir(outpath);
const basefile = await file_name(folder, pagename, ["tsx", "ts", "js"]);
let bundle = await rollup.rollup({
input: basefile,
plugins: [
includepaths({
paths: ["shared", "node_modules"],
}),
typescript(),
resolve({
// not all files you want to resolve are .js files
extensions: [".mjs", ".js", ".jsx", ".json"], // Default: [ '.mjs', '.js', '.json', '.node' ]
// whether to prefer built-in modules (e.g. `fs`, `path`) or
// local ones with the same names
preferBuiltins: false, // Default: true
}),
],
treeshake: true,
});
let { output } = await bundle.generate({
format: "iife",
compact: true,
});
let { code } = output[0];
let sass_res = sass.renderSync({
file: folder + `/${pagename}.scss`,
includePaths: ["./node_modules", folder, "./shared", "../node_modules"],
outputStyle: "compressed",
});
let css = "<style>\n" + sass_res.css.toString("utf8") + "\n</style>\n";
let script = "<script>\n" + code + "\n</script>\n";
let html = readFileSync(`${folder}/${pagename}.hbs`).toString("utf8");
let idx = html.indexOf("</head>");
if (idx < 0) throw new Error("No head element found");
let idx2 = html.indexOf("</body>");
if (idx2 < 0) throw new Error("No body element found");
if (idx < idx2) {
let part1 = html.slice(0, idx);
let part2 = html.slice(idx, idx2);
let part3 = html.slice(idx2, html.length);
html = part1 + css + part2 + script + part3;
} else {
let part1 = html.slice(0, idx2);
let part2 = html.slice(idx2, idx);
let part3 = html.slice(idx, html.length);
html = part1 + script + part2 + css + part3;
}
let result = minify(html, {
removeAttributeQuotes: true,
collapseWhitespace: true,
html5: true,
keepClosingSlash: true,
minifyCSS: false,
minifyJS: false,
removeComments: true,
useShortDoctype: true,
});
let gzips = await gzipSize(result);
writeFileSync(`${outpath}/${pagename}.html`, result);
let stats = {
sass: sass_res.stats,
js: {
chars: code.length,
},
css: {
chars: css.length,
},
bundle_size: result.length,
gzip_size: gzips,
};
writeFileSync(outpath + `/stats.json`, JSON.stringify(stats, null, " "));
}
async function run() {
console.log("Start compiling!");
let pages = getDirectories("./src");
await Promise.all(
pages.map(async (e) => {
try {
await buildPage(e);
} catch (er) {
console.error("Failed compiling", basename(e));
console.log(er);
process.exitCode = 1;
}
})
);
console.log("Finished compiling!");
}
const chokidar = require("chokidar");
if (process.argv.join(" ").toLowerCase().indexOf("watch") >= 0)
chokidar
.watch(
["./src", "./node_modules", "./package.json", "./package-lock.json"],
{
ignoreInitial: true,
}
)
.on("all", () => run());
run();

3
FrontendLegacy/index.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export const register: (dev?: boolean) => Handlebars.TemplateDelegate<any>
export const admin: (dev?: boolean) => Handlebars.TemplateDelegate<any>
export const authorize: (dev?: boolean) => Handlebars.TemplateDelegate<any>

20
FrontendLegacy/index.js Normal file
View File

@ -0,0 +1,20 @@
const handlebars = require("handlebars");
const { readFileSync } = require("fs");
const path = require("path");
const CACHE = {};
function get_template(name, dev) {
if (!dev && CACHE[name]) return CACHE[name];
const template = handlebars.compile(
readFileSync(path.join(__dirname, `./out/${name}/${name}.html`), "utf8")
);
CACHE[name] = template;
return template;
}
exports.register = (dev) => get_template("register", dev);
exports.admin = (dev) => get_template("admin", dev);
exports.authorize = (dev) => get_template("authorize", dev);

View File

@ -0,0 +1,484 @@
<html><head><title>{{i18n "Administration"}}</title><meta charset=utf8 /><meta name=viewport content="width=device-width,initial-scale=1"/><script src=https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js type=text/javascript></script><script src=https://unpkg.com/popper.js@1.12.6/dist/umd/popper.js type=text/javascript></script><script src=https://unpkg.com/bootstrap-material-design@4.1.1/dist/js/bootstrap-material-design.js type=text/javascript></script><script src=https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.min.js type=text/javascript></script><script>$(document).ready(() => $('body').bootstrapMaterialDesign())</script><style>@import"https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons";@import"https://unpkg.com/bootstrap-material-design@4.1.1/dist/css/bootstrap-material-design.min.css";.btn-primary{color:#fff !important;background-color:#1e88e5 !important}.error_card{color:#ff2f00;padding:1rem;font-size:1rem}.bg-primary{background-color:#1e88e5 !important}.spinner{-webkit-animation:rotation 1.35s linear infinite;animation:rotation 1.35s linear infinite;stroke:#1e88e5}@-webkit-keyframes rotation{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(270deg);transform:rotate(270deg)}}@keyframes rotation{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(270deg);transform:rotate(270deg)}}.circle{stroke-dasharray:180;stroke-dashoffset:0;-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center;-webkit-animation:turn 1.35s ease-in-out infinite;animation:turn 1.35s ease-in-out infinite}@-webkit-keyframes turn{0%{stroke-dashoffset:180}50%{stroke-dashoffset:45;-webkit-transform:rotate(135deg);transform:rotate(135deg)}100%{stroke-dashoffset:180;-webkit-transform:rotate(450deg);transform:rotate(450deg)}}@keyframes turn{0%{stroke-dashoffset:180}50%{stroke-dashoffset:45;-webkit-transform:rotate(135deg);transform:rotate(135deg)}100%{stroke-dashoffset:180;-webkit-transform:rotate(450deg);transform:rotate(450deg)}}header{margin-bottom:8px;padding:8px 16px;padding-bottom:0}table{word-wrap:break-word;table-layout:fixed}table td{vertical-align:inherit !important;width:auto}.col.form-group{padding-left:0 !important;margin-left:5px !important}</style></head><body><header class=bg-primary style="display: flex; justify-content: space-between;"><h3 style="display: inline">{{appname}} {{i18n "Administration"}} <span id=sitename>LOADING</span></h3><ul class="nav nav-tabs" style="display: inline-block; margin-left: auto; margin-top: -8px;"><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" data-toggle=dropdown href=# role=button aria-haspopup=true aria-expanded=false>Model</a><div class=dropdown-menu><a class=dropdown-item href="?type=user">User</a> <a class=dropdown-item href="?type=regcode">RegCode</a> <a class=dropdown-item href="?type=client">Client</a></div></li></ul></header><div id=content><div class=container><div id=error_cont class=row style="margin-bottom: 24px;display: none;"><div class=col-sm><div class="card error_card"><div id=error_msg class=card-body></div></div></div></div><div id=custom_data_cont class=row style="margin-bottom: 24px; display: none"><div class=col-sm><div class=card><div id=custom_data class=card-body></div></div></div></div><div class=row><div class=col-sm><div class=card><div class=card-body><div id=table-body><div style="width: 65px; height: 65px; margin: 0 auto;"><svg class=spinner viewBox="0 0 66 66" xmlns=http://www.w3.org/2000/svg><circle class=circle fill=none stroke-width=6 stroke-linecap=round cx=33 cy=33 r=30></circle></svg></div></div></div></div></div></div></div></div><script id=template-spinner type=text/x-handlebars-template><div style="width: 65px; height: 65px; margin: 0 auto;">
<svg class="spinner" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="circle" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
</div></script><script id=template-user-list type=text/x-handlebars-template><table class="table table-bordered" style="margin-bottom: 0">
<thead>
<tr>
<th scope="col">Username</th>
<th scope="col">Name</th>
<th scope="col">Gender</th>
<th scope="col">Role</th>
<th scope="col" style="width: 2.5rem"></th>
</tr>
</thead>
<tbody>
\{{#users}}
<tr>
<td>\{{ username }}</td>
<td>\{{ name }}</td>
<!-- ToDo: Make helper to resolve number to human readaby text-->
<td>\{{humangender gender}}</td>
<td onclick="userOnChangeType('\{{_id}}')">
\{{#if admin}}
<span class="badge badge-danger">Admin</span>
\{{else}}
<span class="badge badge-success">User</span>
\{{/if}}
</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="deleteUser('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
delete
</i>
</button>
</td>
</tr>
\{{/users}}
</tbody>
</table></script><script id=template-regcode-list type=text/x-handlebars-template><button class="btn btn-raised btn-primary" onclick="createRegcode()">Create</button>
<table class="table table-bordered" style="margin-bottom: 0">
<thead>
<tr>
<th scope="col">Code</th>
<th scope="col">Valid</th>
<th scope="col">Till</th>
<th scope="col" style="width: 2.5rem"></th>
</tr>
</thead>
<tbody>
\{{#regcodes}}
<tr>
<td>\{{ token }}</td>
<td>\{{ valid }}</td>
<!-- ToDo: Make helper to resolve number to human readaby text-->
<td>\{{formatDate validTill }}</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="deleteRegcode('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
delete
</i>
</button>
</td>
</tr>
\{{/regcodes}}
</tbody>
</table></script><script id=template-client-list type=text/x-handlebars-template><button class="btn btn-raised btn-primary" onclick="createClient()">Create</button>
<table class="table table-bordered" style="margin-bottom: 0">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Secret</th>
<th scope="col">Maintainer</th>
<th scope="col">Name</th>
<th scope="col" style="width: 80px">Type</th>
<th scope="col">Website</th>
<th scope="col" style="width: 2.5rem">
<div></div>
</th>
<th scope="col" style="width: 2.5rem"></th>
<th scope="col" style="width: 2.5rem"></th>
</tr>
</thead>
<tbody>
\{{#clients}}
<tr>
<td>\{{ client_id }}</td>
<td>\{{ client_secret }}</td>
<td>\{{ maintainer.username }}</td>
<td>\{{ name }}</td>
<td>
\{{#if internal}}
<span class="badge badge-success">Internal</span>
\{{else}}
<span class="badge badge-danger">External</span>
\{{/if}}
</td>
<td>
<a href="\{{ website }}">\{{ website }}</a>
</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="permissionsClient('\{{_id}}')">
perm
</button>
</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="editClient('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
edit
</i>
</button>
</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="deleteClient('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
delete
</i>
</button>
</td>
</tr>
\{{/clients}}
</tbody>
</table></script><script id=template-client-form type=text/x-handlebars-template><form class="form" action="JavaScript:void(null)" onsubmit="createClientSubmit(this)" style="margin-bottom: 0">
<input type=hidden value="\{{_id}}" name=id />
<div class="form-group">
<label for="name_input" class="bmd-label-floating">Name</label>
<input type="text" class="form-control" id="name_input" name=name value="\{{name}}">
</div>
<div class="form-group">
<label for="redirect_input" class="bmd-label-floating">Redirect Url</label>
<input type="text" class="form-control" id="redirect_input" name=redirect_url value="\{{redirect_url}}">
</div>
<div class="form-group">
<label for="website_input" class="bmd-label-floating">Website</label>
<input type="text" class="form-control" id="website_input" name=website value="\{{website}}">
</div>
<div class="form-group">
<label for="logo_input" class="bmd-label-floating">Logo</label>
<input type="text" class="form-control" id="logo_input" name=logo value="\{{logo}}">
</div>
<div class="form-group">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="internal_check" \{{#if internal}} checked="checked" \{{/if}} name=internal>
<label class="form-check-label" for="internal_check">Internal</label>
</div>
</div>
<span class="form-group bmd-form-group">
<!-- needed to match padding for floating labels -->
<button type="submit" class="btn btn-raised btn-primary">Save</button>
</span>
</form></script><script id=template-permission-list type=text/x-handlebars-template><h2><button class="btn btn-raised btn-primary" onclick="gotoClients()">back</button> to \{{client_name}} </h2>
<button class="btn btn-raised btn-primary" onclick="createPermission('\{{ client_id }}')">Create</button>
<table class="table table-bordered" style="margin-bottom: 0">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col" style="width: 10ch">Type</th>
<th scope="col" style="width: 2.5rem"></th>
</tr>
</thead>
<tbody>
\{{#permissions}}
<tr>
<td>\{{ _id }}</td>
<td>\{{ name }}</td>
<td>\{{ description }}</td>
<td>\{{ grant_type }}</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="deletePermission('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
delete
</i>
</button>
</td>
</tr>
\{{/permissions}}
</tbody>
</table></script><script id=template-permission-form type=text/x-handlebars-template><form class="form" action="JavaScript:void(null)" onsubmit="createPermissionSubmit(this)" style="margin-bottom: 0">
<input type=hidden value="\{{client_id}}" name=client />
<div class="form-group">
<label for="name_input" class="bmd-label-floating">Name</label>
<input type="text" class="form-control" id="name_input" name=name value="">
</div>
<div class="form-group">
<label for=description class="bmd-label-floating">Description</label>
<input type="text" class="form-control" id=description name=description value="">
</div>
<div class="form-group">
<label for=type class="bmd-label-floating">Type</label>
<select type="text" class="form-control" id=type name=type>
<option value="user">User granted</option>
<option value="client">Client granted</option>
</select>
</div>
<span class="form-group bmd-form-group">
<!-- needed to match padding for floating labels -->
<button type="submit" class="btn btn-raised btn-primary">Save</button>
</span>
</form></script><script>(function(){'use strict';function request(endpoint, method, data) {
var headers = new Headers();
headers.set("Content-Type", "application/json");
return fetch(endpoint, {
method: method,
body: JSON.stringify(data),
headers: headers,
credentials: "include",
})
.then(async (e) => {
if (e.status !== 200)
throw new Error((await e.text()) || e.statusText);
return e.json();
})
.then((e) => {
if (e.error)
return Promise.reject(
new Error(
typeof e.error === "string"
? e.error
: JSON.stringify(e.error)
)
);
return e;
});
}function getFormData(element) {
let data = {};
if (
element.name !== undefined &&
element.name !== null &&
element.name !== ""
) {
if (typeof element.name === "string") {
if (element.type === "checkbox") data[element.name] = element.checked;
else data[element.name] = element.value;
}
}
element.childNodes.forEach((child) => {
let res = getFormData(child);
data = Object.assign(data, res);
});
return data;
}Handlebars.registerHelper("humangender", function (value, options) {
switch (value) {
case 1:
return "male";
case 2:
return "female";
case 3:
return "other";
default:
case 0:
return "none";
}
});
// Deprecated since version 0.8.0
Handlebars.registerHelper("formatDate", function (datetime, format) {
return new Date(datetime).toLocaleString();
});
(() => {
const tableb = document.getElementById("table-body");
function setTitle(title) {
document.getElementById("sitename").innerText = title;
}
const cc = document.getElementById("custom_data");
const ccc = document.getElementById("custom_data_cont");
function setCustomCard(content) {
if (!content) {
cc.innerHTML = "";
ccc.style.display = "none";
} else {
cc.innerHTML = content;
ccc.style.display = "";
}
}
const error_cont = document.getElementById("error_cont");
const error_msg = document.getElementById("error_msg");
function catchError(error) {
error_cont.style.display = "";
error_msg.innerText = error.message;
console.log(error);
}
async function renderUser() {
console.log("Rendering User");
setTitle("User");
const listt = Handlebars.compile(
document.getElementById("template-user-list").innerText
);
async function loadList() {
let data = await request("/api/admin/user", "GET");
tableb.innerHTML = listt({
users: data,
});
}
window.userOnChangeType = (id) => {
request("/api/admin/user?id=" + id, "PUT")
.then(() => loadList())
.catch(catchError);
};
window.deleteUser = (id) => {
request("/api/admin/user?id=" + id, "DELETE")
.then(() => loadList())
.catch(catchError);
};
await loadList();
}
async function renderPermissions(client_id, client_name) {
const listt = Handlebars.compile(
document.getElementById("template-permission-list").innerText
);
const formt = Handlebars.compile(
document.getElementById("template-permission-form").innerText
);
setCustomCard();
async function loadList() {
try {
let data = await request(
"/api/admin/permission?client=" + client_id,
"GET"
);
tableb.innerHTML = listt({
client_id: client_id,
client_name: client_name,
permissions: data,
});
} catch (err) {
catchError(err);
}
}
window.gotoClients = () => {
renderClient();
};
window.deletePermission = (id) => {
request("/api/admin/permission?id=" + id, "DELETE")
.then(() => loadList())
.catch(catchError);
};
window.createPermission = () => {
try {
setCustomCard(formt({ client_id: client_id }));
} catch (err) {
console.log("Err", err);
}
};
window.createPermissionSubmit = (elm) => {
console.log(elm);
let data = getFormData(elm);
console.log(data);
request("/api/admin/permission", "POST", data)
.then(() => setCustomCard())
.then(() => loadList())
.catch(catchError);
};
await loadList();
}
async function renderClient() {
console.log("Rendering Client");
setTitle("Client");
const listt = Handlebars.compile(
document.getElementById("template-client-list").innerText
);
const formt = Handlebars.compile(
document.getElementById("template-client-form").innerText
);
let clients = [];
async function loadList() {
let data = await request("/api/admin/client", "GET");
clients = data;
tableb.innerHTML = listt({
clients: data,
});
}
window.permissionsClient = (id) => {
renderPermissions(id, clients.find((e) => e._id === id).name);
};
window.deleteClient = (id) => {
request("/api/admin/client/id=" + id, "DELETE")
.then(() => loadList())
.catch(catchError);
};
window.createClientSubmit = (elm) => {
console.log(elm);
let data = getFormData(elm);
console.log(data);
let id = data.id;
delete data.id;
if (id && id !== "") {
request("/api/admin/client?id=" + id, "PUT", data)
.then(() => setCustomCard())
.then(() => loadList())
.catch(catchError);
} else {
request("/api/admin/client", "POST", data)
.then(() => setCustomCard())
.then(() => loadList())
.catch(catchError);
}
};
window.createClient = () => {
setCustomCard(formt());
};
window.editClient = (id) => {
let client = clients.find((e) => e._id === id);
if (!client) return catchError(new Error("Client does not exist!!"));
setCustomCard(formt(client));
};
await loadList().catch(catchError);
}
async function renderRegCode() {
console.log("Rendering RegCode");
setTitle("RegCode");
const listt = Handlebars.compile(
document.getElementById("template-regcode-list").innerText
);
async function loadList() {
let data = await request("/api/admin/regcode", "GET");
tableb.innerHTML = listt({
regcodes: data,
});
}
window.deleteRegcode = (id) => {
request("/api/admin/regcode?id=" + id, "DELETE")
.then(() => loadList())
.catch(catchError);
};
window.createRegcode = () => {
request("/api/admin/regcode", "POST")
.then(() => loadList())
.catch(catchError);
};
await loadList().catch(catchError);
}
const type = new URL(window.location.href).searchParams.get("type");
switch (type) {
case "client":
renderClient().catch(catchError);
break;
case "regcode":
renderRegCode().catch(catchError);
break;
case "user":
default:
renderUser().catch(catchError);
break;
}
})();})();</script></body></html>

View File

@ -0,0 +1,21 @@
{
"sass": {
"entry": "src\\admin/admin.scss",
"start": 1680888864800,
"end": 1680888864814,
"duration": 14,
"includedFiles": [
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\FrontendLegacy\\src\\admin\\admin.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\FrontendLegacy\\shared\\mat_bs.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\FrontendLegacy\\shared\\style.scss"
]
},
"js": {
"chars": 7975
},
"css": {
"chars": 1665
},
"bundle_size": 21873,
"gzip_size": 4359
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,52 @@
{
"sass": {
"entry": "src\\authorize/authorize.scss",
"start": 1680888863485,
"end": 1680888864104,
"duration": 619,
"includedFiles": [
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\FrontendLegacy\\src\\authorize\\authorize.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\button\\mdc-button.import.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\base\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\feature-targeting\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\feature-targeting\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\feature-targeting\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\theme\\_constants.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\theme\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\theme\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\animation\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\elevation\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\ripple\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\rtl\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\touch-target\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\typography\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\typography\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\shape\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\density\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\button\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\button\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\elevation\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\theme\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\elevation\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\ripple\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\animation\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\ripple\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\ripple\\_keyframes.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\rtl\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\touch-target\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\typography\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\shape\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\shape\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\density\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\button\\mdc-button.scss"
]
},
"js": {
"chars": 576
},
"css": {
"chars": 9933
},
"bundle_size": 11387,
"gzip_size": 2740
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
{
"sass": {
"entry": "src\\login/login.scss",
"start": 1596809618526,
"end": 1596809618741,
"duration": 215,
"includedFiles": [
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\src\\login\\login.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\button\\mdc-button.import.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\base\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\feature-targeting\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\feature-targeting\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\feature-targeting\\_functions.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\theme\\_constants.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\theme\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\theme\\_functions.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\animation\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\elevation\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\ripple\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\rtl\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\touch-target\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\typography\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\typography\\_functions.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\shape\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\density\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\button\\_variables.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\button\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\elevation\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\theme\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\elevation\\_functions.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\ripple\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\animation\\_functions.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\ripple\\_functions.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\ripple\\_keyframes.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\rtl\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\touch-target\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\typography\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\shape\\_mixins.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\shape\\_functions.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\density\\_functions.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\node_modules\\@material\\button\\mdc-button.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\shared\\inputs.scss",
"C:\\Users\\micro\\Documents\\Projekte\\OpenAuth\\server\\views\\shared\\style.scss"
]
},
"js": {
"chars": 68059
},
"css": {
"chars": 11795
},
"bundle_size": 81043,
"gzip_size": 20007
}

View File

@ -0,0 +1 @@
<html><head><style></style></head><body><script>(function(){'use strict';console.log("Hello World");})();</script></body></html>

View File

@ -0,0 +1,19 @@
{
"sass": {
"entry": "src\\main/main.scss",
"start": 1680888864122,
"end": 1680888864124,
"duration": 2,
"includedFiles": [
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\FrontendLegacy\\src\\main\\main.scss"
]
},
"js": {
"chars": 57
},
"css": {
"chars": 18
},
"bundle_size": 128,
"gzip_size": 123
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,63 @@
{
"sass": {
"entry": "src\\register/register.scss",
"start": 1680888864210,
"end": 1680888864775,
"duration": 565,
"includedFiles": [
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\FrontendLegacy\\src\\register\\register.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\button\\mdc-button.import.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\base\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\feature-targeting\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\feature-targeting\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\feature-targeting\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\theme\\_constants.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\theme\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\theme\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\animation\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\elevation\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\ripple\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\rtl\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\touch-target\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\typography\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\typography\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\shape\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\density\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\button\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\button\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\elevation\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\theme\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\elevation\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\ripple\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\animation\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\ripple\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\ripple\\_keyframes.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\rtl\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\touch-target\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\typography\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\shape\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\shape\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\density\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\button\\mdc-button.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\form-field\\mdc-form-field.import.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\form-field\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\form-field\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\form-field\\mdc-form-field.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\radio\\mdc-radio.import.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\radio\\_variables.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\radio\\_mixins.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\radio\\_functions.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\node_modules\\@material\\radio\\mdc-radio.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\FrontendLegacy\\shared\\inputs.scss",
"D:\\Projekte\\OpenServer\\OpenAuth\\server\\FrontendLegacy\\shared\\style.scss"
]
},
"js": {
"chars": 21204
},
"css": {
"chars": 19609
},
"bundle_size": 44031,
"gzip_size": 9858
}

View File

@ -0,0 +1,29 @@
{
"name": "@hibas123/openauth-views-v1",
"version": "1.0.0",
"main": "index.js",
"author": "Fabian Stamm <dev@fabianstamm.de>",
"license": "MIT",
"scripts": {
"build": "node build.js",
"watch": "node build.js watch"
},
"dependencies": {
"handlebars": "^4.7.7"
},
"devDependencies": {
"@material/button": "^5.1.0",
"@material/form-field": "^5.1.0",
"@material/radio": "^5.1.0",
"chokidar": "^3.5.3",
"gzip-size": "^6.0.0",
"html-minifier": "^4.0.0",
"preact": "^10.13.2",
"rollup": "^3.20.2",
"rollup-plugin-includepaths": "^0.2.4",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-typescript2": "^0.34.1",
"sass": "^1.61.0",
"typescript": "^5.0.3"
}
}

View File

@ -0,0 +1,20 @@
export function setCookie(cname, cvalue, exdate) {
var expires = exdate ? `;expires=${exdate}` : "";
document.cookie = `${cname}=${cvalue}${expires}`;
}
export function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

View File

@ -0,0 +1,12 @@
export default function fireEvent(element, event) {
if (document.createEventObject) {
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent("on" + event, evt);
} else {
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true); // event type,bubbling,cancelable
return !element.dispatchEvent(evt);
}
}

View File

@ -0,0 +1,18 @@
export default function getFormData(element) {
let data = {};
if (
element.name !== undefined &&
element.name !== null &&
element.name !== ""
) {
if (typeof element.name === "string") {
if (element.type === "checkbox") data[element.name] = element.checked;
else data[element.name] = element.value;
}
}
element.childNodes.forEach((child) => {
let res = getFormData(child);
data = Object.assign(data, res);
});
return data;
}

View File

@ -0,0 +1,33 @@
(() => {
const run = () => {
document.querySelectorAll(".floating>input").forEach((e) => {
function checkState() {
if (e.value !== "") {
if (e.classList.contains("used")) return;
e.classList.add("used");
} else {
if (e.classList.contains("used")) e.classList.remove("used");
}
}
e.addEventListener("change", () => checkState());
checkState();
});
};
run();
var mutationObserver = new MutationObserver(() => {
run();
});
mutationObserver.observe(document.documentElement, {
attributes: false,
characterData: false,
childList: true,
subtree: true,
});
window.Mutt;
window.addEventListener("DOMNodeInserted", () => run());
})();

View File

@ -0,0 +1,113 @@
@import "style";
.group {
position: relative;
margin-bottom: 24px;
min-height: 45px;
}
.floating > input {
font-size: 18px;
padding: 10px 10px 10px 5px;
appearance: none;
-webkit-appearance: none;
display: block;
background: #fafafa;
color: #636363;
width: 100%;
border: none;
border-radius: 0;
border-bottom: 1px solid #757575;
}
.floating > input:focus {
outline: none;
}
/* Label */
.floating > label {
color: #999;
font-size: 18px;
font-weight: normal;
position: absolute;
pointer-events: none;
left: 5px;
top: 10px;
transition: all 0.2s ease;
}
/* active */
.floating > input:focus ~ label,
.floating > input.used ~ label {
top: -0.75em;
transform: scale(0.75);
left: -2px;
/* font-size: 14px; */
color: $primary;
transform-origin: left;
}
/* Underline */
.bar {
position: relative;
display: block;
width: 100%;
}
.bar:before,
.bar:after {
content: "";
height: 2px;
width: 0;
bottom: 1px;
position: absolute;
background: $primary;
transition: all 0.2s ease;
}
.bar:before {
left: 50%;
}
.bar:after {
right: 50%;
}
/* active */
.floating > input:focus ~ .bar:before,
.floating > input:focus ~ .bar:after {
width: 50%;
}
/* Highlight */
.highlight {
position: absolute;
height: 60%;
width: 100px;
top: 25%;
left: 0;
pointer-events: none;
opacity: 0.5;
}
/* active */
.floating > input:focus ~ .highlight {
animation: inputHighlighter 0.3s ease;
}
/* Animations */
@keyframes inputHighlighter {
from {
background: $primary;
}
to {
width: 0;
background: transparent;
}
}

View File

@ -0,0 +1,2 @@
@import url("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons");
@import url("https://unpkg.com/bootstrap-material-design@4.1.1/dist/css/bootstrap-material-design.min.css");

View File

@ -0,0 +1,26 @@
export default function request(endpoint, method, data) {
var headers = new Headers();
headers.set("Content-Type", "application/json");
return fetch(endpoint, {
method: method,
body: JSON.stringify(data),
headers: headers,
credentials: "include",
})
.then(async (e) => {
if (e.status !== 200)
throw new Error((await e.text()) || e.statusText);
return e.json();
})
.then((e) => {
if (e.error)
return Promise.reject(
new Error(
typeof e.error === "string"
? e.error
: JSON.stringify(e.error)
)
);
return e;
});
}

View File

@ -0,0 +1,484 @@
var b;
if (!(b = t)) {
var w = Math,
y = {},
B = (y.p = {}),
aa = function () {},
C = (B.A = {
extend: function (o) {
aa.prototype = this;
var _ = new aa();
return o && _.u(o), (_.z = this), _;
},
create: function () {
var o = this.extend();
return o.h.apply(o, arguments), o;
},
h: function () {},
u: function (o) {
for (var _ in o) o.hasOwnProperty(_) && (this[_] = o[_]);
o.hasOwnProperty("toString") && (this.toString = o.toString);
},
e: function () {
return this.z.extend(this);
},
}),
D = (B.i = C.extend({
h: function (o, _) {
(o = this.d = o || []), (this.c = void 0 == _ ? 4 * o.length : _);
},
toString: function (o) {
return (o || ba).stringify(this);
},
concat: function (o) {
var _ = this.d,
Da = o.d,
Ea = this.c,
o = o.c;
if ((this.t(), Ea % 4))
for (var Fa = 0; Fa < o; Fa++)
_[(Ea + Fa) >>> 2] |=
(255 & (Da[Fa >>> 2] >>> (24 - 8 * (Fa % 4)))) <<
(24 - 8 * ((Ea + Fa) % 4));
else if (65535 < Da.length)
for (Fa = 0; Fa < o; Fa += 4) _[(Ea + Fa) >>> 2] = Da[Fa >>> 2];
else _.push.apply(_, Da);
return (this.c += o), this;
},
t: function () {
var o = this.d,
_ = this.c;
(o[_ >>> 2] &= 4294967295 << (32 - 8 * (_ % 4))),
(o.length = w.ceil(_ / 4));
},
e: function () {
var o = C.e.call(this);
return (o.d = this.d.slice(0)), o;
},
random: function (o) {
for (var _ = [], Da = 0; Da < o; Da += 4)
_.push(0 | (4294967296 * w.random()));
return D.create(_, o);
},
})),
ca = (y.O = {}),
ba = (ca.K = {
stringify: function (o) {
for (var Fa, _ = o.d, o = o.c, Da = [], Ea = 0; Ea < o; Ea++)
(Fa = 255 & (_[Ea >>> 2] >>> (24 - 8 * (Ea % 4)))),
Da.push((Fa >>> 4).toString(16)),
Da.push((15 & Fa).toString(16));
return Da.join("");
},
parse: function (o) {
for (var _ = o.length, Da = [], Ea = 0; Ea < _; Ea += 2)
Da[Ea >>> 3] |=
parseInt(o.substr(Ea, 2), 16) << (24 - 4 * (Ea % 8));
return D.create(Da, _ / 2);
},
}),
da = (ca.M = {
stringify: function (o) {
for (var _ = o.d, o = o.c, Da = [], Ea = 0; Ea < o; Ea++)
Da.push(
String.fromCharCode(
255 & (_[Ea >>> 2] >>> (24 - 8 * (Ea % 4)))
)
);
return Da.join("");
},
parse: function (o) {
for (var _ = o.length, Da = [], Ea = 0; Ea < _; Ea++)
Da[Ea >>> 2] |= (255 & o.charCodeAt(Ea)) << (24 - 8 * (Ea % 4));
return D.create(Da, _);
},
}),
ea = (ca.N = {
stringify: function (o) {
try {
return decodeURIComponent(escape(da.stringify(o)));
} catch (_) {
throw Error("Malformed UTF-8 data");
}
},
parse: function (o) {
return da.parse(unescape(encodeURIComponent(o)));
},
}),
ia = (B.I = C.extend({
reset: function () {
(this.g = D.create()), (this.j = 0);
},
l: function (o) {
"string" == typeof o && (o = ea.parse(o)),
this.g.concat(o),
(this.j += o.c);
},
m: function (o) {
var _ = this.g,
Da = _.d,
Ea = _.c,
Fa = this.n,
Ga = Ea / (4 * Fa),
Ga = o ? w.ceil(Ga) : w.max((0 | Ga) - this.r, 0),
o = Ga * Fa,
Ea = w.min(4 * o, Ea);
if (o) {
for (var Ha = 0; Ha < o; Ha += Fa) this.H(Da, Ha);
(Ha = Da.splice(0, o)), (_.c -= Ea);
}
return D.create(Ha, Ea);
},
e: function () {
var o = C.e.call(this);
return (o.g = this.g.e()), o;
},
r: 0,
}));
B.B = ia.extend({
h: function () {
this.reset();
},
reset: function () {
ia.reset.call(this), this.q();
},
update: function (o) {
return this.l(o), this.m(), this;
},
o: function (o) {
return o && this.l(o), this.G(), this.f;
},
e: function () {
var o = ia.e.call(this);
return (o.f = this.f.e()), o;
},
n: 16,
D: function (o) {
return function (_, Da) {
return o.create(Da).o(_);
};
},
F: function (o) {
return function (_, Da) {
return ja.J.create(o, Da).o(_);
};
},
});
var ja = (y.s = {});
b = y;
}
var t = b,
K = t,
ka = K.p,
la = ka.A,
va = ka.i,
K = (K.w = {});
(K.C = la.extend({
h: function (o, _) {
(this.a = o), (this.b = _);
},
})),
(K.i = la.extend({
h: function (o, _) {
(o = this.d = o || []), (this.c = void 0 == _ ? 8 * o.length : _);
},
v: function () {
for (var Fa, o = this.d, _ = o.length, Da = [], Ea = 0; Ea < _; Ea++)
(Fa = o[Ea]), Da.push(Fa.a), Da.push(Fa.b);
return va.create(Da, this.c);
},
e: function () {
for (
var o = la.e.call(this),
_ = (o.d = this.d.slice(0)),
Da = _.length,
Ea = 0;
Ea < Da;
Ea++
)
_[Ea] = _[Ea].e();
return o;
},
}));
function L() {
return wa.create.apply(wa, arguments);
}
for (
var xa = t.p.B,
M = t.w,
wa = M.C,
ya = M.i,
M = t.s,
za = [
L(1116352408, 3609767458),
L(1899447441, 602891725),
L(3049323471, 3964484399),
L(3921009573, 2173295548),
L(961987163, 4081628472),
L(1508970993, 3053834265),
L(2453635748, 2937671579),
L(2870763221, 3664609560),
L(3624381080, 2734883394),
L(310598401, 1164996542),
L(607225278, 1323610764),
L(1426881987, 3590304994),
L(1925078388, 4068182383),
L(2162078206, 991336113),
L(2614888103, 633803317),
L(3248222580, 3479774868),
L(3835390401, 2666613458),
L(4022224774, 944711139),
L(264347078, 2341262773),
L(604807628, 2007800933),
L(770255983, 1495990901),
L(1249150122, 1856431235),
L(1555081692, 3175218132),
L(1996064986, 2198950837),
L(2554220882, 3999719339),
L(2821834349, 766784016),
L(2952996808, 2566594879),
L(3210313671, 3203337956),
L(3336571891, 1034457026),
L(3584528711, 2466948901),
L(113926993, 3758326383),
L(338241895, 168717936),
L(666307205, 1188179964),
L(773529912, 1546045734),
L(1294757372, 1522805485),
L(1396182291, 2643833823),
L(1695183700, 2343527390),
L(1986661051, 1014477480),
L(2177026350, 1206759142),
L(2456956037, 344077627),
L(2730485921, 1290863460),
L(2820302411, 3158454273),
L(3259730800, 3505952657),
L(3345764771, 106217008),
L(3516065817, 3606008344),
L(3600352804, 1432725776),
L(4094571909, 1467031594),
L(275423344, 851169720),
L(430227734, 3100823752),
L(506948616, 1363258195),
L(659060556, 3750685593),
L(883997877, 3785050280),
L(958139571, 3318307427),
L(1322822218, 3812723403),
L(1537002063, 2003034995),
L(1747873779, 3602036899),
L(1955562222, 1575990012),
L(2024104815, 1125592928),
L(2227730452, 2716904306),
L(2361852424, 442776044),
L(2428436474, 593698344),
L(2756734187, 3733110249),
L(3204031479, 2999351573),
L(3329325298, 3815920427),
L(3391569614, 3928383900),
L(3515267271, 566280711),
L(3940187606, 3454069534),
L(4118630271, 4000239992),
L(116418474, 1914138554),
L(174292421, 2731055270),
L(289380356, 3203993006),
L(460393269, 320620315),
L(685471733, 587496836),
L(852142971, 1086792851),
L(1017036298, 365543100),
L(1126000580, 2618297676),
L(1288033470, 3409855158),
L(1501505948, 4234509866),
L(1607167915, 987167468),
L(1816402316, 1246189591),
],
$ = [],
Aa = 0;
80 > Aa;
Aa++
)
$[Aa] = L();
(M = M.k = xa.extend({
q: function () {
this.f = ya.create([
L(1779033703, 4089235720),
L(3144134277, 2227873595),
L(1013904242, 4271175723),
L(2773480762, 1595750129),
L(1359893119, 2917565137),
L(2600822924, 725511199),
L(528734635, 4215389547),
L(1541459225, 327033209),
]);
},
H: function (o, _) {
for (
var qb,
Da = this.f.d,
Ea = Da[0],
Fa = Da[1],
Ga = Da[2],
Ha = Da[3],
Ia = Da[4],
Ja = Da[5],
Ka = Da[6],
Da = Da[7],
La = Ea.a,
Ma = Ea.b,
Na = Fa.a,
Oa = Fa.b,
Pa = Ga.a,
Qa = Ga.b,
Ra = Ha.a,
Sa = Ha.b,
Ta = Ia.a,
Ua = Ia.b,
Va = Ja.a,
Wa = Ja.b,
Xa = Ka.a,
Ya = Ka.b,
Za = Da.a,
$a = Da.b,
_a = La,
ab = Ma,
bb = Na,
cb = Oa,
db = Pa,
eb = Qa,
fb = Ra,
gb = Sa,
hb = Ta,
ib = Ua,
jb = Va,
kb = Wa,
lb = Xa,
mb = Ya,
nb = Za,
ob = $a,
pb = 0;
80 > pb;
pb++
) {
if (((qb = $[pb]), 16 > pb))
var rb = (qb.a = 0 | o[_ + 2 * pb]),
sb = (qb.b = 0 | o[_ + 2 * pb + 1]);
else {
var rb = $[pb - 15],
sb = rb.a,
tb = rb.b,
rb =
((tb << 31) | (sb >>> 1)) ^
((tb << 24) | (sb >>> 8)) ^
(sb >>> 7),
tb =
((sb << 31) | (tb >>> 1)) ^
((sb << 24) | (tb >>> 8)) ^
((sb << 25) | (tb >>> 7)),
ub = $[pb - 2],
sb = ub.a,
vb = ub.b,
ub =
((vb << 13) | (sb >>> 19)) ^
((sb << 3) | (vb >>> 29)) ^
(sb >>> 6),
vb =
((sb << 13) | (vb >>> 19)) ^
((vb << 3) | (sb >>> 29)) ^
((sb << 26) | (vb >>> 6)),
sb = $[pb - 7],
wb = sb.a,
xb = $[pb - 16],
yb = xb.a,
xb = xb.b,
sb = tb + sb.b,
rb = rb + wb + (sb >>> 0 < tb >>> 0 ? 1 : 0),
sb = sb + vb,
rb = rb + ub + (sb >>> 0 < vb >>> 0 ? 1 : 0),
sb = sb + xb,
rb = rb + yb + (sb >>> 0 < xb >>> 0 ? 1 : 0);
(qb.a = rb), (qb.b = sb);
}
var wb = (hb & jb) ^ (~hb & lb),
xb = (ib & kb) ^ (~ib & mb),
qb = (_a & bb) ^ (_a & db) ^ (bb & db),
tb =
((ab << 4) | (_a >>> 28)) ^
((_a << 30) | (ab >>> 2)) ^
((_a << 25) | (ab >>> 7)),
ub =
((_a << 4) | (ab >>> 28)) ^
((ab << 30) | (_a >>> 2)) ^
((ab << 25) | (_a >>> 7)),
vb = za[pb],
Ab = vb.a,
Bb = vb.b,
vb =
ob +
(((hb << 18) | (ib >>> 14)) ^
((hb << 14) | (ib >>> 18)) ^
((ib << 23) | (hb >>> 9))),
yb =
nb +
(((ib << 18) | (hb >>> 14)) ^
((ib << 14) | (hb >>> 18)) ^
((hb << 23) | (ib >>> 9))) +
(vb >>> 0 < ob >>> 0 ? 1 : 0),
vb = vb + xb,
yb = yb + wb + (vb >>> 0 < xb >>> 0 ? 1 : 0),
vb = vb + Bb,
yb = yb + Ab + (vb >>> 0 < Bb >>> 0 ? 1 : 0),
vb = vb + sb,
yb = yb + rb + (vb >>> 0 < sb >>> 0 ? 1 : 0),
sb = ub + ((ab & cb) ^ (ab & eb) ^ (cb & eb)),
qb = tb + qb + (sb >>> 0 < ub >>> 0 ? 1 : 0),
nb = lb,
ob = mb,
lb = jb,
mb = kb,
jb = hb,
kb = ib,
ib = 0 | (gb + vb),
hb = 0 | (fb + yb + (ib >>> 0 < gb >>> 0 ? 1 : 0)),
fb = db,
gb = eb,
db = bb,
eb = cb,
bb = _a,
cb = ab,
ab = 0 | (vb + sb),
_a = 0 | (yb + qb + (ab >>> 0 < vb >>> 0 ? 1 : 0));
}
(Ma = Ea.b = 0 | (Ma + ab)),
(Ea.a = 0 | (La + _a + (Ma >>> 0 < ab >>> 0 ? 1 : 0))),
(Oa = Fa.b = 0 | (Oa + cb)),
(Fa.a = 0 | (Na + bb + (Oa >>> 0 < cb >>> 0 ? 1 : 0))),
(Qa = Ga.b = 0 | (Qa + eb)),
(Ga.a = 0 | (Pa + db + (Qa >>> 0 < eb >>> 0 ? 1 : 0))),
(Sa = Ha.b = 0 | (Sa + gb)),
(Ha.a = 0 | (Ra + fb + (Sa >>> 0 < gb >>> 0 ? 1 : 0))),
(Ua = Ia.b = 0 | (Ua + ib)),
(Ia.a = 0 | (Ta + hb + (Ua >>> 0 < ib >>> 0 ? 1 : 0))),
(Wa = Ja.b = 0 | (Wa + kb)),
(Ja.a = 0 | (Va + jb + (Wa >>> 0 < kb >>> 0 ? 1 : 0))),
(Ya = Ka.b = 0 | (Ya + mb)),
(Ka.a = 0 | (Xa + lb + (Ya >>> 0 < mb >>> 0 ? 1 : 0))),
($a = Da.b = 0 | ($a + ob)),
(Da.a = 0 | (Za + nb + ($a >>> 0 < ob >>> 0 ? 1 : 0)));
},
G: function () {
var o = this.g,
_ = o.d,
Da = 8 * this.j,
Ea = 8 * o.c;
(_[Ea >>> 5] |= 128 << (24 - (Ea % 32))),
(_[(((Ea + 128) >>> 10) << 5) + 31] = Da),
(o.c = 4 * _.length),
this.m(),
(this.f = this.f.v());
},
n: 32,
})),
(t.k = xa.D(M)),
(t.L = xa.F(M));
export default function sha512(o) {
return t.k(o) + "";
}

View File

@ -0,0 +1,7 @@
// $primary: #4a89dc;
$primary: #1e88e5;
$error: #ff2f00;
.btn-primary {
color: white !important;
background-color: $primary !important;
}

View File

@ -0,0 +1,307 @@
<html>
<head>
<title>{{i18n "Administration"}}</title>
<meta charset="utf8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/popper.js@1.12.6/dist/umd/popper.js" type="text/javascript"></script>
<script src="https://unpkg.com/bootstrap-material-design@4.1.1/dist/js/bootstrap-material-design.js"
type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.min.js"
type="text/javascript"></script>
<script>
$(document).ready(() => $('body').bootstrapMaterialDesign())
</script>
</head>
<body>
<header class=bg-primary style="display: flex; justify-content: space-between;">
<h3 style="display: inline">{{appname}} {{i18n "Administration"}}
<span id="sitename">LOADING</span>
</h3>
<ul class="nav nav-tabs" style="display: inline-block; margin-left: auto; margin-top: -8px;">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
aria-expanded="false">Model</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="?type=user">User</a>
<a class="dropdown-item" href="?type=regcode">RegCode</a>
<a class="dropdown-item" href="?type=client">Client</a>
</div>
</li>
</ul>
</header>
<div id=content>
<div class=container>
<div id=error_cont class=row style="margin-bottom: 24px;display: none;">
<div class=col-sm>
<div class="card error_card">
<div id="error_msg" class="card-body"></div>
</div>
</div>
</div>
<div id=custom_data_cont class=row style="margin-bottom: 24px; display: none">
<div class=col-sm>
<div class=card>
<div id=custom_data class="card-body"></div>
</div>
</div>
</div>
<div class=row>
<div class=col-sm>
<div class=card>
<div class=card-body>
<div id=table-body>
<div style="width: 65px; height: 65px; margin: 0 auto;">
<svg class="spinner" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="circle" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33"
r="30"></circle>
</svg>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script id="template-spinner" type="text/x-handlebars-template">
<div style="width: 65px; height: 65px; margin: 0 auto;">
<svg class="spinner" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="circle" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
</div>
</script>
<script id="template-user-list" type="text/x-handlebars-template">
<table class="table table-bordered" style="margin-bottom: 0">
<thead>
<tr>
<th scope="col">Username</th>
<th scope="col">Name</th>
<th scope="col">Gender</th>
<th scope="col">Role</th>
<th scope="col" style="width: 2.5rem"></th>
</tr>
</thead>
<tbody>
\{{#users}}
<tr>
<td>\{{ username }}</td>
<td>\{{ name }}</td>
<!-- ToDo: Make helper to resolve number to human readaby text-->
<td>\{{humangender gender}}</td>
<td onclick="userOnChangeType('\{{_id}}')">
\{{#if admin}}
<span class="badge badge-danger">Admin</span>
\{{else}}
<span class="badge badge-success">User</span>
\{{/if}}
</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="deleteUser('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
delete
</i>
</button>
</td>
</tr>
\{{/users}}
</tbody>
</table>
</script>
<script id="template-regcode-list" type="text/x-handlebars-template">
<button class="btn btn-raised btn-primary" onclick="createRegcode()">Create</button>
<table class="table table-bordered" style="margin-bottom: 0">
<thead>
<tr>
<th scope="col">Code</th>
<th scope="col">Valid</th>
<th scope="col">Till</th>
<th scope="col" style="width: 2.5rem"></th>
</tr>
</thead>
<tbody>
\{{#regcodes}}
<tr>
<td>\{{ token }}</td>
<td>\{{ valid }}</td>
<!-- ToDo: Make helper to resolve number to human readaby text-->
<td>\{{formatDate validTill }}</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="deleteRegcode('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
delete
</i>
</button>
</td>
</tr>
\{{/regcodes}}
</tbody>
</table>
</script>
<script id="template-client-list" type="text/x-handlebars-template">
<button class="btn btn-raised btn-primary" onclick="createClient()">Create</button>
<table class="table table-bordered" style="margin-bottom: 0">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Secret</th>
<th scope="col">Maintainer</th>
<th scope="col">Name</th>
<th scope="col" style="width: 80px">Type</th>
<th scope="col">Website</th>
<th scope="col" style="width: 2.5rem">
<div></div>
</th>
<th scope="col" style="width: 2.5rem"></th>
<th scope="col" style="width: 2.5rem"></th>
</tr>
</thead>
<tbody>
\{{#clients}}
<tr>
<td>\{{ client_id }}</td>
<td>\{{ client_secret }}</td>
<td>\{{ maintainer.username }}</td>
<td>\{{ name }}</td>
<td>
\{{#if internal}}
<span class="badge badge-success">Internal</span>
\{{else}}
<span class="badge badge-danger">External</span>
\{{/if}}
</td>
<td>
<a href="\{{ website }}">\{{ website }}</a>
</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="permissionsClient('\{{_id}}')">
perm
</button>
</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="editClient('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
edit
</i>
</button>
</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="deleteClient('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
delete
</i>
</button>
</td>
</tr>
\{{/clients}}
</tbody>
</table>
</script>
<script id="template-client-form" type="text/x-handlebars-template">
<form class="form" action="JavaScript:void(null)" onsubmit="createClientSubmit(this)" style="margin-bottom: 0">
<input type=hidden value="\{{_id}}" name=id />
<div class="form-group">
<label for="name_input" class="bmd-label-floating">Name</label>
<input type="text" class="form-control" id="name_input" name=name value="\{{name}}">
</div>
<div class="form-group">
<label for="redirect_input" class="bmd-label-floating">Redirect Url</label>
<input type="text" class="form-control" id="redirect_input" name=redirect_url value="\{{redirect_url}}">
</div>
<div class="form-group">
<label for="website_input" class="bmd-label-floating">Website</label>
<input type="text" class="form-control" id="website_input" name=website value="\{{website}}">
</div>
<div class="form-group">
<label for="logo_input" class="bmd-label-floating">Logo</label>
<input type="text" class="form-control" id="logo_input" name=logo value="\{{logo}}">
</div>
<div class="form-group">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="internal_check" \{{#if internal}} checked="checked" \{{/if}} name=internal>
<label class="form-check-label" for="internal_check">Internal</label>
</div>
</div>
<span class="form-group bmd-form-group">
<!-- needed to match padding for floating labels -->
<button type="submit" class="btn btn-raised btn-primary">Save</button>
</span>
</form>
</script>
<script id="template-permission-list" type="text/x-handlebars-template">
<h2><button class="btn btn-raised btn-primary" onclick="gotoClients()">back</button> to \{{client_name}} </h2>
<button class="btn btn-raised btn-primary" onclick="createPermission('\{{ client_id }}')">Create</button>
<table class="table table-bordered" style="margin-bottom: 0">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col" style="width: 10ch">Type</th>
<th scope="col" style="width: 2.5rem"></th>
</tr>
</thead>
<tbody>
\{{#permissions}}
<tr>
<td>\{{ _id }}</td>
<td>\{{ name }}</td>
<td>\{{ description }}</td>
<td>\{{ grant_type }}</td>
<td style="padding: 0.25em">
<button style="border: 0; background-color: rgba(0, 0, 0, 0); padding: 0; text-align: center;" onclick="deletePermission('\{{_id}}')">
<i class="material-icons" style="font-size: 2rem; display: inline">
delete
</i>
</button>
</td>
</tr>
\{{/permissions}}
</tbody>
</table>
</script>
<script id="template-permission-form" type="text/x-handlebars-template">
<form class="form" action="JavaScript:void(null)" onsubmit="createPermissionSubmit(this)" style="margin-bottom: 0">
<input type=hidden value="\{{client_id}}" name=client />
<div class="form-group">
<label for="name_input" class="bmd-label-floating">Name</label>
<input type="text" class="form-control" id="name_input" name=name value="">
</div>
<div class="form-group">
<label for=description class="bmd-label-floating">Description</label>
<input type="text" class="form-control" id=description name=description value="">
</div>
<div class="form-group">
<label for=type class="bmd-label-floating">Type</label>
<select type="text" class="form-control" id=type name=type>
<option value="user">User granted</option>
<option value="client">Client granted</option>
</select>
</div>
<span class="form-group bmd-form-group">
<!-- needed to match padding for floating labels -->
<button type="submit" class="btn btn-raised btn-primary">Save</button>
</span>
</form>
</script>
</body>
</html>

View File

@ -0,0 +1,239 @@
import request from "../../shared/request";
import getFormData from "../../shared/formdata";
Handlebars.registerHelper("humangender", function (value, options) {
switch (value) {
case 1:
return "male";
case 2:
return "female";
case 3:
return "other";
default:
case 0:
return "none";
}
});
// Deprecated since version 0.8.0
Handlebars.registerHelper("formatDate", function (datetime, format) {
return new Date(datetime).toLocaleString();
});
(() => {
const tableb = document.getElementById("table-body");
function setTitle(title) {
document.getElementById("sitename").innerText = title;
}
const cc = document.getElementById("custom_data");
const ccc = document.getElementById("custom_data_cont");
function setCustomCard(content) {
if (!content) {
cc.innerHTML = "";
ccc.style.display = "none";
} else {
cc.innerHTML = content;
ccc.style.display = "";
}
}
const error_cont = document.getElementById("error_cont");
const error_msg = document.getElementById("error_msg");
function catchError(error) {
error_cont.style.display = "";
error_msg.innerText = error.message;
console.log(error);
}
async function renderUser() {
console.log("Rendering User");
setTitle("User");
const listt = Handlebars.compile(
document.getElementById("template-user-list").innerText
);
async function loadList() {
let data = await request("/api/admin/user", "GET");
tableb.innerHTML = listt({
users: data,
});
}
window.userOnChangeType = (id) => {
request("/api/admin/user?id=" + id, "PUT")
.then(() => loadList())
.catch(catchError);
};
window.deleteUser = (id) => {
request("/api/admin/user?id=" + id, "DELETE")
.then(() => loadList())
.catch(catchError);
};
await loadList();
}
async function renderPermissions(client_id, client_name) {
const listt = Handlebars.compile(
document.getElementById("template-permission-list").innerText
);
const formt = Handlebars.compile(
document.getElementById("template-permission-form").innerText
);
setCustomCard();
async function loadList() {
try {
let data = await request(
"/api/admin/permission?client=" + client_id,
"GET"
);
tableb.innerHTML = listt({
client_id: client_id,
client_name: client_name,
permissions: data,
});
} catch (err) {
catchError(err);
}
}
window.gotoClients = () => {
renderClient();
};
window.deletePermission = (id) => {
request("/api/admin/permission?id=" + id, "DELETE")
.then(() => loadList())
.catch(catchError);
};
window.createPermission = () => {
try {
setCustomCard(formt({ client_id: client_id }));
} catch (err) {
console.log("Err", err);
}
};
window.createPermissionSubmit = (elm) => {
console.log(elm);
let data = getFormData(elm);
console.log(data);
request("/api/admin/permission", "POST", data)
.then(() => setCustomCard())
.then(() => loadList())
.catch(catchError);
};
await loadList();
}
async function renderClient() {
console.log("Rendering Client");
setTitle("Client");
const listt = Handlebars.compile(
document.getElementById("template-client-list").innerText
);
const formt = Handlebars.compile(
document.getElementById("template-client-form").innerText
);
let clients = [];
async function loadList() {
let data = await request("/api/admin/client", "GET");
clients = data;
tableb.innerHTML = listt({
clients: data,
});
}
window.permissionsClient = (id) => {
renderPermissions(id, clients.find((e) => e._id === id).name);
};
window.deleteClient = (id) => {
request("/api/admin/client/id=" + id, "DELETE")
.then(() => loadList())
.catch(catchError);
};
window.createClientSubmit = (elm) => {
console.log(elm);
let data = getFormData(elm);
console.log(data);
let id = data.id;
delete data.id;
if (id && id !== "") {
request("/api/admin/client?id=" + id, "PUT", data)
.then(() => setCustomCard())
.then(() => loadList())
.catch(catchError);
} else {
request("/api/admin/client", "POST", data)
.then(() => setCustomCard())
.then(() => loadList())
.catch(catchError);
}
};
window.createClient = () => {
setCustomCard(formt());
};
window.editClient = (id) => {
let client = clients.find((e) => e._id === id);
if (!client) return catchError(new Error("Client does not exist!!"));
setCustomCard(formt(client));
};
await loadList().catch(catchError);
}
async function renderRegCode() {
console.log("Rendering RegCode");
setTitle("RegCode");
const listt = Handlebars.compile(
document.getElementById("template-regcode-list").innerText
);
async function loadList() {
let data = await request("/api/admin/regcode", "GET");
tableb.innerHTML = listt({
regcodes: data,
});
}
window.deleteRegcode = (id) => {
request("/api/admin/regcode?id=" + id, "DELETE")
.then(() => loadList())
.catch(catchError);
};
window.createRegcode = () => {
request("/api/admin/regcode", "POST")
.then(() => loadList())
.catch(catchError);
};
await loadList().catch(catchError);
}
const type = new URL(window.location.href).searchParams.get("type");
switch (type) {
case "client":
renderClient().catch(catchError);
break;
case "regcode":
renderRegCode().catch(catchError);
break;
case "user":
default:
renderUser().catch(catchError);
break;
}
})();

View File

@ -0,0 +1,103 @@
@import "mat_bs";
@import "style";
.error_card {
color: $error;
padding: 1rem;
font-size: 1rem;
}
.bg-primary {
background-color: $primary !important;
}
.spinner {
-webkit-animation: rotation 1.35s linear infinite;
animation: rotation 1.35s linear infinite;
stroke: $primary;
}
@-webkit-keyframes rotation {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
}
@keyframes rotation {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
}
.circle {
stroke-dasharray: 180;
stroke-dashoffset: 0;
-webkit-transform-origin: center;
-ms-transform-origin: center;
transform-origin: center;
-webkit-animation: turn 1.35s ease-in-out infinite;
animation: turn 1.35s ease-in-out infinite;
}
@-webkit-keyframes turn {
0% {
stroke-dashoffset: 180;
}
50% {
stroke-dashoffset: 45;
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
100% {
stroke-dashoffset: 180;
-webkit-transform: rotate(450deg);
transform: rotate(450deg);
}
}
@keyframes turn {
0% {
stroke-dashoffset: 180;
}
50% {
stroke-dashoffset: 45;
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
100% {
stroke-dashoffset: 180;
-webkit-transform: rotate(450deg);
transform: rotate(450deg);
}
}
header {
/* height: 60px; */
margin-bottom: 8px;
padding: 8px 16px;
padding-bottom: 0;
}
table {
word-wrap: break-word;
table-layout: fixed;
}
table td {
vertical-align: inherit !important;
width: auto;
}
.col.form-group {
padding-left: 0 !important;
margin-left: 5px !important;
}

View File

@ -0,0 +1,53 @@
<html>
<head>
<title>{{title}}</title>
<meta charset="utf8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
</head>
<body>
<div class="card">
<div class="title">
<h1>{{title}}</h1>
</div>
<div class="list">
<hr>
<ul>
{{#scopes}}
<li>
<div class="permission">
{{#if logo}}
{{!-- <div class="image"> --}}
<img class="image" src="{{logo}}">
{{!-- </div> --}}
{{/if}}
<div class="text">
<h3 class="scope_title">{{name}}</h3>
<p class="scope_description">{{description}}</p>
</div>
</div>
<hr>
</li>
{{/scopes}}
</ul>
</div>
<div>
{{information}}
</div>
<div>
<div style="text-align:right;">
<button class="mdc-button mdc-button--raised grey-button" id="cancel">Cancel</button>
<button class="mdc-button mdc-button--raised blue-button" id="allow">Allow</button>
</div>
</div>
</div>
<form method="post" action="/api/oauth/auth?" id="hidden_form" style="display: none;">
<input name="accept" value="true" />
</form>
</body>
</html>

View File

@ -0,0 +1,21 @@
document.getElementById("hidden_form").action += window.location.href.split(
"?"
)[1];
function submit() {
document.getElementById("hidden_form").submit();
}
document.getElementById("cancel").onclick = () => {
let u = new URL(window.location);
let uri = u.searchParams.get("redirect_uri");
if (uri === "$local") {
uri = "/code";
}
window.location.href =
uri + "?error=access_denied&state=" + u.searchParams.get("state");
};
document.getElementById("allow").onclick = () => {
submit();
};

View File

@ -0,0 +1,85 @@
@import "@material/button/mdc-button";
.blue-button {
background: #4a89dc !important;
}
.grey-button {
background: #797979 !important;
}
hr {
// display: block;
// height: 1px;
border: 0;
border-top: 1px solid #b8b8b8;
// margin: 1em 0;
// padding: 0;
}
body {
font-family: Helvetica;
background: #eee;
-webkit-font-smoothing: antialiased;
}
.title {
text-align: center;
}
h1,
h3 {
font-weight: 300;
}
h1 {
color: #636363;
}
ul {
list-style: none;
padding-left: 0;
}
.permission {
display: flex;
img {
height: 50px;
width: 50px;
}
.text {
// width: calc(100% - 60px);
padding-left: 10px;
}
}
// .image {
// height: 50px;
// width: 50px;
// }
// .text {
// // width: calc(100% - 60px);
// padding-left: 10px;
// }
.scope_title {
margin-top: 0;
margin-bottom: 0;
padding-left: 5px;
}
.scope_description {
margin-top: 0;
padding-left: 15px;
font-size: 13px;
color: #202020;
}
.card {
max-width: 480px;
margin: 4em auto;
padding: 3em 2em 2em 2em;
background: #fafafa;
border: 1px solid #ebebeb;
box-shadow: rgba(0, 0, 0, 0.14902) 0px 1px 1px 0px,
rgba(0, 0, 0, 0.09804) 0px 1px 2px 0px;
}

View File

@ -0,0 +1,7 @@
<html>
<head></head>
<body></body>
</html>

View File

@ -0,0 +1 @@
console.log("Hello World");

View File

View File

@ -0,0 +1,115 @@
<html>
<head>
<title>{{i18n "Register"}}</title>
<meta charset="utf8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
</head>
<body>
<hgroup>
<h1>{{i18n "Register"}}</h1>
</hgroup>
<form action="JavaScript:void(0)">
<div class="error invisible" id="error" style="font-size: 18px; margin-bottom: 16px"></div>
<div class="floating group">
<input type="text" id="regcode">
<span class="highlight"></span>
<span class="bar"></span>
<label>{{i18n "Registration code"}}</label>
<div class="error invisible" id="err_regcode"></div>
</div>
<div class="floating group">
<input type="text" id="username">
<span class="highlight"></span>
<span class="bar"></span>
<label>{{i18n "Username"}}</label>
<div class="error invisible" id="err_username"></div>
</div>
<div class="floating group">
<input type="text" id="name">
<span class="highlight"></span>
<span class="bar"></span>
<label>{{i18n "Name"}}</label>
<div class="error invisible" id="err_name"></div>
</div>
<div class="error invisible" id="err_gender"></div>
<div class="mdc-form-field group">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="radio-male" name="radios" checked>
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label for="radio-male" style="position: relative;">{{i18n "Male"}}</label>
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="radio-female" name="radios" checked>
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label for="radio-female" style="position: relative;">{{i18n "Female"}}</label>
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="radio-other" name="radios" checked>
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label for="radio-other" style="position: relative;">{{i18n "Other"}}</label>
</div>
<div class="floating group">
<input type="text" id="mail">
<span class="highlight"></span>
<span class="bar"></span>
<label>{{i18n "Mail"}}</label>
<div class="error invisible" id="err_mail"></div>
</div>
<div class="floating group">
<input type="password" id="password">
<span class="highlight"></span>
<span class="bar"></span>
<label>{{i18n "Password"}}</label>
<div class="error invisible" id="err_password"></div>
</div>
<div class="floating group">
<input type="password" id="passwordrep">
<span class="highlight"></span>
<span class="bar"></span>
<label>{{i18n "Repeat Password"}}</label>
<div class="error invisible" id="err_passwordrep"></div>
</div>
<button type="button" id="registerbutton" class="mdc-button mdc-button--raised">{{i18n "Register"}}
</button>
</form>
<footer>
<p>Powered by {{appname}}</p>
</footer>
<script type="json" id="error_codes">
{
"noregcode": "{{i18n "Registration code required"}}",
"nousername": "{{i18n "Username required"}}",
"noname": "{{i18n "Name required"}}",
"nomail": "{{i18n "Mail required"}}",
"nogender": "{{i18n "You need to select one of the options"}}",
"nopassword": "{{i18n "Password is required"}}",
"nomatch": "{{i18n "The passwords do not match"}}"
}
</script>
</body>
</html>

View File

@ -0,0 +1,159 @@
import "inputs";
import sha from "sha512";
import fireEvent from "event";
(() => {
const translations = JSON.parse(
document.getElementById("error_codes").innerText
);
const regcode = document.getElementById("regcode");
regcode.value = new URL(window.location.href).searchParams.get("regcode");
fireEvent(regcode, "change");
function showError(element, message) {
if (typeof element === "string")
element = document.getElementById(element);
if (!element) console.error("Element not found,", element);
element.innerText = message;
if (!message) {
if (!element.classList.contains("invisible"))
element.classList.add("invisible");
} else {
element.classList.remove("invisible");
}
}
function makeid(length) {
var text = "";
var possible =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
const username = document.getElementById("username");
const name = document.getElementById("name");
const mail = document.getElementById("mail");
const password = document.getElementById("password");
const passwordrep = document.getElementById("passwordrep");
const radio_male = document.getElementById("radio-male");
const radio_female = document.getElementById("radio-female");
const radio_other = document.getElementById("radio-other");
const registerButton = document.getElementById("registerbutton");
registerButton.onclick = () => {
console.log("Register");
showError("error");
let error = false;
if (!regcode.value) {
showError("err_regcode", translations["noregcode"]);
error = true;
} else {
showError("err_regcode");
}
if (!username.value) {
showError("err_username", translations["nousername"]);
error = true;
} else {
showError("err_username");
}
if (!name.value) {
showError("err_name", translations["noname"]);
error = true;
} else {
showError("err_name");
}
if (!mail.value) {
showError("err_mail", translations["nomail"]);
error = true;
} else {
showError("err_mail");
}
if (!password.value) {
showError("err_password", translations["nopassword"]);
error = true;
} else {
showError("err_password");
}
if (password.value !== passwordrep.value) {
showError("err_passwordrep", translations["nomatch"]);
error = true;
} else {
showError("err_passwordrep");
}
if (error) return;
let gender;
if (radio_male.checked) {
gender = "male";
} else if (radio_female.checked) {
gender = "female";
} else {
gender = "other";
}
let salt = makeid(10);
//username, password, salt, mail, gender, name, birthday, regcode
let body = {
username: username.value,
gender: gender,
mail: mail.value,
name: name.value,
regcode: regcode.value,
salt: salt,
password: sha(salt + password.value),
};
fetch("/api/user/register", {
method: "POST",
body: JSON.stringify(body),
headers: {
"content-type": "application/json",
},
})
.then(async (e) => {
if (e.status !== 200)
return Promise.reject(
new Error((await e.text()) || e.statusText)
);
return e.json();
})
.then((data) => {
if (data.error) {
if (!Array.isArray(data.error))
return Promise.reject(new Error(data.error));
let ce = [];
data.error.forEach((e) => {
let ef = document.getElementById("err_" + e.field);
if (!ef) ce.push(e);
else {
showError(ef, e.message);
}
});
if (ce.length > 0) {
showError("error", ce.join("<br>"));
}
} else {
window.location.href = "/login";
}
})
.catch((e) => {
showError("error", e.message);
});
};
})();

View File

@ -0,0 +1,96 @@
@import "@material/button/mdc-button";
@import "@material/form-field/mdc-form-field";
@import "@material/radio/mdc-radio";
@import "inputs";
* {
box-sizing: border-box;
}
body {
font-family: Helvetica;
background: #eee;
-webkit-font-smoothing: antialiased;
}
hgroup {
text-align: center;
margin-top: 1em;
}
h1,
h3 {
font-weight: 300;
}
h1 {
color: #636363;
}
h3 {
color: $primary;
}
form {
max-width: 380px;
margin: 1em auto;
padding: 3em 2em 2em 2em;
background: #fafafa;
border: 1px solid #ebebeb;
box-shadow: rgba(0, 0, 0, 0.14902) 0px 1px 1px 0px,
rgba(0, 0, 0, 0.09804) 0px 1px 2px 0px;
}
#registerbutton {
width: 100%;
background: $primary;
text-shadow: 1px 1px 0 rgba(39, 110, 204, 0.5);
}
footer {
text-align: center;
}
footer p {
color: #888;
font-size: 13px;
letter-spacing: 0.4px;
}
footer a {
color: $primary;
text-decoration: none;
transition: all 0.2s ease;
}
footer a:hover {
color: #666;
text-decoration: underline;
}
footer img {
width: 80px;
transition: all 0.2s ease;
}
footer img:hover {
opacity: 0.83;
}
footer img:focus,
footer a:focus {
outline: none;
}
.invisible {
display: none;
}
.errorColor {
background: $error !important;
}
.error {
color: $error;
margin-top: 5px;
font-size: 13px;
}

View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"lib": ["dom", "es2015", "es6", "es7", "es2018", "esnext"],
"jsxFactory": "h",
"jsx": "react",
"module": "esnext"
},
"include": ["./types.d.ts"]
}

9
FrontendLegacy/types.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
declare module "sha512" {
const val: any;
export default val;
}
declare module "cookie" {
export function getCookie(name: string): string | undefined;
export function setCookie(name: string, value: string, exp?: string): void;
}