From 2c0d7ec2250f3e4f4fde31fbda4b84913ee045bd Mon Sep 17 00:00:00 2001 From: AImighty Bot Date: Sun, 22 Nov 2026 14:20:34 +0000 Subject: [PATCH] Courier: Mail-Gateway mit Resend-API, Queue und SES-Transport --- .env.example | 25 + .github/workflows/ci.yml | 18 + .github/workflows/release.yml | 126 ++ .gitignore | 47 + Dockerfile | 39 + OlaresManifest.yaml | 167 ++ README.md | 67 + app/api/emails/[id]/route.ts | 41 + app/api/emails/batch/route.ts | 50 + app/api/emails/route.ts | 46 + app/api/health/route.ts | 22 + app/api/webhooks/ses/route.ts | 50 + app/favicon.ico | Bin 0 -> 25931 bytes app/globals.css | 378 ++++ app/keys/actions.ts | 45 + app/keys/key-form.tsx | 56 + app/keys/page.tsx | 95 + app/layout.tsx | 33 + app/messages/[id]/page.tsx | 109 ++ app/messages/page.tsx | 77 + app/page.module.css | 167 ++ app/page.tsx | 99 ++ db/migrations/0001_init.sql | 66 + icon.png | Bin 0 -> 11949 bytes icon.svg | 7 + lib/address.ts | 50 + lib/api-key.ts | 72 + lib/config.ts | 18 + lib/db.ts | 50 + lib/events.ts | 85 + lib/format.ts | 12 + lib/http.ts | 17 + lib/limits.ts | 25 + lib/queries.ts | 112 ++ lib/queue.ts | 144 ++ lib/schema.ts | 143 ++ lib/sns.ts | 94 + lib/transport.ts | 119 ++ next.config.ts | 14 + olares/Chart.yaml | 8 + olares/OlaresManifest.yaml | 167 ++ olares/templates/deployment-web.yaml | 98 ++ olares/templates/deployment-worker.yaml | 78 + olares/templates/secret.yaml | 12 + olares/templates/service.yaml | 14 + olares/values-olares-stub.yaml | 13 + olares/values.yaml | 28 + package-lock.json | 2122 +++++++++++++++++++++++ package.json | 35 + public/file.svg | 1 + public/globe.svg | 1 + public/next.svg | 1 + public/vercel.svg | 1 + public/window.svg | 1 + scripts/create-key.mjs | 40 + scripts/entrypoint.sh | 15 + scripts/migrate.mjs | 47 + scripts/ses-records.mjs | 25 + scripts/worker.ts | 81 + tsconfig.json | 27 + types/nodemailer-internals.d.ts | 12 + 61 files changed, 5612 insertions(+) create mode 100644 .env.example create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 OlaresManifest.yaml create mode 100644 README.md create mode 100644 app/api/emails/[id]/route.ts create mode 100644 app/api/emails/batch/route.ts create mode 100644 app/api/emails/route.ts create mode 100644 app/api/health/route.ts create mode 100644 app/api/webhooks/ses/route.ts create mode 100644 app/favicon.ico create mode 100644 app/globals.css create mode 100644 app/keys/actions.ts create mode 100644 app/keys/key-form.tsx create mode 100644 app/keys/page.tsx create mode 100644 app/layout.tsx create mode 100644 app/messages/[id]/page.tsx create mode 100644 app/messages/page.tsx create mode 100644 app/page.module.css create mode 100644 app/page.tsx create mode 100644 db/migrations/0001_init.sql create mode 100644 icon.png create mode 100644 icon.svg create mode 100644 lib/address.ts create mode 100644 lib/api-key.ts create mode 100644 lib/config.ts create mode 100644 lib/db.ts create mode 100644 lib/events.ts create mode 100644 lib/format.ts create mode 100644 lib/http.ts create mode 100644 lib/limits.ts create mode 100644 lib/queries.ts create mode 100644 lib/queue.ts create mode 100644 lib/schema.ts create mode 100644 lib/sns.ts create mode 100644 lib/transport.ts create mode 100644 next.config.ts create mode 100644 olares/Chart.yaml create mode 100644 olares/OlaresManifest.yaml create mode 100644 olares/templates/deployment-web.yaml create mode 100644 olares/templates/deployment-worker.yaml create mode 100644 olares/templates/secret.yaml create mode 100644 olares/templates/service.yaml create mode 100644 olares/values-olares-stub.yaml create mode 100644 olares/values.yaml create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 public/file.svg create mode 100644 public/globe.svg create mode 100644 public/next.svg create mode 100644 public/vercel.svg create mode 100644 public/window.svg create mode 100644 scripts/create-key.mjs create mode 100644 scripts/entrypoint.sh create mode 100644 scripts/migrate.mjs create mode 100644 scripts/ses-records.mjs create mode 100644 scripts/worker.ts create mode 100644 tsconfig.json create mode 100644 types/nodemailer-internals.d.ts diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..b4ba6ac --- /dev/null +++ b/.env.example @@ -0,0 +1,25 @@ +# Datenbank (lokal oder Olares-Middleware) +DATABASE_URL=postgresql://courier@127.0.0.1:55432/courier + +# dry-run | resend | ses +MAIL_TRANSPORT=dry-run + +MAIL_FROM_DOMAIN=hubsport.club +GLOBAL_DAILY_LIMIT=1000 + +# Amazon SES (eu-west-1) +AWS_REGION=eu-west-1 +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +SES_CONFIGURATION_SET=courier-transactional +SNS_TOPIC_ARN= +SNS_WEBHOOK_TOKEN= + +# API-Keys (HMAC-Pepper, lang und zufällig) +API_KEY_PEPPER=dev-only-pepper + +# Nur für den Übergang: Resend als Transport +RESEND_API_KEY= + +# Öffentliche Adresse (für SNS-Webhook/Anzeige) +PUBLIC_BASE_URL=http://127.0.0.1:3400 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9f515f1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: ci + +on: + push: + branches: [main] + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "22" + - run: npm ci + - run: npm run typecheck + - run: npm run build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9968602 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,126 @@ +name: release + +on: + workflow_dispatch: + inputs: + version: + description: "Version ohne v (muss olares/Chart.yaml entsprechen)" + required: true + default: "26.11.1" + +permissions: + contents: write + packages: write + +env: + GITEA_API: https://git.aimighty.olares.de/api/v1 + REGISTRY: git.aimighty.olares.de/aimighty + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Version prüfen + env: + V: ${{ inputs.version }} + run: | + CHART=$(awk '/^version:/{print $2}' olares/Chart.yaml | tr -d '"') + [ "$V" = "$CHART" ] || { echo "::error::Version $V != Chart.yaml $CHART"; exit 1; } + + - uses: actions/setup-node@v4 + with: + node-version: "22" + - run: npm ci + - run: npm run typecheck + - run: npm run build + + - name: install helm + run: | + for url in \ + "https://git.aimighty.olares.de/aimighty/ci-tools/releases/download/helm-3.16.2/helm-v3.16.2-linux-amd64.tar.gz" \ + "https://get.helm.sh/helm-v3.16.2-linux-amd64.tar.gz"; do + if curl -fsSL --retry 3 --retry-all-errors --max-time 180 -o /tmp/helm.tgz "$url" \ + && tar -tzf /tmp/helm.tgz >/dev/null 2>&1; then break; fi + done + tar -C /tmp -xzf /tmp/helm.tgz + install -m 0755 /tmp/linux-amd64/helm /usr/local/bin/helm + helm version --short + + - name: Chart prüfen und packen + env: + V: ${{ inputs.version }} + run: | + helm lint olares -f olares/values-olares-stub.yaml + mkdir -p dist + helm package olares -d dist + test -f "dist/courier-$V.tgz" + + - name: Docker-Daemon des Runners finden (dind am Bridge-Gateway) + run: | + read -r _ dest gw _ < <(awk '$2=="00000000" {print; exit}' /proc/net/route) + GW="$(printf "%d.%d.%d.%d" 0x${gw:6:2} 0x${gw:4:2} 0x${gw:2:2} 0x${gw:0:2})" + ok=0 + for KANDIDAT in "$GW" "172.17.0.1"; do + [ -n "$KANDIDAT" ] || continue + if DOCKER_HOST="tcp://$KANDIDAT:2375" docker version >/dev/null 2>&1; then + echo "DOCKER_HOST=tcp://$KANDIDAT:2375" >> "$GITHUB_ENV" + ok=1 + break + fi + done + [ "$ok" = "1" ] || { echo "::error::kein Docker-Daemon gefunden"; exit 1; } + + - uses: docker/setup-buildx-action@v3 + + - name: Login to Gitea registry + uses: docker/login-action@v3 + with: + registry: git.aimighty.olares.de + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Build & push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ env.REGISTRY }}/courier:${{ inputs.version }} + ${{ env.REGISTRY }}/courier:latest + + - uses: actions/upload-artifact@v4 + with: + name: chart + path: dist/courier-${{ inputs.version }}.tgz + + release: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + env: + V: ${{ inputs.version }} + steps: + - uses: actions/download-artifact@v4 + with: + name: chart + path: dist + + - name: Tag und Release anlegen + env: + GITEA_TOKEN: ${{ secrets.MARKT_TOKEN }} + run: | + NOTES="courier $V — Image ${REGISTRY}/courier:$V, Chart im Anhang." + BODY=$(python3 -c 'import json,sys; print(json.dumps({"tag_name":"v"+sys.argv[1],"target_commitish":sys.argv[2],"name":"v"+sys.argv[1],"body":sys.argv[3]}))' "$V" "${{ github.sha }}" "$NOTES") + RID=$(curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" \ + "$GITEA_API/repos/$GITHUB_REPOSITORY/releases" -d "$BODY" \ + | python3 -c "import sys,json; print(json.load(sys.stdin).get('id') or '')") + [ -n "$RID" ] || { echo "Release-Anlage fehlgeschlagen"; exit 1; } + curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" \ + -F "attachment=@dist/courier-$V.tgz" \ + "$GITEA_API/repos/$GITHUB_REPOSITORY/releases/$RID/assets?name=courier-$V.tgz" >/dev/null + echo "### v$V angelegt" >> "${GITHUB_STEP_SUMMARY:-/dev/null}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4952bd0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# env files (can opt-in for committing if needed) +.env* + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts + +# lokale Daten +.env +.env.local +!.env.example +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a37c8c3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +# syntax=docker/dockerfile:1 + +FROM node:22-alpine AS deps +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci --no-audit --no-fund + +FROM node:22-alpine AS build +WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN npm run build + +FROM node:22-alpine AS runner +WORKDIR /app +ENV NODE_ENV=production \ + NEXT_TELEMETRY_DISABLED=1 \ + PORT=3000 \ + HOSTNAME=0.0.0.0 \ + TZ=Europe/Berlin + +COPY --from=build /app/.next ./.next +COPY --from=build /app/node_modules ./node_modules +COPY --from=build /app/public ./public +COPY --from=build /app/package.json ./package.json +COPY --from=build /app/next.config.ts ./next.config.ts +COPY --from=build /app/tsconfig.json ./tsconfig.json +COPY --from=build /app/lib ./lib +COPY --from=build /app/scripts ./scripts +COPY --from=build /app/db ./db +COPY --from=build /app/types ./types + +RUN chmod +x ./scripts/entrypoint.sh + +USER node +EXPOSE 3000 + +ENTRYPOINT ["sh", "scripts/entrypoint.sh"] diff --git a/OlaresManifest.yaml b/OlaresManifest.yaml new file mode 100644 index 0000000..ad6fe48 --- /dev/null +++ b/OlaresManifest.yaml @@ -0,0 +1,167 @@ +olaresManifest.version: '0.12.0' +olaresManifest.type: app +apiVersion: 'v3' + +workloadReplicas: + courier: 1 + courier-worker: 1 + +metadata: + name: courier + appid: courier + title: Courier + description: Transaktionsmail für deine Apps über Amazon SES. + icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png + version: 26.11.1 + categories: + - Applications + +entrances: + - name: courier + host: courier + port: 3000 + title: Courier + icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png + authLevel: internal + invisible: false + openMethod: window + +middleware: + postgres: + username: courier + databases: + - name: courier + +envs: + - envName: AWS_ACCESS_KEY_ID + required: true + type: password + editable: false + applyOnChange: false + default: "" + description: "IAM-Zugang courier-ses (nur SES senden)." + - envName: AWS_SECRET_ACCESS_KEY + required: true + type: password + editable: false + applyOnChange: false + default: "" + description: "Secret zum IAM-Zugang courier-ses." + - envName: AWS_REGION + required: true + type: string + editable: false + applyOnChange: false + default: "eu-west-1" + - envName: API_KEY_PEPPER + required: true + type: password + editable: false + applyOnChange: false + default: "" + description: "Pepper für die Hashes der Courier-API-Keys." + - envName: SNS_WEBHOOK_TOKEN + required: true + type: password + editable: false + applyOnChange: false + default: "" + description: "Zufälliger Token im SNS-Webhook-Pfad." + - envName: SES_CONFIGURATION_SET + required: true + type: string + editable: false + applyOnChange: false + default: "courier-transactional" + - envName: SNS_TOPIC_ARN + required: true + type: string + editable: false + applyOnChange: false + default: "arn:aws:sns:eu-west-1:945831802901:courier-ses-events" + - envName: MAIL_FROM_DOMAIN + required: true + type: string + editable: true + applyOnChange: true + default: "hubsport.club" + - envName: MAIL_TRANSPORT + required: true + type: string + editable: true + applyOnChange: true + default: "ses" + options: + - title: Amazon SES + value: ses + - title: Resend (Übergang) + value: resend + - title: Dry-Run + value: dry-run + - envName: GLOBAL_DAILY_LIMIT + required: false + type: int + editable: true + applyOnChange: true + default: "1000" + +spec: + versionName: '26.11.1' + fullDescription: | + **Courier** ist ein kleiner Versanddienst für transaktionale E-Mails: + eine Resend-kompatible HTTP-API, Warteschlange, Retry, Logs und + Zustellereignisse. Der Versand läuft über Amazon SES. + + **Funktionen** + - `POST /api/emails` und `/api/emails/batch` (Resend-kompatibel) + - API-Keys pro App mit Domain- und Absenderbeschränkung + - Tages- und Monatslimits, Idempotency-Key + - Queue mit Retry und Backoff + - Bounce-/Complaint-Verarbeitung über SNS, Suppression-Liste + - Übersicht und Nachrichten-Detail im Web + + **Technik** + Next.js 15, PostgreSQL (Olares-Middleware), Amazon SES (eu-west-1). + developer: AImighty + website: https://git.aimighty.olares.de/aimighty/courier + sourceCode: https://git.aimighty.olares.de/aimighty/courier + submitter: AImighty + locale: + - de-DE + doc: https://git.aimighty.olares.de/aimighty/courier#readme + license: + - text: Proprietary + supportArch: + - amd64 + requiredCpu: 250m + requiredMemory: 512Mi + requiredDisk: 1Gi + limitedCpu: 1000m + limitedMemory: 1Gi + limitedDisk: 5Gi + +options: + policies: + - entranceName: courier + description: Mail-API für Apps + uriRegex: ^/api/(emails|health)(/.*)?(\?.*)?$ + level: public + oneTime: false + validDuration: 0s + - entranceName: courier + description: SES-Ereignisse von SNS + uriRegex: ^/api/webhooks/ses(/.*)?(\?.*)?$ + level: public + oneTime: false + validDuration: 0s + dependencies: + - name: olares + type: system + version: '>=1.12.6-0 <2.0.0' + allowMultipleInstall: false + allowedOutboundPorts: + - 443 + runAsUser: "1000" + appScope: + clusterScoped: false + apiTimeout: 30 diff --git a/README.md b/README.md new file mode 100644 index 0000000..1252ac5 --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# Courier + +Transaktionsmail-Gateway für die Apps auf Olares. Nimmt Mail per +Resend-kompatibler HTTP-API an, legt sie in eine Warteschlange und sendet über +Amazon SES. Absenderdomain: `hubsport.club`. + +## Status + +- API, Queue, Retry, API-Keys, Web-Übersicht und Worker stehen. +- Transport `dry-run` und `resend` sind eingebaut, `ses` ist implementiert. +- SES-Identity `hubsport.club` (eu-west-1) ist angelegt, DKIM/DNS noch offen. +- SES Production Access ist noch nicht freigegeben (Sandbox: 200/Tag). + +## Lokal + +```bash +cp .env.example .env +npm ci +npm run db:migrate +npm run db:key -- --app plan --name Plan +npm run dev # http://127.0.0.1:3400 +npm run worker # in einem zweiten Terminal +``` + +Ohne `MAIL_TRANSPORT=ses` landet jede Mail nur im Log (`dry-run`). + +## API + +```bash +curl -X POST http://127.0.0.1:3400/api/emails \ + -H "Authorization: Bearer ck_live_…" \ + -H "Content-Type: application/json" \ + -d '{ + "from": "plan ", + "to": "kunde@example.com", + "subject": "Test", + "html": "

