From 064fb7f7a9332485a666e77990e99693e712c0ae Mon Sep 17 00:00:00 2001 From: Mattsson <111893710+mattssonn@users.noreply.github.com> Date: Wed, 29 Apr 2026 16:32:26 +0200 Subject: [PATCH] Add/white label (#381) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(branding): add BrandingService with default-preserving env layer Introduce lib/branding/service.ts mirroring lib/email/service.ts. Defaults match current gnubok values exactly, so production behaviour is unchanged unless an env var (NEXT_PUBLIC_BRANDING_*, BRANDING_*) or extension override (via registerBrandingService) is set. Resolution order: defaults < env vars < extension override. Co-Authored-By: Claude Opus 4.7 (1M context) * feat(branding): route root layout, manifest, and PWA assets through branding service - app/layout.tsx now reads title, description, themeColor, and apple-touch-icon from getBranding() instead of hardcoded values. - public/manifest.json replaced by dynamic app/manifest.ts so PWA name, short_name, description, theme_color, background_color, and icon paths are resolved at request time. The manifest now serves at /manifest.webmanifest (Next.js convention for the metadata file route). The previous /manifest.json URL is no longer populated; nothing in core references it after this commit. Co-Authored-By: Claude Opus 4.7 (1M context) * feat(branding): route email service and templates through branding service - resend-service.ts: From line uses getBranding().appName instead of hardcoded "Gnubok" in both the with-fromName and bare cases. - invite-templates.ts: subject, HTML header, body, plain text, and the team-invite variants all read from branding (sentence case in prose, uppercased for the styled

header). - consent-notification-templates.ts: signature fallback (companyName || branding) for both HTML and plain text variants. Defaults preserve the exact current strings ("Gnubok", "GNUBOK", "gnubok" in their respective contexts) so no email content changes for production. Co-Authored-By: Claude Opus 4.7 (1M context) * feat(branding): route OAuth consent page through branding service The MCP OAuth consent page rendered for Claude Desktop / Claude.ai connector flows now reads the app name from getBranding() for both the HTML and the body copy. Default still produces "gnubok" in lowercase prose, matching current behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(branding): route auth, dashboard, and onboarding text through branding service Replace user-visible "gnubok" / "Gnubok" references with calls to getBranding(). Touches: - Auth pages (login, register, mfa/enroll): logo src/alt, MFA TOTP friendlyName. - Onboarding (companies/new, invite, sandbox, WelcomeOnboarding, Step2CompanyDetails, NewUserChecklist, BankIdCompanyPicker, ArcimMigrationWorkspace): logo, headings, error/help text. - Dashboard fallback (companyName="gnubok") and settings (backup copy, ApiKeysPanel MCP connector name + login note, CompanyDangerZone, retention-notice). - API routes (support contact subject prefix, enable-banking consent email companyName fallback, AI inbox receipt-request appUrl, pain001 messageId prefix). - MCP server "open the gnubok web app" review message. - Salary/reports filings (AGI Programnamn, KU10 Programnamn, payslip footer, full-archive system metadata, SRU #PROGRAM line). Internal identifiers (cookie names gnubok-company-id / gnubok-invite-token, API key prefix gnubok_sk_, invite token prefix gnubok_inv_, MCP tool names, npm package gnubok-mcp, GNUBOK_API_KEY env name) are deliberately left unchanged — they're stable contracts that whitelabels must not break. Defaults match current behaviour exactly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(branding): support legal page field-level swaps for entity and contact Privacy and DPA pages now interpolate appName, legalEntity, and privacyEmail from the branding service instead of hardcoding "Gnubok", "Arcim", and "privacy@gnubok.se". Page metadata uses generateMetadata() so titles also reflect the brand. lib/support.ts now falls back to getBranding().supportEmail when SUPPORT_RECIPIENT_EMAIL is unset, so a single BRANDING_SUPPORT_EMAIL env var configures both the support form recipient and the displayed support address. Whitelabels with a different legal jurisdiction or entirely different DPA text should override the page route from an extension. Phase 1 intentionally only supports field-level swaps. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(branding): add WHITELABEL.md and example branding extension WHITELABEL.md: fork checklist, env var reference, the "do not change" list (cookies, API key prefixes, invite token prefixes, MCP tool names, gnubok-mcp npm package, GNUBOK_API_KEY env name), out-of-scope items, the upstream sync workflow YAML to copy into a fork, conflict avoidance guidance, and a verification checklist. extensions/general/_example-branding/: copy-paste starter extension with index.ts (commented placeholder values for registerBrandingService), manifest.json, and README.md. Disabled by default (not added to extensions.config.json); whitelabels cp the folder, edit, and enable. sectors.test.ts: bumped expected extension count 12 -> 13 to account for the new starter extension on disk. The generated registry is unchanged because the example is disabled. The sync workflow YAML is documented inline in WHITELABEL.md rather than checked in as a workflow file. It's only meaningful in a fork -- gnubok itself has nothing to sync from. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(branding): address PR review — lazy support email + escape brand in HTML/XML Three issues from code review: P1 — lib/support.ts: SUPPORT_RECIPIENT_EMAIL was a module-level const, evaluated at import time before extensions register branding overrides via ensureInitialized(). Convert to getSupportRecipientEmail() lazy accessor; update the only caller in app/api/support/contact/route.ts. Extension-supplied supportEmail values now route correctly. P2 — app/api/mcp-oauth/authorize/route.ts: appName was interpolated into the consent page HTML without escapeHtml(), inconsistent with the existing escaping of companyName. Wrap appName.toLowerCase() in escapeHtml() at use sites in <title> and the body paragraph. P2 — lib/salary/agi/xml-generator.ts and lib/salary/ku/ku10-generator.ts: appName placed inside <gem:Programnamn> / <Programnamn> XML elements without escapeXml(), the helper already used for other admin-controlled fields in the same files. Wrap accordingly to prevent malformed XML if a brand name contains XML reserved characters. All admin-controlled inputs only — no user-exploitable path. Defense in depth, not a known incident. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(branding): security follow-up — lazy metadata, SRU/email header sanitization Self-audit after the PR review surfaced four more concerns. Fixes them with the same defense-in-depth posture as the prior review fixes. 1. app/layout.tsx — same eager-evaluation class as P1 support.ts. The module-level `const branding = getBranding()` froze branding before extensions registered, so extension-based overrides for title, description, themeColor, and apple-touch-icon silently never applied. - Convert to generateMetadata() / generateViewport() (lazy, run per request, see extension-registered overrides). - Inline getBranding() inside RootLayout for the apple-touch-icon href so it picks up overrides too. - Add ensureInitialized() at module level so extensions are loaded before the first metadata call. Mirrors the API route pattern. 2. app/manifest.ts — same class. The dynamic manifest function reads getBranding() per request, but if the manifest is requested before any other module has triggered ensureInitialized(), extensions are still unloaded. Add ensureInitialized() at module level. 3. lib/reports/ink2/sru-generator.ts — appName interpolated into the SRU `#PROGRAM` directive without sanitization. SRU's reserved char is `#` (directive marker) and CRLF injects new directives. Wrap in the existing sanitizeString() helper to match the pattern used for other admin-controlled fields in this file (#NAMN, #ADRESS, etc.). 4. extensions/general/email/lib/resend-service.ts — appName and the user-controlled fromName both flow into the From header. Resend's API does its own validation, but defense in depth: strip CRLF and angle brackets via a small sanitizeHeaderPart() helper before building the header string. fromName was a pre-existing surface; appName is new with this whitelabel work. All four are admin-controlled inputs (env vars or extension code), not user-exploitable. No known incidents — defense in depth, and correctness for extension-based whitelabels. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --- WHITELABEL.md | 173 ++++++++++++++++++ app/(auth)/login/page.tsx | 7 +- app/(auth)/mfa/enroll/page.tsx | 3 +- app/(auth)/register/page.tsx | 7 +- app/(dashboard)/layout.tsx | 5 +- app/(dashboard)/settings/backup/page.tsx | 4 +- app/(public)/dpa/page.tsx | 18 +- app/(public)/privacy/page.tsx | 16 +- .../inbox-items/[id]/request-receipt/route.ts | 3 +- .../enable-banking/sync/cron/route.ts | 3 +- app/api/mcp-oauth/authorize/route.ts | 7 +- .../salary/runs/[id]/payment/pain001/route.ts | 3 +- app/api/support/contact/route.ts | 7 +- app/companies/new/page.tsx | 9 +- app/invite/[token]/page.tsx | 11 +- app/layout.tsx | 47 +++-- app/manifest.ts | 33 ++++ app/sandbox/page.tsx | 13 +- components/dashboard/WelcomeOnboarding.tsx | 7 +- .../general/ArcimMigrationWorkspace.tsx | 13 +- components/onboarding/BankIdCompanyPicker.tsx | 7 +- components/onboarding/NewUserChecklist.tsx | 5 +- components/onboarding/Step2CompanyDetails.tsx | 5 +- components/settings/ApiKeysPanel.tsx | 12 +- components/settings/CompanyDangerZone.tsx | 5 +- components/ui/retention-notice.tsx | 4 +- .../general/_example-branding/README.md | 24 +++ extensions/general/_example-branding/index.ts | 28 +++ .../general/_example-branding/manifest.json | 19 ++ .../general/email/lib/resend-service.ts | 17 +- extensions/general/mcp-server/server.ts | 3 +- lib/branding/__tests__/service.test.ts | 97 ++++++++++ lib/branding/service.ts | 92 ++++++++++ lib/email/consent-notification-templates.ts | 8 +- lib/email/invite-templates.ts | 22 ++- lib/extensions/__tests__/sectors.test.ts | 6 +- lib/reports/full-archive-export.ts | 6 +- lib/reports/ink2/sru-generator.ts | 4 +- lib/salary/agi/xml-generator.ts | 3 +- lib/salary/ku/ku10-generator.ts | 3 +- lib/salary/pdf/payslip-template.tsx | 3 +- lib/support.ts | 10 +- public/manifest.json | 62 ------- 43 files changed, 673 insertions(+), 161 deletions(-) create mode 100644 WHITELABEL.md create mode 100644 app/manifest.ts create mode 100644 extensions/general/_example-branding/README.md create mode 100644 extensions/general/_example-branding/index.ts create mode 100644 extensions/general/_example-branding/manifest.json create mode 100644 lib/branding/__tests__/service.test.ts create mode 100644 lib/branding/service.ts delete mode 100644 public/manifest.json diff --git a/WHITELABEL.md b/WHITELABEL.md new file mode 100644 index 00000000..ad3fc477 --- /dev/null +++ b/WHITELABEL.md @@ -0,0 +1,173 @@ +# Whitelabel fork checklist + +gnubok is whitelabel-friendly: every user-visible brand reference reads from a single `BrandingService` (`lib/branding/service.ts`). If you don't override anything, the app behaves exactly like upstream gnubok. To run your own brand on top of gnubok, fork the repo and override the values you care about. + +## Quick start + +```bash +# 1. Fork erp-mafia/gnubok on GitHub → you/your-brand +# 2. Clone and add upstream remote (one-time) +git clone https://github.com/you/your-brand +cd your-brand +git remote add upstream https://github.com/erp-mafia/gnubok + +# 3. Copy the example branding extension +cp -r extensions/general/_example-branding extensions/general/your-brand +# Edit extensions/general/your-brand/index.ts with your brand values + +# 4. (Optional) Set env vars instead of / in addition to the extension. See "Env vars" below. + +# 5. Enable the extension +# Edit extensions.config.json and add "your-brand" to the array. + +# 6. Run locally +npm run setup:extensions +npm run dev + +# 7. Deploy to your hosting (Vercel, Docker, etc.) +``` + +## Env vars + +All branding can be set via env vars. Public ones use `NEXT_PUBLIC_BRANDING_*` (build-time inlined, available in client components). Server-only ones use `BRANDING_*`. + +| Env var | Field | Default | +|---|---|---| +| `NEXT_PUBLIC_BRANDING_APP_NAME` | `appName` | `Gnubok` | +| `NEXT_PUBLIC_BRANDING_APP_DESCRIPTION` | `appDescription` | `Ekonomihantering` | +| `BRANDING_LEGAL_ENTITY` | `legalEntity` | `Arcim` | +| `BRANDING_SUPPORT_EMAIL` | `supportEmail` | `support@gnubok.se` | +| `BRANDING_PRIVACY_EMAIL` | `privacyEmail` | `privacy@gnubok.se` | +| `BRANDING_SECURITY_EMAIL` | `securityEmail` | `security@arcim.io` | +| `NEXT_PUBLIC_APP_URL` | `appUrl` | `https://app.gnubok.se` | +| `NEXT_PUBLIC_BRANDING_LOGO_PATH` | `logoPath` | `/gnubokiceon-removebg-preview.png` | +| `NEXT_PUBLIC_BRANDING_FAVICON_PATH` | `faviconPath` | `/favicon.ico` | +| `NEXT_PUBLIC_BRANDING_APPLE_ICON_PATH` | `appleTouchIconPath` | `/icons/icon-192.png` | +| `NEXT_PUBLIC_BRANDING_PWA_ICON_BASE` | `pwaIconBasePath` | `/icons` | +| `NEXT_PUBLIC_BRANDING_THEME_COLOR` | `themeColor` | `#304D83` | +| `NEXT_PUBLIC_BRANDING_MANIFEST_THEME_COLOR` | `manifestThemeColor` | `#1a1a1a` | +| `NEXT_PUBLIC_BRANDING_MANIFEST_BG_COLOR` | `manifestBackgroundColor` | `#ffffff` | + +Resolution order (last wins): **defaults → env vars → extension override**. + +`NEXT_PUBLIC_*` env vars are inlined at build time. Changing them requires a fresh `npm run build` to propagate. + +## Things you MUST NOT change + +These are stable contracts. Renaming them breaks existing data, sessions, or external clients (npm package consumers, MCP connectors, browser sessions, invite links). Leave them alone in your fork: + +| Identifier | Where | Why | +|---|---|---| +| `gnubok-company-id` | cookie | Active company context — renaming breaks logged-in sessions | +| `gnubok-invite-token` | cookie | Pre-auth invite token holding — renaming drops in-flight invites | +| `gnubok_sk_` | API key prefix | All issued API keys; existing clients fail validation | +| `gnubok_inv_` | invite token prefix | All sent invite links break | +| `gnubok_*` | MCP tool names (`gnubok_list_invoices`, etc.) | Published MCP API — Claude clients have these cached | +| `gnubok-mcp` | npm package name | Whitelabel users still install `npx gnubok-mcp`. Document `GNUBOK_URL=https://app.your-brand.se/api/extensions/ext/mcp-server/mcp` so they hit your endpoint | +| `GNUBOK_API_KEY` | env var read by `gnubok-mcp` package | Same reason — npm consumer expects this name | + +## What's outside this branding service + +A few things that look brand-related but are configured elsewhere: + +- **Supabase auth emails** (password reset, magic link) — set in the Supabase dashboard for your project, not in code. +- **Resend sending domain** — verify `noreply@your-brand.se` (or wherever) in Resend, set `RESEND_FROM_EMAIL`. +- **DNS / domain** — point `app.your-brand.se` at your Vercel deployment. +- **OAuth redirect allowlist for MCP** — `app/api/mcp-oauth/authorize/route.ts` lists `claude.ai/api/*`, `claude.com/api/*`, and localhost. Your domain is the OAuth issuer, not a redirect target — no change needed unless you're integrating with new MCP clients. +- **Service worker push notification fallback title** (`public/sw.js`) — currently hardcoded as `'Ekonomi'`. Service workers can't read env vars at runtime; change the file directly in your fork if it matters. +- **iCal feed PRODID** (`lib/calendar/ics-generator.ts`) — defaults to `erp-base.se`, callers may pass their domain. +- **`NEXT_PUBLIC_APP_URL`** — used as the OAuth issuer. Set this to your domain (e.g. `https://app.your-brand.se`). + +## Staying in sync with upstream + +Add this workflow at `.github/workflows/sync-upstream.yml` to your fork. It runs weekly and opens a PR with upstream changes: + +```yaml +name: Sync from upstream + +on: + schedule: + - cron: '0 3 * * 1' # Mondays 03:00 UTC + workflow_dispatch: + +jobs: + sync: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + issues: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Add upstream and fetch + run: | + git remote add upstream https://github.com/erp-mafia/gnubok + git fetch upstream main + + - name: Create sync branch and merge + id: merge + run: | + BRANCH="sync/upstream-$(date +%Y-%m-%d)" + git checkout -b "$BRANCH" + if git merge --no-edit upstream/main; then + echo "status=clean" >> "$GITHUB_OUTPUT" + else + echo "status=conflict" >> "$GITHUB_OUTPUT" + git merge --abort || true + fi + echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" + + - name: Push and open PR (clean merge) + if: steps.merge.outputs.status == 'clean' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if git diff --quiet origin/main..HEAD; then + echo "Up to date with upstream — nothing to do." + exit 0 + fi + git push origin "${{ steps.merge.outputs.branch }}" + gh pr create \ + --base main \ + --head "${{ steps.merge.outputs.branch }}" \ + --title "Sync from upstream gnubok" \ + --body "Automated weekly sync from \`erp-mafia/gnubok@main\`." + + - name: Report conflict + if: steps.merge.outputs.status == 'conflict' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh issue create \ + --title "Upstream sync conflict ($(date +%Y-%m-%d))" \ + --label sync-conflict \ + --body "Automated upstream merge hit a conflict. Resolve manually: \`git fetch upstream && git merge upstream/main\`." +``` + +## Conflict avoidance + +The fork-friendliness of this design depends on you keeping changes confined to your branding extension folder. Every file you edit in `lib/`, `app/`, or `components/` becomes a potential conflict on the next upstream merge. If you find yourself wanting to override something the branding service doesn't expose, prefer: + +1. **Open an upstream issue** — the branding service is intentionally minimal; missing fields can be added. +2. **PR a hook upstream** — extending the service or adding a registry pattern keeps your fork clean. + +## Verifying your whitelabel + +After deploying: + +- [ ] Visit `/` — browser tab title shows your brand. +- [ ] Visit `/login` and `/register` — your logo renders. +- [ ] View source of `/manifest.webmanifest` — `name`, `short_name`, `theme_color` reflect your overrides. +- [ ] Trigger an invite email — From line says `<your-brand> <noreply@...>`, body uses your name. +- [ ] Visit `/dpa` and `/privacy` — legal entity and contact email are yours. +- [ ] Open OAuth flow (`/api/mcp-oauth/authorize?...`) from a test MCP client — consent page references your brand. +- [ ] Submit support form (Settings → Support) — internal subject prefix is `[<your-brand> support]`. diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx index 518abeaa..22214df5 100644 --- a/app/(auth)/login/page.tsx +++ b/app/(auth)/login/page.tsx @@ -13,6 +13,9 @@ import Image from 'next/image' import { getErrorMessage } from '@/lib/errors/get-error-message' import { isBankIdEnabled } from '@/lib/auth/bankid' import { BankIdAuth } from '@/components/auth/BankIdAuth' +import { getBranding } from '@/lib/branding/service' + +const branding = getBranding() import type { BankIdResult } from '@/components/auth/BankIdAuth' export default function LoginPage() { @@ -335,8 +338,8 @@ export default function LoginPage() { <div className="w-full max-w-sm animate-slide-up"> <div className="text-center mb-10"> <Image - src="/gnubokiceon-removebg-preview.png" - alt="Gnubok" + src={branding.logoPath} + alt={branding.appName} width={240} height={240} className="mx-auto mb-2" diff --git a/app/(auth)/mfa/enroll/page.tsx b/app/(auth)/mfa/enroll/page.tsx index 16694131..bb96cafe 100644 --- a/app/(auth)/mfa/enroll/page.tsx +++ b/app/(auth)/mfa/enroll/page.tsx @@ -8,6 +8,7 @@ import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { useToast } from '@/components/ui/use-toast' import { Loader2, ShieldCheck, Copy, Check, ArrowLeft } from 'lucide-react' +import { getBranding } from '@/lib/branding/service' export default function MfaEnrollPage() { return ( @@ -50,7 +51,7 @@ function MfaEnrollContent() { const { data, error } = await supabase.auth.mfa.enroll({ factorType: 'totp', - friendlyName: 'gnubok', + friendlyName: getBranding().appName.toLowerCase(), }) if (error) { diff --git a/app/(auth)/register/page.tsx b/app/(auth)/register/page.tsx index c4b05af9..09125f15 100644 --- a/app/(auth)/register/page.tsx +++ b/app/(auth)/register/page.tsx @@ -14,6 +14,9 @@ import { getErrorMessage } from '@/lib/errors/get-error-message' import { isBankIdEnabled } from '@/lib/auth/bankid' import { BankIdAuth } from '@/components/auth/BankIdAuth' import type { BankIdResult } from '@/components/auth/BankIdAuth' +import { getBranding } from '@/lib/branding/service' + +const branding = getBranding() export default function RegisterPage() { return ( @@ -335,8 +338,8 @@ function RegisterPageContent() { <div className="w-full max-w-sm animate-slide-up"> <div className="text-center mb-10"> <Image - src="/gnubokiceon-removebg-preview.png" - alt="Gnubok" + src={branding.logoPath} + alt={branding.appName} width={240} height={240} className="mx-auto mb-2" diff --git a/app/(dashboard)/layout.tsx b/app/(dashboard)/layout.tsx index 910ed611..d14c167c 100644 --- a/app/(dashboard)/layout.tsx +++ b/app/(dashboard)/layout.tsx @@ -8,6 +8,7 @@ import { SandboxBanner } from '@/components/dashboard/SandboxBanner' import { getExtensionNavItems } from '@/lib/extensions/sectors' import { CompanyProvider } from '@/contexts/CompanyContext' import { getActiveCompanyId } from '@/lib/company/context' +import { getBranding } from '@/lib/branding/service' import type { EntityType, CompanyRole, Team } from '@/types' /** @@ -85,7 +86,7 @@ export default async function DashboardLayout({ <CompanyTabSync /> <div className="min-h-screen bg-background"> <DashboardNav - companyName="gnubok" + companyName={getBranding().appName.toLowerCase()} entityType="enskild_firma" uncategorizedTransactionCount={0} pendingOperationsCount={0} @@ -136,7 +137,7 @@ export default async function DashboardLayout({ <CompanyTabSync /> <div className="min-h-screen bg-background"> <DashboardNav - companyName="gnubok" + companyName={getBranding().appName.toLowerCase()} entityType="enskild_firma" uncategorizedTransactionCount={0} pendingOperationsCount={0} diff --git a/app/(dashboard)/settings/backup/page.tsx b/app/(dashboard)/settings/backup/page.tsx index b2f52d5a..0cacf856 100644 --- a/app/(dashboard)/settings/backup/page.tsx +++ b/app/(dashboard)/settings/backup/page.tsx @@ -1,6 +1,8 @@ import { BackupDownloadForm } from '@/components/settings/BackupDownloadForm' +import { getBranding } from '@/lib/branding/service' export default function BackupSettingsPage() { + const { appName } = getBranding() return ( <div className="space-y-8"> <section className="space-y-2"> @@ -10,7 +12,7 @@ export default function BackupSettingsPage() { <p className="text-sm text-muted-foreground max-w-prose"> Ladda ner en egen kopia av all räkenskapsinformation — SIE-filer, kvitton, underlag och behandlingshistorik — i en enda ZIP-fil. Säkerhetsbackupen är din - egen kopia för trygghet och portabilitet. gnubok arkiverar all + egen kopia för trygghet och portabilitet. {appName.toLowerCase()} arkiverar all räkenskapsinformation i minst 7 år enligt BFL 7 kap. 2 §, så din backup ersätter inte vårt lagkrav — den kompletterar det. </p> diff --git a/app/(public)/dpa/page.tsx b/app/(public)/dpa/page.tsx index 64832654..06285757 100644 --- a/app/(public)/dpa/page.tsx +++ b/app/(public)/dpa/page.tsx @@ -1,12 +1,16 @@ import type { Metadata } from 'next' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import Link from 'next/link' +import { getBranding } from '@/lib/branding/service' -export const metadata: Metadata = { - title: 'Personuppgiftsbitradesavtal - Gnubok', +export function generateMetadata(): Metadata { + return { + title: `Personuppgiftsbitradesavtal - ${getBranding().appName}`, + } } export default function DPAPage() { + const { appName, legalEntity, privacyEmail } = getBranding() return ( <div className="min-h-screen bg-gradient-to-b from-slate-50 to-white py-12 px-4"> <div className="max-w-3xl mx-auto space-y-6"> @@ -28,11 +32,11 @@ export default function DPAPage() { Detta personuppgiftsbitradesavtal ("DPA") ingår mellan: </p> <ul> - <li><strong>Personuppgiftsansvarig ("den Ansvarige"):</strong> Du som användare av Gnubok, + <li><strong>Personuppgiftsansvarig ("den Ansvarige"):</strong> Du som användare av {appName}, i egenskap av ansvarig för de personuppgifter du registrerar i tjänsten (kunder, leverantörer, anställda m.fl.).</li> - <li><strong>Personuppgiftsbiträde ("Biträdet"):</strong> Arcim, som tillhandahåller - Gnubok-tjänsten och behandlar personuppgifter på dina vägnar.</li> + <li><strong>Personuppgiftsbiträde ("Biträdet"):</strong> {legalEntity}, som tillhandahåller + {' '}{appName}-tjänsten och behandlar personuppgifter på dina vägnar.</li> </ul> </CardContent> </Card> @@ -174,8 +178,8 @@ export default function DPAPage() { <CardContent className="pt-6"> <p className="text-sm text-muted-foreground text-center"> Detta personuppgiftsbitradesavtal träder i kraft när du skapar ett konto på - Gnubok och gäller så länge du använder tjänsten. För frågor, kontakta oss - på privacy@gnubok.se. + {' '}{appName} och gäller så länge du använder tjänsten. För frågor, kontakta oss + på {privacyEmail}. </p> </CardContent> </Card> diff --git a/app/(public)/privacy/page.tsx b/app/(public)/privacy/page.tsx index 200d64ce..7e373d78 100644 --- a/app/(public)/privacy/page.tsx +++ b/app/(public)/privacy/page.tsx @@ -1,11 +1,15 @@ import type { Metadata } from 'next' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' +import { getBranding } from '@/lib/branding/service' -export const metadata: Metadata = { - title: 'Integritetspolicy - Gnubok', +export function generateMetadata(): Metadata { + return { + title: `Integritetspolicy - ${getBranding().appName}`, + } } export default function PrivacyPolicyPage() { + const { appName, legalEntity, privacyEmail } = getBranding() return ( <div className="min-h-screen bg-gradient-to-b from-slate-50 to-white py-12 px-4"> <div className="max-w-3xl mx-auto space-y-6"> @@ -24,8 +28,8 @@ export default function PrivacyPolicyPage() { </CardHeader> <CardContent className="prose prose-sm max-w-none"> <p> - Arcim ("vi", "oss") är personuppgiftsansvarig för behandlingen av dina - personuppgifter i samband med användningen av Gnubok. Vi behandlar dina uppgifter i + {legalEntity} ("vi", "oss") är personuppgiftsansvarig för behandlingen av dina + personuppgifter i samband med användningen av {appName}. Vi behandlar dina uppgifter i enlighet med EU:s dataskyddsförordning (GDPR) och svensk dataskyddslagstiftning. </p> </CardContent> @@ -205,8 +209,8 @@ export default function PrivacyPolicyPage() { För frågor om behandlingen av dina personuppgifter, kontakta oss: </p> <ul> - <li><strong>Företag:</strong> Arcim</li> - <li><strong>E-post:</strong> privacy@gnubok.se</li> + <li><strong>Företag:</strong> {legalEntity}</li> + <li><strong>E-post:</strong> {privacyEmail}</li> </ul> <p> Du har även rätt att lämna klagomål till Integritetsskyddsmyndigheten (IMY), diff --git a/app/api/ai/inbox-items/[id]/request-receipt/route.ts b/app/api/ai/inbox-items/[id]/request-receipt/route.ts index fc3be1a0..6b2aec78 100644 --- a/app/api/ai/inbox-items/[id]/request-receipt/route.ts +++ b/app/api/ai/inbox-items/[id]/request-receipt/route.ts @@ -6,6 +6,7 @@ import { requireWritePermission } from '@/lib/auth/require-write' import { getEmailService } from '@/lib/email/service' import { appendProcessingHistory } from '@/lib/processing-history/append' import { gateAgentInbox } from '@/lib/ai/feature-flag' +import { getBranding } from '@/lib/branding/service' import type { InvoiceInboxItem } from '@/types' ensureInitialized() @@ -105,7 +106,7 @@ export async function POST( const currency = extracted?.receipt?.currency ?? 'SEK' const date = extracted?.receipt?.date ?? null - const appUrl = process.env.NEXT_PUBLIC_APP_URL ?? 'https://gnubok.se' + const appUrl = getBranding().appUrl const deepLink = `${appUrl.replace(/\/$/, '')}/agent-inbox` const subject = `[${companyName}] Kvittobild behövs för bokföring` diff --git a/app/api/extensions/enable-banking/sync/cron/route.ts b/app/api/extensions/enable-banking/sync/cron/route.ts index 9438b484..8f8d64df 100644 --- a/app/api/extensions/enable-banking/sync/cron/route.ts +++ b/app/api/extensions/enable-banking/sync/cron/route.ts @@ -11,6 +11,7 @@ import { } from '@/lib/email/consent-notification-templates' import { ensureInitialized } from '@/lib/init' import { verifyCronSecret } from '@/lib/auth/cron' +import { getBranding } from '@/lib/branding/service' import type { StoredAccount } from '@/extensions/general/enable-banking/types' ensureInitialized() @@ -298,7 +299,7 @@ async function sendConsentExpiryNotification( bankName: connection.bank_name as string, daysUntilExpiry: daysLeft, renewalUrl: `${baseUrl}/settings/banking`, - companyName: companySettings?.company_name || 'gnubok', + companyName: companySettings?.company_name || getBranding().appName.toLowerCase(), isExpired, } diff --git a/app/api/mcp-oauth/authorize/route.ts b/app/api/mcp-oauth/authorize/route.ts index 16ee8872..3945a80a 100644 --- a/app/api/mcp-oauth/authorize/route.ts +++ b/app/api/mcp-oauth/authorize/route.ts @@ -2,6 +2,7 @@ import { createClient } from '@/lib/supabase/server' import { NextResponse } from 'next/server' import { createAuthCode } from '@/lib/auth/oauth-codes' import { requireCompanyId } from '@/lib/company/context' +import { getBranding } from '@/lib/branding/service' /** * OAuth 2.0 Authorization Endpoint. @@ -100,6 +101,8 @@ export async function GET(request: Request) { const companyName = settings?.trade_name || settings?.company_name || user.email + const appNameLower = escapeHtml(getBranding().appName.toLowerCase()) + // Render consent page const html = `<!DOCTYPE html> <html lang="sv"> @@ -107,7 +110,7 @@ export async function GET(request: Request) { <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="translate" content="no"> - <title>Anslut MCP-klient — gnubok + Anslut MCP-klient — ${appNameLower}