1
0
Fork 0

Organise API methods.

This commit is contained in:
Kitteh 2021-05-09 11:18:18 +01:00
parent d7d86b6bc8
commit 9339490e8e
37 changed files with 57 additions and 60 deletions

View file

@ -1,4 +1,4 @@
import { appendAPIURL } from "./apiUtils"; import { appendAPIURL } from "../apiUtils";
export async function usernameLogin(username: string, password: string): Promise<string> { export async function usernameLogin(username: string, password: string): Promise<string> {
const request = new Request(appendAPIURL(`/v1/auth/userpass/login/${username}`), { const request = new Request(appendAPIURL(`/v1/auth/userpass/login/${username}`), {

View file

@ -1,6 +1,5 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
import { removeDoubleSlash } from "../utils"; import { removeDoubleSlash } from "../../utils";
export async function createOrUpdateSecret( export async function createOrUpdateSecret(
baseMount: string, baseMount: string,

View file

@ -1,6 +1,5 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
import { removeDoubleSlash } from "../utils"; import { removeDoubleSlash } from "../../utils";
export async function deleteSecret( export async function deleteSecret(
baseMount: string, baseMount: string,

View file

@ -1,5 +1,4 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
export async function getSecret( export async function getSecret(
baseMount: string, baseMount: string,

View file

@ -1,4 +1,4 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
type SecretMetadataType = { type SecretMetadataType = {
versions: Record<string, Record<any, any>> versions: Record<string, Record<any, any>>

View file

@ -1,5 +1,5 @@
import { DoesNotExistError } from "../types/internalErrors"; import { DoesNotExistError } from "../../types/internalErrors";
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
export async function getSecrets( export async function getSecrets(
baseMount: string, baseMount: string,

View file

@ -1,5 +1,5 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
import { getObjectKeys, removeDoubleSlash } from "../utils"; import { getObjectKeys, removeDoubleSlash } from "../../utils";
import { getSecretMetadata } from "./getSecretMetadata"; import { getSecretMetadata } from "./getSecretMetadata";
export async function undeleteSecret( export async function undeleteSecret(

View file

@ -1,5 +1,5 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
import { removeDoubleSlash } from "../utils"; import { removeDoubleSlash } from "../../utils";
export async function getCapabilitiesPath(path: string): Promise<string[]> { export async function getCapabilitiesPath(path: string): Promise<string[]> {

View file

@ -1,4 +1,4 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
type MountsType = { type MountsType = {
[key: string]: { [key: string]: {

View file

@ -1,4 +1,4 @@
import { appendAPIURL } from "./apiUtils"; import { appendAPIURL } from "../apiUtils";
export type SealStatusType = { export type SealStatusType = {
progress: number; progress: number;

View file

@ -1,4 +1,4 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
type TokenInfo = { type TokenInfo = {
expire_time: string; expire_time: string;

View file

@ -1,4 +1,4 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
export async function renewSelf(): Promise<void> { export async function renewSelf(): Promise<void> {
const request = new Request(appendAPIURL("/v1/auth/token/renew-self"), { const request = new Request(appendAPIURL("/v1/auth/token/renew-self"), {

View file

@ -1,4 +1,4 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
export async function sealVault(): Promise<void> { export async function sealVault(): Promise<void> {

View file

@ -1,4 +1,4 @@
import { appendAPIURL } from "./apiUtils"; import { appendAPIURL } from "../apiUtils";
export async function submitUnsealKey(key: string): Promise<void> { export async function submitUnsealKey(key: string): Promise<void> {
const request = new Request(appendAPIURL("/v1/sys/unseal"), { const request = new Request(appendAPIURL("/v1/sys/unseal"), {

View file

@ -1,5 +1,5 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
import { removeDoubleSlash } from "../utils"; import { removeDoubleSlash } from "../../utils";
export async function addNewTOTP(baseMount: string, parms: {name: string}): Promise<void> { export async function addNewTOTP(baseMount: string, parms: {name: string}): Promise<void> {

View file

@ -1,4 +1,4 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
export async function getTOTPCode(baseMount: string, name: string): Promise<string> { export async function getTOTPCode(baseMount: string, name: string): Promise<string> {
const request = const request =

View file

@ -1,5 +1,5 @@
import { DoesNotExistError } from "../types/internalErrors"; import { DoesNotExistError } from "../../types/internalErrors";
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
export async function getTOTPKeys(baseMount: string): Promise<string[]> { export async function getTOTPKeys(baseMount: string): Promise<string[]> {

View file

@ -1,5 +1,5 @@
import { DoesNotExistError } from "../types/internalErrors"; import { DoesNotExistError } from "../../types/internalErrors";
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
export async function getTransitKeys(baseMount: string): Promise<string[]> { export async function getTransitKeys(baseMount: string): Promise<string[]> {
const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), { const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), {

View file

@ -1,5 +1,5 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
import { removeDoubleSlash } from "../utils"; import { removeDoubleSlash } from "../../utils";
type DecryptionResult = { type DecryptionResult = {
plaintext: string; plaintext: string;

View file

@ -1,5 +1,5 @@
import { appendAPIURL, getHeaders } from "./apiUtils"; import { appendAPIURL, getHeaders } from "../apiUtils";
import { removeDoubleSlash } from "../utils"; import { removeDoubleSlash } from "../../utils";
type EncryptionResult = { type EncryptionResult = {
ciphertext: string; ciphertext: string;

View file

@ -17,7 +17,7 @@ import {
changePage, changePage,
renderPage, renderPage,
} from "./pageUtils"; } from "./pageUtils";
import { getSealStatus } from "./api/getSealStatus"; import { getSealStatus } from "./api/sys/getSealStatus";
import { makeElement } from "./htmlUtils"; import { makeElement } from "./htmlUtils";
import { pageState } from "./globalPageState"; import { pageState } from "./globalPageState";
import { playground } from "./playground"; import { playground } from "./playground";

View file

@ -1,7 +1,7 @@
import { Page } from "./types/Page"; import { Page } from "./types/Page";
import { PageState } from "./PageState"; import { PageState } from "./PageState";
import { getSealStatus } from "./api/getSealStatus"; import { getSealStatus } from "./api/sys/getSealStatus";
import { lookupSelf } from "./api/lookupSelf"; import { lookupSelf } from "./api/sys/lookupSelf";
import { makeElement } from "./htmlUtils"; import { makeElement } from "./htmlUtils";
import { pageState } from "./globalPageState"; import { pageState } from "./globalPageState";
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";

View file

@ -1,7 +1,7 @@
import { Page } from "../types/Page"; import { Page } from "../types/Page";
import { changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils"; import { changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils";
import { getMounts } from "../api/getMounts"; import { getMounts } from "../api/sys/getMounts";
import { lookupSelf } from "../api/lookupSelf"; import { lookupSelf } from "../api/sys/lookupSelf";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import { pageState } from "../globalPageState"; import { pageState } from "../globalPageState";
import { sortedObjectMap } from "../utils"; import { sortedObjectMap } from "../utils";

View file

@ -1,6 +1,6 @@
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setPageContent, setTitleElement } from "../../pageUtils";
import { deleteSecret } from "../../api/deleteSecret"; import { deleteSecret } from "../../api/kv/deleteSecret";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,6 +1,6 @@
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { createOrUpdateSecret } from "../../api/createOrUpdateSecret"; import { createOrUpdateSecret } from "../../api/kv/createOrUpdateSecret";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,12 +1,12 @@
import { CopyableInputBox } from "../../elements/CopyableInputBox"; import { CopyableInputBox } from "../../elements/CopyableInputBox";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setPageContent, setTitleElement } from "../../pageUtils";
import { getCapabilities } from "../../api/getCapabilities"; import { getCapabilities } from "../../api/sys/getCapabilities";
import { getSecret } from "../../api/getSecret"; import { getSecret } from "../../api/kv/getSecret";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";
import { sortedObjectMap } from "../../utils"; import { sortedObjectMap } from "../../utils";
import { undeleteSecret } from "../../api/undeleteSecret"; import { undeleteSecret } from "../../api/kv/undeleteSecret";
import Prism from "prismjs"; import Prism from "prismjs";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,8 +1,8 @@
import { CodeJar } from "codejar"; import { CodeJar } from "codejar";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { createOrUpdateSecret } from "../../api/createOrUpdateSecret"; import { createOrUpdateSecret } from "../../api/kv/createOrUpdateSecret";
import { getSecret } from "../../api/getSecret"; import { getSecret } from "../../api/kv/getSecret";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";
import { sortedObjectMap, verifyJSONString } from "../../utils"; import { sortedObjectMap, verifyJSONString } from "../../utils";

View file

@ -1,6 +1,6 @@
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setPageContent, setTitleElement } from "../../pageUtils";
import { getSecretMetadata } from "../../api/getSecretMetadata"; import { getSecretMetadata } from "../../api/kv/getSecretMetadata";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { objectToMap } from "../../utils"; import { objectToMap } from "../../utils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";

View file

@ -1,7 +1,7 @@
import { DoesNotExistError } from "../../types/internalErrors"; import { DoesNotExistError } from "../../types/internalErrors";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { getSecrets } from "../../api/getSecrets"; import { getSecrets } from "../../api/kv/getSecrets";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -2,10 +2,10 @@ import { Margin } from "../elements/Margin";
import { MarginInline } from "../elements/MarginInline"; import { MarginInline } from "../elements/MarginInline";
import { Page } from "../types/Page"; import { Page } from "../types/Page";
import { changePage, setErrorText, setPageContent } from "../pageUtils"; import { changePage, setErrorText, setPageContent } from "../pageUtils";
import { lookupSelf } from "../api/lookupSelf"; import { lookupSelf } from "../api/sys/lookupSelf";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import { pageState } from "../globalPageState"; import { pageState } from "../globalPageState";
import { usernameLogin } from "../api/usernameLogin"; import { usernameLogin } from "../api/auth/usernameLogin";
import i18next from 'i18next'; import i18next from 'i18next';
export class LoginPage extends Page { export class LoginPage extends Page {

View file

@ -1,10 +1,10 @@
import { Page } from "../types/Page"; import { Page } from "../types/Page";
import { addClipboardNotifications, changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils"; import { addClipboardNotifications, changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils";
import { getCapabilitiesPath } from "../api/getCapabilities"; import { getCapabilitiesPath } from "../api/sys/getCapabilities";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import { pageState } from "../globalPageState"; import { pageState } from "../globalPageState";
import { renewSelf } from "../api/renewSelf"; import { renewSelf } from "../api/sys/renewSelf";
import { sealVault } from "../api/sealVault"; import { sealVault } from "../api/sys/sealVault";
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,7 +1,7 @@
import { Margin } from "../../elements/Margin"; import { Margin } from "../../elements/Margin";
import { MarginInline } from "../../elements/MarginInline"; import { MarginInline } from "../../elements/MarginInline";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { addNewTOTP } from "../../api/addNewTOTP"; import { addNewTOTP } from "../../api/totp/addNewTOTP";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";

View file

@ -2,8 +2,8 @@ import { CopyableInputBox } from "../../elements/CopyableInputBox";
import { DoesNotExistError } from "../../types/internalErrors"; import { DoesNotExistError } from "../../types/internalErrors";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { getTOTPCode } from "../../api/getTOTPCode"; import { getTOTPCode } from "../../api/totp/getTOTPCode";
import { getTOTPKeys } from "../../api/getTOTPKeys"; import { getTOTPKeys } from "../../api/totp/getTOTPKeys";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { objectToMap } from "../../utils"; import { objectToMap } from "../../utils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";

View file

@ -5,7 +5,7 @@ import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { fileToBase64, makeElement } from "../../htmlUtils"; import { fileToBase64, makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; 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 UIkit from 'uikit/dist/js/uikit.min.js';
import i18next from "i18next"; import i18next from "i18next";

View file

@ -5,7 +5,7 @@ import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { fileToBase64, makeElement } from "../../htmlUtils"; import { fileToBase64, makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; 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 UIkit from 'uikit/dist/js/uikit.min.js';
import i18next from "i18next"; import i18next from "i18next";

View file

@ -1,7 +1,7 @@
import { DoesNotExistError } from "../../types/internalErrors"; import { DoesNotExistError } from "../../types/internalErrors";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { getTransitKeys } from "../../api/getTransitKeys"; import { getTransitKeys } from "../../api/transit/getTransitKeys";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState"; import { pageState } from "../../globalPageState";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,10 +1,10 @@
import { MarginInline } from "../elements/MarginInline"; import { MarginInline } from "../elements/MarginInline";
import { Page } from "../types/Page"; import { Page } from "../types/Page";
import { QRScanner, QRScannerType } from "../elements/QRScanner"; 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 { changePage, setErrorText, setPageContent } from "../pageUtils";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import { submitUnsealKey } from "../api/submitUnsealKey"; import { submitUnsealKey } from "../api/sys/submitUnsealKey";
import i18next from 'i18next'; import i18next from 'i18next';