Hallo

" + }' +``` + +Unterstützt: `from`, `to`, `cc`, `bcc`, `reply_to`, `subject`, `html`, `text`, +`headers`, `attachments`, `tags`, `Idempotency-Key`; dazu +`POST /api/emails/batch`, `GET /api/emails/:id` und `GET /api/health`. +Fehler kommen im Resend-Format (`statusCode`, `name`, `message`). + +## SES + +```bash +npm run ses:records +``` + +Gibt die Cloudflare-Records für DKIM, MAIL FROM und DMARC aus. Danach im +AWS-Console den Production Access beantragen (SES → Account dashboard). +Zustellereignisse kommen per SNS auf `/api/webhooks/ses?token=…`. + +## Olares + +Chart unter `olares/`. Werte für AWS und SNS kommen aus `.secrets.md` in +`olares/values.yaml` (nie committen). Prüfen: + +```bash +helm lint olares -f olares/values-olares-stub.yaml +helm template courier olares -f olares/values-olares-stub.yaml >/dev/null +``` + +Die öffentlichen Pfade sind auf die Mail-API, den Health-Check und den +SNS-Webhook begrenzt; die Oberfläche bleibt hinter Olares-Authelia. diff --git a/app/api/emails/[id]/route.ts b/app/api/emails/[id]/route.ts new file mode 100644 index 0000000..7a25594 --- /dev/null +++ b/app/api/emails/[id]/route.ts @@ -0,0 +1,41 @@ +import { authenticate } from "@/lib/api-key"; +import { query } from "@/lib/db"; +import { apiError, unauthorized } from "@/lib/http"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; + +export async function GET(request: Request, context: { params: Promise<{ id: string }> }) { + const key = await authenticate(request); + if (!key) return unauthorized(); + const { id } = await context.params; + + const { rows } = await query<{ + id: string; + status: string; + subject: string; + to_emails: string[]; + created_at: string; + sent_at: string | null; + completed_at: string | null; + error: string | null; + }>( + `select id, status, subject, to_emails, created_at, sent_at, completed_at, error + from messages + where id = $1 and api_key_id = $2`, + [id, key.id], + ); + const message = rows[0]; + if (!message) return apiError(404, "not_found", "Nachricht nicht gefunden"); + + return Response.json({ + id: message.id, + status: message.status, + subject: message.subject, + to: message.to_emails, + created_at: message.created_at, + sent_at: message.sent_at, + completed_at: message.completed_at, + error: message.error, + }); +} diff --git a/app/api/emails/batch/route.ts b/app/api/emails/batch/route.ts new file mode 100644 index 0000000..5a89cc6 --- /dev/null +++ b/app/api/emails/batch/route.ts @@ -0,0 +1,50 @@ +import { authenticate, fromAllowed } from "@/lib/api-key"; +import { apiError, serverError, unauthorized, validationError } from "@/lib/http"; +import { enqueue, QuotaExceededError, SuppressedError } from "@/lib/queue"; +import { batchSchema, normalizeMail } from "@/lib/schema"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; + +export async function POST(request: Request) { + const key = await authenticate(request); + if (!key) return unauthorized(); + + let body: unknown; + try { + body = await request.json(); + } catch { + return validationError("Ungültiges JSON"); + } + + const parsed = batchSchema.safeParse(body); + if (!parsed.success) { + return validationError(parsed.error.issues.map((issue) => issue.message).join("; ")); + } + + const ids: { id: string }[] = []; + for (const [index, item] of parsed.data.entries()) { + try { + const mail = normalizeMail(item, key.fromDomain); + if (!fromAllowed(key, mail.from.address)) { + return validationError(`Absender ${mail.from.address} ist für diesen Key nicht erlaubt (Index ${index})`); + } + const result = await enqueue(key, mail, null); + ids.push({ id: result.id }); + } catch (error) { + if (error instanceof QuotaExceededError) { + return apiError(429, "rate_limit_exceeded", error.message); + } + if (error instanceof SuppressedError) { + return apiError(422, "recipient_suppressed", `${error.message} (Index ${index})`); + } + if (error instanceof Error && error.name === "MailValidationError") { + return validationError(`${error.message} (Index ${index})`); + } + console.error("[courier] batch:", error); + return serverError(); + } + } + + return Response.json({ data: ids }); +} diff --git a/app/api/emails/route.ts b/app/api/emails/route.ts new file mode 100644 index 0000000..e15fe7c --- /dev/null +++ b/app/api/emails/route.ts @@ -0,0 +1,46 @@ +import { authenticate, fromAllowed } from "@/lib/api-key"; +import { normalizeMail, sendSchema } from "@/lib/schema"; +import { serverError, unauthorized, validationError } from "@/lib/http"; +import { enqueue, QuotaExceededError, SuppressedError } from "@/lib/queue"; +import { apiError } from "@/lib/http"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; + +export async function POST(request: Request) { + const key = await authenticate(request); + if (!key) return unauthorized(); + + let body: unknown; + try { + body = await request.json(); + } catch { + return validationError("Ungültiges JSON"); + } + + const parsed = sendSchema.safeParse(body); + if (!parsed.success) { + return validationError(parsed.error.issues.map((issue) => issue.message).join("; ")); + } + + try { + const mail = normalizeMail(parsed.data, key.fromDomain); + if (!fromAllowed(key, mail.from.address)) { + return validationError(`Absender ${mail.from.address} ist für diesen Key nicht erlaubt`); + } + const result = await enqueue(key, mail, request.headers.get("idempotency-key")); + return Response.json({ id: result.id }); + } catch (error) { + if (error instanceof QuotaExceededError) { + return apiError(429, "rate_limit_exceeded", error.message); + } + if (error instanceof SuppressedError) { + return apiError(422, "recipient_suppressed", error.message); + } + if (error instanceof Error && error.name === "MailValidationError") { + return validationError(error.message); + } + console.error("[courier] send:", error); + return serverError(); + } +} diff --git a/app/api/health/route.ts b/app/api/health/route.ts new file mode 100644 index 0000000..633fd69 --- /dev/null +++ b/app/api/health/route.ts @@ -0,0 +1,22 @@ +import { config } from "@/lib/config"; +import { query } from "@/lib/db"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; + +export async function GET() { + try { + await query("select 1"); + return Response.json({ + ok: true, + transport: config.transport, + fromDomain: config.fromDomain, + sesConfigured: Boolean(process.env.AWS_ACCESS_KEY_ID || process.env.AWS_PROFILE), + }); + } catch (error) { + return Response.json( + { ok: false, error: error instanceof Error ? error.message : "Datenbank nicht erreichbar" }, + { status: 503 }, + ); + } +} diff --git a/app/api/webhooks/ses/route.ts b/app/api/webhooks/ses/route.ts new file mode 100644 index 0000000..8932fa0 --- /dev/null +++ b/app/api/webhooks/ses/route.ts @@ -0,0 +1,50 @@ +import { safeEqual } from "@/lib/api-key"; +import { config } from "@/lib/config"; +import { handleSesNotification } from "@/lib/events"; +import { confirmSubscription, verifySns, type SnsEnvelope } from "@/lib/sns"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; + +export async function POST(request: Request) { + const token = new URL(request.url).searchParams.get("token") ?? ""; + if (config.snsWebhookToken && !safeEqual(token, config.snsWebhookToken)) { + return new Response("forbidden", { status: 403 }); + } + + let envelope: SnsEnvelope; + try { + envelope = (await request.json()) as SnsEnvelope; + } catch { + return new Response("invalid json", { status: 400 }); + } + + try { + await verifySns(envelope); + } catch (error) { + console.error("[courier] SNS:", error); + return new Response("invalid signature", { status: 403 }); + } + + if (envelope.Type === "SubscriptionConfirmation") { + try { + await confirmSubscription(envelope); + return new Response("confirmed", { status: 200 }); + } catch (error) { + console.error("[courier] SNS confirm:", error); + return new Response("confirmation failed", { status: 502 }); + } + } + + if (envelope.Type === "Notification") { + try { + await handleSesNotification(envelope.Message, envelope.MessageId); + return new Response("ok", { status: 200 }); + } catch (error) { + console.error("[courier] SNS event:", error); + return new Response("retry", { status: 500 }); + } + } + + return new Response("ok", { status: 200 }); +} diff --git a/app/favicon.ico b/app/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..718d6fea4835ec2d246af9800eddb7ffb276240c GIT binary patch literal 25931 zcmeHv30#a{`}aL_*G&7qml|y<+KVaDM2m#dVr!KsA!#An?kSQM(q<_dDNCpjEux83 zLb9Z^XxbDl(w>%i@8hT6>)&Gu{h#Oeyszu?xtw#Zb1mO{pgX9699l+Qppw7jXaYf~-84xW z)w4x8?=youko|}Vr~(D$UXIbiXABHh`p1?nn8Po~fxRJv}|0e(BPs|G`(TT%kKVJAdg5*Z|x0leQq0 zkdUBvb#>9F()jo|T~kx@OM8$9wzs~t2l;K=woNssA3l6|sx2r3+kdfVW@e^8e*E}v zA1y5{bRi+3Z`uD3{F7LgFJDdvm;nJilkzDku>BwXH(8ItVCXk*-lSJnR?-2UN%hJ){&rlvg`CDTj z)Bzo!3v7Ou#83zEDEFcKt(f1E0~=rqeEbTnMvWR#{+9pg%7G8y>u1OVRUSoox-ovF z2Ydma(;=YuBY(eI|04{hXzZD6_f(v~H;C~y5=DhAC{MMS>2fm~1H_t2$56pc$NH8( z5bH|<)71dV-_oCHIrzrT`2s-5w_+2CM0$95I6X8p^r!gHp+j_gd;9O<1~CEQQGS8) zS9Qh3#p&JM-G8rHekNmKVewU;pJRcTAog68KYo^dRo}(M>36U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Y>}W_uq7jGHx{mwE9fZiPCoxN$+7 zrODGGJrOkcPQUB(FD5aoS4g~7#6NR^ma7-!>mHuJfY5kTe6PpNNKC9GGRiu^L31uG z$7v`*JknQHsYB!Tm_W{a32TM099djW%5e+j0Ve_ct}IM>XLF1Ap+YvcrLV=|CKo6S zb+9Nl3_YdKP6%Cxy@6TxZ>;4&nTneadr z_ES90ydCev)LV!dN=#(*f}|ZORFdvkYBni^aLbUk>BajeWIOcmHP#8S)*2U~QKI%S zyrLmtPqb&TphJ;>yAxri#;{uyk`JJqODDw%(Z=2`1uc}br^V%>j!gS)D*q*f_-qf8&D;W1dJgQMlaH5er zN2U<%Smb7==vE}dDI8K7cKz!vs^73o9f>2sgiTzWcwY|BMYHH5%Vn7#kiw&eItCqa zIkR2~Q}>X=Ar8W|^Ms41Fm8o6IB2_j60eOeBB1Br!boW7JnoeX6Gs)?7rW0^5psc- zjS16yb>dFn>KPOF;imD}e!enuIniFzv}n$m2#gCCv4jM#ArwlzZ$7@9&XkFxZ4n!V zj3dyiwW4Ki2QG{@i>yuZXQizw_OkZI^-3otXC{!(lUpJF33gI60ak;Uqitp74|B6I zgg{b=Iz}WkhCGj1M=hu4#Aw173YxIVbISaoc z-nLZC*6Tgivd5V`K%GxhBsp@SUU60-rfc$=wb>zdJzXS&-5(NRRodFk;Kxk!S(O(a0e7oY=E( zAyS;Ow?6Q&XA+cnkCb{28_1N8H#?J!*$MmIwLq^*T_9-z^&UE@A(z9oGYtFy6EZef LrJugUA?W`A8`#=m literal 0 HcmV?d00001 diff --git a/app/globals.css b/app/globals.css new file mode 100644 index 0000000..e1cc9bc --- /dev/null +++ b/app/globals.css @@ -0,0 +1,378 @@ +:root { + --am-blau: #051729; + --am-blau-hell: #102b45; + --am-gold: #caa960; + --am-gold-hell: #e5cf9f; + --am-text: #12202e; + --am-muted: #5b6b7a; + --am-flaeche: #f5f7f9; + --am-karte: #ffffff; + --am-rand: #d9e0e6; + --am-gruen: #1f6f4a; + --am-rot: #9b2c2c; + --am-orange: #8a5a00; + --am-radius: 8px; + --am-space: 4px; + --am-font: var(--font-geist-sans), system-ui, sans-serif; + --am-mono: var(--font-geist-mono), ui-monospace, monospace; +} + +* { + box-sizing: border-box; +} + +html, +body { + margin: 0; + padding: 0; +} + +body { + background: var(--am-flaeche); + color: var(--am-text); + font-family: var(--am-font); + font-size: 15px; + line-height: 1.55; +} + +a { + color: var(--am-blau); + text-decoration-color: var(--am-gold); + text-underline-offset: 3px; +} + +a:hover { + text-decoration-thickness: 2px; +} + +h1, +h2, +h3 { + color: var(--am-blau); + line-height: 1.2; + margin: 0 0 calc(var(--am-space) * 4); +} + +h1 { + font-size: 28px; +} + +h2 { + font-size: 20px; +} + +p { + margin: 0 0 calc(var(--am-space) * 4); +} + +code, +.mono { + font-family: var(--am-mono); + font-size: 13px; +} + +.kopf { + background: var(--am-blau); + color: #fff; + border-bottom: 4px solid var(--am-gold); +} + +.kopf-inhalt { + max-width: 1180px; + margin: 0 auto; + padding: 16px 24px; + display: flex; + align-items: center; + gap: 28px; + flex-wrap: wrap; +} + +.marke { + color: #fff; + font-size: 20px; + font-weight: 700; + letter-spacing: 0.02em; + text-decoration: none; + display: inline-flex; + align-items: center; + gap: 10px; +} + +.marke::before { + content: ""; + width: 10px; + height: 24px; + background: var(--am-gold); + display: inline-block; +} + +.nav { + display: flex; + gap: 4px; + flex-wrap: wrap; +} + +.nav a { + color: #e8eef3; + text-decoration: none; + padding: 10px 14px; + border-radius: var(--am-radius); + min-height: 44px; + display: inline-flex; + align-items: center; +} + +.nav a:hover, +.nav a[aria-current="page"] { + background: var(--am-blau-hell); + color: #fff; +} + +.inhalt { + max-width: 1180px; + margin: 0 auto; + padding: 32px 24px 64px; +} + +.lead { + color: var(--am-muted); + max-width: 70ch; +} + +.karten { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); + gap: 16px; + margin-bottom: 32px; +} + +.karte { + background: var(--am-karte); + border: 1px solid var(--am-rand); + border-radius: var(--am-radius); + padding: 20px; +} + +.karte .zahl { + font-family: var(--am-mono); + font-size: 30px; + color: var(--am-blau); + display: block; + margin-bottom: 4px; +} + +.karte .label { + color: var(--am-muted); + font-size: 13px; + text-transform: uppercase; + letter-spacing: 0.06em; +} + +.abschnitt { + background: var(--am-karte); + border: 1px solid var(--am-rand); + border-radius: var(--am-radius); + padding: 24px; + margin-bottom: 24px; +} + +.abschnitt-kopf { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16px; + flex-wrap: wrap; + margin-bottom: 16px; +} + +.abschnitt-kopf h2 { + margin: 0; +} + +.tabelle { + width: 100%; + border-collapse: collapse; +} + +.tabelle th, +.tabelle td { + text-align: left; + padding: 12px 10px; + border-bottom: 1px solid var(--am-rand); + vertical-align: top; +} + +.tabelle th { + font-size: 12px; + text-transform: uppercase; + letter-spacing: 0.06em; + color: var(--am-muted); + font-weight: 600; +} + +.tabelle tr:last-child td { + border-bottom: none; +} + +.status { + display: inline-block; + padding: 2px 8px; + border-radius: 999px; + border: 1px solid currentColor; + font-size: 12px; + font-weight: 600; +} + +.status-queued, +.status-sending { + color: var(--am-orange); +} + +.status-sent, +.status-delivered { + color: var(--am-gruen); +} + +.status-failed, +.status-bounced, +.status-complained { + color: var(--am-rot); +} + +.knopf { + display: inline-flex; + align-items: center; + justify-content: center; + min-height: 44px; + padding: 10px 18px; + border-radius: var(--am-radius); + border: 1px solid var(--am-gold); + background: var(--am-gold); + color: var(--am-blau); + font: inherit; + font-weight: 650; + cursor: pointer; + text-decoration: none; +} + +.knopf:hover { + background: var(--am-gold-hell); +} + +.knopf-sekundaer { + background: transparent; + color: var(--am-blau); + border-color: var(--am-rand); +} + +.knopf-gefahr { + background: transparent; + color: var(--am-rot); + border-color: var(--am-rot); +} + +.knopf:focus-visible, +.nav a:focus-visible, +input:focus-visible, +select:focus-visible, +textarea:focus-visible { + outline: 3px solid var(--am-gold); + outline-offset: 2px; +} + +.formular { + display: grid; + gap: 14px; + max-width: 620px; +} + +.feld { + display: grid; + gap: 6px; +} + +.feld label { + font-weight: 600; + font-size: 14px; +} + +.feld input, +.feld select, +.feld textarea { + font: inherit; + padding: 10px 12px; + min-height: 44px; + border: 1px solid var(--am-rand); + border-radius: var(--am-radius); + background: #fff; + color: var(--am-text); +} + +.feld .hinweis { + color: var(--am-muted); + font-size: 13px; +} + +.zeile { + display: flex; + gap: 12px; + align-items: center; + flex-wrap: wrap; +} + +.hinweis { + color: var(--am-muted); +} + +.fehler { + color: var(--am-rot); + font-weight: 600; +} + +.erfolg { + color: var(--am-gruen); + font-weight: 600; +} + +.schluessel { + display: block; + padding: 12px; + background: #fff8e6; + border: 1px solid var(--am-gold); + border-radius: var(--am-radius); + word-break: break-all; +} + +.leer { + color: var(--am-muted); + padding: 24px 0; +} + +details { + border-top: 1px solid var(--am-rand); + padding-top: 12px; + margin-top: 12px; +} + +summary { + cursor: pointer; + min-height: 44px; + display: flex; + align-items: center; + font-weight: 600; +} + +@media (max-width: 640px) { + .inhalt { + padding: 24px 16px 48px; + } + + .tabelle { + display: block; + overflow-x: auto; + } + + h1 { + font-size: 24px; + } +} diff --git a/app/keys/actions.ts b/app/keys/actions.ts new file mode 100644 index 0000000..c7ca033 --- /dev/null +++ b/app/keys/actions.ts @@ -0,0 +1,45 @@ +"use server"; + +import { revalidatePath } from "next/cache"; + +import { generateKey, hashKey, keyPrefix } from "@/lib/api-key"; +import { query } from "@/lib/db"; + +export type KeyState = { key?: string; error?: string }; + +export async function createKey(_previous: KeyState, formData: FormData): Promise { + const app = String(formData.get("app") ?? "").trim().toLowerCase(); + const name = String(formData.get("name") ?? "").trim(); + const domain = String(formData.get("domain") ?? "hubsport.club").trim().toLowerCase(); + const from = String(formData.get("from") ?? "").trim().toLowerCase(); + const daily = Number(formData.get("daily") ?? 500); + const monthly = Number(formData.get("monthly") ?? 15000); + + if (!/^[a-z0-9][a-z0-9_-]{1,30}$/.test(app)) return { error: "App-Name: 2–31 Zeichen, a–z, 0–9, _ oder -" }; + if (!name) return { error: "Bezeichnung fehlt" }; + if (!/^[a-z0-9.-]+\.[a-z]{2,}$/.test(domain)) return { error: "Ungültige Domain" }; + if (!Number.isInteger(daily) || daily < 1 || daily > 100000) return { error: "Tageslimit ungültig" }; + if (!Number.isInteger(monthly) || monthly < 1 || monthly > 1000000) return { error: "Monatslimit ungültig" }; + if (from && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(from)) return { error: "Ungültige Absenderadresse" }; + + const key = generateKey(); + try { + await query( + `insert into api_keys (app, name, prefix, key_hash, from_domain, allowed_from, daily_limit, monthly_limit) + values ($1,$2,$3,$4,$5,$6,$7,$8)`, + [app, name, keyPrefix(key), hashKey(key), domain, from ? [from] : null, daily, monthly], + ); + } catch (error) { + return { error: error instanceof Error ? error.message : "Key konnte nicht gespeichert werden" }; + } + + revalidatePath("/keys"); + return { key }; +} + +export async function revokeKey(formData: FormData): Promise { + const id = String(formData.get("id") ?? ""); + if (!id) return; + await query(`update api_keys set revoked_at = now() where id = $1 and revoked_at is null`, [id]); + revalidatePath("/keys"); +} diff --git a/app/keys/key-form.tsx b/app/keys/key-form.tsx new file mode 100644 index 0000000..65e9206 --- /dev/null +++ b/app/keys/key-form.tsx @@ -0,0 +1,56 @@ +"use client"; + +import { useActionState } from "react"; + +import { createKey, type KeyState } from "./actions"; + +export function KeyForm() { + const [state, action, pending] = useActionState(createKey, {}); + + return ( + <> +
+
+ + + Technischer Name, z. B. plan, lunch oder places. +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ +
+
+ + {state.error ?

{state.error}

: null} + {state.key ? ( +
+

Key erzeugt. Er wird nur jetzt angezeigt:

+ {state.key} +
+ ) : null} + + ); +} diff --git a/app/keys/page.tsx b/app/keys/page.tsx new file mode 100644 index 0000000..28c6d04 --- /dev/null +++ b/app/keys/page.tsx @@ -0,0 +1,95 @@ +import { datum } from "@/lib/format"; +import { listApiKeys } from "@/lib/queries"; + +import { KeyForm } from "./key-form"; +import { revokeKey } from "./actions"; + +export const dynamic = "force-dynamic"; + +export default async function Keys() { + let keys: Awaited> = []; + let error = ""; + try { + keys = await listApiKeys(); + } catch (cause) { + error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar"; + } + + return ( + <> +

API-Keys

+

+ Jede App bekommt einen eigenen Key. Der Key gilt nur für die eingetragene Absenderdomain und + wird nur gehasht gespeichert. +

+ + {error ?

Datenbank nicht erreichbar: {error}

: null} + +
+

Neuen Key erzeugen

+ +
+ +
+

Vorhandene Keys

+ {keys.length ? ( + + + + + + + + + + + + + + {keys.map((key) => ( + + + + + + + + + + + ))} + +
AppBezeichnungPrefixDomainLimitZuletztStatus +
{key.app}{key.name}{key.prefix}…{key.from_domain} + {key.daily_limit}/Tag · {key.monthly_limit}/Monat + {datum(key.last_used_at)}{key.revoked_at ? gesperrt : aktiv} + {key.revoked_at ? null : ( +
+ + +
+ )} +
+ ) : ( +

Noch keine Keys.

+ )} +
+ +
+

Verwendung

+

Die API ist weitgehend Resend-kompatibel:

+
{`curl -X POST https://courier.hubsport.club/api/emails \\
+  -H "Authorization: Bearer ck_live_…" \\
+  -H "Content-Type: application/json" \\
+  -d '{
+    "from": "plan ",
+    "to": "kunde@example.com",
+    "subject": "Test",
+    "html": "

Hallo

" + }'`}
+
+ + ); +} diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 0000000..317a2e6 --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,33 @@ +import type { Metadata } from "next"; +import { GeistMono } from "geist/font/mono"; +import { GeistSans } from "geist/font/sans"; + +import "./globals.css"; + +export const metadata: Metadata = { + title: "Courier", + description: "Transaktionsmail für hubsport.club", + robots: { index: false, follow: false }, +}; + +export default function RootLayout({ children }: { children: React.ReactNode }) { + return ( + + +
+ +
+
{children}
+ + + ); +} diff --git a/app/messages/[id]/page.tsx b/app/messages/[id]/page.tsx new file mode 100644 index 0000000..ca88ef0 --- /dev/null +++ b/app/messages/[id]/page.tsx @@ -0,0 +1,109 @@ +import { notFound } from "next/navigation"; + +import { datum } from "@/lib/format"; +import { messageDetail } from "@/lib/queries"; + +export const dynamic = "force-dynamic"; + +export default async function Nachricht({ params }: { params: Promise<{ id: string }> }) { + const { id } = await params; + const detail = await messageDetail(id).catch(() => null); + if (!detail) notFound(); + const { message, events } = detail; + + return ( + <> +

+ ← Nachrichten +

+

{message.subject}

+

+ {message.status}{" "} + {message.id} +

+ +
+

Kopf

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {message.error ? ( + + + + + ) : null} + +
App{message.app}
Von{message.from_name ? `${message.from_name} <${message.from_email}>` : message.from_email}
An{message.to_emails.join(", ")}
CC / BCC + {message.cc_emails.join(", ") || "–"} / {message.bcc_emails.join(", ") || "–"} +
SES-ID{message.provider_message_id || "–"}
Erstellt{datum(message.created_at)}
Gesendet{datum(message.sent_at)}
Abgeschlossen{datum(message.completed_at)}
Versuche{message.attempts}
Fehler{message.error}
+
+ +
+

Events

+ {events.length ? ( + + + + + + + + + + {events.map((event) => ( + + + + + + ))} + +
ZeitTypDetails
{datum(event.created_at)}{event.type} +
+ JSON +
{JSON.stringify(event.payload, null, 2)}
+
+
+ ) : ( +

Noch keine Zustellereignisse.

+ )} +
+ + ); +} diff --git a/app/messages/page.tsx b/app/messages/page.tsx new file mode 100644 index 0000000..fabbf74 --- /dev/null +++ b/app/messages/page.tsx @@ -0,0 +1,77 @@ +import { datum, kurz } from "@/lib/format"; +import { listMessages } from "@/lib/queries"; + +export const dynamic = "force-dynamic"; + +const STATUS = ["queued", "sending", "sent", "delivered", "bounced", "complained", "failed"]; + +export default async function Nachrichten({ + searchParams, +}: { + searchParams: Promise<{ status?: string }>; +}) { + const { status } = await searchParams; + let messages: Awaited> = []; + let error = ""; + try { + messages = await listMessages(status); + } catch (cause) { + error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar"; + } + + return ( + <> +

Nachrichten

+

Die letzten 100 Mails, neueste zuerst.

+ +
+ + Alle + + {STATUS.map((value) => ( + + {value} + + ))} +
+ + {error ? ( +

Datenbank nicht erreichbar: {error}

+ ) : messages.length ? ( +
+ + + + + + + + + + + + + {messages.map((message) => ( + + + + + + + + + ))} + +
ZeitAppEmpfängerBetreffVersucheStatus
{datum(message.created_at)}{message.app}{message.to_emails.join(", ")} + {kurz(message.subject, 70)} + {message.error ?
{kurz(message.error, 80)}
: null} +
{message.attempts} + {message.status} +
+
+ ) : ( +

Keine Nachrichten in dieser Ansicht.

+ )} + + ); +} diff --git a/app/page.module.css b/app/page.module.css new file mode 100644 index 0000000..58c71af --- /dev/null +++ b/app/page.module.css @@ -0,0 +1,167 @@ +.page { + --gray-rgb: 0, 0, 0; + --gray-alpha-200: rgba(var(--gray-rgb), 0.08); + --gray-alpha-100: rgba(var(--gray-rgb), 0.05); + + --button-primary-hover: #383838; + --button-secondary-hover: #f2f2f2; + + display: grid; + grid-template-rows: 20px 1fr 20px; + align-items: center; + justify-items: center; + min-height: 100svh; + padding: 80px; + gap: 64px; + font-family: var(--font-geist-sans); +} + +@media (prefers-color-scheme: dark) { + .page { + --gray-rgb: 255, 255, 255; + --gray-alpha-200: rgba(var(--gray-rgb), 0.145); + --gray-alpha-100: rgba(var(--gray-rgb), 0.06); + + --button-primary-hover: #ccc; + --button-secondary-hover: #1a1a1a; + } +} + +.main { + display: flex; + flex-direction: column; + gap: 32px; + grid-row-start: 2; +} + +.main ol { + font-family: var(--font-geist-mono); + padding-left: 0; + margin: 0; + font-size: 14px; + line-height: 24px; + letter-spacing: -0.01em; + list-style-position: inside; +} + +.main li:not(:last-of-type) { + margin-bottom: 8px; +} + +.main code { + font-family: inherit; + background: var(--gray-alpha-100); + padding: 2px 4px; + border-radius: 4px; + font-weight: 600; +} + +.ctas { + display: flex; + gap: 16px; +} + +.ctas a { + appearance: none; + border-radius: 128px; + height: 48px; + padding: 0 20px; + border: 1px solid transparent; + transition: + background 0.2s, + color 0.2s, + border-color 0.2s; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + font-size: 16px; + line-height: 20px; + font-weight: 500; +} + +a.primary { + background: var(--foreground); + color: var(--background); + gap: 8px; +} + +a.secondary { + border-color: var(--gray-alpha-200); + min-width: 158px; +} + +.footer { + grid-row-start: 3; + display: flex; + gap: 24px; +} + +.footer a { + display: flex; + align-items: center; + gap: 8px; +} + +.footer img { + flex-shrink: 0; +} + +/* Enable hover only on non-touch devices */ +@media (hover: hover) and (pointer: fine) { + a.primary:hover { + background: var(--button-primary-hover); + border-color: transparent; + } + + a.secondary:hover { + background: var(--button-secondary-hover); + border-color: transparent; + } + + .footer a:hover { + text-decoration: underline; + text-underline-offset: 4px; + } +} + +@media (max-width: 600px) { + .page { + padding: 32px; + padding-bottom: 80px; + } + + .main { + align-items: center; + } + + .main ol { + text-align: center; + } + + .ctas { + flex-direction: column; + } + + .ctas a { + font-size: 14px; + height: 40px; + padding: 0 16px; + } + + a.secondary { + min-width: auto; + } + + .footer { + flex-wrap: wrap; + align-items: center; + justify-content: center; + } +} + +@media (prefers-color-scheme: dark) { + .logo { + filter: invert(); + } +} diff --git a/app/page.tsx b/app/page.tsx new file mode 100644 index 0000000..e542920 --- /dev/null +++ b/app/page.tsx @@ -0,0 +1,99 @@ +import { config } from "@/lib/config"; +import { datum, kurz } from "@/lib/format"; +import { dashboardStats } from "@/lib/queries"; + +export const dynamic = "force-dynamic"; + +export default async function Startseite() { + let stats: Awaited> | null = null; + let error = ""; + try { + stats = await dashboardStats(); + } catch (cause) { + error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar"; + } + + return ( + <> +

Übersicht

+

+ Courier nimmt Mails von deinen Apps an, legt sie in eine Warteschlange und übergibt sie an + Amazon SES. Absenderdomain: {config.fromDomain}, Transport:{" "} + {config.transport}. +

+ + {error ? ( +
+

Einrichtung fehlt

+

Datenbank nicht erreichbar: {error}

+

+ Migration ausführen: npm run db:migrate, danach einen Key erzeugen:{" "} + npm run db:key -- --app plan --name Plan. +

+
+ ) : ( + <> +
+
+ {stats?.counts.queued ?? 0} + in Warteschlange +
+
+ {(stats?.counts.sent ?? 0) + (stats?.counts.delivered ?? 0)} + gesendet / zugestellt (24 h) +
+
+ + {(stats?.counts.failed ?? 0) + (stats?.counts.bounced ?? 0) + (stats?.counts.complained ?? 0)} + + Fehler (24 h) +
+
+ {stats?.suppressed ?? 0} + gesperrte Empfänger +
+
+ +
+
+

Letzte Nachrichten

+ + Alle ansehen + +
+ {stats?.recent.length ? ( + + + + + + + + + + + + {stats.recent.map((message) => ( + + + + + + + + ))} + +
ZeitAppEmpfängerBetreffStatus
{datum(message.created_at)}{message.app}{message.to_emails.join(", ")} + {kurz(message.subject, 60)} + + {message.status} +
+ ) : ( +

Noch keine Nachrichten.

+ )} +
+ + )} + + ); +} diff --git a/db/migrations/0001_init.sql b/db/migrations/0001_init.sql new file mode 100644 index 0000000..1d21e4c --- /dev/null +++ b/db/migrations/0001_init.sql @@ -0,0 +1,66 @@ +create extension if not exists pgcrypto; + +create table if not exists api_keys ( + id uuid primary key default gen_random_uuid(), + app text not null, + name text not null, + prefix text not null, + key_hash text not null unique, + from_domain text not null default 'hubsport.club', + allowed_from text[], + daily_limit integer not null default 500, + monthly_limit integer not null default 15000, + revoked_at timestamptz, + last_used_at timestamptz, + created_at timestamptz not null default now() +); + +create table if not exists messages ( + id uuid primary key default gen_random_uuid(), + api_key_id uuid references api_keys(id) on delete set null, + app text not null, + provider_message_id text, + from_email text not null, + from_name text, + to_emails text[] not null default '{}', + cc_emails text[] not null default '{}', + bcc_emails text[] not null default '{}', + reply_to text[] not null default '{}', + subject text not null, + status text not null default 'queued', + error text, + payload jsonb not null, + idempotency_key text, + attempts integer not null default 0, + next_attempt_at timestamptz not null default now(), + created_at timestamptz not null default now(), + sent_at timestamptz, + completed_at timestamptz +); + +create index if not exists messages_queue_idx + on messages (next_attempt_at) + where status = 'queued'; + +create index if not exists messages_created_idx on messages (created_at desc); +create index if not exists messages_key_created_idx on messages (api_key_id, created_at desc); +create index if not exists messages_provider_idx on messages (provider_message_id); +create unique index if not exists messages_idempotency_idx + on messages (api_key_id, idempotency_key); + +create table if not exists message_events ( + id bigserial primary key, + message_id uuid references messages(id) on delete cascade, + sns_message_id text unique, + type text not null, + payload jsonb not null, + created_at timestamptz not null default now() +); + +create index if not exists message_events_message_idx on message_events (message_id, created_at); + +create table if not exists suppressions ( + email text primary key, + reason text not null, + created_at timestamptz not null default now() +); diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..44ed356417e56f7f1153d6288d47bdd9411a14ad GIT binary patch literal 11949 zcmeHtS5#A7+wD&1ML`S*N-rWEK}AG5NG}3{0R$8xAiZ}IM35pKf^?BC(n9Yj(xnSX zmlAqWnj}CtoA>*^|38;!jB{}={&SU#WMyUTr_MQ_6|SqTa*6UfB>(`I)Kr!9000WU zg#zRkFMih*O8|ftP*ajO@J`>F_3=-{Hvj!&SEG54P64f^s!D51j(KPx&|Ny7Cu~4$ zuj4oM$-vY%*SBiXCnImw1D&}~*YV;{p-1-Ak-f5V43$T~&nKVz+Aninudz~4=vEl- z`M$5Q@`FyZbh$-5;rsVPpH{ri!e#B!O|RK`ztZ{d0gcive<%S9)&eNN7!Dpu@d^M~ z+yW0rtqcIDY;ph)g+TxyloJ5jbcq3gG2;I(`oA`Tt3bOwuH#Np*h|8(Gznn%`||&( zy|KTKI|Trgk2l%>XrIhb8h+1A^cYV3TuG@XK04Dr`f!e$4#uc1Po#4qc7w9(t7W*6hv0Rukz91OS)9TN1dBWzjz|#WfZ6irKuxa)VZ*=fhIGu$7zO*8<}G;%<85 zyR}bhNfao}zrKCy`^)tKYn{hTH**=3c9pU+A$eYpKhk(X!<%daDyd4J$!Ypw>pAF1b7#52E_kRDumx$db5xQmwvj$(hrgewNP z;A!~gr~pNN7=HBnLkEW=?w+M|<4!N%hUfa9)7Dq1Cr(Qejg11%D!Q3BmWVF>m8r;5?O6U1j>4(^_vH^d94dvaMn`(7IwEQAhVl_m+Q*pBRxa?myJcM8 z-X7qUfVGeZvinX5>jL)aljYeeVw7q;2~V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}b7p#&9IC*GXs3+uoAN&MRQ`S~0Rj_#dzW_6ya>)Py literal 0 HcmV?d00001 diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..8062e03 --- /dev/null +++ b/icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/lib/address.ts b/lib/address.ts new file mode 100644 index 0000000..cfce4ac --- /dev/null +++ b/lib/address.ts @@ -0,0 +1,50 @@ +import addressparser from "nodemailer/lib/addressparser"; + +export type Mailbox = { address: string; name?: string }; + +const EMAIL = /^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/; + +export function validEmail(value: string): boolean { + return EMAIL.test(value.trim()); +} + +export function parseMailbox(input: string): Mailbox | null { + const parsed = addressparser(input.trim()); + if (parsed.length !== 1) return null; + const address = parsed[0]?.address?.trim().toLowerCase(); + if (!address || !validEmail(address)) return null; + const name = parsed[0]?.name?.replace(/[\r\n]+/g, " ").trim(); + return name ? { address, name } : { address }; +} + +export function parseMailboxList(input: string | string[] | undefined): Mailbox[] { + if (!input) return []; + const values = Array.isArray(input) ? input : [input]; + const result: Mailbox[] = []; + for (const value of values) { + const parsed = addressparser(value); + for (const item of parsed) { + const address = item.address?.trim().toLowerCase(); + if (!address || !validEmail(address)) { + throw new Error(`Ungültige E-Mail-Adresse: ${item.address || value}`); + } + const name = item.name?.replace(/[\r\n]+/g, " ").trim(); + result.push(name ? { address, name } : { address }); + } + } + return result; +} + +export function domainOf(address: string): string { + return address.split("@")[1]?.toLowerCase() ?? ""; +} + +export function formatMailbox(mailbox: Mailbox): string { + if (!mailbox.name) return mailbox.address; + const name = mailbox.name.replace(/["\\]/g, "").replace(/[\r\n]+/g, " "); + return `"${name}" <${mailbox.address}>`; +} + +export function addressesOf(list: Mailbox[]): string[] { + return list.map((item) => item.address); +} diff --git a/lib/api-key.ts b/lib/api-key.ts new file mode 100644 index 0000000..2b3e4b6 --- /dev/null +++ b/lib/api-key.ts @@ -0,0 +1,72 @@ + +import { createHmac, randomBytes, timingSafeEqual } from "node:crypto"; + +import { config } from "./config"; +import { query } from "./db"; + +export type ApiKey = { + id: string; + app: string; + fromDomain: string; + allowedFrom: string[] | null; + dailyLimit: number; + monthlyLimit: number; +}; + +type KeyRow = { + id: string; + app: string; + from_domain: string; + allowed_from: string[] | null; + daily_limit: number; + monthly_limit: number; +}; + +export function hashKey(key: string): string { + return createHmac("sha256", config.apiKeyPepper).update(key).digest("hex"); +} + +export function generateKey(): string { + return `ck_live_${randomBytes(24).toString("base64url")}`; +} + +export function keyPrefix(key: string): string { + return key.slice(0, 16); +} + +export function safeEqual(a: string, b: string): boolean { + const left = Buffer.from(a); + const right = Buffer.from(b); + return left.length === right.length && timingSafeEqual(left, right); +} + +export async function authenticate(request: Request): Promise { + const header = request.headers.get("authorization") ?? ""; + if (!header.toLowerCase().startsWith("bearer ")) return null; + const token = header.slice(7).trim(); + if (!token.startsWith("ck_live_")) return null; + + const { rows } = await query( + `select id, app, from_domain, allowed_from, daily_limit, monthly_limit + from api_keys + where key_hash = $1 and revoked_at is null`, + [hashKey(token)], + ); + const row = rows[0]; + if (!row) return null; + + await query(`update api_keys set last_used_at = now() where id = $1`, [row.id]).catch(() => {}); + return { + id: row.id, + app: row.app, + fromDomain: row.from_domain, + allowedFrom: row.allowed_from, + dailyLimit: row.daily_limit, + monthlyLimit: row.monthly_limit, + }; +} + +export function fromAllowed(key: ApiKey, address: string): boolean { + if (!key.allowedFrom?.length) return true; + return key.allowedFrom.map((value) => value.toLowerCase()).includes(address.toLowerCase()); +} diff --git a/lib/config.ts b/lib/config.ts new file mode 100644 index 0000000..eb25626 --- /dev/null +++ b/lib/config.ts @@ -0,0 +1,18 @@ + +export const config = { + fromDomain: process.env.MAIL_FROM_DOMAIN || "hubsport.club", + transport: (process.env.MAIL_TRANSPORT || "dry-run") as "dry-run" | "ses" | "resend", + databaseUrl: + process.env.DATABASE_URL || + `postgresql://courier@127.0.0.1:${process.env.DB_PORT || "55432"}/courier`, + apiKeyPepper: process.env.API_KEY_PEPPER || "dev-only-pepper", + globalDailyLimit: Number(process.env.GLOBAL_DAILY_LIMIT || 1000), + snsTopicArn: process.env.SNS_TOPIC_ARN || "", + snsWebhookToken: process.env.SNS_WEBHOOK_TOKEN || "", + awsRegion: process.env.AWS_REGION || "eu-west-1", + sesConfigurationSet: process.env.SES_CONFIGURATION_SET || "courier-transactional", + resendApiKey: process.env.RESEND_API_KEY || "", + publicBaseUrl: process.env.PUBLIC_BASE_URL || "", +}; + +export type TransportName = typeof config.transport; diff --git a/lib/db.ts b/lib/db.ts new file mode 100644 index 0000000..b1654dd --- /dev/null +++ b/lib/db.ts @@ -0,0 +1,50 @@ +import { Pool, type PoolClient, type QueryResultRow } from "pg"; + +import { config } from "./config"; + +function connectionString(): string { + if (process.env.DATABASE_URL) return process.env.DATABASE_URL; + const host = process.env.DB_HOST; + if (host) { + const user = encodeURIComponent(process.env.DB_USER ?? ""); + const password = encodeURIComponent(process.env.DB_PASSWORD ?? ""); + const name = process.env.DB_NAME ?? "courier"; + const port = process.env.DB_PORT ?? "5432"; + return `postgresql://${user}:${password}@${host}:${port}/${name}`; + } + return config.databaseUrl; +} + +const globalForPg = globalThis as unknown as { courierPool?: Pool }; + +export const pool = + globalForPg.courierPool ?? + new Pool({ connectionString: connectionString(), max: 10 }); + +if (process.env.NODE_ENV !== "production") { + globalForPg.courierPool = pool; +} + +export async function query( + text: string, + params: unknown[] = [], +) { + return pool.query(text, params as never[]); +} + +export async function transaction( + fn: (client: PoolClient) => Promise, +): Promise { + const client = await pool.connect(); + try { + await client.query("begin"); + const result = await fn(client); + await client.query("commit"); + return result; + } catch (error) { + await client.query("rollback"); + throw error; + } finally { + client.release(); + } +} diff --git a/lib/events.ts b/lib/events.ts new file mode 100644 index 0000000..cc77a0e --- /dev/null +++ b/lib/events.ts @@ -0,0 +1,85 @@ + +import { query } from "./db"; + +type Recipient = { emailAddress?: string; email_address?: string }; + +export type SesEvent = { + eventType: string; + mail?: { messageId?: string; destination?: string[] }; + bounce?: { bounceType?: string; bouncedRecipients?: Recipient[] }; + complaint?: { complainedRecipients?: Recipient[] }; +}; + +function recipientsOf(event: SesEvent): string[] { + const list = event.bounce?.bouncedRecipients ?? event.complaint?.complainedRecipients ?? []; + const fromEvent = list + .map((item) => item.emailAddress ?? item.email_address ?? "") + .filter(Boolean) + .map((value) => value.toLowerCase()); + if (fromEvent.length) return fromEvent; + return (event.mail?.destination ?? []).map((value) => value.toLowerCase()); +} + +export async function handleSesNotification(message: string, snsMessageId: string): Promise { + let event: SesEvent; + try { + event = JSON.parse(message) as SesEvent; + } catch { + return; + } + const providerId = event.mail?.messageId; + if (!providerId) return; + + const { rows } = await query<{ id: string; status: string }>( + `select id, status from messages where provider_message_id = $1 limit 1`, + [providerId], + ); + const messageId = rows[0]?.id ?? null; + + const inserted = await query( + `insert into message_events (message_id, sns_message_id, type, payload) + values ($1,$2,$3,$4) + on conflict (sns_message_id) do nothing + returning id`, + [messageId, snsMessageId, event.eventType, event], + ); + if (!inserted.rows[0] || !messageId) return; + + let next: string | null = null; + if (event.eventType === "Delivery") next = "delivered"; + if (event.eventType === "Bounce") next = "bounced"; + if (event.eventType === "Complaint") next = "complained"; + if (event.eventType === "Reject") next = "failed"; + if (!next) return; + + await query( + `update messages + set status = case + when status in ('complained','bounced') then status + when $2 = 'complained' then 'complained' + when $2 = 'bounced' then 'bounced' + when $2 = 'delivered' then 'delivered' + when $2 = 'failed' and status <> 'delivered' then 'failed' + else status + end, + completed_at = case + when $2 in ('delivered','bounced','complained','failed') then now() + else completed_at + end + where id = $1`, + [messageId, next], + ); + + const permanent = event.eventType === "Complaint" || event.bounce?.bounceType === "Permanent"; + if (permanent) { + const recipients = recipientsOf(event); + if (recipients.length) { + await query( + `insert into suppressions (email, reason) + select unnest($1::text[]), $2 + on conflict (email) do update set reason = excluded.reason`, + [recipients, event.eventType === "Complaint" ? "complaint" : "hard_bounce"], + ); + } + } +} diff --git a/lib/format.ts b/lib/format.ts new file mode 100644 index 0000000..41977d7 --- /dev/null +++ b/lib/format.ts @@ -0,0 +1,12 @@ +export function datum(value: string | Date | null | undefined): string { + if (!value) return "–"; + return new Intl.DateTimeFormat("de-DE", { + dateStyle: "short", + timeStyle: "medium", + timeZone: "Europe/Berlin", + }).format(new Date(value)); +} + +export function kurz(value: string, max = 42): string { + return value.length > max ? `${value.slice(0, max - 1)}…` : value; +} diff --git a/lib/http.ts b/lib/http.ts new file mode 100644 index 0000000..e2d8300 --- /dev/null +++ b/lib/http.ts @@ -0,0 +1,17 @@ +import { NextResponse } from "next/server"; + +export function apiError(statusCode: number, name: string, message: string) { + return NextResponse.json({ statusCode, name, message }, { status: statusCode }); +} + +export function unauthorized(message = "API key is invalid") { + return apiError(401, "validation_error", message); +} + +export function validationError(message: string) { + return apiError(422, "validation_error", message); +} + +export function serverError(message = "Interner Fehler") { + return apiError(500, "internal_server_error", message); +} diff --git a/lib/limits.ts b/lib/limits.ts new file mode 100644 index 0000000..2338b66 --- /dev/null +++ b/lib/limits.ts @@ -0,0 +1,25 @@ + +import { query } from "./db"; + +export type QuotaState = { + keyDaily: number; + keyMonthly: number; + globalDaily: number; +}; + +export async function quotaState(keyId: string): Promise { + const { rows } = await query<{ key_daily: string; key_monthly: string; global_daily: string }>( + `select + count(*) filter (where api_key_id = $1 and created_at >= date_trunc('day', now())) as key_daily, + count(*) filter (where api_key_id = $1 and created_at >= date_trunc('month', now())) as key_monthly, + count(*) filter (where created_at >= date_trunc('day', now())) as global_daily + from messages`, + [keyId], + ); + const row = rows[0]; + return { + keyDaily: Number(row?.key_daily ?? 0), + keyMonthly: Number(row?.key_monthly ?? 0), + globalDaily: Number(row?.global_daily ?? 0), + }; +} diff --git a/lib/queries.ts b/lib/queries.ts new file mode 100644 index 0000000..7f7fca0 --- /dev/null +++ b/lib/queries.ts @@ -0,0 +1,112 @@ + +import { query } from "./db"; + +export type StatusCount = { status: string; count: string }; + +export async function dashboardStats() { + const { rows } = await query( + `select status, count(*)::text as count + from messages + where created_at >= now() - interval '24 hours' + group by status`, + ); + const counts = Object.fromEntries(rows.map((row) => [row.status, Number(row.count)])); + const recent = await query<{ + id: string; + app: string; + subject: string; + to_emails: string[]; + status: string; + created_at: string; + }>( + `select id, app, subject, to_emails, status, created_at + from messages + order by created_at desc + limit 8`, + ); + const suppressed = await query<{ count: string }>(`select count(*)::text as count from suppressions`); + return { counts, recent: recent.rows, suppressed: Number(suppressed.rows[0]?.count ?? 0) }; +} + +export async function listMessages(status: string | undefined, limit = 100) { + const params: unknown[] = []; + let where = ""; + if (status) { + params.push(status); + where = `where status = $${params.length}`; + } + params.push(limit); + const { rows } = await query<{ + id: string; + app: string; + subject: string; + to_emails: string[]; + status: string; + attempts: number; + created_at: string; + completed_at: string | null; + error: string | null; + }>( + `select id, app, subject, to_emails, status, attempts, created_at, completed_at, error + from messages + ${where} + order by created_at desc + limit $${params.length}`, + params, + ); + return rows; +} + +export async function messageDetail(id: string) { + const { rows } = await query<{ + id: string; + app: string; + provider_message_id: string | null; + from_email: string; + from_name: string | null; + to_emails: string[]; + cc_emails: string[]; + bcc_emails: string[]; + reply_to: string[]; + subject: string; + status: string; + error: string | null; + attempts: number; + created_at: string; + sent_at: string | null; + completed_at: string | null; + payload: unknown; + }>(`select * from messages where id = $1`, [id]); + const message = rows[0]; + if (!message) return null; + const events = await query<{ id: string; type: string; payload: unknown; created_at: string }>( + `select id, type, payload, created_at from message_events where message_id = $1 order by created_at`, + [id], + ); + return { message, events: events.rows }; +} + +export async function listApiKeys() { + const { rows } = await query<{ + id: string; + app: string; + name: string; + prefix: string; + from_domain: string; + allowed_from: string[] | null; + daily_limit: number; + monthly_limit: number; + revoked_at: string | null; + last_used_at: string | null; + created_at: string; + }>(`select * from api_keys order by created_at desc`); + return rows; +} + +export async function listSuppressions(limit = 100) { + const { rows } = await query<{ email: string; reason: string; created_at: string }>( + `select email, reason, created_at from suppressions order by created_at desc limit $1`, + [limit], + ); + return rows; +} diff --git a/lib/queue.ts b/lib/queue.ts new file mode 100644 index 0000000..ca69595 --- /dev/null +++ b/lib/queue.ts @@ -0,0 +1,144 @@ + +import { randomUUID } from "node:crypto"; + +import type { ApiKey } from "./api-key"; +import { addressesOf } from "./address"; +import { config } from "./config"; +import { query, transaction } from "./db"; +import type { NormalizedMail } from "./schema"; + +export class QuotaExceededError extends Error { + constructor(message = "Tageslimit erreicht") { + super(message); + this.name = "QuotaExceededError"; + } +} + +export class SuppressedError extends Error { + recipients: string[]; + + constructor(recipients: string[]) { + super(`Empfänger gesperrt: ${recipients.join(", ")}`); + this.name = "SuppressedError"; + this.recipients = recipients; + } +} + +export type StoredPayload = { + from: ReturnType; + to: ReturnType[]; + cc: ReturnType[]; + bcc: ReturnType[]; + reply_to: ReturnType[]; + subject: string; + html?: string; + text?: string; + headers: Record; + attachments: { filename: string; content: string; content_type?: string }[]; + tags: { name: string; value: string }[]; +}; + +function payloadFrom(mailbox: { address: string; name?: string }) { + return mailbox.name ? { address: mailbox.address, name: mailbox.name } : { address: mailbox.address }; +} + +export function storedPayload(mail: NormalizedMail): StoredPayload { + return { + from: payloadFrom(mail.from), + to: mail.to.map(payloadFrom), + cc: mail.cc.map(payloadFrom), + bcc: mail.bcc.map(payloadFrom), + reply_to: mail.replyTo.map(payloadFrom), + subject: mail.subject, + html: mail.html, + text: mail.text, + headers: mail.headers, + attachments: mail.attachments.map((item) => ({ + filename: item.filename, + content: item.content.toString("base64"), + content_type: item.contentType, + })), + tags: mail.tags, + }; +} + +export async function enqueue( + apiKey: ApiKey, + mail: NormalizedMail, + idempotencyKey?: string | null, +): Promise<{ id: string; duplicate: boolean }> { + const recipients = addressesOf([...mail.to, ...mail.cc, ...mail.bcc]); + const { rows: suppressed } = await query<{ email: string }>( + `select email from suppressions where email = any($1::text[])`, + [recipients], + ); + if (suppressed.length) throw new SuppressedError(suppressed.map((row) => row.email)); + + const payload = storedPayload(mail); + + return transaction(async (client) => { + await client.query(`select pg_advisory_xact_lock(hashtext($1))`, [apiKey.id]); + + if (idempotencyKey) { + const existing = await client.query<{ id: string }>( + `select id from messages where api_key_id = $1 and idempotency_key = $2`, + [apiKey.id, idempotencyKey], + ); + if (existing.rows[0]) return { id: existing.rows[0].id, duplicate: true }; + } + + const usage = await client.query<{ key_daily: string; key_monthly: string; global_daily: string }>( + `select + count(*) filter (where api_key_id = $1 and created_at >= date_trunc('day', now())) as key_daily, + count(*) filter (where api_key_id = $1 and created_at >= date_trunc('month', now())) as key_monthly, + count(*) filter (where created_at >= date_trunc('day', now())) as global_daily + from messages`, + [apiKey.id], + ); + const row = usage.rows[0]; + if (Number(row?.key_daily ?? 0) >= apiKey.dailyLimit) { + throw new QuotaExceededError(`Tageslimit für ${apiKey.app} erreicht`); + } + if (Number(row?.key_monthly ?? 0) >= apiKey.monthlyLimit) { + throw new QuotaExceededError(`Monatslimit für ${apiKey.app} erreicht`); + } + if (Number(row?.global_daily ?? 0) >= config.globalDailyLimit) { + throw new QuotaExceededError("Globales Tageslimit erreicht"); + } + + const id = randomUUID(); + const inserted = await client.query<{ id: string }>( + `insert into messages ( + id, api_key_id, app, from_email, from_name, to_emails, cc_emails, bcc_emails, + reply_to, subject, status, payload, idempotency_key + ) values ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,'queued',$11,$12) + on conflict (api_key_id, idempotency_key) do nothing + returning id`, + [ + id, + apiKey.id, + apiKey.app, + mail.from.address, + mail.from.name ?? null, + addressesOf(mail.to), + addressesOf(mail.cc), + addressesOf(mail.bcc), + addressesOf(mail.replyTo), + mail.subject, + payload, + idempotencyKey || null, + ], + ); + + if (!inserted.rows[0] && idempotencyKey) { + const existing = await client.query<{ id: string }>( + `select id from messages where api_key_id = $1 and idempotency_key = $2`, + [apiKey.id, idempotencyKey], + ); + return { id: existing.rows[0]?.id ?? id, duplicate: true }; + } + + await client.query(`select pg_notify('courier_queue', $1)`, [id]); + return { id: inserted.rows[0]?.id ?? id, duplicate: false }; + }); +} diff --git a/lib/schema.ts b/lib/schema.ts new file mode 100644 index 0000000..225c1a7 --- /dev/null +++ b/lib/schema.ts @@ -0,0 +1,143 @@ +import { z } from "zod"; + +import { + domainOf, + formatMailbox, + parseMailbox, + parseMailboxList, + type Mailbox, +} from "./address"; + +const addressInput = z.union([z.string().min(3), z.array(z.string().min(3)).min(1).max(50)]); +const attachmentInput = z.object({ + filename: z.string().min(1).max(255), + content: z.string().min(1), + content_type: z.string().min(3).max(200).optional(), +}); + +export const sendSchema = z + .object({ + from: z.string().min(3), + to: addressInput, + cc: addressInput.optional(), + bcc: addressInput.optional(), + reply_to: addressInput.optional(), + subject: z.string().min(1).max(998), + html: z.string().max(2_000_000).optional(), + text: z.string().max(2_000_000).optional(), + headers: z.record(z.string(), z.string()).optional(), + attachments: z.array(attachmentInput).max(20).optional(), + tags: z + .array(z.object({ name: z.string().min(1).max(256), value: z.string().min(1).max(256) })) + .max(50) + .optional(), + }) + .refine((value) => Boolean(value.html || value.text), { + message: "html oder text ist erforderlich", + path: ["html"], + }); + +export const batchSchema = z.array(sendSchema).min(1).max(100); + +export type SendInput = z.infer; + +export type NormalizedMail = { + from: Mailbox; + to: Mailbox[]; + cc: Mailbox[]; + bcc: Mailbox[]; + replyTo: Mailbox[]; + subject: string; + html?: string; + text?: string; + headers: Record; + attachments: { filename: string; content: Buffer; contentType?: string }[]; + tags: { name: string; value: string }[]; +}; + +const RESERVED_HEADERS = new Set([ + "from", + "to", + "cc", + "bcc", + "reply-to", + "subject", + "date", + "message-id", + "mime-version", + "content-type", + "content-transfer-encoding", + "return-path", +]); + +export class MailValidationError extends Error { + constructor(message: string) { + super(message); + this.name = "MailValidationError"; + } +} + +export function normalizeMail(input: SendInput, fromDomain: string): NormalizedMail { + const from = parseMailbox(input.from); + if (!from) throw new MailValidationError("Ungültige from-Adresse"); + + const domain = domainOf(from.address); + if (domain !== fromDomain && !domain.endsWith(`.${fromDomain}`)) { + throw new MailValidationError(`Absenderdomain ${domain} ist nicht erlaubt`); + } + + const to = parseMailboxList(input.to); + const cc = parseMailboxList(input.cc); + const bcc = parseMailboxList(input.bcc); + if (to.length + cc.length + bcc.length === 0) { + throw new MailValidationError("Mindestens ein Empfänger ist erforderlich"); + } + + const headers: Record = {}; + for (const [name, value] of Object.entries(input.headers ?? {})) { + const lower = name.toLowerCase(); + if (RESERVED_HEADERS.has(lower)) continue; + if (!/^[A-Za-z0-9-]+$/.test(name)) continue; + if (/[\r\n]/.test(value)) throw new MailValidationError(`Ungültiger Header: ${name}`); + headers[name] = value; + } + + const attachments = (input.attachments ?? []).map((item) => { + const content = Buffer.from(item.content, "base64"); + if (content.length === 0) throw new MailValidationError("Leerer Anhang"); + return { filename: item.filename, content, contentType: item.content_type }; + }); + const total = attachments.reduce((sum, item) => sum + item.content.length, 0); + if (total > 10 * 1024 * 1024) { + throw new MailValidationError("Anhänge sind zusammen größer als 10 MB"); + } + + return { + from, + to, + cc, + bcc, + replyTo: parseMailboxList(input.reply_to), + subject: input.subject.replace(/[\r\n]+/g, " "), + html: input.html, + text: input.text, + headers, + attachments, + tags: input.tags ?? [], + }; +} + +export function mailPreview(mail: NormalizedMail) { + return { + from: formatMailbox(mail.from), + to: mail.to.map(formatMailbox), + cc: mail.cc.map(formatMailbox), + bcc: mail.bcc.map(formatMailbox), + reply_to: mail.replyTo.map(formatMailbox), + subject: mail.subject, + html: mail.html, + text: mail.text, + headers: mail.headers, + tags: mail.tags, + }; +} diff --git a/lib/sns.ts b/lib/sns.ts new file mode 100644 index 0000000..bd75a74 --- /dev/null +++ b/lib/sns.ts @@ -0,0 +1,94 @@ + +import { createVerify } from "node:crypto"; + +import { config } from "./config"; + +type SnsEnvelope = { + Type: string; + MessageId: string; + TopicArn: string; + Message: string; + Timestamp: string; + Signature: string; + SignatureVersion?: string; + SigningCertURL: string; + Subject?: string; + SubscribeURL?: string; + Token?: string; +}; + +const certCache = new Map(); + +function allowedCertUrl(value: string): boolean { + try { + const url = new URL(value); + return ( + url.protocol === "https:" && + /^sns\.[a-z0-9-]+\.amazonaws\.com$/.test(url.hostname) && + url.pathname.endsWith(".pem") + ); + } catch { + return false; + } +} + +function allowedSubscribeUrl(value: string): boolean { + try { + const url = new URL(value); + return url.protocol === "https:" && /^sns\.[a-z0-9-]+\.amazonaws\.com$/.test(url.hostname); + } catch { + return false; + } +} + +async function signingCert(url: string): Promise { + const cached = certCache.get(url); + if (cached) return cached; + const response = await fetch(url); + if (!response.ok) throw new Error(`SNS-Zertifikat ${response.status}`); + const pem = await response.text(); + if (!pem.includes("BEGIN CERTIFICATE")) throw new Error("SNS-Zertifikat ungültig"); + certCache.set(url, pem); + return pem; +} + +function canonical(envelope: SnsEnvelope): string { + if (envelope.Type === "SubscriptionConfirmation" || envelope.Type === "UnsubscribeConfirmation") { + const parts = [ + "Message", envelope.Message, + "MessageId", envelope.MessageId, + "SubscribeURL", envelope.SubscribeURL ?? "", + "Timestamp", envelope.Timestamp, + "Token", envelope.Token ?? "", + "TopicArn", envelope.TopicArn, + "Type", envelope.Type, + ]; + return `${parts.join("\n")}\n`; + } + const parts = ["Message", envelope.Message, "MessageId", envelope.MessageId]; + if (envelope.Subject) parts.push("Subject", envelope.Subject); + parts.push("Timestamp", envelope.Timestamp, "TopicArn", envelope.TopicArn, "Type", envelope.Type); + return `${parts.join("\n")}\n`; +} + +export async function verifySns(envelope: SnsEnvelope): Promise { + if (envelope.TopicArn !== config.snsTopicArn) throw new Error("SNS-Topic unbekannt"); + if (!allowedCertUrl(envelope.SigningCertURL)) throw new Error("SNS-Zertifikats-URL ungültig"); + const cert = await signingCert(envelope.SigningCertURL); + const verifier = createVerify(envelope.SignatureVersion === "2" ? "RSA-SHA256" : "RSA-SHA1"); + verifier.update(canonical(envelope), "utf8"); + verifier.end(); + if (!verifier.verify(cert, envelope.Signature, "base64")) { + throw new Error("SNS-Signatur ungültig"); + } +} + +export async function confirmSubscription(envelope: SnsEnvelope): Promise { + if (!envelope.SubscribeURL || !allowedSubscribeUrl(envelope.SubscribeURL)) { + throw new Error("SNS-Subscribe-URL ungültig"); + } + const response = await fetch(envelope.SubscribeURL); + if (!response.ok) throw new Error(`SNS-Bestätigung ${response.status}`); +} + +export type { SnsEnvelope }; diff --git a/lib/transport.ts b/lib/transport.ts new file mode 100644 index 0000000..7e49524 --- /dev/null +++ b/lib/transport.ts @@ -0,0 +1,119 @@ + +import { randomUUID } from "node:crypto"; + +import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2"; +import MailComposer from "nodemailer/lib/mail-composer"; + +import { addressesOf, formatMailbox } from "./address"; +import { config } from "./config"; +import type { StoredPayload } from "./queue"; + +export type SendResult = { providerMessageId: string }; + +export type SendFailure = Error & { retryable?: boolean; statusCode?: number }; + +function mimeOptions(payload: StoredPayload) { + return { + from: formatMailbox(payload.from), + to: payload.to.map(formatMailbox), + cc: payload.cc.map(formatMailbox), + bcc: payload.bcc.map(formatMailbox), + replyTo: payload.reply_to.map(formatMailbox), + subject: payload.subject, + text: payload.text, + html: payload.html, + headers: payload.headers, + attachments: payload.attachments.map((item) => ({ + filename: item.filename, + content: Buffer.from(item.content, "base64"), + contentType: item.content_type, + })), + }; +} + +function buildRaw(payload: StoredPayload): Promise { + return new Promise((resolve, reject) => { + new MailComposer(mimeOptions(payload)) + .compile() + .build((error, message) => { + if (error) reject(error); + else resolve(message); + }); + }); +} + +export async function sendStored(payload: StoredPayload): Promise { + if (config.transport === "dry-run") { + console.log("[courier] dry-run", JSON.stringify({ from: payload.from, to: payload.to, subject: payload.subject })); + return { providerMessageId: `dry-${randomUUID()}` }; + } + + if (config.transport === "resend") { + if (!config.resendApiKey) throw Object.assign(new Error("RESEND_API_KEY fehlt"), { retryable: false }); + const response = await fetch("https://api.resend.com/emails", { + method: "POST", + headers: { + authorization: `Bearer ${config.resendApiKey}`, + "content-type": "application/json", + }, + body: JSON.stringify({ + from: formatMailbox(payload.from), + to: payload.to.map(formatMailbox), + cc: payload.cc.map(formatMailbox), + bcc: payload.bcc.map(formatMailbox), + reply_to: payload.reply_to.map(formatMailbox), + subject: payload.subject, + html: payload.html, + text: payload.text, + headers: payload.headers, + attachments: payload.attachments.map((item) => ({ + filename: item.filename, + content: item.content, + content_type: item.content_type, + })), + tags: payload.tags, + }), + }); + if (!response.ok) { + const detail = await response.text(); + const error = Object.assign(new Error(`Resend ${response.status}: ${detail}`), { + retryable: response.status === 429 || response.status >= 500, + statusCode: response.status, + }); + throw error; + } + const data = (await response.json()) as { id?: string }; + if (!data.id) throw Object.assign(new Error("Resend lieferte keine Message-ID"), { retryable: false }); + return { providerMessageId: data.id }; + } + + const raw = await buildRaw(payload); + const client = new SESv2Client({ region: config.awsRegion }); + try { + const result = await client.send( + new SendEmailCommand({ + FromEmailAddress: formatMailbox(payload.from), + Destination: { + ToAddresses: addressesOf(payload.to), + CcAddresses: addressesOf(payload.cc), + BccAddresses: addressesOf(payload.bcc), + }, + ReplyToAddresses: addressesOf(payload.reply_to), + Content: { Raw: { Data: raw } }, + ConfigurationSetName: config.sesConfigurationSet, + EmailTags: payload.tags.map((tag) => ({ Name: tag.name, Value: tag.value })), + }), + ); + if (!result.MessageId) throw Object.assign(new Error("SES lieferte keine Message-ID"), { retryable: false }); + return { providerMessageId: result.MessageId }; + } catch (error) { + const status = (error as { $metadata?: { httpStatusCode?: number } }).$metadata?.httpStatusCode; + const name = (error as Error).name || ""; + const retryable = + status === 429 || + (status !== undefined && status >= 500) || + /throttl|timeout|temporar|slow down|service unavailable/i.test(name) || + /throttl|timeout|temporar|slow down|service unavailable/i.test((error as Error).message || ""); + throw Object.assign(error as Error, { retryable, statusCode: status }); + } +} diff --git a/next.config.ts b/next.config.ts new file mode 100644 index 0000000..c77ff2f --- /dev/null +++ b/next.config.ts @@ -0,0 +1,14 @@ +import type { NextConfig } from "next"; + +const config: NextConfig = { + distDir: process.env.NEXT_DIST_DIR || ".next", + experimental: { + serverActions: { + allowedOrigins: ["courier.hubsport.club", "courier.kaivostudio.olares.de"], + }, + }, + basePath: process.env.NEXT_BASE_PATH || undefined, + trailingSlash: true, +}; + +export default config; diff --git a/olares/Chart.yaml b/olares/Chart.yaml new file mode 100644 index 0000000..1d2299a --- /dev/null +++ b/olares/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: courier +description: Transaktionsmail-Gateway für hubsport.club über Amazon SES. +type: application +version: 26.11.1 +appVersion: "26.11.1" +icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png +home: https://git.aimighty.olares.de/aimighty/courier diff --git a/olares/OlaresManifest.yaml b/olares/OlaresManifest.yaml new file mode 100644 index 0000000..ad6fe48 --- /dev/null +++ b/olares/OlaresManifest.yaml @@ -0,0 +1,167 @@ +olaresManifest.version: '0.12.0' +olaresManifest.type: app +apiVersion: 'v3' + +workloadReplicas: + courier: 1 + courier-worker: 1 + +metadata: + name: courier + appid: courier + title: Courier + description: Transaktionsmail für deine Apps über Amazon SES. + icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png + version: 26.11.1 + categories: + - Applications + +entrances: + - name: courier + host: courier + port: 3000 + title: Courier + icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png + authLevel: internal + invisible: false + openMethod: window + +middleware: + postgres: + username: courier + databases: + - name: courier + +envs: + - envName: AWS_ACCESS_KEY_ID + required: true + type: password + editable: false + applyOnChange: false + default: "" + description: "IAM-Zugang courier-ses (nur SES senden)." + - envName: AWS_SECRET_ACCESS_KEY + required: true + type: password + editable: false + applyOnChange: false + default: "" + description: "Secret zum IAM-Zugang courier-ses." + - envName: AWS_REGION + required: true + type: string + editable: false + applyOnChange: false + default: "eu-west-1" + - envName: API_KEY_PEPPER + required: true + type: password + editable: false + applyOnChange: false + default: "" + description: "Pepper für die Hashes der Courier-API-Keys." + - envName: SNS_WEBHOOK_TOKEN + required: true + type: password + editable: false + applyOnChange: false + default: "" + description: "Zufälliger Token im SNS-Webhook-Pfad." + - envName: SES_CONFIGURATION_SET + required: true + type: string + editable: false + applyOnChange: false + default: "courier-transactional" + - envName: SNS_TOPIC_ARN + required: true + type: string + editable: false + applyOnChange: false + default: "arn:aws:sns:eu-west-1:945831802901:courier-ses-events" + - envName: MAIL_FROM_DOMAIN + required: true + type: string + editable: true + applyOnChange: true + default: "hubsport.club" + - envName: MAIL_TRANSPORT + required: true + type: string + editable: true + applyOnChange: true + default: "ses" + options: + - title: Amazon SES + value: ses + - title: Resend (Übergang) + value: resend + - title: Dry-Run + value: dry-run + - envName: GLOBAL_DAILY_LIMIT + required: false + type: int + editable: true + applyOnChange: true + default: "1000" + +spec: + versionName: '26.11.1' + fullDescription: | + **Courier** ist ein kleiner Versanddienst für transaktionale E-Mails: + eine Resend-kompatible HTTP-API, Warteschlange, Retry, Logs und + Zustellereignisse. Der Versand läuft über Amazon SES. + + **Funktionen** + - `POST /api/emails` und `/api/emails/batch` (Resend-kompatibel) + - API-Keys pro App mit Domain- und Absenderbeschränkung + - Tages- und Monatslimits, Idempotency-Key + - Queue mit Retry und Backoff + - Bounce-/Complaint-Verarbeitung über SNS, Suppression-Liste + - Übersicht und Nachrichten-Detail im Web + + **Technik** + Next.js 15, PostgreSQL (Olares-Middleware), Amazon SES (eu-west-1). + developer: AImighty + website: https://git.aimighty.olares.de/aimighty/courier + sourceCode: https://git.aimighty.olares.de/aimighty/courier + submitter: AImighty + locale: + - de-DE + doc: https://git.aimighty.olares.de/aimighty/courier#readme + license: + - text: Proprietary + supportArch: + - amd64 + requiredCpu: 250m + requiredMemory: 512Mi + requiredDisk: 1Gi + limitedCpu: 1000m + limitedMemory: 1Gi + limitedDisk: 5Gi + +options: + policies: + - entranceName: courier + description: Mail-API für Apps + uriRegex: ^/api/(emails|health)(/.*)?(\?.*)?$ + level: public + oneTime: false + validDuration: 0s + - entranceName: courier + description: SES-Ereignisse von SNS + uriRegex: ^/api/webhooks/ses(/.*)?(\?.*)?$ + level: public + oneTime: false + validDuration: 0s + dependencies: + - name: olares + type: system + version: '>=1.12.6-0 <2.0.0' + allowMultipleInstall: false + allowedOutboundPorts: + - 443 + runAsUser: "1000" + appScope: + clusterScoped: false + apiTimeout: 30 diff --git a/olares/templates/deployment-web.yaml b/olares/templates/deployment-web.yaml new file mode 100644 index 0000000..cb88e88 --- /dev/null +++ b/olares/templates/deployment-web.yaml @@ -0,0 +1,98 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: courier + labels: + app: courier +spec: + replicas: {{ .Values.workloads.courier.replicaCount }} + selector: + matchLabels: + app: courier + template: + metadata: + labels: + app: courier + spec: + containers: + - name: courier + image: "{{ .Values.images.registry }}/courier:{{ .Values.images.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.images.pullPolicy }} + ports: + - name: http + containerPort: 3000 + env: + - name: DB_HOST + value: {{ .Values.postgres.host | quote }} + - name: DB_PORT + value: {{ .Values.postgres.port | quote }} + - name: DB_USER + value: {{ .Values.postgres.username | quote }} + - name: DB_PASSWORD + value: {{ .Values.postgres.password | quote }} + - name: DB_NAME + value: {{ .Values.postgres.databases.courier | quote }} + - name: MAIL_TRANSPORT + value: {{ .Values.olaresEnv.MAIL_TRANSPORT | quote }} + - name: MAIL_FROM_DOMAIN + value: {{ .Values.olaresEnv.MAIL_FROM_DOMAIN | quote }} + - name: GLOBAL_DAILY_LIMIT + value: {{ .Values.olaresEnv.GLOBAL_DAILY_LIMIT | quote }} + - name: PUBLIC_BASE_URL + value: {{ .Values.app.publicBaseUrl | default (printf "https://courier.%s" .Values.user.zone) | quote }} + - name: AWS_REGION + value: {{ .Values.olaresEnv.AWS_REGION | quote }} + - name: SES_CONFIGURATION_SET + value: {{ .Values.olaresEnv.SES_CONFIGURATION_SET | quote }} + - name: SNS_TOPIC_ARN + value: {{ .Values.olaresEnv.SNS_TOPIC_ARN | quote }} + - name: TZ + value: {{ .Values.app.timezone | quote }} + - name: PORT + value: "3000" + - name: HOSTNAME + value: "0.0.0.0" + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: courier-secrets + key: AWS_ACCESS_KEY_ID + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: courier-secrets + key: AWS_SECRET_ACCESS_KEY + - name: API_KEY_PEPPER + valueFrom: + secretKeyRef: + name: courier-secrets + key: API_KEY_PEPPER + - name: SNS_WEBHOOK_TOKEN + valueFrom: + secretKeyRef: + name: courier-secrets + key: SNS_WEBHOOK_TOKEN + readinessProbe: + httpGet: + path: /api/health/ + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + livenessProbe: + httpGet: + path: /api/health/ + port: http + initialDelaySeconds: 30 + periodSeconds: 20 + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + cpu: 500m + memory: 512Mi + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL diff --git a/olares/templates/deployment-worker.yaml b/olares/templates/deployment-worker.yaml new file mode 100644 index 0000000..9122a36 --- /dev/null +++ b/olares/templates/deployment-worker.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: courier-worker + labels: + app: courier-worker +spec: + replicas: {{ (index .Values.workloads "courier-worker").replicaCount }} + selector: + matchLabels: + app: courier-worker + template: + metadata: + labels: + app: courier-worker + spec: + containers: + - name: courier-worker + image: "{{ .Values.images.registry }}/courier:{{ .Values.images.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.images.pullPolicy }} + command: + - ./node_modules/.bin/tsx + - scripts/worker.ts + env: + - name: DB_HOST + value: {{ .Values.postgres.host | quote }} + - name: DB_PORT + value: {{ .Values.postgres.port | quote }} + - name: DB_USER + value: {{ .Values.postgres.username | quote }} + - name: DB_PASSWORD + value: {{ .Values.postgres.password | quote }} + - name: DB_NAME + value: {{ .Values.postgres.databases.courier | quote }} + - name: MAIL_TRANSPORT + value: {{ .Values.olaresEnv.MAIL_TRANSPORT | quote }} + - name: MAIL_FROM_DOMAIN + value: {{ .Values.olaresEnv.MAIL_FROM_DOMAIN | quote }} + - name: AWS_REGION + value: {{ .Values.olaresEnv.AWS_REGION | quote }} + - name: SES_CONFIGURATION_SET + value: {{ .Values.olaresEnv.SES_CONFIGURATION_SET | quote }} + - name: SNS_TOPIC_ARN + value: {{ .Values.olaresEnv.SNS_TOPIC_ARN | quote }} + - name: TZ + value: {{ .Values.app.timezone | quote }} + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: courier-secrets + key: AWS_ACCESS_KEY_ID + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: courier-secrets + key: AWS_SECRET_ACCESS_KEY + - name: API_KEY_PEPPER + valueFrom: + secretKeyRef: + name: courier-secrets + key: API_KEY_PEPPER + - name: SNS_WEBHOOK_TOKEN + valueFrom: + secretKeyRef: + name: courier-secrets + key: SNS_WEBHOOK_TOKEN + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + cpu: 250m + memory: 512Mi + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL diff --git a/olares/templates/secret.yaml b/olares/templates/secret.yaml new file mode 100644 index 0000000..6d44280 --- /dev/null +++ b/olares/templates/secret.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: courier-secrets + labels: + app: courier +type: Opaque +stringData: + AWS_ACCESS_KEY_ID: {{ .Values.olaresEnv.AWS_ACCESS_KEY_ID | quote }} + AWS_SECRET_ACCESS_KEY: {{ .Values.olaresEnv.AWS_SECRET_ACCESS_KEY | quote }} + API_KEY_PEPPER: {{ .Values.olaresEnv.API_KEY_PEPPER | quote }} + SNS_WEBHOOK_TOKEN: {{ .Values.olaresEnv.SNS_WEBHOOK_TOKEN | quote }} diff --git a/olares/templates/service.yaml b/olares/templates/service.yaml new file mode 100644 index 0000000..c043229 --- /dev/null +++ b/olares/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: courier + labels: + app: courier +spec: + type: ClusterIP + selector: + app: courier + ports: + - name: http + port: 3000 + targetPort: 3000 diff --git a/olares/values-olares-stub.yaml b/olares/values-olares-stub.yaml new file mode 100644 index 0000000..fb5c898 --- /dev/null +++ b/olares/values-olares-stub.yaml @@ -0,0 +1,13 @@ +# Nur zum Prüfen mit `helm lint` und `helm template`. Die echten Werte +# injiziert Olares zur Laufzeit. +postgres: + host: postgres-cluster.os-platform + port: "5432" + username: courier + password: nur-zum-pruefen + databases: + courier: courier-db +bfl: + username: pruefer +user: + zone: pruefer.olares.com diff --git a/olares/values.yaml b/olares/values.yaml new file mode 100644 index 0000000..4681e8f --- /dev/null +++ b/olares/values.yaml @@ -0,0 +1,28 @@ +workloads: + courier: + replicaCount: 1 + courier-worker: + replicaCount: 1 + +images: + registry: git.aimighty.olares.de/aimighty + tag: "" + pullPolicy: IfNotPresent + +app: + timezone: Europe/Berlin + publicBaseUrl: "" + +# Olares überschreibt diese Map beim Install mit den envs aus dem Manifest. +# Die Schlüssel müssen hier stehen, sonst rendert ein nacktes helm template nicht. +olaresEnv: + AWS_ACCESS_KEY_ID: "" + AWS_SECRET_ACCESS_KEY: "" + AWS_REGION: "eu-west-1" + API_KEY_PEPPER: "" + SNS_WEBHOOK_TOKEN: "" + SES_CONFIGURATION_SET: "courier-transactional" + SNS_TOPIC_ARN: "arn:aws:sns:eu-west-1:945831802901:courier-ses-events" + MAIL_FROM_DOMAIN: "hubsport.club" + MAIL_TRANSPORT: "ses" + GLOBAL_DAILY_LIMIT: "1000" diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..1c7194e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2122 @@ +{ + "name": "courier", + "version": "26.11.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "courier", + "version": "26.11.1", + "dependencies": { + "@aws-sdk/client-sesv2": "^3.1175.0", + "geist": "^1.9.2", + "next": "15.5.29", + "nodemailer": "^10.6.1", + "pg": "^8.23.1", + "react": "19.1.0", + "react-dom": "19.1.0", + "server-only": "^0.0.1", + "tsx": "^4.23.15", + "zod": "^4.6.7" + }, + "devDependencies": { + "@types/node": "^20", + "@types/nodemailer": "^8.0.2", + "@types/pg": "^8.23.1", + "@types/react": "^19", + "@types/react-dom": "^19", + "typescript": "^5" + } + }, + "node_modules/@aws-sdk/client-sesv2": { + "version": "3.1175.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sesv2/-/client-sesv2-3.1175.0.tgz", + "integrity": "sha512-oxIfaX2daPBG1/EIwmuLzB3T+hKjIIRQljOLzfvdPdU1/hNhcIwOQS+xUkV/5JLpP8CBHIdTaP+xlXeFHGfsQw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/credential-provider-node": "^3.972.98", + "@aws-sdk/signature-v4-multi-region": "^3.996.52", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/core": { + "version": "3.981.1", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.981.1.tgz", + "integrity": "sha512-sERtJaZjzvBdFMm2uei4k0WwPNUJtIrMBH9h0AEw7G0KkhIbnN3e5ZcwGjbVKClR+rrJCmyL1jhtXkseE7DU4A==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.975.1", + "@aws-sdk/xml-builder": "^3.972.43", + "@aws/lambda-invoke-store": "^0.3.0", + "@smithy/core": "^3.40.0", + "@smithy/signature-v4": "^5.7.5", + "@smithy/types": "^4.20.0", + "bowser": "^2.11.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-env": { + "version": "3.972.85", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.85.tgz", + "integrity": "sha512-IkIfFWmDbUyDEdNZpyAMmD3Givrm11I9UrqbgmLu1kUL/oh96QMqbfuHcbH08ErngZPDCQ2+7fW3U4r/W2k2Xg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-http": { + "version": "3.972.87", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.87.tgz", + "integrity": "sha512-NWQNmfmllENW1TOpMfhEZeRzEvbSaFsS5yrb2TZJ0wu+fVL5hyVSfGVLd8HTWb2UECD2bCw/kDXaA6dR1VJf3g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-ini": { + "version": "3.973.31", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.31.tgz", + "integrity": "sha512-K6jkaKaAaVn9qAl/I14lzDHnYWHiESkxYLnmPYnJg3OfTRtWz39NerpidQIzqbMpoE/pmFqhgSJ+Sx/j1++8sA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/credential-provider-env": "^3.972.85", + "@aws-sdk/credential-provider-http": "^3.972.87", + "@aws-sdk/credential-provider-login": "^3.972.93", + "@aws-sdk/credential-provider-process": "^3.972.85", + "@aws-sdk/credential-provider-sso": "^3.973.29", + "@aws-sdk/credential-provider-web-identity": "^3.972.91", + "@aws-sdk/nested-clients": "^3.998.4", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/credential-provider-imds": "^4.5.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-login": { + "version": "3.972.93", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.93.tgz", + "integrity": "sha512-JofxFKJyNGLc9MmFMKy/vmjVwvNIWKNvHOf8rkXheH9x4+WJpIexhk1cqbmxWkodDYAodqGTiCEdBAVuiyH0iA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/nested-clients": "^3.998.4", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-node": { + "version": "3.972.98", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.98.tgz", + "integrity": "sha512-EpRL6YwSqvNlMjvRmwR2o3exV6DaETTdaWr1U7fZ456LQeK6ErOSluc6mWMY+OjkrBVFK4PgrU4NlERXTcgzKg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/credential-provider-env": "^3.972.85", + "@aws-sdk/credential-provider-http": "^3.972.87", + "@aws-sdk/credential-provider-ini": "^3.973.31", + "@aws-sdk/credential-provider-process": "^3.972.85", + "@aws-sdk/credential-provider-sso": "^3.973.29", + "@aws-sdk/credential-provider-web-identity": "^3.972.91", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/credential-provider-imds": "^4.5.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-process": { + "version": "3.972.85", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.85.tgz", + "integrity": "sha512-19kc3xj6woR3Nb2NWFxowRkCnuR43jMFcTLLLCqkzB/rPxxE1+NfHnAP5fpXgrI4xRRgDzvWeDREjhGrJxqfxA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-sso": { + "version": "3.973.29", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.29.tgz", + "integrity": "sha512-DJuKIs0bn5MZXc5uE1sf/R67YVC4ivFnL/dbKHukhdb5B6Fy80k8/BqiQykzXEqoT/qlSQaqYXU29hqVAYjcsg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/nested-clients": "^3.998.4", + "@aws-sdk/token-providers": "3.1175.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-web-identity": { + "version": "3.972.91", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.91.tgz", + "integrity": "sha512-4k4beWSkxhwKeGMVfgppv/LwCfCd1zAycWgqop7GHkdvdNK9TTkWn299LjUQOgDMfBX2Sv08t+J1mAWKHatttw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/nested-clients": "^3.998.4", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/nested-clients": { + "version": "3.998.4", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.998.4.tgz", + "integrity": "sha512-8Vzg3e9ia6eHQStnoSn17asRNWHrf/ozgQslLMGOdM5JifyV+AAk1+lgVXcQMmrzgRhR9phRUEFxAOg/cBh7MQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/signature-v4-multi-region": "^3.996.52", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/signature-v4-multi-region": { + "version": "3.996.52", + "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.52.tgz", + "integrity": "sha512-6W6SjGc8OXUhMzNxU1X922ghD+PP1XvzmCk5Scui0jaYsLezycMYR1RaLp5xTIOUrhTXyb4DnAbPr3fBgmdnzg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.975.1", + "@smithy/signature-v4": "^5.7.5", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/token-providers": { + "version": "3.1175.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1175.0.tgz", + "integrity": "sha512-irdg9wmKjTDumWoZeXIM3ecgfriHEEm0Q05bjiHwGNRCXXexz+5roMS28IzKWELI5QX/XZjL1vvvaIyptlCfAQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.1", + "@aws-sdk/nested-clients": "^3.998.4", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/types": { + "version": "3.975.1", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.975.1.tgz", + "integrity": "sha512-7rGxUkCB2QPoQOeJmonmAICTN2zrH+fpmi1p4Iwu72lnxNaMhOgqcbpyddifnM1DBb19TWQ1u6z/XjkaFNEDWw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/xml-builder": { + "version": "3.972.43", + "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.43.tgz", + "integrity": "sha512-rG8QVx4DOrJWptsogu1Aq+CDsnPKaBrAlJpKLxrJrIDXAq1ElnW0yQjjBnlWSXll0cDakCG6UDvaqwz0A9d9Og==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws/lambda-invoke-store": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@aws/lambda-invoke-store/-/lambda-invoke-store-0.3.0.tgz", + "integrity": "sha512-sl4Bm6yiMNYrZKkqqDFWN0UfnWhlS8ivKxrYl+6t0gCLrqr8y3B2IqZZbFRkfaVVp7C/baApyh71P+LeE1A2sQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz", + "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz", + "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz", + "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==", + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz", + "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz", + "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz", + "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz", + "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz", + "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz", + "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz", + "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz", + "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz", + "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz", + "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz", + "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz", + "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz", + "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz", + "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz", + "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz", + "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz", + "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz", + "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz", + "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==", + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.11.3" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz", + "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz", + "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz", + "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz", + "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@next/env": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.29.tgz", + "integrity": "sha512-9SrTiTsgORa+KfhlXXAGC1eSs847E+d2MQTPUX+n7R5XA8g/B6ZitfL6GoYHNMLwG3Hzs1wjDH0/ME5WrGMqBQ==", + "license": "MIT" + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.29.tgz", + "integrity": "sha512-vozRDuM23T0faRR0O3oN1eRqjEqUue4Eljhkb9f7urQgzmyzve7j3atzTv3Z1AnjQ9IeVY0X3aS1/an56TOiTg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.29.tgz", + "integrity": "sha512-FzrcEzMZVcp/SqFXCW5SXyPil10bB9l5wpTBapEs9ZMqke3W+hyC5mNAdAa1divn+4SZ7LD5BtK67XvK7SucWQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.29.tgz", + "integrity": "sha512-FWbWE5P313Yy5062vgY9UspNz/t6Ve/s35X9v6YU7ilsbhqKGabPBPIWcMEPhyomeRdwfv19NAITkU2FFIhGwA==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.29.tgz", + "integrity": "sha512-xjTHrVisb9GeDSNFOwJI+4UJrKdwlpjz95q8sEvQh46yUp3+JikNcf26pode/HlHktSdJwcHx3iVMCjfPcnU+A==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.29.tgz", + "integrity": "sha512-5WqW7kHscT02wyF8TlbYv9+zx3KhnQeZwk+FkTCr1r7TuvMrqqOZ3RDkdDKl3O0M0Er3VuQEzoEIrj8VX5fjaw==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.29.tgz", + "integrity": "sha512-I0QJ1Be9vtdq5FABhNcSbkELllA91WnhG+m4BjJHCn1bXAIL8AuDABIKIJ7Bz84T/sIkZP6TvOEWJcKckrX3yQ==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.29.tgz", + "integrity": "sha512-q4fQFWtR7nH7ZDhU8RIvwNW0S/nHImaZkoOSw7rOXFgoP51HTesm8/8P/w3ACjc9GxqytXj0LZZesykK3arFBw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.29.tgz", + "integrity": "sha512-putWQ+CTEJunAPIPDPfb06Kc4emhYpdM5FoCDHSkC/ym7Dy2xOBMPgBjBbRkw2Hp5/550ACYxCmUtV4k4ui3Iw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@smithy/core": { + "version": "3.41.0", + "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.41.0.tgz", + "integrity": "sha512-fuZ34H1uizS3WgcX9VXG7Uy8od5A5/kCc+CR3NkHLNm2H/BE9AUHG02VIdu8ZB7FYhLqsr/RZbqAoXuOCg/Oxg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/credential-provider-imds": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.5.2.tgz", + "integrity": "sha512-A9uSdn72ozbRUSit0eib0TW7nXuNPlaeM0zcGkJ+nE6tFcSDbnmtwoxbTCFBukVQcszDAyvsd7+rTduPTXpygg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.33.2", + "@smithy/types": "^4.17.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/fetch-http-handler": { + "version": "5.8.1", + "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.1.tgz", + "integrity": "sha512-h8BdMUrUBhMhMaeK7QqAdINRZezCGuYOCpcOZZ1ewxbHST9rdTd09xwNpvLTYfzDRehxQiReK4SKbdYZxBA+ew==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.39.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/node-http-handler": { + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.14.2.tgz", + "integrity": "sha512-i1uORV1v3qBqP43ayRKzIdm1q5x14tf8N4Dd06/QUX1Szm6VxHMrTsu20X5E63UFsaNZCRjI4SXG0jDmqYa+3w==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.39.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/signature-v4": { + "version": "5.7.5", + "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.7.5.tgz", + "integrity": "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.38.0", + "@smithy/types": "^4.19.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/types": { + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.20.0.tgz", + "integrity": "sha512-lCA6QG22dPk9ecHbv91jDQZsmtPUjdS1aE2Il6NNPqe7DrYc0dZQi6DhcESk2KYXH2sp5xbAcGdYMZDFnuzA2A==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@swc/helpers": { + "version": "0.5.15", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz", + "integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.8.0" + } + }, + "node_modules/@types/node": { + "version": "20.19.43", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.43.tgz", + "integrity": "sha512-6oYBAi5ikg4Pl+kGsoYtawUMBT2zZMCvPNF7pVLnHZfd1zf38DRiWn/gT01RYCdUqkv7Fhr+C9ot4/tb+2sVvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/nodemailer": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-8.0.2.tgz", + "integrity": "sha512-c7M5ox8p0nEOfbJ2E9Qcmt8/QCu/VzsiAhzBiZbvky2PhKZDHpKB3sQHBM5MEZNkCfBOaS6S9//AGPRTNB7IaA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/pg": { + "version": "8.23.1", + "resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.23.1.tgz", + "integrity": "sha512-fKVHpikPdg4GKks3JuLEhvwSyvwzF23hnabPy6DD8ljVbC7+6J5dQzdv4arV6jqq57djnMgs1HKBxX4P8aBI3A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "pg-protocol": "*", + "pg-types": "^2.2.0" + } + }, + "node_modules/@types/react": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", + "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz", + "integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.3.0" + } + }, + "node_modules/bowser": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.15.1.tgz", + "integrity": "sha512-ma47ABeUiTsmG4McKDtGCgQSiTCatM97Mlbn13K42N1kPSFE14oN3WFMjtyL4KubhGvQTqYheKl4Qx2bJtMXLQ==", + "license": "MIT" + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001826", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001826.tgz", + "integrity": "sha512-wTB+9tIbLro/BCXwLuNV1meHE4L9dS6dArMDwgYfNBPMYScqClHyGunhkCSDtHhe/69Xl0sHlKgBVZ+fNsYtWA==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/client-only": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", + "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==", + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.4.tgz", + "integrity": "sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/geist": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/geist/-/geist-1.9.2.tgz", + "integrity": "sha512-UU1x2q5Khob0+i4csFvXk1Ki4DePdu7xISuXyEcj1tzQMg64oN7Kbuy4e5z5QhcUWbbvOMJNs3ZxYQqpsEMV3w==", + "license": "SIL OPEN FONT LICENSE", + "peerDependencies": { + "next": ">=13.2.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/next": { + "version": "15.5.29", + "resolved": "https://registry.npmjs.org/next/-/next-15.5.29.tgz", + "integrity": "sha512-93AMszTCdi9Az7fD5VzcWy46SHCdQF45+i53K0LpDc4dDXCwB9P1SxP1wBYZKW6dF3HJnz41jyEni1vmgCluiw==", + "license": "MIT", + "dependencies": { + "@next/env": "15.5.29", + "@swc/helpers": "0.5.15", + "caniuse-lite": "^1.0.30001579", + "postcss": "8.4.31", + "styled-jsx": "5.1.6" + }, + "bin": { + "next": "dist/bin/next" + }, + "engines": { + "node": "^18.18.0 || ^19.8.0 || >= 20.0.0" + }, + "optionalDependencies": { + "@next/swc-darwin-arm64": "15.5.29", + "@next/swc-darwin-x64": "15.5.29", + "@next/swc-linux-arm64-gnu": "15.5.29", + "@next/swc-linux-arm64-musl": "15.5.29", + "@next/swc-linux-x64-gnu": "15.5.29", + "@next/swc-linux-x64-musl": "15.5.29", + "@next/swc-win32-arm64-msvc": "15.5.29", + "@next/swc-win32-x64-msvc": "15.5.29", + "sharp": "^0.34.3 || ^0.35.5" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.1.0", + "@playwright/test": "^1.51.1", + "babel-plugin-react-compiler": "*", + "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", + "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", + "sass": "^1.3.0" + }, + "peerDependenciesMeta": { + "@opentelemetry/api": { + "optional": true + }, + "@playwright/test": { + "optional": true + }, + "babel-plugin-react-compiler": { + "optional": true + }, + "sass": { + "optional": true + } + } + }, + "node_modules/nodemailer": { + "version": "10.6.1", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.6.1.tgz", + "integrity": "sha512-d7kfFfS/tR4Aca+SBvRaQ+MXKNv7d2JiRe5TxaRcFT/kYMh4GGPnW9aKksTIEvyEbA7d/7HYWE4YPDEHxzJj/g==", + "license": "MIT-0", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/pg": { + "version": "8.23.1", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.23.1.tgz", + "integrity": "sha512-aL96AHANtWjPLDOLqnhx+ngp9+UK7ETEU8VJrDCGvsSSi/mGLcWYsS6Herg7lmaBJe4uwrfqsa7gTEFaSizDoQ==", + "license": "MIT", + "dependencies": { + "pg-connection-string": "^2.14.1", + "pg-pool": "^3.14.0", + "pg-protocol": "^1.16.1", + "pg-types": "2.2.0", + "pgpass": "1.0.5" + }, + "engines": { + "node": ">= 16.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.4.1" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.4.1.tgz", + "integrity": "sha512-6PQbsFWZcp9EmJEwy5cGQ2La+AMWpP46lgbb8X+U/XsHIUweYDNCpeuKck5RxL2MdVFi7krbbEi5nX4Zh7JhrQ==", + "license": "MIT", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.14.1.tgz", + "integrity": "sha512-qR3kGNPBLpCNtz0evbKA0Y/MRFXwSSdT+pTJvYp/bXTcReZbvX1kzF0IyTc1QnxqF7AZbOeBhNL8R5mYQZV/MA==", + "license": "MIT" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "license": "ISC", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.14.0.tgz", + "integrity": "sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==", + "license": "MIT", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.16.1.tgz", + "integrity": "sha512-p9VOFMiHB/ZbJATetbg+99PxssTVSQRnyuPSQ67mN1+1KBOjZaZ83ZQzltnxPhJwSsC3nwVjJ10DVJlerbFzLg==", + "license": "MIT" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "license": "MIT", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "license": "MIT", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.1.tgz", + "integrity": "sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "license": "MIT", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", + "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", + "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.26.0" + }, + "peerDependencies": { + "react": "^19.1.0" + } + }, + "node_modules/scheduler": { + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz", + "integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", + "license": "ISC", + "optional": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/server-only": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/server-only/-/server-only-0.0.1.tgz", + "integrity": "sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA==", + "license": "MIT" + }, + "node_modules/sharp": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz", + "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==", + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.5", + "@img/sharp-darwin-x64": "0.35.5", + "@img/sharp-freebsd-wasm32": "0.35.5", + "@img/sharp-libvips-darwin-arm64": "1.3.4", + "@img/sharp-libvips-darwin-x64": "1.3.4", + "@img/sharp-libvips-linux-arm": "1.3.4", + "@img/sharp-libvips-linux-arm64": "1.3.4", + "@img/sharp-libvips-linux-ppc64": "1.3.4", + "@img/sharp-libvips-linux-riscv64": "1.3.4", + "@img/sharp-libvips-linux-s390x": "1.3.4", + "@img/sharp-libvips-linux-x64": "1.3.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4", + "@img/sharp-libvips-linuxmusl-x64": "1.3.4", + "@img/sharp-linux-arm": "0.35.5", + "@img/sharp-linux-arm64": "0.35.5", + "@img/sharp-linux-ppc64": "0.35.5", + "@img/sharp-linux-riscv64": "0.35.5", + "@img/sharp-linux-s390x": "0.35.5", + "@img/sharp-linux-x64": "0.35.5", + "@img/sharp-linuxmusl-arm64": "0.35.5", + "@img/sharp-linuxmusl-x64": "0.35.5", + "@img/sharp-webcontainers-wasm32": "0.35.5", + "@img/sharp-win32-arm64": "0.35.5", + "@img/sharp-win32-ia32": "0.35.5", + "@img/sharp-win32-x64": "0.35.5" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/source-map-js": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.4.tgz", + "integrity": "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/styled-jsx": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz", + "integrity": "sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==", + "license": "MIT", + "dependencies": { + "client-only": "0.0.1" + }, + "engines": { + "node": ">= 12.0.0" + }, + "peerDependencies": { + "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "license": "0BSD" + }, + "node_modules/tsx": { + "version": "4.23.15", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.23.15.tgz", + "integrity": "sha512-Yiex1Ovn8z2xPpOWckIiysV1SSyRMY9BkLF++q0yKiDxCqRhosKfMg3janKkiLBwZ5c/YryloKwGZcrEmtwxKw==", + "license": "MIT", + "dependencies": { + "esbuild": "~0.28.0" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..35fd41d --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "courier", + "version": "26.11.1", + "private": true, + "scripts": { + "dev": "next dev -H 0.0.0.0 -p 3400", + "build": "next build", + "start": "next start -H 0.0.0.0 -p 3400", + "typecheck": "tsc --noEmit", + "db:migrate": "node scripts/migrate.mjs", + "db:key": "node scripts/create-key.mjs", + "worker": "tsx scripts/worker.ts", + "ses:records": "node scripts/ses-records.mjs" + }, + "dependencies": { + "@aws-sdk/client-sesv2": "^3.1175.0", + "geist": "^1.9.2", + "next": "15.5.29", + "nodemailer": "^10.6.1", + "pg": "^8.23.1", + "react": "19.1.0", + "react-dom": "19.1.0", + "server-only": "^0.0.1", + "tsx": "^4.23.15", + "zod": "^4.6.7" + }, + "devDependencies": { + "@types/node": "^20", + "@types/nodemailer": "^8.0.2", + "@types/pg": "^8.23.1", + "@types/react": "^19", + "@types/react-dom": "^19", + "typescript": "^5" + } +} diff --git a/public/file.svg b/public/file.svg new file mode 100644 index 0000000..004145c --- /dev/null +++ b/public/file.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/globe.svg b/public/globe.svg new file mode 100644 index 0000000..567f17b --- /dev/null +++ b/public/globe.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/next.svg b/public/next.svg new file mode 100644 index 0000000..5174b28 --- /dev/null +++ b/public/next.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/vercel.svg b/public/vercel.svg new file mode 100644 index 0000000..7705396 --- /dev/null +++ b/public/vercel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/window.svg b/public/window.svg new file mode 100644 index 0000000..b2b2a44 --- /dev/null +++ b/public/window.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/create-key.mjs b/scripts/create-key.mjs new file mode 100644 index 0000000..1acbb4e --- /dev/null +++ b/scripts/create-key.mjs @@ -0,0 +1,40 @@ +import { createHmac, randomBytes } from "node:crypto"; +import pg from "pg"; + +const args = process.argv.slice(2); +const get = (name, fallback) => { + const index = args.indexOf(`--${name}`); + return index >= 0 ? args[index + 1] : fallback; +}; + +const app = get("app"); +if (!app) { + console.error("Aufruf: npm run db:key -- --app plan --name 'Plan' [--daily 400] [--monthly 12000] [--from plan@hubsport.club]"); + process.exit(1); +} + +const name = get("name", app); +const domain = get("domain", process.env.MAIL_FROM_DOMAIN || "hubsport.club"); +const daily = Number(get("daily", 500)); +const monthly = Number(get("monthly", 15000)); +const from = get("from"); +const pepper = process.env.API_KEY_PEPPER || "dev-only-pepper"; +const key = `ck_live_${randomBytes(24).toString("base64url")}`; +const hash = createHmac("sha256", pepper).update(key).digest("hex"); +const prefix = key.slice(0, 16); + +const url = + process.env.DATABASE_URL || + `postgresql://courier@127.0.0.1:${process.env.DB_PORT || "55432"}/courier`; +const client = new pg.Client({ connectionString: url }); +await client.connect(); +const { rows } = await client.query( + `insert into api_keys (app, name, prefix, key_hash, from_domain, allowed_from, daily_limit, monthly_limit) + values ($1,$2,$3,$4,$5,$6,$7,$8) + returning id, app, created_at`, + [app, name, prefix, hash, domain, from ? [from] : null, daily, monthly], +); +await client.end(); + +console.log(JSON.stringify(rows[0], null, 2)); +console.log(`\nAPI-Key (nur jetzt sichtbar):\n${key}\n`); diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100644 index 0000000..a473a2a --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -e + +i=0 +until node scripts/migrate.mjs; do + i=$((i + 1)) + if [ "$i" -ge 30 ]; then + echo "Datenbank nicht erreichbar, Migration abgebrochen." >&2 + exit 1 + fi + echo "Migration erneut in 2s (Versuch $i)…" >&2 + sleep 2 +done + +exec ./node_modules/.bin/next start -H 0.0.0.0 -p "${PORT:-3000}" diff --git a/scripts/migrate.mjs b/scripts/migrate.mjs new file mode 100644 index 0000000..7904e52 --- /dev/null +++ b/scripts/migrate.mjs @@ -0,0 +1,47 @@ +import { createHash } from "node:crypto"; +import { readdir, readFile } from "node:fs/promises"; +import path from "node:path"; +import pg from "pg"; + +const url = + process.env.DATABASE_URL || + `postgresql://courier@127.0.0.1:${process.env.DB_PORT || "55432"}/courier`; + +const client = new pg.Client({ connectionString: url }); +await client.connect(); + +await client.query(` + create table if not exists schema_migrations ( + name text primary key, + checksum text not null, + applied_at timestamptz not null default now() + ) +`); + +const dir = path.join(process.cwd(), "db", "migrations"); +const files = (await readdir(dir)).filter((file) => file.endsWith(".sql")).sort(); + +for (const file of files) { + const sql = await readFile(path.join(dir, file), "utf8"); + const checksum = createHash("sha256").update(sql).digest("hex"); + const { rows } = await client.query(`select checksum from schema_migrations where name = $1`, [file]); + if (rows[0]) { + if (rows[0].checksum !== checksum) { + throw new Error(`${file} wurde nach dem Anwenden geändert`); + } + continue; + } + console.log(`migrate ${file}`); + await client.query("begin"); + try { + await client.query(sql); + await client.query(`insert into schema_migrations (name, checksum) values ($1, $2)`, [file, checksum]); + await client.query("commit"); + } catch (error) { + await client.query("rollback"); + throw error; + } +} + +await client.end(); +console.log("Datenbank aktuell."); diff --git a/scripts/ses-records.mjs b/scripts/ses-records.mjs new file mode 100644 index 0000000..1444dec --- /dev/null +++ b/scripts/ses-records.mjs @@ -0,0 +1,25 @@ +import { SESv2Client, GetEmailIdentityCommand } from "@aws-sdk/client-sesv2"; + +const domain = process.env.MAIL_FROM_DOMAIN || "hubsport.club"; +const region = process.env.AWS_REGION || "eu-west-1"; +const client = new SESv2Client({ region }); +const identity = await client.send(new GetEmailIdentityCommand({ EmailIdentity: domain })); +const status = identity.DkimAttributes?.Status ?? "UNKNOWN"; +const tokens = identity.DkimAttributes?.Tokens ?? []; +const mailFrom = identity.MailFromAttributes?.MailFromDomain ?? `bounce.${domain}`; + +console.log(`SES-Identity: ${domain} (${region})`); +console.log(`DKIM: ${status}`); +console.log(`Sending aktiv: ${identity.VerifiedForSendingStatus ? "ja" : "nein"}\n`); + +console.log("Cloudflare-Records (Proxy aus):\n"); +for (const token of tokens) { + console.log(`CNAME ${token}._domainkey.${domain} -> ${token}.dkim.amazonses.com`); +} +console.log(`MX ${mailFrom} -> 10 feedback-smtp.${region}.amazonses.com`); +console.log(`TXT ${mailFrom} -> "v=spf1 include:amazonses.com ~all"`); +console.log(`TXT _dmarc.${domain} -> "v=DMARC1; p=none;"\n`); + +if (tokens.length === 0) { + console.log("Keine DKIM-Tokens gefunden. Ist die Identity im richtigen Account/Region angelegt?"); +} diff --git a/scripts/worker.ts b/scripts/worker.ts new file mode 100644 index 0000000..f4e9b58 --- /dev/null +++ b/scripts/worker.ts @@ -0,0 +1,81 @@ +import { query } from "../lib/db"; +import { sendStored, type SendFailure } from "../lib/transport"; +import type { StoredPayload } from "../lib/queue"; + +const MAX_ATTEMPTS = 5; +const POLL_MS = 1000; + +type Claimed = { + id: string; + attempts: number; + payload: StoredPayload; +}; + +let running = true; +process.on("SIGTERM", () => { + running = false; +}); +process.on("SIGINT", () => { + running = false; +}); + +function sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +async function claim(): Promise { + const { rows } = await query( + `update messages + set status = 'sending', attempts = attempts + 1 + where id = ( + select id from messages + where status = 'queued' and next_attempt_at <= now() + order by next_attempt_at + limit 1 + for update skip locked + ) + returning id, attempts, payload`, + ); + return rows[0] ?? null; +} + +async function run() { + console.log(`[courier-worker] gestartet, Transport ${process.env.MAIL_TRANSPORT || "dry-run"}`); + while (running) { + const job = await claim(); + if (!job) { + await sleep(POLL_MS); + continue; + } + + try { + const result = await sendStored(job.payload); + await query( + `update messages + set status = 'sent', provider_message_id = $2, sent_at = now(), error = null + where id = $1`, + [job.id, result.providerMessageId], + ); + console.log(`[courier-worker] ${job.id} gesendet (${result.providerMessageId})`); + } catch (error) { + const failure = error as SendFailure; + const retry = failure.retryable !== false && job.attempts < MAX_ATTEMPTS; + const delay = Math.min(3600, 30 * 2 ** Math.max(0, job.attempts - 1)); + await query( + `update messages + set status = $2, + error = $3, + next_attempt_at = case when $2 = 'queued' then now() + ($4 || ' seconds')::interval else next_attempt_at end + where id = $1`, + [job.id, retry ? "queued" : "failed", String(failure.message || failure).slice(0, 2000), String(delay)], + ); + console.error(`[courier-worker] ${job.id} ${retry ? `erneut in ${delay}s` : "endgültig fehlgeschlagen"}:`, failure.message); + } + } + console.log("[courier-worker] beendet"); +} + +run().catch((error) => { + console.error("[courier-worker] Absturz:", error); + process.exit(1); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..d8b9323 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "ES2017", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "plugins": [ + { + "name": "next" + } + ], + "paths": { + "@/*": ["./*"] + } + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/types/nodemailer-internals.d.ts b/types/nodemailer-internals.d.ts new file mode 100644 index 0000000..bc55b95 --- /dev/null +++ b/types/nodemailer-internals.d.ts @@ -0,0 +1,12 @@ +declare module "nodemailer/lib/addressparser" { + export type ParsedAddress = { address: string; name: string }; + export default function addressparser(address: string): ParsedAddress[]; +} + +declare module "nodemailer/lib/mail-composer" { + import type { Options } from "nodemailer/lib/mailer"; + export default class MailComposer { + constructor(mail: Options); + compile(): { build(callback: (error: Error | null, message: Buffer) => void): void }; + } +}