2021-05-12 16:01:04 +01:00
|
|
|
"use strict";
|
2021-04-15 13:01:58 +01:00
|
|
|
|
2021-04-18 11:28:55 +01:00
|
|
|
// JS & CSS
|
|
|
|
|
2021-05-10 11:35:14 +01:00
|
|
|
/* eslint-disable */
|
2021-04-15 13:01:58 +01:00
|
|
|
import "./scss/main.scss";
|
2021-05-10 12:07:19 +01:00
|
|
|
import UIkit from 'uikit';
|
2021-05-12 15:25:25 +01:00
|
|
|
// Don't Sort These!
|
2021-05-10 12:07:19 +01:00
|
|
|
import Icons from 'uikit/dist/js/uikit-icons';
|
2021-05-10 11:35:14 +01:00
|
|
|
// @ts-ignore
|
2021-04-15 13:01:58 +01:00
|
|
|
UIkit.use(Icons);
|
|
|
|
|
2021-05-08 03:28:37 +01:00
|
|
|
import Prism from "prismjs";
|
2021-05-12 15:22:08 +01:00
|
|
|
// Don't Sort These!
|
2021-05-09 10:08:04 +01:00
|
|
|
import "prismjs/components/prism-json";
|
2021-05-26 12:38:40 +01:00
|
|
|
import "prismjs/components/prism-hcl";
|
2021-05-12 15:22:08 +01:00
|
|
|
|
2021-04-15 13:01:58 +01:00
|
|
|
Prism.highlightAll();
|
2021-05-03 09:30:22 +01:00
|
|
|
/* eslint-enable */
|
2021-04-15 13:01:58 +01:00
|
|
|
|
2021-05-24 09:48:13 +01:00
|
|
|
// @ts-ignore
|
|
|
|
import translations from "./translations/index.mjs";
|
2021-05-14 13:38:29 +01:00
|
|
|
|
2021-05-24 09:48:13 +01:00
|
|
|
// Actual Imports
|
2021-11-21 10:51:12 +00:00
|
|
|
import { PageRouter } from "./pagerouter/PageRouter";
|
2021-05-14 13:38:29 +01:00
|
|
|
import { formatDistance } from "./formatDistance";
|
2021-05-09 11:18:18 +01:00
|
|
|
import { getSealStatus } from "./api/sys/getSealStatus";
|
2022-01-06 18:53:38 +00:00
|
|
|
//import { pageList } from "./allPages";
|
2021-05-08 03:28:37 +01:00
|
|
|
import { pageState } from "./globalPageState";
|
|
|
|
import { playground } from "./playground";
|
2022-01-06 18:53:38 +00:00
|
|
|
import { NavBar } from "./ui/elements/NavBar";
|
|
|
|
import { render, Component } from "preact";
|
2021-05-12 16:01:04 +01:00
|
|
|
import i18next from "i18next";
|
2022-01-06 18:53:38 +00:00
|
|
|
import Router from 'preact-router';
|
|
|
|
import { Home } from "./ui/pages/Home";
|
|
|
|
import { Me } from "./ui/pages/Me";
|
|
|
|
import { Login } from "./ui/pages/Login";
|
|
|
|
import { PasswordGenerator } from "./ui/pages/PwGen";
|
|
|
|
import { SetVaultURL } from "./ui/pages/SetVaultURL";
|
|
|
|
import { Unseal } from "./ui/pages/Unseal";
|
|
|
|
import { SetLanguage } from "./ui/pages/SetLanguage";
|
|
|
|
import { Secrets } from "./ui/pages/Secrets/SecretsHome";
|
|
|
|
import { TOTPView } from "./ui/pages/Secrets/TOTP/TOTPView";
|
|
|
|
import { TOTPNew } from "./ui/pages/Secrets/TOTP/TOTPNew";
|
|
|
|
import { TOTPDelete } from "./ui/pages/Secrets/TOTP/TOTPDelete";
|
|
|
|
import { NewSecretsEngine } from "./ui/pages/Secrets/NewSecretsEngine";
|
|
|
|
import { NewKVEngine } from "./ui/pages/Secrets/NewEngines/NewKVEngine";
|
|
|
|
import { NewTOTPEngine } from "./ui/pages/Secrets/NewEngines/NewTOTPEngine";
|
|
|
|
import { NewTransitEngine } from "./ui/pages/Secrets/NewEngines/NewTransitEngine";
|
|
|
|
import { DeleteSecretsEngine } from "./ui/pages/Secrets/DeleteSecretsEngine";
|
|
|
|
import { KeyValueView } from "./ui/pages/Secrets/KeyValue/KeyValueView";
|
|
|
|
import { KeyValueSecret } from "./ui/pages/Secrets/KeyValue/KeyValueSecret";
|
|
|
|
import { KeyValueSecretEdit } from "./ui/pages/Secrets/KeyValue/KeyValueSecretsEdit";
|
|
|
|
import { KeyValueDelete } from "./ui/pages/Secrets/KeyValue/KeyValueDelete";
|
2022-01-06 22:57:12 +00:00
|
|
|
import { TransitView } from "./ui/pages/Secrets/Transit/TransitView";
|
|
|
|
import { TransitViewSecret } from "./ui/pages/Secrets/Transit/TransitViewSecret";
|
|
|
|
import { NewTransitKey } from "./ui/pages/Secrets/Transit/NewTransitKey";
|
2021-05-12 15:25:25 +01:00
|
|
|
|
2021-05-12 17:37:09 +01:00
|
|
|
async function onLoad(): Promise<void> {
|
2022-01-06 18:53:38 +00:00
|
|
|
const Main = () => (
|
|
|
|
<Router>
|
|
|
|
<Home path="/" state={pageState} />
|
|
|
|
<Me path="/me" state={pageState} />
|
|
|
|
<Login path="/login" state={pageState} />
|
|
|
|
<PasswordGenerator path="/pw_gen" />
|
|
|
|
<SetVaultURL path="/set_vault_url" state={pageState} />
|
|
|
|
<Unseal path="/unseal" state={pageState} />
|
|
|
|
<SetLanguage path="/set_language" state={pageState} />
|
|
|
|
|
|
|
|
<Secrets path="/secrets" state={pageState} />
|
|
|
|
<DeleteSecretsEngine path="/secrets/delete_engine/:mount" state={pageState} />
|
|
|
|
|
|
|
|
<NewSecretsEngine path="/secrets/new_secrets_engine" />
|
|
|
|
<NewKVEngine path="/secrets/new_secrets_engine/kv" />
|
|
|
|
<NewTOTPEngine path="/secrets/new_secrets_engine/totp" />
|
|
|
|
<NewTransitEngine path="/secrets/new_secrets_engine/trasit" />
|
|
|
|
|
2022-01-06 22:57:12 +00:00
|
|
|
<KeyValueView path="/secrets/kv/list/:baseMount/:secretPath*?" state={pageState} />
|
|
|
|
<KeyValueSecret path="/secrets/kv/view/:item/:baseMount/:secretPath+" state={pageState} />
|
|
|
|
<KeyValueSecretEdit path="/secrets/kv/edit/:item/:baseMount/:secretPath+" state={pageState} />
|
|
|
|
<KeyValueDelete path="/secrets/kv/delete/:item/:baseMount/:secretPath+" state={pageState} />
|
|
|
|
|
|
|
|
<TOTPView path="/secrets/totp/list/:baseMount" state={pageState} />
|
|
|
|
<TOTPNew path="/secrets/totp/new/:baseMount" state={pageState} />
|
|
|
|
<TOTPDelete path="/secrets/totp/delete/:baseMount/:item" state={pageState} />
|
|
|
|
|
|
|
|
<TransitView path="/secrets/transit/list/:baseMount" state={pageState} />
|
|
|
|
<TransitViewSecret path="/secrets/transit/view/:baseMount/:secretItem" state={pageState} />
|
|
|
|
<NewTransitKey path="/secrets/transit/new/:baseMount" state={pageState} />
|
2022-01-06 18:53:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
<div default><p>PAGE NOT YET IMPLEMENTED</p></div>
|
|
|
|
|
|
|
|
</Router>
|
|
|
|
);
|
2022-01-06 22:57:12 +00:00
|
|
|
|
2021-05-24 09:48:13 +01:00
|
|
|
render(
|
|
|
|
<>
|
2022-01-06 18:53:38 +00:00
|
|
|
<NavBar />
|
2021-05-24 09:48:13 +01:00
|
|
|
<div class="uk-container uk-container-medium uk-align-center">
|
|
|
|
<div class="uk-card uk-card-body">
|
2022-01-06 18:53:38 +00:00
|
|
|
<Main />
|
2021-05-24 09:48:13 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>,
|
|
|
|
document.body,
|
2021-05-12 16:01:04 +01:00
|
|
|
);
|
2021-04-17 10:56:44 +01:00
|
|
|
|
2022-01-06 18:53:38 +00:00
|
|
|
//const pageRouter = new PageRouter({
|
|
|
|
// pageList: pageList,
|
|
|
|
// state: pageState,
|
|
|
|
// pageTitleElement: document.querySelector("#pageTitle"),
|
|
|
|
// pageContentElement: document.querySelector("#pageContent"),
|
|
|
|
// resetElementContent: !true,
|
|
|
|
// onPageChange: async function () {
|
|
|
|
// pageState.currentPage = await pageRouter.getCurrentPageID();
|
|
|
|
// document.documentElement.dir = pageState.pageDirection;
|
|
|
|
// },
|
|
|
|
//});
|
|
|
|
//
|
|
|
|
//reloadNavBar(pageRouter);
|
2021-05-14 13:38:29 +01:00
|
|
|
|
2021-05-07 20:41:40 +01:00
|
|
|
if (process.env.NODE_ENV == "development") {
|
2022-01-06 18:53:38 +00:00
|
|
|
// await playground(pageRouter);
|
2021-05-07 20:41:40 +01:00
|
|
|
}
|
|
|
|
|
2022-01-06 18:53:38 +00:00
|
|
|
//await pageRouter.changePage(pageState.currentPage);
|
|
|
|
|
|
|
|
//setInterval(async () => {
|
|
|
|
// if ((await pageRouter.getCurrentPageID()) != "UNSEAL") {
|
|
|
|
// if (pageState.apiURL.length != 0) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// const sealStatus = await getSealStatus();
|
|
|
|
// if (sealStatus.sealed) {
|
|
|
|
// await pageRouter.changePage("UNSEAL");
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}, 5000);
|
2021-04-24 16:26:31 +01:00
|
|
|
}
|
2021-04-18 11:28:55 +01:00
|
|
|
|
2021-05-12 16:01:04 +01:00
|
|
|
document.addEventListener(
|
|
|
|
"DOMContentLoaded",
|
2021-05-16 12:37:23 +01:00
|
|
|
async () => {
|
2021-05-12 16:01:04 +01:00
|
|
|
console.log("Loading...");
|
|
|
|
// @ts-expect-error
|
|
|
|
console.log("Build Data:", BUILD_STRING);
|
2021-05-16 12:37:23 +01:00
|
|
|
await i18next.init({
|
|
|
|
lng: pageState.language,
|
|
|
|
fallbackLng: "en",
|
|
|
|
debug: true,
|
|
|
|
// @ts-ignore
|
|
|
|
resources: Object.fromEntries(
|
|
|
|
Object.entries(translations).map(([k, v]) => [k, { translation: v }]),
|
|
|
|
),
|
|
|
|
interpolation: {
|
2021-05-22 09:50:55 +01:00
|
|
|
escape: (str) => {
|
|
|
|
return str;
|
|
|
|
},
|
2021-05-16 12:37:23 +01:00
|
|
|
format: function (value: unknown, format, _): string {
|
|
|
|
if (format === "until_date" && value instanceof Date)
|
|
|
|
return formatDistance(new Date(), new Date(value), pageState.language);
|
|
|
|
return value as string;
|
2021-05-12 16:01:04 +01:00
|
|
|
},
|
2021-05-16 12:37:23 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
await onLoad();
|
2021-05-12 16:01:04 +01:00
|
|
|
},
|
|
|
|
false,
|
|
|
|
);
|