diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 885e3ed..c9aa36a 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -4,7 +4,7 @@ contact_links: url: https://github.com/NodeByteLTD/ByteSend/blob/main/SECURITY.md about: Please report vulnerabilities privately. - name: Community support (Discord) - url: https://discord.gg/xqkqzVRC4S + url: https://discord.gg/C2Q4GHXKQA about: Ask questions and get help from the community. - name: Documentation url: https://docs.bytesend.cloud diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml index 13e8a3d..0972952 100644 --- a/.github/workflows/npm-release.yml +++ b/.github/workflows/npm-release.yml @@ -31,21 +31,32 @@ jobs: with: version: 9.0.0 - - name: Set up Node.js 20.x - uses: actions/setup-node@v4 + # Trusted publishing needs npm 11.5+, which ships with Node 24. + - name: Set up Node.js 24.x + uses: actions/setup-node@v5 with: - node-version: 20.x + node-version: 24.x registry-url: "https://registry.npmjs.org" cache: pnpm cache-dependency-path: pnpm-lock.yaml - - name: Upgrade npm - run: npm install -g npm@latest - - name: Install dependencies run: pnpm install --filter "./packages/sdk..." --frozen-lockfile + - name: Check whether this version is already published + id: version + working-directory: packages/sdk + run: | + VERSION=$(node -p "require('./package.json').version") + if npm view "bytesend-js@${VERSION}" version >/dev/null 2>&1; then + echo "bytesend-js@${VERSION} is already on npm; bump the version in packages/sdk/package.json to publish." + echo "publish=false" >> "$GITHUB_OUTPUT" + else + echo "publish=true" >> "$GITHUB_OUTPUT" + fi + - name: Publish SDK + if: steps.version.outputs.publish == 'true' working-directory: packages/sdk run: | pnpm run build diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 6cd5bcc..e09a4fe 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -1,4 +1,4 @@ -name: Relase Python SDK +name: Release Python SDK env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" @@ -46,4 +46,6 @@ jobs: - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - packages-dir: packages/python-sdk/dist \ No newline at end of file + packages-dir: packages/python-sdk/dist + # Pushes that don't bump the version in pyproject.toml would otherwise fail on the duplicate upload. + skip-existing: true \ No newline at end of file diff --git a/.github/workflows/website-test.yml b/.github/workflows/website-test.yml index c4304c1..d1a7949 100644 --- a/.github/workflows/website-test.yml +++ b/.github/workflows/website-test.yml @@ -64,7 +64,7 @@ jobs: uses: pnpm/action-setup@v4 - name: Setup Node - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: 22 cache: pnpm diff --git a/CHANGELOG.md b/CHANGELOG.md index 26d89f2..51b3756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Brand asset kit** (`public/brand/`) — SVG marks (colour, mono black/white, compact, glyph), light/dark wordmarks, 1024px app icon, social avatar, GitHub social preview (1280×640), Discord banner (960×540) and invite splash (1920×1080), X/Twitter header (1500×500) - **`pnpm --filter web brand:generate`** — regenerates every logo, favicon, app icon and banner from the shared geometry in `src/lib/brand.tsx` - **Open Graph & Twitter images** — generated `opengraph-image` / `twitter-image` routes for the site and the changelog using `next/og`, replacing the externally hosted share image +- **Discord emoji set** (`public/brand/discord-emojis/`) — static `bs_logo`, `bs_send`, `bs_api`, `bs_delivered`, `bs_bounced`, `bs_held`, `bs_verified` and animated `bs_sending`, `bs_loading`, `bs_mailfly`, all 128×128 and well under Discord's 256 KB limit; regenerate with `pnpm --filter web brand:emojis` + +#### Website +- **Refreshed homepage** — reordered to hero → proof points → developer quick-start → features → how it works → pricing → comparison → call to action, with smooth anchor scrolling and gentle scroll-in animations that respect reduced-motion settings +- New hero copy with a "What's new" link to the changelog, and the brand palette across headings, feature icons and accents +- Features rewritten as a bento grid that now covers deliverability guardrails, spam protection and sending regions +- New "How it works" section: verify a domain, send, watch it land +- Proof strip now lists verifiable facts (free tier, AGPL-3.0, REST + SMTP + three SDKs, self-hosting) in place of unverified uptime and delivery-time figures +- Free-tier copy clarifies that the 12,500 free emails a month are transactional +- Comparison table re-checked against each provider's published plans (SendGrid's free plan is now a 60-day trial; Resend has a visual editor) and dated +- All Discord links point to the new ByteSend community server #### Admin Panel - **Overview dashboard** (`/admin`) — 7/30/90-day KPIs with prior-period deltas, sending and signup charts, SES quota and sandbox status per region, a "Needs attention" panel (teams over bounce/complaint warning thresholds, blocked teams, failing domains) and recent admin activity @@ -45,14 +56,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Prisma query logging** is now opt-in in development via `PRISMA_LOG_QUERIES=true` - Teams and users admin pages are now searchable lists that open the new detail pages; domains, webhooks, billing and email analytics share the refreshed admin layout - Bounce/complaint thresholds moved to `src/lib/constants/deliverability.ts`, shared by `LimitService` and the admin views +- **`/api/version`** caches the release lookup for 10 minutes and falls back to the last known version, instead of calling GitHub up to three times on every dashboard load; the sidebar no longer shows a stale hard-coded version when the lookup fails +- **Syntax highlighting** loads only the eight languages and two themes the site uses instead of every Shiki grammar, shrinking the homepage bundle and dev compile +- **SDKs** — `bytesend-js` 0.1.3 and the `bytesend` Python package 0.1.2 add the `HELD` email status +- Release workflows skip versions that are already published instead of failing, and the npm release runs on Node 24 (npm 12 no longer supports Node 20) ### Fixed +- **Security: dashboard route gate** — the middleware treated every path as public because `/` matched every route as a prefix, so the dashboard was never gated at the edge. It now requires a session for all dashboard routes and sends signed-out visitors to the login page, which returns them to the page they asked for. (Sessions are stored in the database, so bans and 2FA continue to be enforced on the server for every request.) - **Security: OAuth account takeover** — sign-in with GitHub, Google or Discord now requires the provider to have verified the email address; previously an unverified provider email could be linked to an existing ByteSend account - Webhook-call cleanup job was never started, so call history was never pruned - "Paid users only" in admin email analytics only counted the BASIC plan - Admin team settings reset dropped extra domain/member slots after saving; literal `…`/`–` text in the teams page - Web manifest pointed at icon paths that did not exist - Discord notification icon URL now uses `bytesend.cloud` +- The campaign scheduler no longer removes and re-creates its own job on every start +- CI: unit and tRPC test mocks updated for the per-request ban check, and the email-change tests rewritten for the two-step verification flow ### Documentation - New guides: [Spam Protection](https://docs.bytesend.cloud/guides/spam-protection), [Changing Sending Region](https://docs.bytesend.cloud/guides/sending-regions), [Connected Accounts](https://docs.bytesend.cloud/guides/connected-accounts) and, for self-hosters, [Admin Panel](https://docs.bytesend.cloud/self-hosting/admin-panel) diff --git a/apps/docs/guides/admin-operations.mdx b/apps/docs/guides/admin-operations.mdx index ce155e9..4e91fc0 100644 --- a/apps/docs/guides/admin-operations.mdx +++ b/apps/docs/guides/admin-operations.mdx @@ -292,4 +292,4 @@ For privacy inquiries: - [Manage your team members](/guides/plan-management) - [Configure notification alerts](https://bytesend.cloud/settings/notifications) - [Explore your usage](https://bytesend.cloud/settings/usage) -- [Contact support](https://discord.gg/xqkqzVRC4S) +- [Contact support](https://discord.gg/C2Q4GHXKQA) diff --git a/apps/docs/guides/discord-notifications.mdx b/apps/docs/guides/discord-notifications.mdx index c7161f9..768e478 100644 --- a/apps/docs/guides/discord-notifications.mdx +++ b/apps/docs/guides/discord-notifications.mdx @@ -236,7 +236,7 @@ To reduce alert noise: If messages don't look formatted: - Ensure the bot has embed permissions - Try deleting and recreating the webhook -- Contact [ByteSend Support](https://discord.gg/xqkqzVRC4S) +- Contact [ByteSend Support](https://discord.gg/C2Q4GHXKQA) ### Webhook URL Expired @@ -280,4 +280,4 @@ Discord webhooks don't expire, but: - [Return to notification providers](/guides/notification-providers) - [Set up Slack notifications](/guides/slack-notifications) - [Manage all notifications settings](https://bytesend.cloud/settings/notifications) -- [Join the community Discord](https://discord.gg/xqkqzVRC4S) +- [Join the community Discord](https://discord.gg/C2Q4GHXKQA) diff --git a/apps/docs/guides/github-oauth.mdx b/apps/docs/guides/github-oauth.mdx index 3ed13e1..407f739 100644 --- a/apps/docs/guides/github-oauth.mdx +++ b/apps/docs/guides/github-oauth.mdx @@ -95,7 +95,7 @@ If you click "Cancel" during GitHub authorization: If your accounts didn't merge as expected: -1. Contact [ByteSend Support](https://discord.gg/xqkqzVRC4S) +1. Contact [ByteSend Support](https://discord.gg/C2Q4GHXKQA) 2. We can manually verify and link your accounts 3. Include the email address of both accounts in your support message @@ -119,7 +119,7 @@ If you have multiple GitHub organizations: If you need to use traditional email/password authentication: -1. Contact [ByteSend Support](https://discord.gg/xqkqzVRC4S) +1. Contact [ByteSend Support](https://discord.gg/C2Q4GHXKQA) 2. We can reset your authentication method 3. You'll be able to set a traditional password @@ -129,4 +129,4 @@ After logging in with GitHub OAuth: - [Set up your first domain](/guides/getting-started) - [Explore the dashboard](https://bytesend.cloud/dashboard) -- [Join our community](https://discord.gg/xqkqzVRC4S) +- [Join our community](https://discord.gg/C2Q4GHXKQA) diff --git a/apps/docs/guides/plans-and-pricing.mdx b/apps/docs/guides/plans-and-pricing.mdx index 8e784ab..1e10ec7 100644 --- a/apps/docs/guides/plans-and-pricing.mdx +++ b/apps/docs/guides/plans-and-pricing.mdx @@ -164,7 +164,7 @@ Yes! With the LIFETIME plan: ### Do you offer enterprise plans? -Yes! For high-volume needs (1M+ emails/month), we offer custom enterprise pricing. [Contact sales](https://discord.gg/xqkqzVRC4S) to discuss your requirements. +Yes! For high-volume needs (1M+ emails/month), we offer custom enterprise pricing. [Contact sales](https://discord.gg/C2Q4GHXKQA) to discuss your requirements. ### Can I cancel my subscription? @@ -196,7 +196,7 @@ All invoices are available in your dashboard: For billing questions or concerns: -- **Free Plan**: Community support via [Discord](https://discord.gg/xqkqzVRC4S) +- **Free Plan**: Community support via [Discord](https://discord.gg/C2Q4GHXKQA) - **BASIC/LIFETIME Plans**: Priority email and Discord support ## Next Steps diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index 0d82357..f958e4a 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -2,62 +2,69 @@ import { NextRequest, NextResponse } from "next/server"; import { getToken } from "next-auth/jwt"; import { validateTwoFactorCookieEdge, TWO_FACTOR_COOKIE } from "~/lib/edge-2fa-utils"; -export async function middleware(request: NextRequest) { - const pathname = request.nextUrl.pathname; +const PROTECTED_PREFIXES = [ + "/admin", + "/broadcasts", + "/campaigns", + "/contacts", + "/dashboard", + "/dev-settings", + "/domains", + "/emails", + "/logs", + "/payments", + "/settings", + "/suppressions", + "/templates", + "/webhooks", +]; + +const SESSION_COOKIES = ["__Secure-next-auth.session-token", "next-auth.session-token"]; - const publicPaths = [ - "/login", - "/signup", - "/banned", - "/api", - "/auth", - "/", - "/privacy", - "/terms", - "/cookie-policy", - "/dmca", - "/dpa", - "/acceptable-use", - "/legal", - "/changelog", - "/_next", - "/favicon.ico", - ]; +function matchesPrefix(pathname: string, prefix: string) { + return pathname === prefix || pathname.startsWith(`${prefix}/`); +} - if (publicPaths.some((path) => pathname.startsWith(path))) { +export async function middleware(request: NextRequest) { + const { pathname } = request.nextUrl; + + if (!PROTECTED_PREFIXES.some((prefix) => matchesPrefix(pathname, prefix))) { return NextResponse.next(); } - if (pathname.startsWith("/dashboard") || pathname.startsWith("/broadcasts") || pathname.startsWith("/campaigns")) { - const token = await getToken({ req: request, secret: process.env.NEXTAUTH_SECRET }); + // Sessions are stored in the database, so the edge can only check that a session cookie exists; + // the server validates it (and enforces bans and 2FA) on every request. + const hasSessionCookie = SESSION_COOKIES.some((name) => request.cookies.has(name)); + if (!hasSessionCookie) { + const loginUrl = new URL("/login", request.url); + loginUrl.searchParams.set("callbackUrl", `${pathname}${request.nextUrl.search}`); + return NextResponse.redirect(loginUrl); + } - if (!token) { - return NextResponse.redirect(new URL("/login", request.url)); - } + // Only populated if the app switches to JWT sessions; database sessions have no decodable token. + const token = await getToken({ req: request, secret: process.env.NEXTAUTH_SECRET }); + if (!token) { + return NextResponse.next(); + } - if (token.isBanned) { - return NextResponse.redirect(new URL("/banned", request.url)); - } + if (token.isBanned) { + return NextResponse.redirect(new URL("/banned", request.url)); + } - const cookieValue = request.cookies.get(TWO_FACTOR_COOKIE)?.value; - const userId = token.sub ? parseInt(token.sub, 10) : null; + const cookieValue = request.cookies.get(TWO_FACTOR_COOKIE)?.value; + const userId = token.sub ? parseInt(token.sub, 10) : null; - if (cookieValue && userId) { - const isValid = await validateTwoFactorCookieEdge( - cookieValue, - userId, - process.env.NEXTAUTH_SECRET ?? "dev-secret" - ); - if (!isValid) { - const url = new URL("/auth/2fa-verify", request.url); - const res = NextResponse.redirect(url); - res.cookies.delete(TWO_FACTOR_COOKIE); - return res; - } - return NextResponse.next(); + if (cookieValue && userId) { + const isValid = await validateTwoFactorCookieEdge( + cookieValue, + userId, + process.env.NEXTAUTH_SECRET ?? "dev-secret", + ); + if (!isValid) { + const res = NextResponse.redirect(new URL("/auth/2fa-verify", request.url)); + res.cookies.delete(TWO_FACTOR_COOKIE); + return res; } - - return NextResponse.next(); } return NextResponse.next(); diff --git a/apps/web/src/app/(marketing)/page.tsx b/apps/web/src/app/(marketing)/page.tsx index b3a69ce..660ddf2 100644 --- a/apps/web/src/app/(marketing)/page.tsx +++ b/apps/web/src/app/(marketing)/page.tsx @@ -1,8 +1,4 @@ -import Image from "next/image"; -import Link from "next/link"; import { redirect } from "next/navigation"; -import { Button } from "@bytesend/ui/src/button"; -import { PricingCalculator } from "~/components/marketing/PricingCalculator"; import { CallToAction } from "~/components/marketing/CallToAction"; import { ComparisonTable } from "~/components/marketing/Comparison"; import { TrustStrip } from "~/components/marketing/TrustStrip"; @@ -10,6 +6,7 @@ import { Pricing } from "~/components/marketing/PricingSection"; import { DevSection } from "~/components/marketing/DevSection"; import { Features } from "~/components/marketing/Features"; import { Hero } from "~/components/marketing/Hero"; +import { HowItWorks } from "~/components/marketing/HowItWorks"; import { env } from "~/env"; @@ -22,8 +19,9 @@ export default function Page() {
- + + diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css index 5b8747b..ec81242 100644 --- a/apps/web/src/app/globals.css +++ b/apps/web/src/app/globals.css @@ -6,3 +6,46 @@ @source "../../../../packages/lib/src/**/*.{js,jsx,ts,tsx,mdx}"; @import "@bytesend/ui/styles/globals.css"; + +@theme { + --color-brand-ice: #85fcff; + --color-brand-teal: #00c3d6; + --color-brand-sky: #1fb5ff; + --color-brand-blue: #0057ff; + --color-brand-ink: #05070d; +} + +html { + scroll-behavior: smooth; +} + +/* Anchored sections land below the fixed marketing nav instead of under it. */ +section[id] { + scroll-margin-top: 5rem; +} + +[data-reveal] { + opacity: 0; + transform: translateY(16px); + transition: + opacity 600ms cubic-bezier(0.22, 1, 0.36, 1), + transform 600ms cubic-bezier(0.22, 1, 0.36, 1); + transition-delay: var(--reveal-delay, 0ms); +} + +[data-reveal="visible"] { + opacity: 1; + transform: none; +} + +@media (prefers-reduced-motion: reduce) { + html { + scroll-behavior: auto; + } + + [data-reveal] { + opacity: 1; + transform: none; + transition: none; + } +} diff --git a/apps/web/src/app/login/login-page.tsx b/apps/web/src/app/login/login-page.tsx index b813133..74b60e7 100644 --- a/apps/web/src/app/login/login-page.tsx +++ b/apps/web/src/app/login/login-page.tsx @@ -49,9 +49,15 @@ export default function LoginPage({ const isVerifying = searchParams.get("verify") === "1"; const errorParam = searchParams.get("error"); + const requestedCallback = searchParams.get("callbackUrl"); + // Only same-site paths are honoured so the parameter can't be used as an open redirect. + const safeCallback = + requestedCallback && requestedCallback.startsWith("/") && !requestedCallback.startsWith("//") + ? requestedCallback + : null; const callbackUrl = inviteId ? `/join-team?inviteId=${inviteId}` - : "/dashboard"; + : (safeCallback ?? "/dashboard"); // When NextAuth redirects to ?verify=1 after the user clicks the magic link, // restore the email we stored in sessionStorage before submitting diff --git a/apps/web/src/components/marketing/CallToAction.tsx b/apps/web/src/components/marketing/CallToAction.tsx index a1d6a08..32881ad 100644 --- a/apps/web/src/components/marketing/CallToAction.tsx +++ b/apps/web/src/components/marketing/CallToAction.tsx @@ -1,33 +1,28 @@ -"use client"; - -import React from "react"; import Link from "next/link"; import { Button } from "@bytesend/ui/src/button"; +import { BrandMark } from "~/lib/brand"; +import { Reveal } from "./Reveal"; -export function CallToAction() { - - const APP_URL = "/login"; +const APP_URL = "/login"; +export function CallToAction() { return ( -
-
-
- - Free tier available no credit card required -
+
+
+ +
-

- Start sending today. -

-

- Create your free account in seconds. 12,500 emails per month, forever. + +

Start sending today.

+

+ Create a free account in seconds and send 12,500 transactional emails a month, free, for as long as you like.

-
- -

- Also available as a Docker container for self-hosting.{" "} - - Learn more → + Prefer to run it yourself?{" "} + + Self-host ByteSend with Docker →

+ + +
+ + + +
); diff --git a/apps/web/src/components/marketing/Comparison.tsx b/apps/web/src/components/marketing/Comparison.tsx index e0f2544..d32bf96 100644 --- a/apps/web/src/components/marketing/Comparison.tsx +++ b/apps/web/src/components/marketing/Comparison.tsx @@ -4,16 +4,19 @@ import React from "react"; import Link from "next/link"; import { Button } from "@bytesend/ui/src/button"; +// Competitor details as published on their pricing and docs pages; re-check before changing claims. +const COMPARISON_CHECKED = "October 2026"; + const comparisonRows: { feature: string; bs: string | boolean; resend: string | boolean; sendgrid: string | boolean; postmark: string | boolean; ses: string | boolean }[] = [ - { feature: "Free tier", bs: "12,500/mo", resend: "3,000 tx/mo", sendgrid: "100/day", postmark: "100 test/mo", ses: "Pay-per-use" }, - { feature: "Marketing campaigns", bs: true, resend: true, sendgrid: true, postmark: false, ses: false }, - { feature: "Visual email editor", bs: true, resend: false, sendgrid: "Basic", postmark: false, ses: false }, + { feature: "Free tier", bs: "12,500/mo", resend: "3,000/mo (100/day)", sendgrid: "60-day trial", postmark: "100/mo", ses: "Pay-per-use" }, + { feature: "Marketing campaigns", bs: true, resend: true, sendgrid: true, postmark: "Broadcast API", ses: false }, + { feature: "Visual email editor", bs: true, resend: true, sendgrid: true, postmark: false, ses: false }, { feature: "Self-hostable", bs: true, resend: false, sendgrid: false, postmark: false, ses: false }, - { feature: "Contact management", bs: true, resend: true, sendgrid: true, postmark: "Lists only", ses: false }, - { feature: "Webhooks", bs: true, resend: true, sendgrid: true, postmark: true, ses: false }, + { feature: "Contact management", bs: true, resend: true, sendgrid: true, postmark: false, ses: "Basic" }, + { feature: "Webhooks", bs: true, resend: true, sendgrid: true, postmark: true, ses: "Via SNS" }, { feature: "SMTP relay", bs: true, resend: true, sendgrid: true, postmark: true, ses: true }, - { feature: "Analytics dashboard", bs: true, resend: "Basic", sendgrid: true, postmark: "Basic", ses: false }, - { feature: "Custom plans", bs: true, resend: true, sendgrid: true, postmark: true, ses: false }, + { feature: "Analytics dashboard", bs: true, resend: true, sendgrid: true, postmark: true, ses: "Basic" }, + { feature: "Open source", bs: true, resend: false, sendgrid: false, postmark: false, ses: false }, ]; const APP_URL = "/login"; @@ -27,7 +30,7 @@ export function ComparisonTable() {
-

