Organise API methods.
This commit is contained in:
parent
d7d86b6bc8
commit
9339490e8e
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL } from "./apiUtils";
|
||||
import { appendAPIURL } from "../apiUtils";
|
||||
|
||||
export async function usernameLogin(username: string, password: string): Promise<string> {
|
||||
const request = new Request(appendAPIURL(`/v1/auth/userpass/login/${username}`), {
|
|
@ -1,6 +1,5 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { removeDoubleSlash } from "../utils";
|
||||
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
import { removeDoubleSlash } from "../../utils";
|
||||
|
||||
export async function createOrUpdateSecret(
|
||||
baseMount: string,
|
|
@ -1,6 +1,5 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { removeDoubleSlash } from "../utils";
|
||||
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
import { removeDoubleSlash } from "../../utils";
|
||||
|
||||
export async function deleteSecret(
|
||||
baseMount: string,
|
|
@ -1,5 +1,4 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
export async function getSecret(
|
||||
baseMount: string,
|
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
type SecretMetadataType = {
|
||||
versions: Record<string, Record<any, any>>
|
|
@ -1,5 +1,5 @@
|
|||
import { DoesNotExistError } from "../types/internalErrors";
|
||||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { DoesNotExistError } from "../../types/internalErrors";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
export async function getSecrets(
|
||||
baseMount: string,
|
|
@ -1,5 +1,5 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { getObjectKeys, removeDoubleSlash } from "../utils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
import { getObjectKeys, removeDoubleSlash } from "../../utils";
|
||||
import { getSecretMetadata } from "./getSecretMetadata";
|
||||
|
||||
export async function undeleteSecret(
|
|
@ -1,5 +1,5 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { removeDoubleSlash } from "../utils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
import { removeDoubleSlash } from "../../utils";
|
||||
|
||||
|
||||
export async function getCapabilitiesPath(path: string): Promise<string[]> {
|
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
type MountsType = {
|
||||
[key: string]: {
|
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL } from "./apiUtils";
|
||||
import { appendAPIURL } from "../apiUtils";
|
||||
|
||||
export type SealStatusType = {
|
||||
progress: number;
|
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
type TokenInfo = {
|
||||
expire_time: string;
|
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
export async function renewSelf(): Promise<void> {
|
||||
const request = new Request(appendAPIURL("/v1/auth/token/renew-self"), {
|
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
|
||||
export async function sealVault(): Promise<void> {
|
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL } from "./apiUtils";
|
||||
import { appendAPIURL } from "../apiUtils";
|
||||
|
||||
export async function submitUnsealKey(key: string): Promise<void> {
|
||||
const request = new Request(appendAPIURL("/v1/sys/unseal"), {
|
|
@ -1,5 +1,5 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { removeDoubleSlash } from "../utils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
import { removeDoubleSlash } from "../../utils";
|
||||
|
||||
|
||||
export async function addNewTOTP(baseMount: string, parms: {name: string}): Promise<void> {
|
|
@ -1,4 +1,4 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
export async function getTOTPCode(baseMount: string, name: string): Promise<string> {
|
||||
const request =
|
|
@ -1,5 +1,5 @@
|
|||
import { DoesNotExistError } from "../types/internalErrors";
|
||||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { DoesNotExistError } from "../../types/internalErrors";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
|
||||
export async function getTOTPKeys(baseMount: string): Promise<string[]> {
|
|
@ -1,5 +1,5 @@
|
|||
import { DoesNotExistError } from "../types/internalErrors";
|
||||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { DoesNotExistError } from "../../types/internalErrors";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
|
||||
export async function getTransitKeys(baseMount: string): Promise<string[]> {
|
||||
const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), {
|
|
@ -1,5 +1,5 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { removeDoubleSlash } from "../utils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
import { removeDoubleSlash } from "../../utils";
|
||||
|
||||
type DecryptionResult = {
|
||||
plaintext: string;
|
|
@ -1,5 +1,5 @@
|
|||
import { appendAPIURL, getHeaders } from "./apiUtils";
|
||||
import { removeDoubleSlash } from "../utils";
|
||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||
import { removeDoubleSlash } from "../../utils";
|
||||
|
||||
type EncryptionResult = {
|
||||
ciphertext: string;
|
|
@ -17,7 +17,7 @@ import {
|
|||
changePage,
|
||||
renderPage,
|
||||
} from "./pageUtils";
|
||||
import { getSealStatus } from "./api/getSealStatus";
|
||||
import { getSealStatus } from "./api/sys/getSealStatus";
|
||||
import { makeElement } from "./htmlUtils";
|
||||
import { pageState } from "./globalPageState";
|
||||
import { playground } from "./playground";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Page } from "./types/Page";
|
||||
import { PageState } from "./PageState";
|
||||
import { getSealStatus } from "./api/getSealStatus";
|
||||
import { lookupSelf } from "./api/lookupSelf";
|
||||
import { getSealStatus } from "./api/sys/getSealStatus";
|
||||
import { lookupSelf } from "./api/sys/lookupSelf";
|
||||
import { makeElement } from "./htmlUtils";
|
||||
import { pageState } from "./globalPageState";
|
||||
import ClipboardJS from "clipboard";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Page } from "../types/Page";
|
||||
import { changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils";
|
||||
import { getMounts } from "../api/getMounts";
|
||||
import { lookupSelf } from "../api/lookupSelf";
|
||||
import { getMounts } from "../api/sys/getMounts";
|
||||
import { lookupSelf } from "../api/sys/lookupSelf";
|
||||
import { makeElement } from "../htmlUtils";
|
||||
import { pageState } from "../globalPageState";
|
||||
import { sortedObjectMap } from "../utils";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Page } from "../../types/Page";
|
||||
import { changePage, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { deleteSecret } from "../../api/deleteSecret";
|
||||
import { deleteSecret } from "../../api/kv/deleteSecret";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import i18next from 'i18next';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Page } from "../../types/Page";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { createOrUpdateSecret } from "../../api/createOrUpdateSecret";
|
||||
import { createOrUpdateSecret } from "../../api/kv/createOrUpdateSecret";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import i18next from 'i18next';
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { CopyableInputBox } from "../../elements/CopyableInputBox";
|
||||
import { Page } from "../../types/Page";
|
||||
import { changePage, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { getCapabilities } from "../../api/getCapabilities";
|
||||
import { getSecret } from "../../api/getSecret";
|
||||
import { getCapabilities } from "../../api/sys/getCapabilities";
|
||||
import { getSecret } from "../../api/kv/getSecret";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import { sortedObjectMap } from "../../utils";
|
||||
import { undeleteSecret } from "../../api/undeleteSecret";
|
||||
import { undeleteSecret } from "../../api/kv/undeleteSecret";
|
||||
import Prism from "prismjs";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { CodeJar } from "codejar";
|
||||
import { Page } from "../../types/Page";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { createOrUpdateSecret } from "../../api/createOrUpdateSecret";
|
||||
import { getSecret } from "../../api/getSecret";
|
||||
import { createOrUpdateSecret } from "../../api/kv/createOrUpdateSecret";
|
||||
import { getSecret } from "../../api/kv/getSecret";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import { sortedObjectMap, verifyJSONString } from "../../utils";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Page } from "../../types/Page";
|
||||
import { changePage, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { getSecretMetadata } from "../../api/getSecretMetadata";
|
||||
import { getSecretMetadata } from "../../api/kv/getSecretMetadata";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { objectToMap } from "../../utils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { DoesNotExistError } from "../../types/internalErrors";
|
||||
import { Page } from "../../types/Page";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { getSecrets } from "../../api/getSecrets";
|
||||
import { getSecrets } from "../../api/kv/getSecrets";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import i18next from 'i18next';
|
||||
|
|
|
@ -2,10 +2,10 @@ import { Margin } from "../elements/Margin";
|
|||
import { MarginInline } from "../elements/MarginInline";
|
||||
import { Page } from "../types/Page";
|
||||
import { changePage, setErrorText, setPageContent } from "../pageUtils";
|
||||
import { lookupSelf } from "../api/lookupSelf";
|
||||
import { lookupSelf } from "../api/sys/lookupSelf";
|
||||
import { makeElement } from "../htmlUtils";
|
||||
import { pageState } from "../globalPageState";
|
||||
import { usernameLogin } from "../api/usernameLogin";
|
||||
import { usernameLogin } from "../api/auth/usernameLogin";
|
||||
import i18next from 'i18next';
|
||||
|
||||
export class LoginPage extends Page {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { Page } from "../types/Page";
|
||||
import { addClipboardNotifications, changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils";
|
||||
import { getCapabilitiesPath } from "../api/getCapabilities";
|
||||
import { getCapabilitiesPath } from "../api/sys/getCapabilities";
|
||||
import { makeElement } from "../htmlUtils";
|
||||
import { pageState } from "../globalPageState";
|
||||
import { renewSelf } from "../api/renewSelf";
|
||||
import { sealVault } from "../api/sealVault";
|
||||
import { renewSelf } from "../api/sys/renewSelf";
|
||||
import { sealVault } from "../api/sys/sealVault";
|
||||
import ClipboardJS from "clipboard";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Margin } from "../../elements/Margin";
|
||||
import { MarginInline } from "../../elements/MarginInline";
|
||||
import { Page } from "../../types/Page";
|
||||
import { addNewTOTP } from "../../api/addNewTOTP";
|
||||
import { addNewTOTP } from "../../api/totp/addNewTOTP";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
|
|
|
@ -2,8 +2,8 @@ import { CopyableInputBox } from "../../elements/CopyableInputBox";
|
|||
import { DoesNotExistError } from "../../types/internalErrors";
|
||||
import { Page } from "../../types/Page";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { getTOTPCode } from "../../api/getTOTPCode";
|
||||
import { getTOTPKeys } from "../../api/getTOTPKeys";
|
||||
import { getTOTPCode } from "../../api/totp/getTOTPCode";
|
||||
import { getTOTPKeys } from "../../api/totp/getTOTPKeys";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { objectToMap } from "../../utils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Page } from "../../types/Page";
|
|||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { fileToBase64, makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import { transitDecrypt } from "../../api/transitDecrypt";
|
||||
import { transitDecrypt } from "../../api/transit/transitDecrypt";
|
||||
import UIkit from 'uikit/dist/js/uikit.min.js';
|
||||
import i18next from "i18next";
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Page } from "../../types/Page";
|
|||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { fileToBase64, makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import { transitEncrypt } from "../../api/transitEncrypt";
|
||||
import { transitEncrypt } from "../../api/transit/transitEncrypt";
|
||||
import UIkit from 'uikit/dist/js/uikit.min.js';
|
||||
import i18next from "i18next";
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { DoesNotExistError } from "../../types/internalErrors";
|
||||
import { Page } from "../../types/Page";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
|
||||
import { getTransitKeys } from "../../api/getTransitKeys";
|
||||
import { getTransitKeys } from "../../api/transit/getTransitKeys";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import i18next from 'i18next';
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { MarginInline } from "../elements/MarginInline";
|
||||
import { Page } from "../types/Page";
|
||||
import { QRScanner, QRScannerType } from "../elements/QRScanner";
|
||||
import { SealStatusType, getSealStatus } from "../api/getSealStatus";
|
||||
import { SealStatusType, getSealStatus } from "../api/sys/getSealStatus";
|
||||
import { changePage, setErrorText, setPageContent } from "../pageUtils";
|
||||
import { makeElement } from "../htmlUtils";
|
||||
import { submitUnsealKey } from "../api/submitUnsealKey";
|
||||
import { submitUnsealKey } from "../api/sys/submitUnsealKey";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue