diff --git a/src/allPages.ts b/src/allPages.ts index 969a6ff..712aaea 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -32,6 +32,7 @@ import { AccessHomePage } from "./pages/Access/AccessHome"; /* eslint-disable */ import { PageType } from "z-pagerouter"; import { AuthHomePage } from "./pages/Access/Auth/AuthHome"; +import { AuthViewConfigPage } from "./pages/Access/Auth/AuthViewConfig"; /* eslint-enable */ type pagesList = { @@ -43,6 +44,7 @@ export const allPages: pagesList = { SECRETS_HOME: new SecretsHomePage(), ACCESS_HOME: new AccessHomePage(), AUTH_HOME: new AuthHomePage(), + AUTH_VIEW_CONFIG: new AuthViewConfigPage(), ME: new MePage(), TOTP: new TOTPViewPage(), NEW_TOTP: new NewTOTPPage(), diff --git a/src/pages/Access/AccessHome.ts b/src/pages/Access/AccessHome.ts index a63bc24..99138f8 100644 --- a/src/pages/Access/AccessHome.ts +++ b/src/pages/Access/AccessHome.ts @@ -1,9 +1,6 @@ -import { MountType, getMounts } from "../../api/sys/getMounts"; import { Page } from "../../types/Page"; -import { getCapabilitiesPath } from "../../api/sys/getCapabilities"; import { makeElement } from "z-makeelement"; import { prePageChecks, setErrorText } from "../../pageUtils"; -import { sortedObjectMap } from "../../utils"; import i18next from "i18next"; import { Tile } from "../../elements/Tile"; diff --git a/src/pages/Access/Auth/AuthHome.ts b/src/pages/Access/Auth/AuthHome.ts index d92598a..eaf778f 100644 --- a/src/pages/Access/Auth/AuthHome.ts +++ b/src/pages/Access/Auth/AuthHome.ts @@ -1,13 +1,11 @@ import { Page } from "../../../types/Page"; import i18next from "i18next"; -import { setErrorText } from "../../../pageUtils"; import { listAuth } from "../../../api/auth/listAuth"; import { objectToMap } from "../../../utils"; import { AuthMethod } from "../../../api/types/auth"; import { makeElement } from "z-makeelement"; - -export function AuthListElement(path: string, method: AuthMethod): HTMLElement { +export function AuthListElement(page: Page, path: string, method: AuthMethod): HTMLElement { const isClickable = method.type != "token"; return makeElement({ @@ -31,16 +29,19 @@ export function AuthListElement(path: string, method: AuthMethod): HTMLElement { makeElement({ tag: "button", class: "uk-button uk-button-small uk-button-primary", - text: "View Config", + text: i18next.t("auth_home_view_config"), + onclick: async () => { + page.state.currentBaseMount = path; + await page.router.changePage("AUTH_VIEW_CONFIG"); + }, }), makeElement({ tag: "button", class: "uk-button uk-button-small uk-button-primary", - text: "Edit Config", + text: i18next.t("auth_home_edit_config"), }), ] }), - ], }); } @@ -53,11 +54,13 @@ export class AuthHomePage extends Page { await this.router.changePage("ACCESS_HOME"); } async render(): Promise { + this.state.currentSecretPath = []; + let authList = objectToMap(await listAuth()) as Map; const contentElement = makeElement({ tag: "div" }); this.router.setPageContent(contentElement); for (const [path, details] of authList) { - contentElement.appendChild(AuthListElement(path, details)) + contentElement.appendChild(AuthListElement(this, path, details)) } } get name(): string { diff --git a/src/pages/Access/Auth/AuthViewConfig.ts b/src/pages/Access/Auth/AuthViewConfig.ts new file mode 100644 index 0000000..d5ce77e --- /dev/null +++ b/src/pages/Access/Auth/AuthViewConfig.ts @@ -0,0 +1,86 @@ +import { Page } from "../../../types/Page"; +import i18next from "i18next"; +import { listAuth } from "../../../api/auth/listAuth"; +import { objectToMap } from "../../../utils"; +import { AuthMethod } from "../../../api/types/auth"; +import { makeElement } from "z-makeelement"; + +export function HeaderAndContent(title: string, content: string): HTMLElement { + return makeElement({ + tag: "tr", + children: [ + makeElement({ + tag: "td", + children: makeElement({ + tag: "h5", + text: title, + }) + }), + makeElement({ + tag: "td", + children: makeElement({ + tag: "p", + text: content, + }), + }), + ] + }) +} + + +export class AuthViewConfigPage extends Page { + constructor() { + super(); + } + async goBack(): Promise { + await this.router.changePage("AUTH_HOME"); + } + + async render(): Promise { + const tableElement = makeElement({ + tag: "table", + class: "uk-table", + }); + this.router.setPageContent(tableElement); + const contentElement = makeElement({ tag: "tbody" }); + tableElement.appendChild(contentElement); + + let authList = objectToMap(await listAuth()) as Map; + let authMethod = authList.get(this.state.currentBaseMount); + + contentElement.appendChild( + HeaderAndContent("Type", authMethod.type) + ); + contentElement.appendChild( + HeaderAndContent("Path", this.state.currentBaseMount) + ); + contentElement.appendChild( + HeaderAndContent("Description", authMethod.description) + ); + contentElement.appendChild( + HeaderAndContent("Accessor", authMethod.accessor) + ); + contentElement.appendChild( + HeaderAndContent("Local", String(authMethod.local).toString()) + ); + contentElement.appendChild( + HeaderAndContent("Seal Wrap", String(authMethod.seal_wrap).toString()) + ); + contentElement.appendChild( + HeaderAndContent("List when unauthenticated?", String(authMethod.config.listing_visibility).toString()) + ); + contentElement.appendChild( + HeaderAndContent("Default Lease TTL", String(authMethod.config.default_lease_ttl).toString()) + ); + contentElement.appendChild( + HeaderAndContent("Max Lease TTL", String(authMethod.config.max_lease_ttl).toString()) + ); + contentElement.appendChild( + HeaderAndContent("Token Type", authMethod.config.token_type as string) + ); + } + + get name(): string { + return i18next.t("auth_view_config_title"); + } +} diff --git a/src/pages/Home.ts b/src/pages/Home.ts index b6cb06d..707c764 100644 --- a/src/pages/Home.ts +++ b/src/pages/Home.ts @@ -13,6 +13,11 @@ export class HomePage extends Page { await this.router.setPageContent(""); if (!(await prePageChecks(this.router))) return; + this.state.currentBaseMount = ""; + this.state.currentSecretPath = []; + this.state.currentSecret = ""; + this.state.currentSecretVersion = null; + const homePageContent = makeElement({ tag: "div" }); await this.router.setPageContent(homePageContent); const textList = makeElement({ diff --git a/src/pages/Secrets/KeyValue/KeyValueDelete.ts b/src/pages/Secrets/KeyValue/KeyValueDelete.ts index 7a91edc..f74e662 100644 --- a/src/pages/Secrets/KeyValue/KeyValueDelete.ts +++ b/src/pages/Secrets/KeyValue/KeyValueDelete.ts @@ -1,5 +1,5 @@ import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { deleteSecret } from "../../../api/kv/deleteSecret"; import { makeElement } from "z-makeelement"; import i18next from "i18next"; diff --git a/src/pages/Secrets/KeyValue/KeyValueNew.ts b/src/pages/Secrets/KeyValue/KeyValueNew.ts index 54dd3ba..e0c1b9e 100644 --- a/src/pages/Secrets/KeyValue/KeyValueNew.ts +++ b/src/pages/Secrets/KeyValue/KeyValueNew.ts @@ -1,5 +1,5 @@ import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { createOrUpdateSecret } from "../../../api/kv/createOrUpdateSecret"; import { makeElement } from "z-makeelement"; import { setErrorText } from "../../../pageUtils"; diff --git a/src/pages/Secrets/KeyValue/KeyValueSecret.ts b/src/pages/Secrets/KeyValue/KeyValueSecret.ts index c9126dd..6abaf1e 100644 --- a/src/pages/Secrets/KeyValue/KeyValueSecret.ts +++ b/src/pages/Secrets/KeyValue/KeyValueSecret.ts @@ -1,6 +1,6 @@ import { CopyableInputBox } from "../../../elements/CopyableInputBox"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { getCapabilities } from "../../../api/sys/getCapabilities"; import { getSecret } from "../../../api/kv/getSecret"; import { makeElement } from "z-makeelement"; diff --git a/src/pages/Secrets/KeyValue/KeyValueSecretsEdit.ts b/src/pages/Secrets/KeyValue/KeyValueSecretsEdit.ts index bb71c5d..61215a4 100644 --- a/src/pages/Secrets/KeyValue/KeyValueSecretsEdit.ts +++ b/src/pages/Secrets/KeyValue/KeyValueSecretsEdit.ts @@ -1,6 +1,6 @@ import { CodeJar } from "codejar"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { createOrUpdateSecret } from "../../../api/kv/createOrUpdateSecret"; import { getSecret } from "../../../api/kv/getSecret"; import { makeElement } from "z-makeelement"; diff --git a/src/pages/Secrets/KeyValue/KeyValueVersions.ts b/src/pages/Secrets/KeyValue/KeyValueVersions.ts index e630390..d971f00 100644 --- a/src/pages/Secrets/KeyValue/KeyValueVersions.ts +++ b/src/pages/Secrets/KeyValue/KeyValueVersions.ts @@ -1,5 +1,5 @@ import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { getSecretMetadata } from "../../../api/kv/getSecretMetadata"; import { makeElement } from "z-makeelement"; import { objectToMap } from "../../../utils"; diff --git a/src/pages/Secrets/KeyValue/KeyValueView.ts b/src/pages/Secrets/KeyValue/KeyValueView.ts index 1e482ac..9651bcc 100644 --- a/src/pages/Secrets/KeyValue/KeyValueView.ts +++ b/src/pages/Secrets/KeyValue/KeyValueView.ts @@ -1,6 +1,6 @@ import { DoesNotExistError } from "../../../types/internalErrors"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { getSecrets } from "../../../api/kv/getSecrets"; import { makeElement } from "z-makeelement"; import { setErrorText } from "../../../pageUtils"; diff --git a/src/elements/SecretTitleElement.ts b/src/pages/Secrets/SecretTitleElement.ts similarity index 97% rename from src/elements/SecretTitleElement.ts rename to src/pages/Secrets/SecretTitleElement.ts index ba510c0..a11e7b0 100644 --- a/src/elements/SecretTitleElement.ts +++ b/src/pages/Secrets/SecretTitleElement.ts @@ -1,5 +1,5 @@ import { PageRouter } from "z-pagerouter"; -import { PageState } from "../PageState"; +import { PageState } from "../../PageState"; import { makeElement } from "z-makeelement"; function currentTitleSecretText(state: PageState, suffix = ""): string { diff --git a/src/pages/Secrets/TOTP/NewTOTP.ts b/src/pages/Secrets/TOTP/NewTOTP.ts index 2fb2fba..6e4970d 100644 --- a/src/pages/Secrets/TOTP/NewTOTP.ts +++ b/src/pages/Secrets/TOTP/NewTOTP.ts @@ -1,7 +1,7 @@ import { Margin } from "../../../elements/Margin"; import { MarginInline } from "../../../elements/MarginInline"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { addNewTOTP } from "../../../api/totp/addNewTOTP"; import { makeElement } from "z-makeelement"; import { setErrorText } from "../../../pageUtils"; diff --git a/src/pages/Secrets/TOTP/TOTPView.ts b/src/pages/Secrets/TOTP/TOTPView.ts index 46807d2..c6de492 100644 --- a/src/pages/Secrets/TOTP/TOTPView.ts +++ b/src/pages/Secrets/TOTP/TOTPView.ts @@ -1,7 +1,7 @@ import { CopyableInputBox } from "../../../elements/CopyableInputBox"; import { DoesNotExistError } from "../../../types/internalErrors"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { getTOTPCode } from "../../../api/totp/getTOTPCode"; import { getTOTPKeys } from "../../../api/totp/getTOTPKeys"; import { makeElement } from "z-makeelement"; diff --git a/src/pages/Secrets/Transit/NewTransitKey.ts b/src/pages/Secrets/Transit/NewTransitKey.ts index 00db21a..8b34b09 100644 --- a/src/pages/Secrets/Transit/NewTransitKey.ts +++ b/src/pages/Secrets/Transit/NewTransitKey.ts @@ -1,7 +1,7 @@ import { Margin } from "../../../elements/Margin"; import { Option } from "../../../elements/Option"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { makeElement } from "z-makeelement"; import { newTransitKey } from "../../../api/transit/newTransitKey"; import { setErrorText } from "../../../pageUtils"; diff --git a/src/pages/Secrets/Transit/TransitDecrypt.ts b/src/pages/Secrets/Transit/TransitDecrypt.ts index 8b5d6b2..e281cd0 100644 --- a/src/pages/Secrets/Transit/TransitDecrypt.ts +++ b/src/pages/Secrets/Transit/TransitDecrypt.ts @@ -2,7 +2,7 @@ import { CopyableModal } from "../../../elements/CopyableModal"; import { FileUploadInput } from "../../../elements/FileUploadInput"; import { Margin } from "../../../elements/Margin"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { fileToBase64 } from "../../../htmlUtils"; import { makeElement } from "z-makeelement"; import { setErrorText } from "../../../pageUtils"; diff --git a/src/pages/Secrets/Transit/TransitEncrypt.ts b/src/pages/Secrets/Transit/TransitEncrypt.ts index 1ffaf9f..3d6879a 100644 --- a/src/pages/Secrets/Transit/TransitEncrypt.ts +++ b/src/pages/Secrets/Transit/TransitEncrypt.ts @@ -2,7 +2,7 @@ import { CopyableModal } from "../../../elements/CopyableModal"; import { FileUploadInput } from "../../../elements/FileUploadInput"; import { Margin } from "../../../elements/Margin"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { fileToBase64 } from "../../../htmlUtils"; import { makeElement } from "z-makeelement"; import { setErrorText } from "../../../pageUtils"; diff --git a/src/pages/Secrets/Transit/TransitRewrap.ts b/src/pages/Secrets/Transit/TransitRewrap.ts index 558a229..0f74315 100644 --- a/src/pages/Secrets/Transit/TransitRewrap.ts +++ b/src/pages/Secrets/Transit/TransitRewrap.ts @@ -2,7 +2,7 @@ import { CopyableModal } from "../../../elements/CopyableModal"; import { Margin } from "../../../elements/Margin"; import { Option } from "../../../elements/Option"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { getTransitKey } from "../../../api/transit/getTransitKey"; import { makeElement } from "z-makeelement"; import { objectToMap } from "../../../utils"; diff --git a/src/pages/Secrets/Transit/TransitView.ts b/src/pages/Secrets/Transit/TransitView.ts index 938e71c..8a96dd3 100644 --- a/src/pages/Secrets/Transit/TransitView.ts +++ b/src/pages/Secrets/Transit/TransitView.ts @@ -1,6 +1,6 @@ import { DoesNotExistError } from "../../../types/internalErrors"; import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { getTransitKeys } from "../../../api/transit/getTransitKeys"; import { makeElement } from "z-makeelement"; import { setErrorText } from "../../../pageUtils"; diff --git a/src/pages/Secrets/Transit/TransitViewSecret.ts b/src/pages/Secrets/Transit/TransitViewSecret.ts index 3b96d90..3d8fc14 100644 --- a/src/pages/Secrets/Transit/TransitViewSecret.ts +++ b/src/pages/Secrets/Transit/TransitViewSecret.ts @@ -1,5 +1,5 @@ import { Page } from "../../../types/Page"; -import { SecretTitleElement } from "../../../elements/SecretTitleElement"; +import { SecretTitleElement } from "../SecretTitleElement"; import { Tile } from "../../../elements/Tile"; import { getTransitKey } from "../../../api/transit/getTransitKey"; import { makeElement } from "z-makeelement"; diff --git a/src/translations/en.js b/src/translations/en.js index 2dce818..b317ac8 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -222,4 +222,8 @@ module.exports = { auth_home_title: "Auth", auth_home_view_config: "View Config", auth_home_edit_config: "Edit Config", + + // Auth View Conig Page + auth_view_config_title: "Auth View Config", + auth_view_config_suffix: " (view config)", };