Compare

+

Compare

Why teams choose ByteSend

See how we stack up against Resend, SendGrid, Postmark, and AWS SES. @@ -70,6 +73,11 @@ export function ComparisonTable() {

+

+ Based on each provider's published plans, checked {COMPARISON_CHECKED}. Free tiers for ByteSend and + Resend are for transactional email. +

+

Ready to switch? Migration takes minutes.

-

- Free forever · No credit card · Self-host with Docker + No credit card · 12,500 emails a month free · Open source

- {/* Dashboard screenshot */} -
-
-
+
+
+
ByteSend dashboard ByteSend dashboard diff --git a/apps/web/src/components/marketing/HowItWorks.tsx b/apps/web/src/components/marketing/HowItWorks.tsx new file mode 100644 index 0000000..16663c1 --- /dev/null +++ b/apps/web/src/components/marketing/HowItWorks.tsx @@ -0,0 +1,51 @@ +import { Reveal } from "./Reveal"; + +const steps = [ + { + title: "Verify your domain", + description: + "Add your domain and copy the DKIM, SPF and DMARC records into your DNS. ByteSend checks them for you and tells you exactly what's missing.", + }, + { + title: "Send your first email", + description: + "Create an API key and send with one call from an SDK or the REST API — or point an existing app at the SMTP relay.", + }, + { + title: "Watch it land", + description: + "Follow every message from queued to delivered, opened and clicked. Webhooks and alerts tell you the moment something needs attention.", + }, +]; + +export function HowItWorks() { + return ( +
+
+ +

+ How it works +

+

From sign-up to inbox in three steps

+
+ +
    + {steps.map((step, index) => ( + + + {index + 1} + +

    {step.title}

    +

    {step.description}

    +
    + ))} +
+
+
+ ); +} + +export default HowItWorks; diff --git a/apps/web/src/components/marketing/PricingSection.tsx b/apps/web/src/components/marketing/PricingSection.tsx index 90698d3..84b281b 100644 --- a/apps/web/src/components/marketing/PricingSection.tsx +++ b/apps/web/src/components/marketing/PricingSection.tsx @@ -11,13 +11,13 @@ export function Pricing() {
-

Pricing

+

Pricing

- Estimate your monthly ByteSend bill + Simple pricing that grows with you

- One calculator for both transactional and marketing volume. Fine-tune by plan, - then choose your final subscription in dashboard billing. + Start free with 12,500 transactional emails a month. Estimate a paid plan for your + transactional and marketing volume below, then pick it in the dashboard when you're ready.

@@ -31,13 +31,10 @@ export function Pricing() {

-

- Final plan selection and checkout are handled inside the dashboard billing page. -

); diff --git a/apps/web/src/components/marketing/Reveal.tsx b/apps/web/src/components/marketing/Reveal.tsx new file mode 100644 index 0000000..50382b3 --- /dev/null +++ b/apps/web/src/components/marketing/Reveal.tsx @@ -0,0 +1,50 @@ +"use client"; + +import { useEffect, useRef, type CSSProperties, type ReactNode } from "react"; +import { cn } from "@bytesend/ui/lib/utils"; + +// Content is visible without JavaScript: the hidden state only applies once this component mounts. +export function Reveal({ + children, + delay = 0, + className, + as: Tag = "div", +}: { + children: ReactNode; + delay?: number; + className?: string; + as?: "div" | "li"; +}) { + const ref = useRef(null); + + useEffect(() => { + const node = ref.current; + if (!node) return; + + if (typeof IntersectionObserver === "undefined") { + node.dataset.reveal = "visible"; + return; + } + + node.dataset.reveal = "hidden"; + const observer = new IntersectionObserver( + (entries) => { + for (const entry of entries) { + if (entry.isIntersecting) { + node.dataset.reveal = "visible"; + observer.disconnect(); + } + } + }, + { rootMargin: "0px 0px -10% 0px", threshold: 0.1 }, + ); + observer.observe(node); + return () => observer.disconnect(); + }, []); + + return ( + + {children} + + ); +} diff --git a/apps/web/src/components/marketing/TrustStrip.tsx b/apps/web/src/components/marketing/TrustStrip.tsx index b05c853..231806f 100644 --- a/apps/web/src/components/marketing/TrustStrip.tsx +++ b/apps/web/src/components/marketing/TrustStrip.tsx @@ -1,27 +1,24 @@ -"use client"; +import { Reveal } from "./Reveal"; -import React from "react"; +const facts = [ + { value: "12,500", label: "Free transactional emails a month" }, + { value: "AGPL-3.0", label: "Open source, every line" }, + { value: "REST · SMTP", label: "Plus TypeScript, Python and Go SDKs" }, + { value: "Docker", label: "Self-host on your own AWS account" }, +]; export function TrustStrip() { - - const stats = [ - { value: "12,500", label: "Free emails/month" }, - { value: "96.6%", label: "Uptime SLA" }, - { value: "<2s", label: "Avg. delivery" }, - { value: "24/7", label: "Monitoring" }, - ]; - return ( -
+
-
- {stats.map((s) => ( -
-
{s.value}
-
{s.label}
-
+
    + {facts.map((fact, index) => ( + +
    {fact.value}
    +
    {fact.label}
    +
    ))} -
+
); diff --git a/apps/web/src/middleware.unit.test.ts b/apps/web/src/middleware.unit.test.ts new file mode 100644 index 0000000..788e926 --- /dev/null +++ b/apps/web/src/middleware.unit.test.ts @@ -0,0 +1,66 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { NextRequest } from "next/server"; + +const { mockGetToken } = vi.hoisted(() => ({ mockGetToken: vi.fn() })); + +vi.mock("next-auth/jwt", () => ({ getToken: mockGetToken })); +vi.mock("~/lib/edge-2fa-utils", () => ({ + TWO_FACTOR_COOKIE: "bytesend_2fa", + validateTwoFactorCookieEdge: vi.fn().mockResolvedValue(true), +})); + +import { middleware } from "../middleware"; + +function request(path: string, cookies: Record = {}) { + const req = new NextRequest(new URL(path, "https://bytesend.test")); + for (const [name, value] of Object.entries(cookies)) req.cookies.set(name, value); + return req; +} + +const location = (res: Response) => res.headers.get("location"); + +describe("middleware", () => { + beforeEach(() => { + mockGetToken.mockReset(); + mockGetToken.mockResolvedValue(null); + }); + + it.each(["/", "/privacy", "/login", "/changelog", "/api/v1/emails", "/join-team"])( + "lets %s through without a session", + async (path) => { + const res = await middleware(request(path)); + expect(location(res)).toBeNull(); + }, + ); + + it.each(["/dashboard", "/settings/account", "/admin/teams/4", "/domains/12"])( + "sends anonymous visitors from %s to login with a callback", + async (path) => { + const res = await middleware(request(path)); + const target = new URL(location(res)!); + expect(target.pathname).toBe("/login"); + expect(target.searchParams.get("callbackUrl")).toBe(path); + }, + ); + + it("does not treat look-alike paths as protected", async () => { + const res = await middleware(request("/dashboarding")); + expect(location(res)).toBeNull(); + }); + + it("lets a request with a database session cookie through", async () => { + const res = await middleware(request("/dashboard", { "next-auth.session-token": "abc" })); + expect(location(res)).toBeNull(); + }); + + it("accepts the secure cookie name used over HTTPS", async () => { + const res = await middleware(request("/settings", { "__Secure-next-auth.session-token": "abc" })); + expect(location(res)).toBeNull(); + }); + + it("redirects banned users when a JWT is available", async () => { + mockGetToken.mockResolvedValue({ sub: "1", isBanned: true }); + const res = await middleware(request("/dashboard", { "next-auth.session-token": "abc" })); + expect(new URL(location(res)!).pathname).toBe("/banned"); + }); +}); diff --git a/apps/web/src/server/api/routers/campaign-security.trpc.test.ts b/apps/web/src/server/api/routers/campaign-security.trpc.test.ts index f5bba62..1d356ba 100644 --- a/apps/web/src/server/api/routers/campaign-security.trpc.test.ts +++ b/apps/web/src/server/api/routers/campaign-security.trpc.test.ts @@ -2,6 +2,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; const { mockDb, mockValidateDomainFromEmail, mockCheckCampaignLimit } = vi.hoisted(() => ({ mockDb: { + user: { + // authedProcedure re-checks the ban flag on every call. + findUnique: async () => ({ isBanned: false }), + }, teamUser: { findFirst: vi.fn(), }, diff --git a/apps/web/src/server/api/routers/team-security.trpc.test.ts b/apps/web/src/server/api/routers/team-security.trpc.test.ts index 91a773c..b82c2e5 100644 --- a/apps/web/src/server/api/routers/team-security.trpc.test.ts +++ b/apps/web/src/server/api/routers/team-security.trpc.test.ts @@ -2,6 +2,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; const { mockDb, mockSendTeamInviteEmail } = vi.hoisted(() => ({ mockDb: { + user: { + // authedProcedure re-checks the ban flag on every call. + findUnique: async () => ({ isBanned: false }), + }, teamUser: { findFirst: vi.fn(), }, diff --git a/apps/web/src/server/api/routers/user.trpc.test.ts b/apps/web/src/server/api/routers/user.trpc.test.ts index 428d4e4..a358b9c 100644 --- a/apps/web/src/server/api/routers/user.trpc.test.ts +++ b/apps/web/src/server/api/routers/user.trpc.test.ts @@ -21,6 +21,7 @@ const { pendingEmailChange: { findUnique: vi.fn(), upsert: vi.fn(), + update: vi.fn(), delete: vi.fn(), }, twoFactorRecoveryCode: { @@ -80,32 +81,20 @@ describe("userRouter.requestEmailChange", () => { beforeEach(() => { mockDb.user.findUnique.mockReset(); mockDb.user.findFirst.mockReset(); - mockDb.account.findMany.mockReset(); mockDb.pendingEmailChange.upsert.mockReset(); mockSendEmailChangeVerificationEmail.mockReset(); }); it("rejects when new email same as current", async () => { mockDb.user.findUnique.mockResolvedValue({ id: 1, email: "user@example.com" }); - mockDb.account.findMany.mockResolvedValue([]); const caller = createCaller(getCtx()); await expect(caller.requestEmailChange({ email: "user@example.com" })).rejects.toMatchObject({ code: "BAD_REQUEST", }); }); - it("rejects OAuth users", async () => { - mockDb.user.findUnique.mockResolvedValue({ id: 1, email: "user@example.com" }); - mockDb.account.findMany.mockResolvedValue([{ provider: "github" }]); - const caller = createCaller(getCtx()); - await expect(caller.requestEmailChange({ email: "new@example.com" })).rejects.toMatchObject({ - code: "FORBIDDEN", - }); - }); - it("rejects email already in use by another account", async () => { mockDb.user.findUnique.mockResolvedValue({ id: 1, email: "user@example.com" }); - mockDb.account.findMany.mockResolvedValue([]); mockDb.user.findFirst.mockResolvedValue({ id: 2 }); const caller = createCaller(getCtx()); await expect(caller.requestEmailChange({ email: "taken@example.com" })).rejects.toMatchObject({ @@ -113,59 +102,110 @@ describe("userRouter.requestEmailChange", () => { }); }); - it("sends verification code for valid new email", async () => { + it("sends a code to both the current and the new address", async () => { mockDb.user.findUnique.mockResolvedValue({ id: 1, email: "user@example.com" }); - mockDb.account.findMany.mockResolvedValue([]); mockDb.user.findFirst.mockResolvedValue(null); mockDb.pendingEmailChange.upsert.mockResolvedValue({}); mockSendEmailChangeVerificationEmail.mockResolvedValue(undefined); const caller = createCaller(getCtx()); + const result = await caller.requestEmailChange({ email: "new@example.com" }); - expect(result.sent).toBe(true); - expect(mockSendEmailChangeVerificationEmail).toHaveBeenCalledWith("new@example.com", expect.any(String)); + + expect(result).toMatchObject({ step: "verify_old", currentEmail: "user@example.com", newEmail: "new@example.com" }); + expect(mockSendEmailChangeVerificationEmail).toHaveBeenCalledWith("user@example.com", expect.any(String), expect.any(String)); + expect(mockSendEmailChangeVerificationEmail).toHaveBeenCalledWith("new@example.com", expect.any(String), expect.any(String)); + }); + + it("allows accounts linked to OAuth providers to change email", async () => { + mockDb.user.findUnique.mockResolvedValue({ id: 1, email: "user@example.com" }); + mockDb.user.findFirst.mockResolvedValue(null); + mockDb.pendingEmailChange.upsert.mockResolvedValue({}); + mockSendEmailChangeVerificationEmail.mockResolvedValue(undefined); + const caller = createCaller(getCtx()); + + await expect(caller.requestEmailChange({ email: "provider@example.com" })).resolves.toMatchObject({ + step: "verify_old", + }); }); }); -describe("userRouter.confirmEmailChange", () => { +const pending = (overrides: Record = {}) => ({ + id: "p1", + codeOld: "OLD123", + codeNew: "NEW456", + verifiedOld: false, + expiresAt: new Date(Date.now() + 60_000), + ...overrides, +}); + +describe("userRouter.confirmOldEmail", () => { beforeEach(() => { mockDb.pendingEmailChange.findUnique.mockReset(); - mockDb.user.findFirst.mockReset(); - mockDb.user.update.mockReset(); + mockDb.pendingEmailChange.update.mockReset(); mockDb.pendingEmailChange.delete.mockReset(); }); - it("rejects invalid or expired code", async () => { + it("rejects when no change is pending", async () => { mockDb.pendingEmailChange.findUnique.mockResolvedValue(null); const caller = createCaller(getCtx()); - await expect( - caller.confirmEmailChange({ email: "new@example.com", code: "ABC123" }) - ).rejects.toMatchObject({ code: "BAD_REQUEST" }); + await expect(caller.confirmOldEmail({ email: "new@example.com", code: "OLD123" })).rejects.toMatchObject({ + code: "BAD_REQUEST", + }); + }); + + it("rejects and clears an expired request", async () => { + mockDb.pendingEmailChange.findUnique.mockResolvedValue(pending({ expiresAt: new Date(Date.now() - 1000) })); + const caller = createCaller(getCtx()); + await expect(caller.confirmOldEmail({ email: "new@example.com", code: "OLD123" })).rejects.toMatchObject({ + code: "BAD_REQUEST", + }); + expect(mockDb.pendingEmailChange.delete).toHaveBeenCalledWith({ where: { id: "p1" } }); }); - it("rejects expired code", async () => { - mockDb.pendingEmailChange.findUnique.mockResolvedValue({ - id: "p1", - code: "ABC123", - expiresAt: new Date(Date.now() - 1000), + it("rejects the new address's code", async () => { + mockDb.pendingEmailChange.findUnique.mockResolvedValue(pending()); + const caller = createCaller(getCtx()); + await expect(caller.confirmOldEmail({ email: "new@example.com", code: "NEW456" })).rejects.toMatchObject({ + code: "BAD_REQUEST", }); + }); + + it("marks the current address verified", async () => { + mockDb.pendingEmailChange.findUnique.mockResolvedValue(pending()); + mockDb.pendingEmailChange.update.mockResolvedValue({}); const caller = createCaller(getCtx()); - await expect( - caller.confirmEmailChange({ email: "new@example.com", code: "ABC123" }) - ).rejects.toMatchObject({ code: "BAD_REQUEST" }); + const result = await caller.confirmOldEmail({ email: "new@example.com", code: "old123" }); + expect(result.step).toBe("verify_new"); + expect(mockDb.pendingEmailChange.update).toHaveBeenCalledWith({ where: { id: "p1" }, data: { verifiedOld: true } }); + }); +}); + +describe("userRouter.confirmNewEmail", () => { + beforeEach(() => { + mockDb.pendingEmailChange.findUnique.mockReset(); + mockDb.pendingEmailChange.delete.mockReset(); + mockDb.user.findFirst.mockReset(); + mockDb.user.update.mockReset(); }); - it("updates email on valid code", async () => { - mockDb.pendingEmailChange.findUnique.mockResolvedValue({ - id: "p1", - code: "ABC123", - expiresAt: new Date(Date.now() + 60000), + it("requires the current address to be verified first", async () => { + mockDb.pendingEmailChange.findUnique.mockResolvedValue(pending()); + const caller = createCaller(getCtx()); + await expect(caller.confirmNewEmail({ email: "new@example.com", code: "NEW456" })).rejects.toMatchObject({ + code: "BAD_REQUEST", }); + expect(mockDb.user.update).not.toHaveBeenCalled(); + }); + + it("updates the email once both codes are confirmed", async () => { + mockDb.pendingEmailChange.findUnique.mockResolvedValue(pending({ verifiedOld: true })); mockDb.user.findFirst.mockResolvedValue(null); mockDb.user.update.mockResolvedValue({ id: 1, email: "new@example.com", emailVerified: new Date() }); mockDb.pendingEmailChange.delete.mockResolvedValue({}); const caller = createCaller(getCtx()); - const result = await caller.confirmEmailChange({ email: "new@example.com", code: "ABC123" }); + const result = await caller.confirmNewEmail({ email: "new@example.com", code: "NEW456" }); expect(result.email).toBe("new@example.com"); + expect(mockDb.pendingEmailChange.delete).toHaveBeenCalledWith({ where: { id: "p1" } }); }); }); diff --git a/apps/web/src/server/api/routers/user.ts b/apps/web/src/server/api/routers/user.ts index be44684..affa621 100644 --- a/apps/web/src/server/api/routers/user.ts +++ b/apps/web/src/server/api/routers/user.ts @@ -93,18 +93,6 @@ export const userRouter = createTRPCRouter({ throw new TRPCError({ code: "NOT_FOUND", message: "User not found" }); } - const oauthAccounts = await db.account.findMany({ - where: { userId: ctx.session.user.id, type: "oauth" }, - select: { provider: true }, - }); - if (oauthAccounts.length > 0) { - const providers = oauthAccounts.map((a) => a.provider).join(", "); - throw new TRPCError({ - code: "FORBIDDEN", - message: `Email changes are not allowed for accounts linked to OAuth providers (${providers}). Sign in with email to manage your email address.`, - }); - } - const currentEmail = currentUser.email?.trim().toLowerCase() ?? null; if (currentEmail === nextEmail) { throw new TRPCError({ diff --git a/apps/web/src/server/api/routers/webhook-domain-filter.trpc.test.ts b/apps/web/src/server/api/routers/webhook-domain-filter.trpc.test.ts index 47b637d..a763aec 100644 --- a/apps/web/src/server/api/routers/webhook-domain-filter.trpc.test.ts +++ b/apps/web/src/server/api/routers/webhook-domain-filter.trpc.test.ts @@ -2,6 +2,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; const { mockDb, mockWebhookService } = vi.hoisted(() => ({ mockDb: { + user: { + // authedProcedure re-checks the ban flag on every call. + findUnique: async () => ({ isBanned: false }), + }, teamUser: { findFirst: vi.fn(), }, diff --git a/apps/web/src/server/api/trpc.trpc.test.ts b/apps/web/src/server/api/trpc.trpc.test.ts index 38f3509..f33c05c 100644 --- a/apps/web/src/server/api/trpc.trpc.test.ts +++ b/apps/web/src/server/api/trpc.trpc.test.ts @@ -3,6 +3,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; const { mockDb } = vi.hoisted(() => ({ mockDb: { + user: { + // authedProcedure re-checks the ban flag on every call. + findUnique: async () => ({ isBanned: false }), + }, teamUser: { findFirst: vi.fn(), }, diff --git a/apps/web/src/server/service/domain-service.unit.test.ts b/apps/web/src/server/service/domain-service.unit.test.ts index 5790830..d7235e7 100644 --- a/apps/web/src/server/service/domain-service.unit.test.ts +++ b/apps/web/src/server/service/domain-service.unit.test.ts @@ -60,6 +60,7 @@ vi.mock("~/server/service/webhook-service", () => ({ vi.mock("~/server/redis", () => ({ getRedis: () => mockRedis, redisKey: (key: string) => key, + BULL_PREFIX: "bull", })); vi.mock("~/server/mailer", () => ({ diff --git a/packages/python-sdk/pyproject.toml b/packages/python-sdk/pyproject.toml index ab631fd..0f386d2 100644 --- a/packages/python-sdk/pyproject.toml +++ b/packages/python-sdk/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bytesend" -version = "0.1.1" +version = "0.1.2" description = "Python SDK for the ByteSend API" authors = ["NodeByte LTD"] license = "AGPL-3.0" diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 8d3ea15..193ecf3 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "bytesend-js", - "version": "0.1.2", + "version": "0.1.3", "description": "Official JavaScript SDK for ByteSend, the email sending service built for developers.", "license": "AGPL-3.0-only", "repository": {