From 1b1a7a1d2dd7eb7cbcbe46c7635ee2b79002969c Mon Sep 17 00:00:00 2001 From: Kitteh Date: Sat, 8 May 2021 00:21:58 +0100 Subject: [PATCH] Add typing to API/*.ts. --- src/api/{addNewTOTP.js => addNewTOTP.ts} | 8 +++---- src/api/apiUtils.js | 9 -------- src/api/apiUtils.ts | 9 ++++++++ ...pdateSecret.js => createOrUpdateSecret.ts} | 14 +++++++++---- src/api/{deleteSecret.js => deleteSecret.ts} | 16 +++++++++----- ...{getCapabilities.js => getCapabilities.ts} | 10 ++++++--- src/api/getMounts.js | 13 ------------ src/api/getMounts.ts | 21 +++++++++++++++++++ .../{getSealStatus.js => getSealStatus.ts} | 9 ++++++-- src/api/{getSecret.js => getSecret.ts} | 12 ++++++++--- src/api/getSecretMetadata.js | 14 ------------- src/api/getSecretMetadata.ts | 21 +++++++++++++++++++ src/api/{getSecrets.js => getSecrets.ts} | 11 ++++++---- src/api/getTOTPCode.js | 13 ------------ src/api/getTOTPCode.ts | 13 ++++++++++++ src/api/{getTOTPKeys.js => getTOTPKeys.ts} | 4 ++-- .../{getTransitKeys.js => getTransitKeys.ts} | 5 ++--- src/api/{lookupSelf.js => lookupSelf.ts} | 7 +++++-- src/api/{renewSelf.js => renewSelf.ts} | 5 ++--- src/api/{sealVault.js => sealVault.ts} | 4 ++-- ...{submitUnsealKey.js => submitUnsealKey.ts} | 9 ++++---- .../{transitDecrypt.js => transitDecrypt.ts} | 17 ++++++++++----- .../{transitEncrypt.js => transitEncrypt.ts} | 17 ++++++++++----- .../{undeleteSecret.js => undeleteSecret.ts} | 20 +++++++++++------- .../{usernameLogin.js => usernameLogin.ts} | 5 ++--- src/pages/KeyValue/KeyValueSecretsEdit.js | 4 ++-- src/pages/KeyValue/KeyValueVersions.js | 2 +- src/pages/Me.js | 6 +++--- src/pages/Unseal.js | 4 ++-- 29 files changed, 182 insertions(+), 120 deletions(-) rename src/api/{addNewTOTP.js => addNewTOTP.ts} (61%) delete mode 100644 src/api/apiUtils.js create mode 100644 src/api/apiUtils.ts rename src/api/{createOrUpdateSecret.js => createOrUpdateSecret.ts} (68%) rename src/api/{deleteSecret.js => deleteSecret.ts} (73%) rename src/api/{getCapabilities.js => getCapabilities.ts} (68%) delete mode 100644 src/api/getMounts.js create mode 100644 src/api/getMounts.ts rename src/api/{getSealStatus.js => getSealStatus.ts} (50%) rename src/api/{getSecret.js => getSecret.ts} (65%) delete mode 100644 src/api/getSecretMetadata.js create mode 100644 src/api/getSecretMetadata.ts rename src/api/{getSecrets.js => getSecrets.ts} (72%) delete mode 100644 src/api/getTOTPCode.js create mode 100644 src/api/getTOTPCode.ts rename src/api/{getTOTPKeys.js => getTOTPKeys.ts} (74%) rename src/api/{getTransitKeys.js => getTransitKeys.ts} (73%) rename src/api/{lookupSelf.js => lookupSelf.ts} (68%) rename src/api/{renewSelf.js => renewSelf.ts} (78%) rename src/api/{sealVault.js => sealVault.ts} (73%) rename src/api/{submitUnsealKey.js => submitUnsealKey.ts} (58%) rename src/api/{transitDecrypt.js => transitDecrypt.ts} (54%) rename src/api/{transitEncrypt.js => transitEncrypt.ts} (53%) rename src/api/{undeleteSecret.js => undeleteSecret.ts} (59%) rename src/api/{usernameLogin.js => usernameLogin.ts} (78%) diff --git a/src/api/addNewTOTP.js b/src/api/addNewTOTP.ts similarity index 61% rename from src/api/addNewTOTP.js rename to src/api/addNewTOTP.ts index 74788ca..4d05421 100644 --- a/src/api/addNewTOTP.js +++ b/src/api/addNewTOTP.ts @@ -1,8 +1,8 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; import { removeDoubleSlash } from "../utils"; -export async function addNewTOTP(baseMount, parms) { +export async function addNewTOTP(baseMount: string, parms: {name: string}): Promise { const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/keys/${parms.name}`)), { method: 'POST', headers: { @@ -11,9 +11,9 @@ export async function addNewTOTP(baseMount, parms) { }, body: JSON.stringify(parms) }); - let response = await fetch(request); + const response = await fetch(request); if (!response.ok) { - let json = await response.json(); + const json = await response.json(); throw new Error(json.errors[0]); } } diff --git a/src/api/apiUtils.js b/src/api/apiUtils.js deleted file mode 100644 index 87f185c..0000000 --- a/src/api/apiUtils.js +++ /dev/null @@ -1,9 +0,0 @@ -import { pageState } from "../globalPageState.ts"; - -export function getHeaders() { - return { - "X-Vault-Token": pageState.token, - } -} - -export const appendAPIURL = (url) => pageState.apiURL + url; \ No newline at end of file diff --git a/src/api/apiUtils.ts b/src/api/apiUtils.ts new file mode 100644 index 0000000..c82d16c --- /dev/null +++ b/src/api/apiUtils.ts @@ -0,0 +1,9 @@ +import { pageState } from "../globalPageState"; + +export function getHeaders(): any { + return { + "X-Vault-Token": pageState.token, + } +} + +export const appendAPIURL = (url: string): string => pageState.apiURL + url; \ No newline at end of file diff --git a/src/api/createOrUpdateSecret.js b/src/api/createOrUpdateSecret.ts similarity index 68% rename from src/api/createOrUpdateSecret.js rename to src/api/createOrUpdateSecret.ts index e92887f..9daf706 100644 --- a/src/api/createOrUpdateSecret.js +++ b/src/api/createOrUpdateSecret.ts @@ -1,8 +1,14 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; import { removeDoubleSlash } from "../utils"; -export async function createOrUpdateSecret(baseMount, mountType, secretPath, name, data) { +export async function createOrUpdateSecret( + baseMount: string, + mountType: string, + secretPath: string[], + name: string, + data: Record +): Promise { let secretURL = ""; let APIData = {}; @@ -23,9 +29,9 @@ export async function createOrUpdateSecret(baseMount, mountType, secretPath, nam }, body: JSON.stringify(APIData, null, 0) }); - let response = await fetch(request); + const response = await fetch(request); if (!response.ok) { - let json = await response.json(); + const json = await response.json(); throw new Error(json.errors[0]); } } diff --git a/src/api/deleteSecret.js b/src/api/deleteSecret.ts similarity index 73% rename from src/api/deleteSecret.js rename to src/api/deleteSecret.ts index b60cf74..be10a64 100644 --- a/src/api/deleteSecret.js +++ b/src/api/deleteSecret.ts @@ -1,8 +1,14 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; import { removeDoubleSlash } from "../utils"; -export async function deleteSecret(baseMount, mountType, secretPath, name, version = null) { +export async function deleteSecret( + baseMount: string, + mountType: string, + secretPath: string[], + name: string, + version: string | null = null +): Promise { let secretURL = ""; let request; @@ -27,12 +33,12 @@ export async function deleteSecret(baseMount, mountType, secretPath, name, versi secretURL = removeDoubleSlash(secretURL).replace(/\/$/, ""); request = new Request(appendAPIURL(secretURL), { method: "DELETE", - headers: getHeaders(), + headers: (getHeaders() as any), }); } - let response = await fetch(request); + const response = await fetch(request); if (!response.ok) { - let json = await response.json(); + const json = await response.json(); throw new Error(json.errors[0]); } } diff --git a/src/api/getCapabilities.js b/src/api/getCapabilities.ts similarity index 68% rename from src/api/getCapabilities.js rename to src/api/getCapabilities.ts index b0811c4..01dce97 100644 --- a/src/api/getCapabilities.js +++ b/src/api/getCapabilities.ts @@ -1,8 +1,8 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; import { removeDoubleSlash } from "../utils"; -export async function getCapabilitiesPath(path) { +export async function getCapabilitiesPath(path: string): Promise { const request = new Request(appendAPIURL("/v1/sys/capabilities-self"), { method: "POST", headers: { @@ -22,6 +22,10 @@ export async function getCapabilitiesPath(path) { }); } -export async function getCapabilities(baseMount, secretPath, name) { +export async function getCapabilities( + baseMount: string, + secretPath: string[], + name: string +): Promise { return await getCapabilitiesPath(removeDoubleSlash(baseMount + secretPath.join("/") + "/" + name)); } diff --git a/src/api/getMounts.js b/src/api/getMounts.js deleted file mode 100644 index b4a62d2..0000000 --- a/src/api/getMounts.js +++ /dev/null @@ -1,13 +0,0 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; - - -export async function getMounts() { - const request = new Request(appendAPIURL("/v1/sys/internal/ui/mounts"), { - headers: getHeaders(), - }); - return fetch(request).then(response => { - return response.json(); - }).then(data => { - return data.data.secret; - }); -} diff --git a/src/api/getMounts.ts b/src/api/getMounts.ts new file mode 100644 index 0000000..17e90e1 --- /dev/null +++ b/src/api/getMounts.ts @@ -0,0 +1,21 @@ +import { appendAPIURL, getHeaders } from "./apiUtils"; + +type MountsType = { + [key: string]: { + type: string + options: { + version: string + } + } +} + +export async function getMounts(): Promise { + const request = new Request(appendAPIURL("/v1/sys/internal/ui/mounts"), { + headers: (getHeaders() as any), + }); + return fetch(request).then(response => { + return response.json(); + }).then(data => { + return data.data.secret; + }); +} diff --git a/src/api/getSealStatus.js b/src/api/getSealStatus.ts similarity index 50% rename from src/api/getSealStatus.js rename to src/api/getSealStatus.ts index b0b0758..fdd4213 100644 --- a/src/api/getSealStatus.js +++ b/src/api/getSealStatus.ts @@ -1,7 +1,12 @@ -import { appendAPIURL } from "./apiUtils.js"; +import { appendAPIURL } from "./apiUtils"; +type SealStatusType = { + progress: number; + t: number; + sealed: boolean; +} -export async function getSealStatus() { +export async function getSealStatus(): Promise { const request = new Request(appendAPIURL("/v1/sys/seal-status")); return fetch(request).then(response => { return response.json(); diff --git a/src/api/getSecret.js b/src/api/getSecret.ts similarity index 65% rename from src/api/getSecret.js rename to src/api/getSecret.ts index 92a8829..5a4af5a 100644 --- a/src/api/getSecret.js +++ b/src/api/getSecret.ts @@ -1,7 +1,13 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; -export async function getSecret(baseMount, mountType, secretPath, name, version = null) { +export async function getSecret( + baseMount: string, + mountType: string, + secretPath: string[], + name: string, + version: string|null = null +): Promise> { let secretURL = ""; if (mountType == "kv-v2") { secretURL = `/v1/${baseMount}/data/${secretPath.join("")}/${name}`; @@ -11,7 +17,7 @@ export async function getSecret(baseMount, mountType, secretPath, name, version secretURL = `/v1/${baseMount}/${secretPath.join("")}/${name}`; } const request = new Request(appendAPIURL(secretURL), { - headers: getHeaders(), + headers: (getHeaders() as any), }); return fetch(request).then(response => { diff --git a/src/api/getSecretMetadata.js b/src/api/getSecretMetadata.js deleted file mode 100644 index ec67292..0000000 --- a/src/api/getSecretMetadata.js +++ /dev/null @@ -1,14 +0,0 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; - - -export async function getSecretMetadata(baseMount, secretPath, name) { - const request = new Request(appendAPIURL(`/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`), { - headers: getHeaders(), - }); - - return fetch(request).then(response => { - return response.json(); - }).then(data => { - return data.data; - }); -} diff --git a/src/api/getSecretMetadata.ts b/src/api/getSecretMetadata.ts new file mode 100644 index 0000000..fc1e09f --- /dev/null +++ b/src/api/getSecretMetadata.ts @@ -0,0 +1,21 @@ +import { appendAPIURL, getHeaders } from "./apiUtils"; + +type SecretMetadataType = { + versions: Record> +} + +export async function getSecretMetadata( + baseMount: string, + secretPath: string[], + name: string +): Promise { + const request = new Request(appendAPIURL(`/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`), { + headers: (getHeaders() as any), + }); + + return fetch(request).then(response => { + return response.json(); + }).then(data => { + return data.data; + }); +} diff --git a/src/api/getSecrets.js b/src/api/getSecrets.ts similarity index 72% rename from src/api/getSecrets.js rename to src/api/getSecrets.ts index 1288ddf..ff50cd0 100644 --- a/src/api/getSecrets.js +++ b/src/api/getSecrets.ts @@ -1,8 +1,11 @@ import { DoesNotExistError } from "../types/internalErrors"; -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; - -export async function getSecrets(baseMount, mountType, secretPath) { +export async function getSecrets( + baseMount: string, + mountType: string, + secretPath: string[] +): Promise { let secretURL = ""; if (mountType == "kv-v2") { secretURL = `/v1/${baseMount}/metadata/${secretPath.join("")}?list=true`; @@ -11,7 +14,7 @@ export async function getSecrets(baseMount, mountType, secretPath) { secretURL = `/v1/${baseMount}/${secretPath.join("")}?list=true`; } const request = new Request(appendAPIURL(secretURL), { - headers: getHeaders(), + headers: (getHeaders() as any), }); return fetch(request).then(response => { if (response.status == 404) { diff --git a/src/api/getTOTPCode.js b/src/api/getTOTPCode.js deleted file mode 100644 index bae6473..0000000 --- a/src/api/getTOTPCode.js +++ /dev/null @@ -1,13 +0,0 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; - - -export async function getTOTPCode(baseMount, name) { - const request = new Request(appendAPIURL(`/v1/${baseMount}/code/${name}`), { - headers: getHeaders(), - }); - return fetch(request).then(response => { - return response.json(); - }).then(data => { - return data.data.code; - }); -} diff --git a/src/api/getTOTPCode.ts b/src/api/getTOTPCode.ts new file mode 100644 index 0000000..539f17e --- /dev/null +++ b/src/api/getTOTPCode.ts @@ -0,0 +1,13 @@ +import { appendAPIURL, getHeaders } from "./apiUtils"; + +export async function getTOTPCode(baseMount: string, name: string): Promise { + const request = + new Request(appendAPIURL(`/v1/${baseMount}/code/${name}`), { + headers: getHeaders(), + }); + return fetch(request).then(response => { + return response.json(); + }).then(data => { + return data.data.code; + }); +} diff --git a/src/api/getTOTPKeys.js b/src/api/getTOTPKeys.ts similarity index 74% rename from src/api/getTOTPKeys.js rename to src/api/getTOTPKeys.ts index 243ced5..2d0bcab 100644 --- a/src/api/getTOTPKeys.js +++ b/src/api/getTOTPKeys.ts @@ -1,8 +1,8 @@ import { DoesNotExistError } from "../types/internalErrors"; -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; -export async function getTOTPKeys(baseMount) { +export async function getTOTPKeys(baseMount: string): Promise { const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), { headers: getHeaders(), }); diff --git a/src/api/getTransitKeys.js b/src/api/getTransitKeys.ts similarity index 73% rename from src/api/getTransitKeys.js rename to src/api/getTransitKeys.ts index 7fd8b92..d2f9533 100644 --- a/src/api/getTransitKeys.js +++ b/src/api/getTransitKeys.ts @@ -1,8 +1,7 @@ import { DoesNotExistError } from "../types/internalErrors"; -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; - -export async function getTransitKeys(baseMount) { +export async function getTransitKeys(baseMount: string): Promise { const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), { headers: getHeaders(), }); diff --git a/src/api/lookupSelf.js b/src/api/lookupSelf.ts similarity index 68% rename from src/api/lookupSelf.js rename to src/api/lookupSelf.ts index f54f9c5..fbf453b 100644 --- a/src/api/lookupSelf.js +++ b/src/api/lookupSelf.ts @@ -1,7 +1,10 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; +type TokenInfo = { + expire_time: string; +} -export async function lookupSelf() { +export async function lookupSelf(): Promise { const request = new Request(appendAPIURL("/v1/auth/token/lookup-self"), { headers: getHeaders(), }); diff --git a/src/api/renewSelf.js b/src/api/renewSelf.ts similarity index 78% rename from src/api/renewSelf.js rename to src/api/renewSelf.ts index fee7c08..317d7ed 100644 --- a/src/api/renewSelf.js +++ b/src/api/renewSelf.ts @@ -1,7 +1,6 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; - -export async function renewSelf() { +export async function renewSelf(): Promise { const request = new Request(appendAPIURL("/v1/auth/token/renew-self"), { method: 'POST', headers: { diff --git a/src/api/sealVault.js b/src/api/sealVault.ts similarity index 73% rename from src/api/sealVault.js rename to src/api/sealVault.ts index 40a14da..92d945d 100644 --- a/src/api/sealVault.js +++ b/src/api/sealVault.ts @@ -1,7 +1,7 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; -export async function sealVault() { +export async function sealVault(): Promise { const request = new Request(appendAPIURL("/v1/sys/seal"), { method: 'PUT', headers: getHeaders(), diff --git a/src/api/submitUnsealKey.js b/src/api/submitUnsealKey.ts similarity index 58% rename from src/api/submitUnsealKey.js rename to src/api/submitUnsealKey.ts index e29e1f4..cc160f6 100644 --- a/src/api/submitUnsealKey.js +++ b/src/api/submitUnsealKey.ts @@ -1,7 +1,6 @@ -import { appendAPIURL } from "./apiUtils.js"; +import { appendAPIURL } from "./apiUtils"; - -export async function submitUnsealKey(key) { +export async function submitUnsealKey(key: string): Promise { const request = new Request(appendAPIURL("/v1/sys/unseal"), { method: "POST", headers: { @@ -11,9 +10,9 @@ export async function submitUnsealKey(key) { "key": key }) }); - let response = await fetch(request); + const response = await fetch(request); if (!response.ok) { - let json = await response.json(); + const json = await response.json(); throw new Error(json.errors[0]); } } diff --git a/src/api/transitDecrypt.js b/src/api/transitDecrypt.ts similarity index 54% rename from src/api/transitDecrypt.js rename to src/api/transitDecrypt.ts index d5b7e55..cc606a3 100644 --- a/src/api/transitDecrypt.js +++ b/src/api/transitDecrypt.ts @@ -1,8 +1,15 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; import { removeDoubleSlash } from "../utils"; +type DecryptionResult = { + plaintext: string; +} -export async function transitDecrypt(baseMount, name, data) { +export async function transitDecrypt( + baseMount: string, + name: string, + data: string +): Promise { const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/decrypt/${name}`)), { method: 'POST', headers: { @@ -11,12 +18,12 @@ export async function transitDecrypt(baseMount, name, data) { }, body: JSON.stringify({ ciphertext: data }) }); - let response = await fetch(request); + const response = await fetch(request); if (!response.ok) { - let json = await response.json(); + const json = await response.json(); throw new Error(json.errors[0]); } else { - let json = await response.json(); + const json = await response.json(); return json.data; } } diff --git a/src/api/transitEncrypt.js b/src/api/transitEncrypt.ts similarity index 53% rename from src/api/transitEncrypt.js rename to src/api/transitEncrypt.ts index d20a661..5949a35 100644 --- a/src/api/transitEncrypt.js +++ b/src/api/transitEncrypt.ts @@ -1,8 +1,15 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; import { removeDoubleSlash } from "../utils"; +type EncryptionResult = { + ciphertext: string; +} -export async function transitEncrypt(baseMount, name, data) { +export async function transitEncrypt( + baseMount: string, + name: string, + data: string +): Promise { const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/encrypt/${name}`)), { method: 'POST', headers: { @@ -11,12 +18,12 @@ export async function transitEncrypt(baseMount, name, data) { }, body: JSON.stringify({ plaintext: data }) }); - let response = await fetch(request); + const response = await fetch(request); if (!response.ok) { - let json = await response.json(); + const json = await response.json(); throw new Error(json.errors[0]); } else { - let json = await response.json(); + const json = await response.json(); return json.data; } } diff --git a/src/api/undeleteSecret.js b/src/api/undeleteSecret.ts similarity index 59% rename from src/api/undeleteSecret.js rename to src/api/undeleteSecret.ts index 0ef8438..c43cd13 100644 --- a/src/api/undeleteSecret.js +++ b/src/api/undeleteSecret.ts @@ -1,22 +1,26 @@ -import { appendAPIURL, getHeaders } from "./apiUtils.js"; +import { appendAPIURL, getHeaders } from "./apiUtils"; import { getObjectKeys, removeDoubleSlash } from "../utils"; import { getSecretMetadata } from "./getSecretMetadata"; - -export async function undeleteSecret(baseMount, secretPath, name, version = null) { +export async function undeleteSecret( + baseMount: string, + secretPath: string[], + name: string, + version: string|null = null +): Promise { let secretURL = `/v1/${baseMount}/undelete/${secretPath.join("/")}/${name}`; secretURL = removeDoubleSlash(secretURL).replace(/\/$/, ""); if (version == null) { - let meta = await getSecretMetadata( + const meta = await getSecretMetadata( baseMount, secretPath, name ); - let versions = getObjectKeys(meta.versions); + const versions = getObjectKeys(meta.versions); version = String(versions[versions.length - 1]); } - let request = new Request(appendAPIURL(secretURL), { + const request = new Request(appendAPIURL(secretURL), { method: "POST", headers: { ...getHeaders(), @@ -24,9 +28,9 @@ export async function undeleteSecret(baseMount, secretPath, name, version = null }, body: JSON.stringify({ "versions": [version] }) }); - let response = await fetch(request); + const response = await fetch(request); if (!response.ok) { - let json = await response.json(); + const json = await response.json(); throw new Error(json.errors[0]); } } diff --git a/src/api/usernameLogin.js b/src/api/usernameLogin.ts similarity index 78% rename from src/api/usernameLogin.js rename to src/api/usernameLogin.ts index afea14f..2da2608 100644 --- a/src/api/usernameLogin.js +++ b/src/api/usernameLogin.ts @@ -1,7 +1,6 @@ -import { appendAPIURL } from "./apiUtils.js"; +import { appendAPIURL } from "./apiUtils"; - -export async function usernameLogin(username, password) { +export async function usernameLogin(username: string, password: string): Promise { const request = new Request(appendAPIURL(`/v1/auth/userpass/login/${username}`), { method: 'POST', headers: { diff --git a/src/pages/KeyValue/KeyValueSecretsEdit.js b/src/pages/KeyValue/KeyValueSecretsEdit.js index 1b5154e..aaeeb33 100644 --- a/src/pages/KeyValue/KeyValueSecretsEdit.js +++ b/src/pages/KeyValue/KeyValueSecretsEdit.js @@ -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.js"; -import { getSecret } from "../../api/getSecret.js"; +import { createOrUpdateSecret } from "../../api/createOrUpdateSecret"; +import { getSecret } from "../../api/getSecret"; import { makeElement } from "../../htmlUtils"; import { pageState } from "../../globalPageState.ts"; import { verifyJSONString } from "../../utils"; diff --git a/src/pages/KeyValue/KeyValueVersions.js b/src/pages/KeyValue/KeyValueVersions.js index e6f8beb..e11de82 100644 --- a/src/pages/KeyValue/KeyValueVersions.js +++ b/src/pages/KeyValue/KeyValueVersions.js @@ -1,6 +1,6 @@ import { Page } from "../../types/Page"; import { changePage, setPageContent, setTitleElement } from "../../pageUtils"; -import { getSecretMetadata } from "../../api/getSecretMetadata.js"; +import { getSecretMetadata } from "../../api/getSecretMetadata"; import { makeElement } from "../../htmlUtils"; import { objectToMap } from "../../utils"; import { pageState } from "../../globalPageState.ts"; diff --git a/src/pages/Me.js b/src/pages/Me.js index b668a84..b329603 100644 --- a/src/pages/Me.js +++ b/src/pages/Me.js @@ -1,10 +1,10 @@ import { Page } from "../types/Page"; import { addClipboardNotifications, changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils"; -import { getCapabilitiesPath } from "../api/getCapabilities.js"; +import { getCapabilitiesPath } from "../api/getCapabilities"; import { makeElement } from "../htmlUtils"; import { pageState } from "../globalPageState.ts"; -import { renewSelf } from "../api/renewSelf.js"; -import { sealVault } from "../api/sealVault.js"; +import { renewSelf } from "../api/renewSelf"; +import { sealVault } from "../api/sealVault"; import ClipboardJS from "clipboard"; import i18next from 'i18next'; diff --git a/src/pages/Unseal.js b/src/pages/Unseal.js index eb9f8a9..3c96fa1 100644 --- a/src/pages/Unseal.js +++ b/src/pages/Unseal.js @@ -2,9 +2,9 @@ import { MarginInline } from "../elements/MarginInline.js"; import { Page } from "../types/Page"; import { QRScanner } from "../elements/QRScanner.js"; import { changePage, setErrorText, setPageContent } from "../pageUtils"; -import { getSealStatus } from "../api/getSealStatus.js"; +import { getSealStatus } from "../api/getSealStatus"; import { makeElement } from "../htmlUtils"; -import { submitUnsealKey } from "../api/submitUnsealKey.js"; +import { submitUnsealKey } from "../api/submitUnsealKey"; import i18next from 'i18next';