🎉 Init

This commit is contained in:
2026-07-19 16:43:30 +02:00
commit 3e380643d7
61 changed files with 4644 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+17
View File
@@ -0,0 +1,17 @@
FROM node:24-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
+5
View File
@@ -0,0 +1,5 @@
# Vue 3 + TypeScript + Vite
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
+13
View File
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lockaway</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location /api/ {
proxy_pass http://backend/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
try_files $uri $uri/ /index.html;
}
}
+1954
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview"
},
"dependencies": {
"@fontsource-variable/big-shoulders-display": "^5.3.0",
"@fontsource-variable/mulish": "^5.2.8",
"@fontsource/ibm-plex-mono": "^5.3.0",
"@tailwindcss/vite": "^4.3.3",
"@vueuse/core": "^14.3.0",
"axios": "^1.18.1",
"material-symbols": "^0.45.8",
"tailwindcss": "^4.3.3",
"vue": "^3.5.39"
},
"devDependencies": {
"@types/node": "^24.13.2",
"@vitejs/plugin-vue": "^6.0.7",
"@vue/tsconfig": "^0.9.1",
"typescript": "~6.0.2",
"vite": "^8.1.1",
"vue-tsc": "^3.3.5"
}
}
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
DEV_TAG=3
IMAGE="harbor.dinauer.dev/lockaway/frontend:dev-${DEV_TAG}"
echo "==> Building Docker image ${IMAGE}"
docker build --no-cache -t "${IMAGE}" .
echo "==> Pushing image to Harbor"
if [[ -n "${HARBOR_USERNAME:-}" && -n "${HARBOR_PASSWORD:-}" ]]; then
echo "${HARBOR_PASSWORD}" | docker login harbor.dinauer.dev -u "${HARBOR_USERNAME}" --password-stdin
docker push "${IMAGE}"
docker logout harbor.dinauer.dev
else
docker push "${IMAGE}"
fi
echo "==> Removing local image"
docker image rm --force "${IMAGE}"
echo "==> Done: ${IMAGE}"
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

