commit 2c0d7ec2250f3e4f4fde31fbda4b84913ee045bd Author: AImighty Bot Date: Sun Nov 22 14:20:34 2026 +0000 Courier: Mail-Gateway mit Resend-API, Queue und SES-Transport 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 0000000..718d6fe Binary files /dev/null and b/app/favicon.ico differ 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 0000000..44ed356 Binary files /dev/null and b/icon.png differ 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 }; + } +}