@beesolve/dmarc-dashboard

中文文档
0.10.11发布于 2026/10/28MITTypeScriptES Module构建来源已验证近 30 天下载 2206

DMARC dashboard — SvelteKit app for viewing DMARC reports

原始使用文档
文档目录11 节
  1. Architecture
  2. Prerequisites
  3. CDK Setup
  4. Data layer (remote functions)
  5. First Deployment
  6. Local Development
  7. Faking the session
  8. Required env vars
  9. Features
  10. Source IP enrichment (ipinfo.io)
  11. License

@beesolve/dmarc-dashboard

SvelteKit dashboard for viewing DMARC reports — deployed on AWS Lambda behind CloudFront with email-code authentication.

[!WARNING] Pre-1.0 — unstable API. This package is 0.x and under active development. Breaking changes can land in any 0.x release without a major version bump. Pin an exact version and review the changelog before upgrading. Once the API stabilizes and the package reaches 1.0.0, it follows semantic versioning and this notice is removed.

Architecture

┌────────────┐     ┌──────────────┐     ┌─────────┐     ┌──────────┐
│ CloudFront │ ──► │ Lambda (SSR) │ ──► │ DynamoDB│     │   SES    │
└────────────┘     └──────────────┘     └─────────┘     └──────────┘
       │                                                      ▲
       └── /auth/* ──► AuthGateway (authorizer)               │
                                                    OTP emails via
                                                    @beesolve/email-service

Prerequisites

npm install \
  @beesolve/dmarc-dashboard \
  @beesolve/dmarc-reports \
  @beesolve/dmarc-consumer \
  @beesolve/auth-service \
  aws-cdk \
  aws-cdk-lib \
  constructs

CDK Setup

import { AuthGateway } from "@beesolve/auth-service/cdk";
import { DmarcConsumer } from "@beesolve/dmarc-consumer/cdk";
import { DmarcDashboard } from "@beesolve/dmarc-dashboard/cdk";
import { DmarcReports } from "@beesolve/dmarc-reports/cdk";
import { App, Stack } from "aws-cdk-lib";

const frontendUri = process.env.FRONTEND_URI;
if (frontendUri == null) throw new Error("FRONTEND_URI environment variable is required");

const app = new App();
const stack = new Stack(app, "DmarcStack", {
  env: { account: "123456789012", region: "eu-central-1" },
});

// 1. Set up report ingestion (SES → S3 → EventBridge)
const dmarcReports = new DmarcReports(stack, "DmarcReports", {
  recipient: "[email protected]",
});

// 2. Set up consumer (EventBridge → SQS → Lambda → DynamoDB)
const consumer = new DmarcConsumer(stack, "DmarcConsumer");

// 3. Set up authentication
const auth = new AuthGateway(stack, "Auth", {
  stage: "prod",
  frontendUri,
  allowSignUp: false,
  authorizerCache: "disabled",
});

// 4. Deploy the dashboard
const dashboard = new DmarcDashboard(stack, "DmarcDashboard", {
  auth,
  consumer,
  emailSender: {
    name: "DMARC Dashboard",
    emailAddress: "[email protected]",
  },
});

The DmarcDashboard construct provisions:

  • SvelteKit app on Lambda (via kit-on-lambda)
  • CloudFront distribution with auth cookie enforcement
  • Auth behavior for /auth/* routes
  • Email service for OTP codes
  • EventBridge rule for auth events (sends OTP emails)

Data layer (remote functions)

The dashboard reads and writes its data through SvelteKit remote functions, not +page.server.ts load/actions. Definitions live in src/lib/remote/*.remote.ts, organized by domain area (domains, reports, stats, users, setup):

  • query(...) for reads (domain list, stats, report detail, domain overview). URL filters such as cursor/date/month are passed as Valibot-validated arguments.
  • form(...) for user-submitted mutations (invite user, edit user, complete setup).
  • command(...) for programmatic mutations invoked from event handlers (domain refresh).

Each function reads request context via getRequestEvent().locals (locals.user, locals.session, locals.services), which hooks.server.ts populates. Admin and per-domain guards live inside the remote functions. After a mutation, the relevant query(...).refresh() is called for a single-flight UI update.

Error mapping is centralized in src/lib/server/httpErrors.ts: toRemoteError(error, { redirectOnUnauthorized }) turns domain errors into SvelteKit error()/redirect(), and requireUser(user) guards a present session. Call toRemoteError(...) directly inside a catch - never throw its result.

Remote functions are enabled by experimental.remoteFunctions and compilerOptions.experimental.async in vite.config.ts. The only retained server loads are +layout.server.ts (supplies user), the setup/+page.server.ts redirect guard, and the sign-in universal/layout loads.

Environment variables are declared in src/env.ts via defineEnvVars (Valibot schemas) and imported, typed and validated, from $app/env/private. The sign-in / verify /auth/* flows hit the auth-service CloudFront origin and are intentionally left outside the remote-functions layer.

First Deployment

The SvelteKit build requires a FRONTEND_URI environment variable (the CloudFront URL), which doesn't exist until after the first deploy:

  1. Set FRONTEND_URI to a placeholder URL (e.g. https://placeholder.cloudfront.net)
  2. Deploy — note the CloudFront URL from CDK output
  3. Update FRONTEND_URI with the real URL and redeploy

Local Development

Run the SvelteKit dev server against the real deployed backend — no fixtures:

bun install
cp .env.local.example .env.local   # then fill in real values
aws sso login                      # (or export AWS_PROFILE) so SDK clients can reach AWS
bun run dev

bun run dev serves on http://localhost:5173. The dev script runs bun --env-file=.env.local vite dev, so .env.local is loaded into process.env before the server starts. The two table vars are then declared in src/env.ts (defineEnvVars) and read, typed and validated, from $app/env/private in hooks.server.ts; the workspace SDK clients still read their own vars from process.env at import time. (.env.local must exist - it is the local dev config; copy it from .env.local.example.)

Faking the session

There is no Lambda authorizer locally, so @beesolve/auth-service injects a dev session automatically. Set DEV_USER_EMAIL in .env.local to a real user's email in the DMARC table — the app looks it up to resolve that user's role (admin/user) and permitted domains, so you see the same UI they would. This is guarded by import.meta.env.DEV and is never included in the deployed bundle.

If DEV_USER_EMAIL is unset, the auth service falls back to its built-in dev-user session, which won't resolve against the table (nav hides admin-only links and data lookups for that user return nothing).

Required env vars

See .env.local.example for the full list. The two table vars (DMARC_TABLE_NAME, DMARC_REVERSE_INDEX) are declared in src/env.ts and validated by defineEnvVars when first imported from $app/env/private. The auth/email/consumer SDK clients parse their own env at import time (auth handler ARN, email queue/table/bucket, tasks queue), so all must be present or the first request will throw.

Features

  • Domain overview with aggregate pass/fail stats
  • Per-domain report timeline with pagination
  • User management (invite, remove)
  • Email-code sign-in (no passwords)

Source IP enrichment (ipinfo.io)

Source IPs can be enriched with ASN / organization name and country via the free ipinfo.io Lite API. This is optional — without a key the ASN / country columns render as —. See docs/ipinfo-setup.md for how to obtain a key and configure it locally and in a deployment.

License

MIT

版本与发布记录

@beesolve/dmarc-dashboard 共发布 45 个版本,首次发布于 2026/08/14;过去 12 个月发布了 45 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.10.11latest2026/10/2811 天前
0.10.102026/10/2019 天前
0.10.92026/10/2019 天前
0.10.82026/10/1721 天前
0.10.72026/10/1326 天前
0.10.62026/10/1326 天前

关于 @beesolve/dmarc-dashboard 的常见问题

@beesolve/dmarc-dashboard 是什么?

DMARC dashboard — SvelteKit app for viewing DMARC reports

如何安装 @beesolve/dmarc-dashboard?

在项目目录运行 npm install @beesolve/dmarc-dashboard,或使用 pnpm add / yarn add / bun add。

@beesolve/dmarc-dashboard 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@beesolve/dmarc-dashboard 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@beesolve/dmarc-dashboard 可以商用吗?

@beesolve/dmarc-dashboard 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@beesolve/dmarc-dashboard 的下载量有多少?

根据 npm 官方下载统计,@beesolve/dmarc-dashboard 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,206 次,日均约 74 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@beesolve/dmarc-dashboard 还在维护吗?

最新版本 0.10.11 发布于 2026/10/28(11 天前);至今共发布 45 个版本,其中过去 12 个月发布了 45 个;首次发布于 2026/08/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。