+43
View File
@@ -0,0 +1,43 @@
<script setup lang="ts">
import HeaderComponent from './components/HeaderComponent.vue'
import SearchInput from './components/SearchInput.vue'
import SecretList from './components/SecretList.vue'
import MasterPasswordGate from './components/MasterPasswordGate.vue'
import CreateSecretPopup from './components/CreateSecretPopup.vue'
import { usePopup } from './components/popup/Popup'
import { useSecrets } from './composables/useSecrets'
import { useMasterPassword } from './composables/useMasterPassword'
const { masterPassword, isRestoring } = useMasterPassword()
const { secrets, searchText, load } = useSecrets()
function openCreateSecretPopup() {
usePopup().open(CreateSecretPopup, { onCreated: load })
}
</script>
<template>
<template v-if="!isRestoring">
<MasterPasswordGate v-if="!masterPassword" />
<template v-else>
<HeaderComponent @imported="load" />
<main class="mx-auto max-w-5xl space-y-5 p-6">
<div class="flex gap-2">
<SearchInput v-model="searchText" />
<button
type="button"
class="flex h-10 shrink-0 items-center gap-1.5 rounded bg-brass px-4 text-sm font-bold tracking-[0.08em] text-ink transition-colors hover:bg-brass-bright active:scale-[0.98] tracking-normal"
@click="openCreateSecretPopup"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20">
add
</span>
NEW ENTRY
</button>
</div>
<SecretList :secrets="secrets" @deleted="load" @updated="load" />
</main>
</template>
</template>
<component :is="usePopup().get()" />
</template>
+5
View File
@@ -0,0 +1,5 @@
import axios from 'axios'
export const apiClient = axios.create({
baseURL: '/api',
})
+13
View File
@@ -0,0 +1,13 @@
import axios from 'axios'
const ERROR_MESSAGES: Record<string, string> = {
secret_conflict: 'Ein Secret mit diesem Namen existiert bereits in einem der ausgewählten Namespaces.',
}
export function extractErrorMessage(error: unknown): string {
if (axios.isAxiosError(error) && typeof error.response?.data?.error === 'string') {
const key = error.response.data.error
return ERROR_MESSAGES[key] ?? key
}
return 'Etwas ist schiefgelaufen.'
}
+5
View File
@@ -0,0 +1,5 @@
import { apiClient } from './client'
export function exportSecrets(): Promise<Blob> {
return apiClient.get('/_export', { responseType: 'blob' }).then((response) => response.data)
}
+5
View File
@@ -0,0 +1,5 @@
import { apiClient } from './client'
export function importSecrets(secrets: unknown): Promise<void> {
return apiClient.post('/_import', secrets).then(() => undefined)
}
+47
View File
@@ -0,0 +1,47 @@
import { apiClient } from './client'
import type { Secret } from '../types/Secret'
interface SecretResponse {
id: string
name: string
namespaces: string[]
contentHash: string
entries: Record<string, string>
type: string
}
function toSecret(response: SecretResponse): Secret {
return {
id: response.id,
name: response.name,
namespaces: response.namespaces,
contentHash: response.contentHash,
entries: Object.entries(response.entries).map(([key, value]) => ({ key, value })),
type: response.type,
}
}
export function getSecrets(searchText?: string): Promise<Secret[]> {
return apiClient
.get<SecretResponse[]>('/secrets', { params: { searchText } })
.then((response) => response.data.map(toSecret))
}
export interface SecretCreatePayload {
name: string
namespaces: string[]
entries: Record<string, string>
type: string
}
export function createSecret(payload: SecretCreatePayload): Promise<void> {
return apiClient.post('/secrets', payload).then(() => undefined)
}
export function updateSecret(id: string, payload: SecretCreatePayload): Promise<void> {
return apiClient.put(`/secrets/${id}`, payload).then(() => undefined)
}
export function deleteSecret(id: string): Promise<void> {
return apiClient.delete(`/secrets/${id}`).then(() => undefined)
}
+11
View File
@@ -0,0 +1,11 @@
import { apiClient } from './client'
export function getVerificationValue(): Promise<string | null> {
return apiClient
.get<{ value: string } | ''>('/verification', { validateStatus: (status) => status === 200 || status === 204 })
.then((response) => (response.status === 204 ? null : (response.data as { value: string }).value))
}
export function setVerificationValue(value: string): Promise<void> {
return apiClient.post('/verification', { value }).then(() => undefined)
}
@@ -0,0 +1,69 @@
<script setup lang="ts">
import { ref } from 'vue'
import PopupTemplate from './popup/PopupTemplate.vue'
import SecretForm from './SecretForm.vue'
import { usePopup } from './popup/Popup'
import { useMasterPassword } from '../composables/useMasterPassword'
import { encryptValue } from '../crypto/secretCrypto'
import { createSecret } from '../api/secrets'
import { extractErrorMessage } from '../api/errors'
const { onCreated } = usePopup().data<{ onCreated: () => void }>()
const { derivedKey } = useMasterPassword()
const name = ref('')
const namespaces = ref<string[]>([])
const entries = ref([{ key: '', value: '' }])
const type = ref('Opaque')
const isSubmitting = ref(false)
const errorMessage = ref('')
function submit() {
const key = derivedKey.value
if (!key) {
return
}
isSubmitting.value = true
errorMessage.value = ''
Promise.all(
entries.value
.filter((entry) => entry.key)
.map((entry) => encryptValue(key, entry.value).then((encrypted) => [entry.key, encrypted] as const)),
)
.then((encryptedPairs) =>
createSecret({
name: name.value,
namespaces: namespaces.value,
entries: Object.fromEntries(encryptedPairs),
type: type.value,
}),
)
.then(() => {
onCreated()
usePopup().close()
})
.catch((error) => {
errorMessage.value = extractErrorMessage(error)
})
.finally(() => {
isSubmitting.value = false
})
}
</script>
<template>
<PopupTemplate heading="Secret erstellen">
<SecretForm
v-model:name="name"
v-model:namespaces="namespaces"
v-model:entries="entries"
v-model:type="type"
submit-label="Erstellen"
:submitting="isSubmitting"
:error-message="errorMessage"
@submit="submit"
/>
</PopupTemplate>
</template>
@@ -0,0 +1,39 @@
<script setup lang="ts">
import PopupTemplate from './popup/PopupTemplate.vue'
import { usePopup } from './popup/Popup'
import { deleteSecret } from '../api/secrets'
import type { Secret } from '../types/Secret'
const { secret, onDeleted } = usePopup().data<{ secret: Secret; onDeleted: () => void }>()
function confirmDelete() {
deleteSecret(secret.id).then(() => {
onDeleted()
usePopup().close()
})
}
</script>
<template>
<PopupTemplate heading="Secret löschen" size="sm">
<p class="text-sm text-paper-dim">
Soll <span class="font-mono text-paper">{{ secret.name }}</span> wirklich gelöscht werden?
</p>
<div class="mt-4 flex justify-end gap-2">
<button
type="button"
class="rounded px-4 py-2 text-sm font-semibold text-paper-dim transition-colors hover:bg-panel-2 hover:text-paper"
@click="usePopup().close()"
>
Abbrechen
</button>
<button
type="button"
class="rounded bg-rust px-4 py-2 text-sm font-bold tracking-[0.08em] text-paper transition-colors hover:brightness-110 active:scale-[0.98]"
@click="confirmDelete"
>
LÖSCHEN
</button>
</div>
</PopupTemplate>
</template>
@@ -0,0 +1,87 @@
<script setup lang="ts">
import { ref } from 'vue'
import PopupTemplate from './popup/PopupTemplate.vue'
import SecretForm from './SecretForm.vue'
import { usePopup } from './popup/Popup'
import { useMasterPassword } from '../composables/useMasterPassword'
import { decryptValue, encryptValue } from '../crypto/secretCrypto'
import { updateSecret } from '../api/secrets'
import { extractErrorMessage } from '../api/errors'
import type { Secret } from '../types/Secret'
const { secret, onUpdated } = usePopup().data<{ secret: Secret; onUpdated: () => void }>()
const { derivedKey } = useMasterPassword()
const name = ref(secret.name)
const namespaces = ref<string[]>([...secret.namespaces])
const entries = ref<{ key: string; value: string }[]>([])
const type = ref(secret.type)
const isLoading = ref(true)
const isSubmitting = ref(false)
const errorMessage = ref('')
const decryptionKey = derivedKey.value
if (decryptionKey) {
Promise.all(
secret.entries.map((entry) =>
decryptValue(decryptionKey, entry.value)
.then((value) => ({ key: entry.key, value }))
.catch(() => ({ key: entry.key, value: '' })),
),
).then((decrypted) => {
entries.value = decrypted
isLoading.value = false
})
}
function submit() {
const encryptionKey = derivedKey.value
if (!encryptionKey) {
return
}
isSubmitting.value = true
errorMessage.value = ''
Promise.all(
entries.value
.filter((entry) => entry.key)
.map((entry) => encryptValue(encryptionKey, entry.value).then((encrypted) => [entry.key, encrypted] as const)),
)
.then((encryptedPairs) =>
updateSecret(secret.id, {
name: name.value,
namespaces: namespaces.value,
entries: Object.fromEntries(encryptedPairs),
type: type.value,
}),
)
.then(() => {
onUpdated()
usePopup().close()
})
.catch((error) => {
errorMessage.value = extractErrorMessage(error)
})
.finally(() => {
isSubmitting.value = false
})
}
</script>
<template>
<PopupTemplate heading="Secret bearbeiten">
<div v-if="isLoading" class="text-sm text-paper-dim">Entschlüssele…</div>
<SecretForm
v-else
v-model:name="name"
v-model:namespaces="namespaces"
v-model:entries="entries"
v-model:type="type"
submit-label="Speichern"
:submitting="isSubmitting"
:error-message="errorMessage"
@submit="submit"
/>
</PopupTemplate>
</template>
@@ -0,0 +1,76 @@
<script setup lang="ts">
import { useMasterPassword } from '../composables/useMasterPassword'
import { exportSecrets } from '../api/export'
import { usePopup } from './popup/Popup'
import ImportSecretsPopup from './ImportSecretsPopup.vue'
const emit = defineEmits<{ imported: [] }>()
const { lock } = useMasterPassword()
function exportFilename() {
const now = new Date()
const pad = (n: number) => String(n).padStart(2, '0')
const date = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
const time = `${pad(now.getHours())}-${pad(now.getMinutes())}`
return `${date}_${time}_lockaway-export.json`
}
function download() {
exportSecrets().then((blob) => {
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = exportFilename()
link.click()
URL.revokeObjectURL(url)
})
}
function openImportPopup() {
usePopup().open(ImportSecretsPopup, { onImported: () => emit('imported') })
}
</script>
<template>
<header class="sticky top-0 z-30 flex items-center justify-between gap-3 border-b border-hairline bg-panel px-5 py-3">
<div class="flex items-center gap-2.5">
<span class="material-symbols-outlined text-[1.35rem] leading-none text-brass" style="font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24">
lock
</span>
<span class="font-display text-[1.7rem] font-semibold leading-none tracking-wide text-paper">Lockaway</span>
</div>
<div class="flex items-center gap-1.5">
<button
type="button"
class="flex items-center gap-1.5 rounded px-3 py-1.5 text-sm font-semibold text-paper-dim transition-colors hover:bg-panel-2 hover:text-paper"
@click="openImportPopup"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20">
upload
</span>
Import
</button>
<button
type="button"
class="flex items-center gap-1.5 rounded px-3 py-1.5 text-sm font-semibold text-paper-dim transition-colors hover:bg-panel-2 hover:text-paper"
@click="download"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20">
download
</span>
Export
</button>
<button
type="button"
class="flex items-center gap-1.5 rounded px-3 py-1.5 text-sm font-semibold text-paper-dim transition-colors hover:bg-panel-2 hover:text-paper"
@click="lock"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20">
logout
</span>
Logout
</button>
</div>
</header>
</template>
@@ -0,0 +1,73 @@
<script setup lang="ts">
import { ref } from 'vue'
import PopupTemplate from './popup/PopupTemplate.vue'
import { usePopup } from './popup/Popup'
import { importSecrets } from '../api/import'
import { extractErrorMessage } from '../api/errors'
const { onImported } = usePopup().data<{ onImported: () => void }>()
const file = ref<File | null>(null)
const errorMessage = ref('')
const isSubmitting = ref(false)
function onFileSelected(event: Event) {
file.value = (event.target as HTMLInputElement).files?.[0] ?? null
errorMessage.value = ''
}
function submit() {
if (!file.value) {
errorMessage.value = 'Bitte eine Datei auswählen.'
return
}
isSubmitting.value = true
errorMessage.value = ''
file.value
.text()
.then((text) => importSecrets(JSON.parse(text)))
.then(() => {
onImported()
usePopup().close()
})
.catch((error) => {
errorMessage.value = extractErrorMessage(error)
})
.finally(() => {
isSubmitting.value = false
})
}
</script>
<template>
<PopupTemplate heading="Secrets importieren" size="sm">
<div class="space-y-3">
<input
type="file"
accept="application/json"
class="w-full rounded border border-hairline bg-ink px-3 py-2 text-sm text-paper-dim file:mr-3 file:rounded file:border-0 file:bg-panel-2 file:px-3 file:py-1.5 file:text-sm file:font-semibold file:text-paper"
@change="onFileSelected"
/>
<p v-if="errorMessage" class="text-sm text-rust">{{ errorMessage }}</p>
</div>
<div class="mt-4 flex justify-end gap-2">
<button
type="button"
class="rounded px-4 py-2 text-sm font-semibold text-paper-dim transition-colors hover:bg-panel-2 hover:text-paper"
@click="usePopup().close()"
>
Abbrechen
</button>
<button
type="button"
:disabled="isSubmitting"
class="rounded bg-brass px-4 py-2 text-sm font-bold tracking-[0.08em] text-ink transition-colors hover:bg-brass-bright disabled:opacity-50"
@click="submit"
>
IMPORT
</button>
</div>
</PopupTemplate>
</template>
@@ -0,0 +1,174 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useMasterPassword } from '../composables/useMasterPassword'
import { useVerification } from '../composables/useVerification'
const { unlock } = useMasterPassword()
const { needsSetup, setup, verify } = useVerification()
const password = ref('')
const repeatPassword = ref('')
const errorMessage = ref('')
const isSubmitting = ref(false)
function submitSetup() {
errorMessage.value = ''
if (password.value.length < 8) {
errorMessage.value = 'Master Password muss mindestens 8 Zeichen lang sein.'
return
}
if (password.value !== repeatPassword.value) {
errorMessage.value = 'Die Passwörter stimmen nicht überein.'
return
}
isSubmitting.value = true
setup(password.value)
.then(() => unlock(password.value))
.catch(() => {
errorMessage.value = 'Einrichtung fehlgeschlagen.'
})
.finally(() => {
isSubmitting.value = false
})
}
function submitUnlock() {
errorMessage.value = ''
isSubmitting.value = true
verify(password.value)
.then((isValid) => {
if (!isValid) {
errorMessage.value = 'Falsches Master Password.'
return undefined
}
return unlock(password.value)
})
.finally(() => {
isSubmitting.value = false
})
}
</script>
<template>
<div class="flex min-h-screen items-center justify-center p-4">
<div class="flex w-full max-w-sm flex-col items-center space-y-6">
<div class="dial">
<div class="dial__ticks" />
<div class="dial__face">
<span class="material-symbols-outlined text-[1.75rem] leading-none text-brass" style="font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24">
lock
</span>
</div>
</div>
<div class="text-center">
<h1 class="font-display text-3xl font-semibold leading-none tracking-wide text-paper">Lockaway</h1>
<p v-if="needsSetup === null" class="mt-2 text-sm text-paper-dim">Prüfe Tresor-Status…</p>
<p v-else-if="needsSetup" class="mt-2 text-sm text-paper-dim">Noch kein Master Password gesetzt — richte den Tresor ein.</p>
<p v-else class="mt-2 text-sm text-paper-dim">Master Password eingeben, um den Tresor zu öffnen.</p>
</div>
<form
v-if="needsSetup === true"
@submit.prevent="submitSetup"
class="w-full space-y-3 rounded border border-hairline bg-panel p-5"
>
<input
v-model="password"
type="password"
placeholder="Master Password"
autocomplete="new-password"
autofocus
class="w-full rounded border border-hairline bg-ink px-3 py-2.5 font-mono text-sm text-paper outline-none transition-colors placeholder:text-paper-dim/60 focus:border-brass/60"
/>
<input
v-model="repeatPassword"
type="password"
placeholder="Master Password wiederholen"
autocomplete="new-password"
class="w-full rounded border border-hairline bg-ink px-3 py-2.5 font-mono text-sm text-paper outline-none transition-colors placeholder:text-paper-dim/60 focus:border-brass/60"
/>
<p v-if="errorMessage" class="text-sm text-rust">{{ errorMessage }}</p>
<button
type="submit"
:disabled="isSubmitting"
class="flex w-full items-center justify-center gap-2 rounded bg-brass py-2.5 text-sm font-bold tracking-[0.08em] text-ink transition-colors hover:bg-brass-bright disabled:opacity-50"
>
TRESOR EINRICHTEN
</button>
</form>
<form
v-else-if="needsSetup === false"
@submit.prevent="submitUnlock"
class="w-full space-y-3 rounded border border-hairline bg-panel p-5"
>
<input
v-model="password"
type="password"
placeholder="Master Password"
autocomplete="current-password"
autofocus
class="w-full rounded border border-hairline bg-ink px-3 py-2.5 font-mono text-sm text-paper outline-none transition-colors placeholder:text-paper-dim/60 focus:border-brass/60"
/>
<p v-if="errorMessage" class="text-sm text-rust">{{ errorMessage }}</p>
<button
type="submit"
:disabled="isSubmitting"
class="flex w-full items-center justify-center gap-2 rounded bg-brass py-2.5 text-sm font-bold tracking-[0.08em] text-ink transition-colors hover:bg-brass-bright disabled:opacity-50"
>
ENTSPERREN
</button>
</form>
</div>
</div>
</template>
<style scoped>
.dial {
position: relative;
width: 6.5rem;
height: 6.5rem;
}
.dial__ticks {
position: absolute;
inset: 0;
border-radius: 9999px;
background: repeating-conic-gradient(var(--color-brass) 0deg 2deg, transparent 2deg 18deg);
-webkit-mask-image: radial-gradient(closest-side, transparent 74%, black 78%, black 92%, transparent 96%);
mask-image: radial-gradient(closest-side, transparent 74%, black 78%, black 92%, transparent 96%);
animation: settle 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.dial__face {
position: absolute;
inset: 0.85rem;
display: flex;
align-items: center;
justify-content: center;
border-radius: 9999px;
background: var(--color-panel);
border: 1px solid var(--color-hairline);
}
@keyframes settle {
from {
transform: rotate(-45deg);
opacity: 0;
}
to {
transform: rotate(0deg);
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.dial__ticks {
animation: none;
}
}
</style>
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { ref } from 'vue'
const model = defineModel<string[]>({ required: true })
const input = ref('')
function addNamespace() {
const value = input.value.trim()
if (value && !model.value.includes(value)) {
model.value.push(value)
}
input.value = ''
}
function removeNamespace(namespace: string) {
model.value = model.value.filter((n) => n !== namespace)
}
</script>
<template>
<div>
<div v-if="model.length" class="mb-2 flex flex-wrap gap-1.5">
<span
v-for="namespace in model"
:key="namespace"
class="flex items-center gap-1 rounded border border-hairline py-1 pl-2 pr-1 font-mono text-xs text-paper-dim"
>
{{ namespace }}
<button
type="button"
class="flex h-3 w-3 items-center justify-center rounded-full text-paper-dim hover:text-rust"
@click="removeNamespace(namespace)"
>
<span
class="material-symbols-outlined text-[1em] leading-none"
style="font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20"
>
close
</span>
</button>
</span>
</div>
<input
v-model="input"
type="text"
placeholder="Namespace eingeben und Enter drücken"
class="w-full rounded border border-hairline bg-ink px-3 py-2 font-mono text-sm text-paper outline-none transition-colors placeholder:text-paper-dim/60 focus:border-brass/60"
@keydown.enter.prevent="addNamespace"
@blur="addNamespace"
/>
</div>
</template>
+20
View File
@@ -0,0 +1,20 @@
<script setup lang="ts">
const model = defineModel<string>({ required: true })
</script>
<template>
<div class="relative flex-1">
<span
class="material-symbols-outlined pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[18px] text-paper-dim"
style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20"
>
search
</span>
<input
v-model="model"
type="text"
placeholder="Suche nach Name, Namespace oder Key…"
class="h-10 w-full rounded border border-hairline bg-panel pl-9 pr-3 font-mono text-sm text-paper outline-none transition-colors placeholder:text-paper-dim/70 focus:border-brass/60"
/>
</div>
</template>
+161
View File
@@ -0,0 +1,161 @@
<script setup lang="ts">
import { ref, watch } from 'vue'
import { useClipboard } from '@vueuse/core'
import type { Secret } from '../types/Secret'
import { useMasterPassword } from '../composables/useMasterPassword'
import { decryptValue } from '../crypto/secretCrypto'
import { usePopup } from './popup/Popup'
import DeleteSecretPopup from './DeleteSecretPopup.vue'
import EditSecretPopup from './EditSecretPopup.vue'
const props = defineProps<{ secret: Secret }>()
const emit = defineEmits<{ deleted: []; updated: [] }>()
const { derivedKey } = useMasterPassword()
const { copy, copied } = useClipboard()
const decryptedValues = ref<Record<string, string>>({})
const revealed = ref<Record<string, boolean>>({})
const copiedKey = ref<string | null>(null)
function toggleReveal(key: string) {
revealed.value[key] = !revealed.value[key]
}
function copyValue(key: string) {
const value = decryptedValues.value[key]
if (value === undefined) {
return
}
copiedKey.value = key
copy(value)
}
function openDeletePopup() {
usePopup().open(DeleteSecretPopup, { secret: props.secret, onDeleted: () => emit('deleted') })
}
function openEditPopup() {
usePopup().open(EditSecretPopup, { secret: props.secret, onUpdated: () => emit('updated') })
}
watch(
() => props.secret,
(secret) => {
const key = derivedKey.value
if (!key) {
return
}
Promise.all(
secret.entries.map((entry) =>
decryptValue(key, entry.value)
.then((value) => [entry.key, value] as const)
.catch(() => [entry.key, '⚠️ falsches Master Password'] as const),
),
).then((pairs) => {
decryptedValues.value = Object.fromEntries(pairs)
})
},
{ immediate: true },
)
</script>
<template>
<details class="group rounded border border-hairline bg-panel transition-colors open:border-brass/40">
<summary class="flex cursor-pointer list-none items-center gap-3 px-4 py-3">
<span
class="material-symbols-outlined shrink-0 text-paper-dim transition-transform group-open:rotate-90"
style="font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20"
>
chevron_right
</span>
<div class="flex min-w-0 flex-1 items-center gap-2">
<h2 class="shrink truncate font-display text-lg font-bold leading-none tracking-widest text-paper">
{{ secret.name.toUpperCase() }}
</h2>
<span
v-if="secret.type !== 'Opaque'"
class="hidden shrink-0 rounded border border-verdigris/40 px-1.5 py-0.5 font-mono text-[11px] text-verdigris sm:inline"
:title="`Secret-Type: ${secret.type}`"
>
{{ secret.type }}
</span>
<span
class="hidden shrink-0 font-mono text-[13px] tracking-wide text-brass/70 sm:inline"
title="Secret-ID (gekürzt)"
>
#{{ secret.id.slice(0, 8) }}
</span>
</div>
<div class="flex shrink-0 items-center gap-1.5">
<span
v-for="namespace in secret.namespaces"
:key="namespace"
class="rounded border border-hairline px-2 py-0.5 font-mono text-sm text-paper-dim"
>
{{ namespace }}
</span>
<button
type="button"
class="flex h-8 w-8 shrink-0 items-center justify-center rounded text-paper-dim transition-colors hover:bg-panel-2 hover:text-paper"
@click.stop.prevent="openEditPopup"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20">
edit
</span>
</button>
<button
type="button"
class="flex h-8 w-8 shrink-0 items-center justify-center rounded text-paper-dim transition-colors hover:bg-panel-2 hover:text-rust"
@click.stop.prevent="openDeletePopup"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20">
delete
</span>
</button>
</div>
</summary>
<div class="space-y-2 border-t border-hairline px-4 py-3">
<div v-for="entry in secret.entries" :key="entry.key" class="flex items-baseline gap-2">
<span class="shrink-0 font-mono text-[14px] uppercase tracking-wide text-verdigris">{{ entry.key }}</span>
<span class="leader" />
<button
type="button"
class="flex max-w-xs shrink-0 items-center gap-1.5 font-mono text-[14px] text-paper transition-colors hover:text-brass"
@click="toggleReveal(entry.key)"
>
<span class="truncate">{{ revealed[entry.key] ? (decryptedValues[entry.key] ?? '…') : entry.value }}</span>
<span
class="material-symbols-outlined shrink-0 text-[1em] leading-none text-paper-dim"
style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20"
>
{{ revealed[entry.key] ? 'visibility_off' : 'visibility' }}
</span>
</button>
<button
type="button"
class="flex h-6 w-6 shrink-0 self-center items-center justify-center rounded text-paper-dim transition-colors hover:bg-panel-2 hover:text-brass"
title="In Zwischenablage kopieren"
@click="copyValue(entry.key)"
>
<span
class="material-symbols-outlined text-[1em] leading-none"
:class="copied && copiedKey === entry.key ? 'text-verdigris' : ''"
style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20"
>
{{ copied && copiedKey === entry.key ? 'check' : 'content_copy' }}
</span>
</button>
</div>
</div>
</details>
</template>
<style scoped>
.leader {
flex: 1 1 auto;
border-bottom: 1px dotted var(--color-hairline);
margin-bottom: 0.3rem;
min-width: 1rem;
}
</style>
+106
View File
@@ -0,0 +1,106 @@
<script setup lang="ts">
import NamespacePicker from './NamespacePicker.vue'
const name = defineModel<string>('name', { required: true })
const namespaces = defineModel<string[]>('namespaces', { required: true })
const entries = defineModel<{ key: string; value: string }[]>('entries', { required: true })
const type = defineModel<string>('type', { required: true })
const SECRET_TYPES = [
'Opaque',
'kubernetes.io/tls',
'kubernetes.io/dockerconfigjson',
'kubernetes.io/basic-auth',
'kubernetes.io/ssh-auth',
]
defineProps<{ submitLabel: string; submitting: boolean; errorMessage?: string | null }>()
const emit = defineEmits<{ submit: [] }>()
function addEntry() {
entries.value.push({ key: '', value: '' })
}
function removeEntry(index: number) {
entries.value.splice(index, 1)
}
</script>
<template>
<form class="space-y-4" @submit.prevent="emit('submit')">
<div>
<label class="mb-2 block font-sans text-xs font-bold tracking-[0.15em] text-paper-dim">NAME</label>
<input
v-model="name"
type="text"
required
class="w-full rounded border border-hairline bg-ink px-3 py-2 font-mono text-sm text-paper outline-none transition-colors focus:border-brass/60"
/>
</div>
<div>
<label class="mb-2 block font-sans text-xs font-bold tracking-[0.15em] text-paper-dim">NAMESPACES</label>
<NamespacePicker v-model="namespaces" />
</div>
<div>
<label class="mb-2 block font-sans text-xs font-bold tracking-[0.15em] text-paper-dim">TYPE</label>
<select
v-model="type"
class="w-full rounded border border-hairline bg-ink px-3 py-2 font-mono text-sm text-paper outline-none transition-colors focus:border-brass/60"
>
<option v-for="secretType in SECRET_TYPES" :key="secretType" :value="secretType">{{ secretType }}</option>
</select>
</div>
<div>
<label class="mb-2 block font-sans text-xs font-bold tracking-[0.15em] text-paper-dim">ENTRIES</label>
<div class="space-y-2">
<div v-for="(entry, index) in entries" :key="index" class="flex items-start gap-2">
<input
v-model="entry.key"
type="text"
placeholder="Key"
class="w-1/3 rounded border border-hairline bg-ink px-3 py-2 font-mono text-sm text-paper outline-none transition-colors placeholder:text-paper-dim/60 focus:border-brass/60"
@keydown.enter.prevent
/>
<textarea
v-model="entry.value"
placeholder="Value"
rows="1"
class="flex-1 resize-y rounded border border-hairline bg-ink px-3 py-2 font-mono text-sm text-paper outline-none transition-colors placeholder:text-paper-dim/60 focus:border-brass/60"
/>
<button
type="button"
class="flex h-9 w-9 shrink-0 items-center justify-center rounded text-paper-dim transition-colors hover:bg-panel-2 hover:text-rust"
@click="removeEntry(index)"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20">
close
</span>
</button>
</div>
</div>
<button
type="button"
class="mt-2 flex items-center gap-1 text-xs font-semibold text-verdigris transition-colors hover:text-brass"
@click="addEntry"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20">
add
</span>
Entry hinzufügen
</button>
</div>
<p v-if="errorMessage" class="text-sm text-rust">{{ errorMessage }}</p>
<button
type="submit"
:disabled="submitting"
class="w-full rounded bg-brass py-2.5 text-sm font-bold tracking-[0.08em] text-ink transition-colors hover:bg-brass-bright active:scale-[0.98] disabled:opacity-50 disabled:active:scale-100"
>
{{ submitLabel.toUpperCase() }}
</button>
</form>
</template>
+25
View File
@@ -0,0 +1,25 @@
<script setup lang="ts">
import type { Secret } from '../types/Secret'
import SecretCard from './SecretCard.vue'
defineProps<{ secrets: Secret[] }>()
const emit = defineEmits<{ deleted: []; updated: [] }>()
</script>
<template>
<div v-if="secrets.length" class="space-y-2">
<SecretCard
v-for="secret in secrets"
:key="secret.id"
:secret="secret"
@deleted="emit('deleted')"
@updated="emit('updated')"
/>
</div>
<div v-else class="flex flex-col items-center gap-2 rounded border border-dashed border-hairline py-16 text-paper-dim">
<span class="material-symbols-outlined text-[32px]" style="font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 40">
search_off
</span>
<p class="text-sm font-bold tracking-[0.1em]">DER TRESOR IST LEER</p>
</div>
</template>
+29
View File
@@ -0,0 +1,29 @@
import { shallowRef, type Component } from 'vue'
const component = shallowRef<Component | undefined>(undefined)
let payload: unknown = undefined
function disableScrolling() {
document.body.style.overflow = 'hidden'
}
function enableScrolling() {
document.body.style.overflow = 'visible'
}
export function usePopup() {
return {
get: () => component.value,
data: <T>() => payload as T,
open(newComponent: Component, newPayload?: unknown) {
component.value = newComponent
payload = newPayload
disableScrolling()
},
close() {
component.value = undefined
payload = undefined
enableScrolling()
},
}
}
@@ -0,0 +1,65 @@
<script setup lang="ts">
import { onMounted, onUnmounted } from 'vue'
import { usePopup } from './Popup'
defineProps<{
heading: string
size?: 'sm' | 'md'
}>()
function onKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') {
usePopup().close()
}
}
onMounted(() => document.addEventListener('keydown', onKeydown))
onUnmounted(() => document.removeEventListener('keydown', onKeydown))
</script>
<template>
<Transition
enter-active-class="transition duration-150 ease-out"
enter-from-class="opacity-0"
enter-to-class="opacity-100"
leave-active-class="transition duration-100 ease-in"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
appear
>
<div
class="fixed inset-0 z-50 flex items-center justify-center bg-ink/80 p-4"
@click="usePopup().close()"
>
<Transition
enter-active-class="transition duration-150 ease-out"
enter-from-class="opacity-0 scale-95"
enter-to-class="opacity-100 scale-100"
leave-active-class="transition duration-100 ease-in"
leave-from-class="opacity-100 scale-100"
leave-to-class="opacity-0 scale-95"
appear
>
<div
class="w-full rounded border border-hairline bg-panel p-5"
:class="size === 'sm' ? 'max-w-sm' : 'max-w-3xl'"
@click.stop
>
<div class="mb-4 flex items-center justify-between">
<h2 class="text-lg font-bold tracking-[0.04em] text-paper">{{ heading.toUpperCase() }}</h2>
<button
type="button"
class="flex h-7 w-7 items-center justify-center rounded text-paper-dim transition-colors hover:bg-panel-2 hover:text-paper"
@click="usePopup().close()"
>
<span class="material-symbols-outlined text-[1em] leading-none" style="font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20">
close
</span>
</button>
</div>
<slot />
</div>
</Transition>
</div>
</Transition>
</template>
@@ -0,0 +1,55 @@
import { ref, watch } from 'vue'
import { useIdle } from '@vueuse/core'
import { deriveKey } from '../crypto/secretCrypto'
const STORAGE_KEY = 'lockaway_master_password'
const IDLE_TIMEOUT_MS = 5 * 60 * 1000
const masterPassword = ref<string | null>(null)
const derivedKey = ref<CryptoKey | null>(null)
const isRestoring = ref(true)
const { idle } = useIdle(IDLE_TIMEOUT_MS)
watch(idle, (isIdle) => {
if (isIdle && masterPassword.value) {
lock()
}
})
function setUnlocked(password: string): Promise<void> {
return deriveKey(password).then((key) => {
derivedKey.value = key
masterPassword.value = password
})
}
function lock() {
masterPassword.value = null
derivedKey.value = null
sessionStorage.removeItem(STORAGE_KEY)
}
function restore() {
const password = sessionStorage.getItem(STORAGE_KEY)
if (password) {
setUnlocked(password).then(() => {
isRestoring.value = false
})
} else {
isRestoring.value = false
}
}
restore()
export function useMasterPassword() {
function unlock(password: string): Promise<void> {
return setUnlocked(password).then(() => {
sessionStorage.setItem(STORAGE_KEY, password)
})
}
return { masterPassword, derivedKey, isRestoring, unlock, lock }
}
+24
View File
@@ -0,0 +1,24 @@
import { onMounted, ref, watch } from 'vue'
import { getSecrets } from '../api/secrets'
import type { Secret } from '../types/Secret'
export function useSecrets() {
const secrets = ref<Secret[]>([])
const searchText = ref('')
function load() {
getSecrets(searchText.value).then((result) => {
secrets.value = result
})
}
let debounceTimeout: ReturnType<typeof setTimeout>
watch(searchText, () => {
clearTimeout(debounceTimeout)
debounceTimeout = setTimeout(load, 250)
})
onMounted(load)
return { secrets, searchText, load }
}
@@ -0,0 +1,44 @@
import { ref } from 'vue'
import { getVerificationValue, setVerificationValue } from '../api/verification'
import { decryptValue, deriveKey, encryptValue } from '../crypto/secretCrypto'
const VERIFICATION_PLAINTEXT = 'lockaway-verification-v1'
const needsSetup = ref<boolean | null>(null)
const storedValue = ref<string | null>(null)
function load(): Promise<void> {
return getVerificationValue().then((value) => {
storedValue.value = value
needsSetup.value = value === null
})
}
load()
export function useVerification() {
function setup(password: string): Promise<void> {
return deriveKey(password)
.then((key) => encryptValue(key, VERIFICATION_PLAINTEXT))
.then((encrypted) =>
setVerificationValue(encrypted).then(() => {
storedValue.value = encrypted
needsSetup.value = false
}),
)
}
function verify(password: string): Promise<boolean> {
const value = storedValue.value
if (!value) {
return Promise.resolve(false)
}
return deriveKey(password)
.then((key) => decryptValue(key, value))
.then((plaintext) => plaintext === VERIFICATION_PLAINTEXT)
.catch(() => false)
}
return { needsSetup, setup, verify }
}
+40
View File
@@ -0,0 +1,40 @@
const HKDF_INFO = 'lockaway-secret-encryption-v1'
function hmacSha256(keyBytes: Uint8Array, data: Uint8Array): Promise<Uint8Array> {
return crypto.subtle
.importKey('raw', keyBytes as BufferSource, { name: 'HMAC', hash: 'SHA-256' }, false, ['sign'])
.then((key) => crypto.subtle.sign('HMAC', key, data as BufferSource))
.then((signature) => new Uint8Array(signature))
}
export function deriveKey(masterPassword: string): Promise<CryptoKey> {
const encoder = new TextEncoder()
const salt = new Uint8Array(32)
return hmacSha256(salt, encoder.encode(masterPassword))
.then((prk) => hmacSha256(prk, new Uint8Array([...encoder.encode(HKDF_INFO), 1])))
.then((okm) => crypto.subtle.importKey('raw', okm.slice(0, 32), { name: 'AES-GCM' }, false, ['encrypt', 'decrypt']))
}
export function decryptValue(key: CryptoKey, base64: string): Promise<string> {
const raw = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))
const iv = raw.slice(0, 12)
const ciphertext = raw.slice(12)
return crypto.subtle
.decrypt({ name: 'AES-GCM', iv, tagLength: 128 }, key, ciphertext)
.then((plaintext) => new TextDecoder().decode(plaintext))
}
export function encryptValue(key: CryptoKey, value: string): Promise<string> {
const iv = crypto.getRandomValues(new Uint8Array(12))
return crypto.subtle
.encrypt({ name: 'AES-GCM', iv, tagLength: 128 }, key, new TextEncoder().encode(value))
.then((ciphertext) => {
const raw = new Uint8Array(iv.length + ciphertext.byteLength)
raw.set(iv, 0)
raw.set(new Uint8Array(ciphertext), iv.length)
return btoa(String.fromCharCode(...raw))
})
}
+1
View File
@@ -0,0 +1 @@
declare module '@fontsource-variable/big-shoulders-display/wght'
+11
View File
@@ -0,0 +1,11 @@
import { createApp } from 'vue'
import '@fontsource-variable/mulish/index.css'
import '@fontsource-variable/big-shoulders-display/wght'
import '@fontsource/ibm-plex-mono/400.css'
import '@fontsource/ibm-plex-mono/500.css'
import '@fontsource/ibm-plex-mono/600.css'
import 'material-symbols/outlined.css'
import './style.css'
import App from './App.vue'
createApp(App).mount('#app')
+42
View File
@@ -0,0 +1,42 @@
@import "tailwindcss";
@theme {
--font-sans: 'Mulish Variable', sans-serif;
--font-display: 'Big Shoulders Display Variable', sans-serif;
--font-mono: 'IBM Plex Mono', monospace;
--color-ink: #12151a;
--color-panel: #1a1e25;
--color-panel-2: #22262e;
--color-hairline: #333944;
--color-paper: #e9e4d8;
--color-paper-dim: #c5ab87;
--color-brass: #c6a15b;
--color-brass-bright: #e0c07e;
--color-rust: #b5533c;
--color-verdigris: #6e9b8c;
}
@layer base {
html {
font-size: 16px;
color-scheme: dark;
}
body {
@apply font-sans text-[color:var(--color-paper)];
font-weight: 500;
min-height: 100vh;
background: var(--color-ink);
}
::selection {
background: var(--color-brass);
color: var(--color-ink);
}
:focus-visible {
outline: 1.5px solid color-mix(in srgb, var(--color-brass) 55%, transparent);
outline-offset: 2px;
}
}
+4
View File
@@ -0,0 +1,4 @@
export interface Entry {
key: string
value: string
}
+10
View File
@@ -0,0 +1,10 @@
import type { Entry } from './Entry'
export interface Secret {
id: string
name: string
namespaces: string[]
contentHash: string
entries: Entry[]
type: string
}
+15
View File
@@ -0,0 +1,15 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"types": ["vite/client"],
"allowArbitraryExtensions": true,
/* Linting */
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
}
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "es2023",
"lib": ["ES2023"],
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"module": "nodenext",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
+19
View File
@@ -0,0 +1,19 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
const backendUrl = process.env.BACKEND_URL ?? 'http://localhost:8080'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue(), tailwindcss()],
server: {
proxy: {
'/api': {
target: backendUrl,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
})