1
0
Fork 0

Rename some pageState things.

This commit is contained in:
Kitteh 2021-05-20 14:12:12 +01:00
parent 555825787c
commit 0273793569
29 changed files with 150 additions and 152 deletions

View file

@ -5,7 +5,7 @@ export class PageState {
// NOTE: When a item in the page state isn't a string (e.g it is a array or object),
// you need to add helper methods to mutate it or else it wont save.
// example: currentSecretPath is a array so when you try to .push() to it
// example: secretPath is a array so when you try to .push() to it
// it will modify the object that was getted from this class
// then when you try to access it again, there will be a different object.
// I guess you could make another class that emulates a Array or Map
@ -42,57 +42,54 @@ export class PageState {
localStorage.setItem("language", value);
}
get currentBaseMount(): string {
return localStorage.getItem("currentBaseMount") || "";
get baseMount(): string {
return localStorage.getItem("baseMount") || "";
}
set currentBaseMount(value: string) {
localStorage.setItem("currentBaseMount", value);
set baseMount(value: string) {
localStorage.setItem("baseMount", value);
}
// Since this is a array we can't act directly on it so we need
// functions to do the same modifications.
// See the note at the start o
popCurrentSecretPath(): void {
const secPath = this.currentSecretPath;
popSecretPath(): void {
const secPath = this.secretPath;
secPath.pop();
this.currentSecretPath = secPath;
this.secretPath = secPath;
}
pushCurrentSecretPath(...args: string[]): void {
const secPath = this.currentSecretPath;
pushSecretPath(...args: string[]): void {
const secPath = this.secretPath;
secPath.push(...args);
this.currentSecretPath = secPath;
this.secretPath = secPath;
}
get currentSecretPath(): string[] {
return JSON.parse(localStorage.getItem("currentSecretPath") || "[]") as string[];
get secretPath(): string[] {
return JSON.parse(localStorage.getItem("secretPath") || "[]") as string[];
}
set currentSecretPath(value: string[]) {
localStorage.setItem("currentSecretPath", JSON.stringify(value));
set secretPath(value: string[]) {
localStorage.setItem("secretPath", JSON.stringify(value));
}
get currentSecretVersion(): string | null {
const result = localStorage.getItem("currentSecretVersion");
get secretVersion(): string | null {
const result = localStorage.getItem("secretVersion");
return result != "null" ? result || null : null;
}
set currentSecretVersion(value: string) {
localStorage.setItem("currentSecretVersion", String(value));
set secretVersion(value: string) {
localStorage.setItem("secretVersion", String(value));
}
get currentSecret(): string {
return localStorage.getItem("currentSecret") || "";
get secretItem(): string {
return localStorage.getItem("secretItem") || "";
}
set currentSecret(value: string) {
localStorage.setItem("currentSecret", value);
set secretItem(value: string) {
localStorage.setItem("secretItem", value);
}
get currentMountType(): string {
return localStorage.getItem("currentMountType") || "";
get secretMountType(): string {
return localStorage.getItem("secretMountType") || "";
}
set currentMountType(value: string) {
localStorage.setItem("currentMountType", value);
}
get currentPageString(): string {
return this.currentPage;
set secretMountType(value: string) {
localStorage.setItem("secretMountType", value);
}
get currentPage(): string {
const curPage = localStorage.getItem("currentPage") || "HOME";

View file

@ -3,7 +3,7 @@ import { removeDoubleSlash } from "../../utils";
export async function createOrUpdateSecret(
baseMount: string,
mountType: string,
secretMountType: string,
secretPath: string[],
name: string,
data: Record<string, unknown>,
@ -11,7 +11,7 @@ export async function createOrUpdateSecret(
let secretURL = "";
let APIData = {};
if (mountType == "kv-v2") {
if (secretMountType == "kv-v2") {
secretURL = `/v1/${baseMount}/data/${secretPath.join("/")}/${name}`;
APIData = { data: data };
} else {

View file

@ -3,7 +3,7 @@ import { removeDoubleSlash } from "../../utils";
export async function deleteSecret(
baseMount: string,
mountType: string,
secretMountType: string,
secretPath: string[],
name: string,
version: string | null = null,
@ -12,7 +12,7 @@ export async function deleteSecret(
let request;
if (mountType == "kv-v2" && version != null) {
if (secretMountType == "kv-v2" && version != null) {
secretURL = `/v1/${baseMount}/delete/${secretPath.join("")}/${name}`;
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
request = new Request(appendAPIURL(secretURL), {
@ -24,7 +24,7 @@ export async function deleteSecret(
body: version != null ? JSON.stringify({ versions: [version] }) : "{}",
});
} else {
if (mountType == "kv-v2") {
if (secretMountType == "kv-v2") {
secretURL = `/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`;
} else {
secretURL = `/v1/${baseMount}/${secretPath.join("")}/${name}`;

View file

@ -2,13 +2,13 @@ import { appendAPIURL, getHeaders } from "../apiUtils";
export async function getSecret(
baseMount: string,
mountType: string,
secretMountType: string,
secretPath: string[],
name: string,
version: string | null = null,
): Promise<Record<string, unknown>> {
let secretURL = "";
if (mountType == "kv-v2") {
if (secretMountType == "kv-v2") {
secretURL = `/v1/${baseMount}/data/${secretPath.join("")}/${name}`;
if (version != null) secretURL += `?version=${version}`;
} else {
@ -20,7 +20,7 @@ export async function getSecret(
const resp = await fetch(request);
const data = (await resp.json()) as unknown;
if (mountType == "kv-v2") {
if (secretMountType == "kv-v2") {
return (data as { data: { data: Record<string, unknown> } }).data.data;
} else {
return (data as { data: Record<string, unknown> }).data;

View file

@ -3,11 +3,11 @@ import { appendAPIURL, getHeaders } from "../apiUtils";
export async function getSecrets(
baseMount: string,
mountType: string,
secretMountType: string,
secretPath: string[],
): Promise<string[]> {
let secretURL = "";
if (mountType == "kv-v2") {
if (secretMountType == "kv-v2") {
secretURL = `/v1/${baseMount}/metadata/${secretPath.join("")}?list=true`;
} else {
// cubbyhole and v1 are identical

View file

@ -76,7 +76,7 @@ async function onLoad(): Promise<void> {
await playground(pageRouter);
}
await pageRouter.changePage(pageState.currentPageString);
await pageRouter.changePage(pageState.currentPage);
setInterval(async () => {
if ((await pageRouter.getCurrentPageID()) != "UNSEAL") {

View file

@ -17,7 +17,7 @@ export function AuthListElement(page: Page, path: string, method: AuthMethod): H
class: "uk-h4 uk-margin-bottom",
text: path,
onclick: async () => {
page.state.currentBaseMount = path;
page.state.baseMount = path;
if (method.type == "userpass") {
await page.router.changePage("USERPASS_USERS_LIST");
}
@ -37,7 +37,7 @@ export function AuthListElement(page: Page, path: string, method: AuthMethod): H
class: "uk-button uk-button-small uk-button-primary",
text: i18next.t("auth_home_view_config"),
onclick: async () => {
page.state.currentBaseMount = path;
page.state.baseMount = path;
await page.router.changePage("AUTH_VIEW_CONFIG");
},
}),
@ -60,7 +60,7 @@ export class AuthHomePage extends Page {
await this.router.changePage("ACCESS_HOME");
}
async render(): Promise<void> {
this.state.currentSecretPath = [];
this.state.secretPath = [];
const authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
const contentElement = makeElement({ tag: "div" });

View file

@ -45,10 +45,10 @@ export class AuthViewConfigPage extends Page {
tableElement.appendChild(contentElement);
const authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
const authMethod = authList.get(this.state.currentBaseMount);
const authMethod = authList.get(this.state.baseMount);
contentElement.appendChild(HeaderAndContent("Type", authMethod.type));
contentElement.appendChild(HeaderAndContent("Path", this.state.currentBaseMount));
contentElement.appendChild(HeaderAndContent("Path", this.state.baseMount));
contentElement.appendChild(HeaderAndContent("Description", authMethod.description));
contentElement.appendChild(HeaderAndContent("Accessor", authMethod.accessor));
contentElement.appendChild(HeaderAndContent("Local", String(authMethod.local).toString()));

View file

@ -16,7 +16,7 @@ export class UserPassUsersListPage extends Page {
const pageContent = makeElement({ tag: "div" });
await this.router.setPageContent(pageContent);
const users = await listUserPassUsers(this.state.currentBaseMount);
const users = await listUserPassUsers(this.state.baseMount);
pageContent.appendChild(
makeElement({
tag: "ul",

View file

@ -13,10 +13,10 @@ 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;
this.state.baseMount = "";
this.state.secretPath = [];
this.state.secretItem = "";
this.state.secretVersion = null;
const homePageContent = makeElement({ tag: "div" });
await this.router.setPageContent(homePageContent);

View file

@ -9,11 +9,11 @@ export class KeyValueDeletePage extends Page {
super();
}
async goBack(): Promise<void> {
if (this.state.currentSecretVersion != null) {
this.state.currentSecretVersion = null;
if (this.state.secretVersion != null) {
this.state.secretVersion = null;
await this.router.changePage("KEY_VALUE_SECRET");
} else {
this.state.currentSecret = "";
this.state.secretItem = "";
await this.router.changePage("KEY_VALUE_VIEW");
}
}
@ -32,11 +32,11 @@ export class KeyValueDeletePage extends Page {
text: i18next.t("kv_delete_btn"),
onclick: async () => {
await deleteSecret(
this.state.currentBaseMount,
this.state.currentMountType,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.currentSecretVersion,
this.state.baseMount,
this.state.secretMountType,
this.state.secretPath,
this.state.secretItem,
this.state.secretVersion,
);
await this.goBack();
},

View file

@ -63,15 +63,15 @@ export class KeyValueNewPage extends Page {
const path = formData.get("path") as string;
let keyData = {};
if (["kv-v1", "cubbyhole"].includes(this.state.currentMountType)) {
if (["kv-v1", "cubbyhole"].includes(this.state.secretMountType)) {
keyData = { key: "value" };
}
try {
await createOrUpdateSecret(
this.state.currentBaseMount,
this.state.currentMountType,
this.state.currentSecretPath,
this.state.baseMount,
this.state.secretMountType,
this.state.secretPath,
path,
keyData,
);

View file

@ -14,11 +14,11 @@ export class KeyValueSecretPage extends Page {
super();
}
async goBack(): Promise<void> {
if (this.state.currentSecretVersion != null) {
this.state.currentSecretVersion = null;
if (this.state.secretVersion != null) {
this.state.secretVersion = null;
await this.router.changePage("KEY_VALUE_VERSIONS");
} else {
this.state.currentSecret = "";
this.state.secretItem = "";
await this.router.changePage("KEY_VALUE_VIEW");
}
}
@ -48,20 +48,20 @@ export class KeyValueSecretPage extends Page {
const kvList = document.querySelector("#kvList");
let isSecretNestedJson = false;
const caps = await getCapabilities(
this.state.currentBaseMount,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.baseMount,
this.state.secretPath,
this.state.secretItem,
);
if (caps.includes("delete")) {
let deleteButtonText = i18next.t("kv_secret_delete_btn");
if (this.state.currentMountType == "kv-v2" && this.state.currentSecretVersion == null) {
if (this.state.secretMountType == "kv-v2" && this.state.secretVersion == null) {
deleteButtonText = i18next.t("kv_secret_delete_all_btn");
} else if (
this.state.currentMountType == "kv-v2" &&
this.state.currentSecretVersion != null
this.state.secretMountType == "kv-v2" &&
this.state.secretVersion != null
) {
deleteButtonText = i18next.t("kv_secret_delete_version_btn", {
version: this.state.currentSecretVersion,
version: this.state.secretVersion,
});
}
buttonsBlock.appendChild(
@ -77,7 +77,7 @@ export class KeyValueSecretPage extends Page {
);
}
if (caps.includes("update")) {
if (this.state.currentSecretVersion == null) {
if (this.state.secretVersion == null) {
buttonsBlock.appendChild(
makeElement({
tag: "button",
@ -91,7 +91,7 @@ export class KeyValueSecretPage extends Page {
);
}
}
if (this.state.currentMountType == "kv-v2") {
if (this.state.secretMountType == "kv-v2") {
buttonsBlock.appendChild(
makeElement({
tag: "button",
@ -106,13 +106,14 @@ export class KeyValueSecretPage extends Page {
}
const secretInfo = await getSecret(
this.state.currentBaseMount,
this.state.currentMountType,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.currentSecretVersion,
this.state.baseMount,
this.state.secretMountType,
this.state.secretPath,
this.state.secretItem,
this.state.secretVersion,
);
if (secretInfo == null && this.state.currentMountType == "kv-v2") {
if (secretInfo == null && this.state.secretMountType == "kv-v2") {
document.querySelector("#buttonsBlock").remove();
document.getElementById("loadingText").remove();
@ -131,12 +132,12 @@ export class KeyValueSecretPage extends Page {
class: ["uk-button", "uk-button-primary"],
onclick: async () => {
await undeleteSecret(
this.state.currentBaseMount,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.currentSecretVersion,
this.state.baseMount,
this.state.secretPath,
this.state.secretItem,
this.state.secretVersion,
);
await this.router.changePage(this.state.currentPageString);
await this.router.refresh();
},
}),
);

View file

@ -45,10 +45,10 @@ export class KeyValueSecretEditPage extends Page {
}),
);
const secretInfo = await getSecret(
this.state.currentBaseMount,
this.state.currentMountType,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.baseMount,
this.state.secretMountType,
this.state.secretPath,
this.state.secretItem,
);
loadingText.remove();
@ -65,10 +65,10 @@ export class KeyValueSecretEditPage extends Page {
try {
await createOrUpdateSecret(
this.state.currentBaseMount,
this.state.currentMountType,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.baseMount,
this.state.secretMountType,
this.state.secretPath,
this.state.secretItem,
JSON.parse(jar.toString()),
);
await this.router.changePage("KEY_VALUE_SECRET");

View file

@ -10,8 +10,8 @@ export class KeyValueVersionsPage extends Page {
super();
}
async goBack(): Promise<void> {
if (this.state.currentSecretVersion != null) {
this.state.currentSecretVersion = null;
if (this.state.secretVersion != null) {
this.state.secretVersion = null;
}
await this.router.changePage("KEY_VALUE_SECRET");
}
@ -24,9 +24,9 @@ export class KeyValueVersionsPage extends Page {
await this.router.setPageContent(versionsList);
const metadata = await getSecretMetadata(
this.state.currentBaseMount,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.baseMount,
this.state.secretPath,
this.state.secretItem,
);
objectToMap(metadata.versions).forEach((_, ver) => {
@ -37,7 +37,7 @@ export class KeyValueVersionsPage extends Page {
tag: "a",
text: `v${ver}`,
onclick: async () => {
this.state.currentSecretVersion = ver;
this.state.secretVersion = ver;
await this.router.changePage("KEY_VALUE_SECRET");
},
}),

View file

@ -11,20 +11,20 @@ export class KeyValueViewPage extends Page {
super();
}
async goBack(): Promise<void> {
if (this.state.currentSecretPath.length != 0) {
this.state.popCurrentSecretPath();
if (this.state.secretPath.length != 0) {
this.state.popSecretPath();
await this.router.changePage("KEY_VALUE_VIEW");
} else {
await this.router.changePage("SECRETS_HOME");
}
}
async render(): Promise<void> {
this.state.currentSecret = "";
this.state.secretItem = "";
const kvViewPageContent = makeElement({ tag: "div" });
await this.router.setPageContent(kvViewPageContent);
if (this.state.currentMountType == "cubbyhole") {
if (this.state.secretMountType == "cubbyhole") {
kvViewPageContent.appendChild(
makeElement({
tag: "p",
@ -45,9 +45,9 @@ export class KeyValueViewPage extends Page {
try {
const res = await getSecrets(
this.state.currentBaseMount,
this.state.currentMountType,
this.state.currentSecretPath,
this.state.baseMount,
this.state.secretMountType,
this.state.secretPath,
);
kvViewPageContent.appendChild(
@ -63,10 +63,10 @@ export class KeyValueViewPage extends Page {
text: secret,
onclick: async () => {
if (secret.endsWith("/")) {
this.state.pushCurrentSecretPath(secret);
this.state.pushSecretPath(secret);
await this.router.changePage("KEY_VALUE_VIEW");
} else {
this.state.currentSecret = secret;
this.state.secretItem = secret;
await this.router.changePage("KEY_VALUE_SECRET");
}
},
@ -80,7 +80,7 @@ export class KeyValueViewPage extends Page {
const error = e as Error;
if (error == DoesNotExistError) {
// getSecrets also 404's on no keys so dont go all the way back.
if (this.state.currentSecretPath.length != 0) {
if (this.state.secretPath.length != 0) {
return this.goBack();
} else {
kvViewPageContent.appendChild(

View file

@ -75,8 +75,8 @@ export class NewKVEnginePage extends Page {
version: version,
},
});
this.state.currentMountType = "kv-v" + version;
this.state.currentBaseMount = name + "/";
this.state.secretMountType = "kv-v" + version;
this.state.baseMount = name + "/";
await this.router.changePage("KEY_VALUE_VIEW");
} catch (e) {
const error = e as Error;

View file

@ -57,8 +57,8 @@ export class NewTOTPEnginePage extends Page {
name: name,
type: "totp",
});
this.state.currentMountType = "totp";
this.state.currentBaseMount = name + "/";
this.state.secretMountType = "totp";
this.state.baseMount = name + "/";
await this.router.changePage("TOTP");
} catch (e) {
const error = e as Error;

View file

@ -57,8 +57,8 @@ export class NewTransitEnginePage extends Page {
name: name,
type: "transit",
});
this.state.currentMountType = "transit";
this.state.currentBaseMount = name + "/";
this.state.secretMountType = "transit";
this.state.baseMount = name + "/";
await this.router.changePage("TRANSIT_VIEW");
} catch (e) {
const error = e as Error;

View file

@ -3,10 +3,10 @@ import { PageState } from "../../PageState";
import { makeElement } from "z-makeelement";
function currentTitleSecretText(state: PageState, suffix = ""): string {
let currentSecretText = state.currentSecret;
currentSecretText += suffix;
if (state.currentSecretVersion !== null) currentSecretText += ` (v${state.currentSecretVersion})`;
return currentSecretText;
let secretItemText = state.secretItem;
secretItemText += suffix;
if (state.secretVersion !== null) secretItemText += ` (v${state.secretVersion})`;
return secretItemText;
}
export async function SecretTitleElement(router: PageRouter, suffix = ""): Promise<HTMLElement> {
@ -16,29 +16,29 @@ export async function SecretTitleElement(router: PageRouter, suffix = ""): Promi
children: [
makeElement({
tag: "a",
text: state.currentBaseMount + " ",
text: state.baseMount + " ",
onclick: async () => {
state.currentSecretPath = [];
state.currentSecret = "";
state.currentSecretVersion = null;
state.secretPath = [];
state.secretItem = "";
state.secretVersion = null;
if (state.currentMountType.startsWith("kv") || state.currentMountType == "cubbyhole") {
if (state.secretMountType.startsWith("kv") || state.secretMountType == "cubbyhole") {
await router.changePage("KEY_VALUE_VIEW");
} else if (state.currentMountType == "totp") {
} else if (state.secretMountType == "totp") {
await router.changePage("TOTP");
} else if (state.currentMountType == "transit") {
} else if (state.secretMountType == "transit") {
await router.changePage("TRANSIT_VIEW");
}
},
}),
...state.currentSecretPath.map((secretPath, index, secretPaths) => {
...state.secretPath.map((secretPath, index, secretPaths) => {
return makeElement({
tag: "a",
text: secretPath + " ",
onclick: async () => {
state.currentSecretVersion = null;
if (state.currentMountType.startsWith("kv")) {
state.currentSecretPath = secretPaths.slice(0, index + 1);
state.secretVersion = null;
if (state.secretMountType.startsWith("kv")) {
state.secretPath = secretPaths.slice(0, index + 1);
await router.changePage("KEY_VALUE_VIEW");
}
},
@ -46,7 +46,7 @@ export async function SecretTitleElement(router: PageRouter, suffix = ""): Promi
}),
makeElement({
tag: "span",
condition: state.currentSecret.length != 0,
condition: state.secretItem.length != 0,
text: currentTitleSecretText(state, suffix),
}),
],

View file

@ -34,10 +34,10 @@ export class SecretsHomePage extends Page {
);
}
this.state.currentBaseMount = "";
this.state.currentSecretPath = [];
this.state.currentSecret = "";
this.state.currentSecretVersion = null;
this.state.baseMount = "";
this.state.secretPath = [];
this.state.secretItem = "";
this.state.secretVersion = null;
const navList = makeElement({
tag: "ul",
@ -55,7 +55,7 @@ export class SecretsHomePage extends Page {
if (!("type" in mount)) return;
if (!["kv", "totp", "transit", "cubbyhole"].includes(mount.type)) return;
const mountType = mount.type == "kv" ? "kv-v" + String(mount.options.version) : mount.type;
const secretMountType = mount.type == "kv" ? "kv-v" + String(mount.options.version) : mount.type;
let linkText = "";
let linkPage: string;
@ -80,8 +80,8 @@ export class SecretsHomePage extends Page {
tag: "a",
text: linkText,
onclick: async () => {
this.state.currentBaseMount = baseMount;
this.state.currentMountType = mountType;
this.state.baseMount = baseMount;
this.state.secretMountType = secretMountType;
await this.router.changePage(linkPage);
},
}),

View file

@ -97,7 +97,7 @@ export class NewTOTPPage extends Page {
};
try {
await addNewTOTP(this.state.currentBaseMount, parms);
await addNewTOTP(this.state.baseMount, parms);
await this.router.changePage("TOTP");
} catch (e: unknown) {
const error = e as Error;

View file

@ -54,7 +54,7 @@ export class TOTPViewPage extends Page {
);
try {
const res = await getTOTPKeys(this.state.currentBaseMount);
const res = await getTOTPKeys(this.state.baseMount);
for (const totpKeyName of res) {
const totpListElement = this.makeTOTPListElement(totpKeyName);
totpList.appendChild(totpListElement);
@ -91,7 +91,7 @@ export class TOTPViewPage extends Page {
}
async updateTOTPElement(totpKeyName: string, totpListElement: TOTPListElement): Promise<void> {
totpListElement.setCode(await getTOTPCode(this.state.currentBaseMount, totpKeyName));
totpListElement.setCode(await getTOTPCode(this.state.baseMount, totpKeyName));
}
makeTOTPListElement(totpKeyName: string): TOTPListElement {

View file

@ -74,11 +74,11 @@ export class NewTransitKeyPage extends Page {
const type = formData.get("type") as string;
try {
await newTransitKey(this.state.currentBaseMount, {
await newTransitKey(this.state.baseMount, {
name: name,
type: type,
});
this.state.currentSecret = name;
this.state.secretItem = name;
await this.router.changePage("TRANSIT_VIEW_SECRET");
} catch (e) {
const error = e as Error;

View file

@ -96,7 +96,7 @@ export class TransitDecryptPage extends Page {
}
try {
const res = await transitDecrypt(this.state.currentBaseMount, this.state.currentSecret, {
const res = await transitDecrypt(this.state.baseMount, this.state.secretItem, {
ciphertext: ciphertext,
});
let plaintext = res.plaintext;

View file

@ -98,7 +98,7 @@ export class TransitEncryptPage extends Page {
}
try {
const res = await transitEncrypt(this.state.currentBaseMount, this.state.currentSecret, {
const res = await transitEncrypt(this.state.baseMount, this.state.secretItem, {
plaintext: plaintext,
});
const modal = CopyableModal(

View file

@ -24,7 +24,7 @@ export class TransitRewrapPage extends Page {
transitRewrapForm: HTMLFormElement;
async render(): Promise<void> {
const transitKey = await getTransitKey(this.state.currentBaseMount, this.state.currentSecret);
const transitKey = await getTransitKey(this.state.baseMount, this.state.secretItem);
const stringVersions = Array.from(
objectToMap(transitKey.keys).keys(),
@ -92,7 +92,7 @@ export class TransitRewrapPage extends Page {
async transitRewrapFormHandler(): Promise<void> {
const formData = new FormData(this.transitRewrapForm);
try {
const res = await transitRewrap(this.state.currentBaseMount, this.state.currentSecret, {
const res = await transitRewrap(this.state.baseMount, this.state.secretItem, {
ciphertext: formData.get("ciphertext") as string,
key_version: parseInt(formData.get("version") as string, 10),
});

View file

@ -16,7 +16,7 @@ export class TransitViewPage extends Page {
}
async render(): Promise<void> {
this.state.currentSecret = "";
this.state.secretItem = "";
const transitViewContent = makeElement({ tag: "div" });
await this.router.setPageContent(transitViewContent);
@ -32,7 +32,7 @@ export class TransitViewPage extends Page {
transitViewContent.appendChild(newButton);
try {
const res = await getTransitKeys(this.state.currentBaseMount);
const res = await getTransitKeys(this.state.baseMount);
transitViewContent.appendChild(
makeElement({
@ -46,7 +46,7 @@ export class TransitViewPage extends Page {
tag: "a",
text: secret,
onclick: async () => {
this.state.currentSecret = secret;
this.state.secretItem = secret;
await this.router.changePage("TRANSIT_VIEW_SECRET");
},
}),

View file

@ -15,7 +15,7 @@ export class TransitViewSecretPage extends Page {
}
async render(): Promise<void> {
const transitKey = await getTransitKey(this.state.currentBaseMount, this.state.currentSecret);
const transitKey = await getTransitKey(this.state.baseMount, this.state.secretItem);
await this.router.setPageContent(
makeElement({