Add/white label (#381)
* 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) <noreply@anthropic.com> * 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) <noreply@anthropic.com> * 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 <p> 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) <noreply@anthropic.com> * 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 <title> 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>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
2d36dedf34
commit
064fb7f7a9
+173
@@ -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]`.
|
||||
@@ -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"
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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`
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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</title>
|
||||
<title>Anslut MCP-klient — ${appNameLower}</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: system-ui, -apple-system, sans-serif; background: #fafafa; color: #111; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
|
||||
@@ -128,7 +131,7 @@ export async function GET(request: Request) {
|
||||
<body>
|
||||
<div class="card">
|
||||
<h1>Anslut MCP-klient</h1>
|
||||
<p>En extern applikation vill ansluta till ditt gnubok-konto.</p>
|
||||
<p>En extern applikation vill ansluta till ditt ${appNameLower}-konto.</p>
|
||||
<div class="account">${escapeHtml(companyName)}</div>
|
||||
<ul class="permissions">
|
||||
<li>Visa och kategorisera transaktioner</li>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { NextResponse } from 'next/server'
|
||||
import { ensureInitialized } from '@/lib/init'
|
||||
import { requireCompanyId } from '@/lib/company/context'
|
||||
import { generatePain001 } from '@/lib/salary/payment/pain001-generator'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
import type { Pain001CompanyData, Pain001Employee } from '@/lib/salary/payment/pain001-generator'
|
||||
|
||||
ensureInitialized()
|
||||
@@ -105,7 +106,7 @@ export async function GET(
|
||||
})
|
||||
|
||||
const periodLabel = `${run.period_year}-${String(run.period_month).padStart(2, '0')}`
|
||||
const messageId = `GNUBOK-${company.org_number?.replace('-', '')}-${periodLabel}`
|
||||
const messageId = `${getBranding().appName.toUpperCase()}-${company.org_number?.replace('-', '')}-${periodLabel}`
|
||||
|
||||
const xml = generatePain001(companyData, employees, {
|
||||
messageId,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { createClient } from '@/lib/supabase/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { getEmailService } from '@/lib/email/service'
|
||||
import { SUPPORT_RECIPIENT_EMAIL } from '@/lib/support'
|
||||
import { getSupportRecipientEmail } from '@/lib/support'
|
||||
import { requireCompanyId } from '@/lib/company/context'
|
||||
import { ensureInitialized } from '@/lib/init'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
ensureInitialized()
|
||||
|
||||
@@ -47,8 +48,8 @@ export async function POST(request: Request) {
|
||||
const safeMessage = escapeHtml(message).replace(/\n/g, '<br />')
|
||||
|
||||
const result = await emailService.sendEmail({
|
||||
to: SUPPORT_RECIPIENT_EMAIL,
|
||||
subject: `[gnubok support] ${subject}`,
|
||||
to: getSupportRecipientEmail(),
|
||||
subject: `[${getBranding().appName.toLowerCase()} support] ${subject}`,
|
||||
replyTo: user.email,
|
||||
html: `
|
||||
<p><strong>Från:</strong> ${escapeHtml(user.email || '')}</p>
|
||||
|
||||
@@ -13,6 +13,9 @@ import { cn } from '@/lib/utils'
|
||||
import { ENABLED_EXTENSION_IDS } from '@/lib/extensions/_generated/enabled-extensions'
|
||||
import type { CompanyLookupResult } from '@/lib/company-lookup/types'
|
||||
import type { CompanySettings, EntityType, MomsPeriod } from '@/types'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
|
||||
import Step1EntityType from '@/components/onboarding/Step1EntityType'
|
||||
import Step2CompanyDetails from '@/components/onboarding/Step2CompanyDetails'
|
||||
@@ -229,13 +232,13 @@ function NewCompanyContent() {
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
</Link>
|
||||
<Image
|
||||
src="/gnubokiceon-removebg-preview.png"
|
||||
alt="Gnubok"
|
||||
src={branding.logoPath}
|
||||
alt={branding.appName}
|
||||
width={30}
|
||||
height={30}
|
||||
className="invert opacity-90"
|
||||
/>
|
||||
<span className="font-display text-base tracking-tight">gnubok</span>
|
||||
<span className="font-display text-base tracking-tight">{branding.appName.toLowerCase()}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
{STEP_INFO.map((_, i) => {
|
||||
|
||||
@@ -9,6 +9,9 @@ import { Card } from '@/components/ui/card'
|
||||
import { Loader2, Building2, AlertCircle } from 'lucide-react'
|
||||
import { createClient } from '@/lib/supabase/client'
|
||||
import { useToast } from '@/components/ui/use-toast'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
|
||||
interface InviteInfo {
|
||||
type: 'company'
|
||||
@@ -164,13 +167,13 @@ export default function InvitePage() {
|
||||
<div className="relative z-10 max-w-2xl mx-auto w-full px-6 md:px-10 pt-5 pb-6 md:pt-6 md:pb-8">
|
||||
<div className="flex items-center gap-2.5 mb-5 md:mb-6">
|
||||
<Image
|
||||
src="/gnubokiceon-removebg-preview.png"
|
||||
alt="Gnubok"
|
||||
src={branding.logoPath}
|
||||
alt={branding.appName}
|
||||
width={30}
|
||||
height={30}
|
||||
className="invert opacity-90"
|
||||
/>
|
||||
<span className="font-display text-base tracking-tight">gnubok</span>
|
||||
<span className="font-display text-base tracking-tight">{branding.appName.toLowerCase()}</span>
|
||||
</div>
|
||||
<div className="animate-fade-in">
|
||||
<h1 className="font-display text-2xl md:text-3xl font-medium tracking-tight leading-[1.1]">
|
||||
@@ -291,7 +294,7 @@ export default function InvitePage() {
|
||||
Du har bjudits in som medlem till detta företag.
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
<strong>{invite.email}</strong> har redan ett konto på gnubok.
|
||||
<strong>{invite.email}</strong> har redan ett konto på {branding.appName.toLowerCase()}.
|
||||
Logga in för att gå med.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
+30
-17
@@ -4,8 +4,15 @@ import { Fraunces } from "next/font/google";
|
||||
import Script from "next/script";
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
import { ThemeProvider } from "@/components/theme-provider";
|
||||
import { ensureInitialized } from "@/lib/init";
|
||||
import { getBranding } from "@/lib/branding/service";
|
||||
import "./globals.css";
|
||||
|
||||
// Load extensions before metadata/viewport functions read the branding service.
|
||||
// Without this, an extension that calls registerBrandingService() at its module
|
||||
// load time would not have run yet when the first request hits this layout.
|
||||
ensureInitialized();
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
subsets: ["latin"],
|
||||
@@ -22,34 +29,40 @@ const fraunces = Fraunces({
|
||||
display: "swap",
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Gnubok",
|
||||
description: "Ekonomihantering",
|
||||
manifest: "/manifest.json",
|
||||
appleWebApp: {
|
||||
capable: true,
|
||||
statusBarStyle: "default",
|
||||
title: "Gnubok",
|
||||
},
|
||||
};
|
||||
export function generateMetadata(): Metadata {
|
||||
const b = getBranding();
|
||||
return {
|
||||
title: b.appName,
|
||||
description: b.appDescription,
|
||||
manifest: "/manifest.webmanifest",
|
||||
appleWebApp: {
|
||||
capable: true,
|
||||
statusBarStyle: "default",
|
||||
title: b.appName,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const viewport: Viewport = {
|
||||
themeColor: "#304D83",
|
||||
width: "device-width",
|
||||
initialScale: 1,
|
||||
viewportFit: "cover",
|
||||
};
|
||||
export function generateViewport(): Viewport {
|
||||
return {
|
||||
themeColor: getBranding().themeColor,
|
||||
width: "device-width",
|
||||
initialScale: 1,
|
||||
viewportFit: "cover",
|
||||
};
|
||||
}
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
const branding = getBranding();
|
||||
return (
|
||||
<html lang="sv" translate="no" suppressHydrationWarning className={`${geistSans.variable} ${geistMono.variable} ${fraunces.variable}`}>
|
||||
<head>
|
||||
<meta name="google" content="notranslate" />
|
||||
<link rel="apple-touch-icon" href="/icons/icon-192.png" />
|
||||
<link rel="apple-touch-icon" href={branding.appleTouchIconPath} />
|
||||
<script
|
||||
src="https://cdn.recapt.app/browser/glimt.js"
|
||||
async
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { MetadataRoute } from 'next'
|
||||
import { ensureInitialized } from '@/lib/init'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
// Guarantee branding extensions have registered before the manifest is built.
|
||||
ensureInitialized()
|
||||
|
||||
export default function manifest(): MetadataRoute.Manifest {
|
||||
const b = getBranding()
|
||||
const sizes = [72, 96, 128, 144, 152, 192, 384, 512]
|
||||
// Next.js's Icon type doesn't accept the space-separated "any maskable" purpose
|
||||
// that the original public/manifest.json used. Cast preserves the same JSON
|
||||
// output so PWA install prompts behave identically to before.
|
||||
const icons = sizes.map((size) => ({
|
||||
src: `${b.pwaIconBasePath}/icon-${size}.png`,
|
||||
sizes: `${size}x${size}`,
|
||||
type: 'image/png',
|
||||
purpose: 'any maskable',
|
||||
})) as unknown as MetadataRoute.Manifest['icons']
|
||||
return {
|
||||
name: b.appName,
|
||||
short_name: b.appName,
|
||||
description: b.appDescription,
|
||||
start_url: '/',
|
||||
display: 'standalone',
|
||||
background_color: b.manifestBackgroundColor,
|
||||
theme_color: b.manifestThemeColor,
|
||||
orientation: 'portrait-primary',
|
||||
icons,
|
||||
categories: ['business', 'finance', 'productivity'],
|
||||
lang: 'sv-SE',
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,9 @@ import { createClient } from '@/lib/supabase/client'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useToast } from '@/components/ui/use-toast'
|
||||
import { Loader2, Receipt, ArrowLeftRight, BookOpen, BarChart3 } from 'lucide-react'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
|
||||
export default function SandboxPage() {
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
@@ -79,8 +82,8 @@ export default function SandboxPage() {
|
||||
<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"
|
||||
@@ -114,15 +117,15 @@ export default function SandboxPage() {
|
||||
<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"
|
||||
priority
|
||||
/>
|
||||
<h1 className="text-xl font-medium tracking-tight mt-3">
|
||||
Testa gnubok utan att registrera dig
|
||||
Testa {branding.appName.toLowerCase()} utan att registrera dig
|
||||
</h1>
|
||||
<p className="text-muted-foreground text-sm mt-2 leading-relaxed">
|
||||
Utforska ett fullt demoföretag med riktig data — helt gratis.
|
||||
|
||||
@@ -8,6 +8,9 @@ import { useToast } from '@/components/ui/use-toast'
|
||||
import { Building2 } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { ENABLED_EXTENSION_IDS } from '@/lib/extensions/_generated/enabled-extensions'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
import type { CompanyLookupResult } from '@/lib/company-lookup/types'
|
||||
import type { CompanySettings, EntityType, MomsPeriod } from '@/types'
|
||||
|
||||
@@ -143,7 +146,7 @@ export default function WelcomeOnboarding({
|
||||
let backToStep2 = false
|
||||
if (result.error === 'org_number_exists') {
|
||||
title = 'Företaget finns redan'
|
||||
description = 'Det här företaget finns redan i gnubok. Be en befintlig administratör att bjuda in dig.'
|
||||
description = `Det här företaget finns redan i ${branding.appName.toLowerCase()}. Be en befintlig administratör att bjuda in dig.`
|
||||
backToStep2 = true
|
||||
} else if (result.error === 'org_number_invalid') {
|
||||
title = 'Ogiltigt organisationsnummer'
|
||||
@@ -191,7 +194,7 @@ export default function WelcomeOnboarding({
|
||||
<div className="flex flex-col items-start justify-center min-h-[60vh] animate-fade-in">
|
||||
<p className="text-muted-foreground/50 text-sm mb-2">{greeting}</p>
|
||||
<h1 className="font-display text-4xl md:text-5xl font-medium tracking-tight leading-[1.05] mb-10">
|
||||
Välkommen till Gnubok
|
||||
Välkommen till {branding.appName}
|
||||
</h1>
|
||||
<button
|
||||
onClick={() => setStarted(true)}
|
||||
|
||||
@@ -11,6 +11,9 @@ import { cn } from '@/lib/utils'
|
||||
import { ConfirmationDialog } from '@/components/ui/confirmation-dialog'
|
||||
import Link from 'next/link'
|
||||
import { FallbackPrompt } from '@/components/ui/fallback-prompt'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
import {
|
||||
ArrowLeft,
|
||||
ArrowRight,
|
||||
@@ -415,8 +418,8 @@ function ConnectStep({
|
||||
const needsCompanyId = provider === 'bokio' || provider === 'bjornlunden'
|
||||
|
||||
const tokenDescription = isClientCredentials
|
||||
? `Ange ditt företags-ID (GUID) från Björn Lundén. gnubok ansluter automatiskt via sin integrationspartner-åtkomst.`
|
||||
: `Ange din API-nyckel från ${providerName} för att ge gnubok tillgång att läsa din bokföringsdata.`
|
||||
? `Ange ditt företags-ID (GUID) från Björn Lundén. ${branding.appName.toLowerCase()} ansluter automatiskt via sin integrationspartner-åtkomst.`
|
||||
: `Ange din API-nyckel från ${providerName} för att ge ${branding.appName.toLowerCase()} tillgång att läsa din bokföringsdata.`
|
||||
|
||||
const tokenHelpText = isClientCredentials
|
||||
? `Hittas i Björn Lundén under Inställningar \u2192 Företagsinformation (GUID-format).`
|
||||
@@ -436,7 +439,7 @@ function ConnectStep({
|
||||
<CardDescription>
|
||||
{authType === 'token'
|
||||
? tokenDescription
|
||||
: `Logga in i ${providerName} för att ge gnubok tillgång att läsa din bokföringsdata.`
|
||||
: `Logga in i ${providerName} för att ge ${branding.appName.toLowerCase()} tillgång att läsa din bokföringsdata.`
|
||||
}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
@@ -638,7 +641,7 @@ function PreviewStep({
|
||||
<div>
|
||||
<p className="text-sm font-medium text-destructive">SIE-import krävs</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Bokföringsdata (kontoplan, verifikationer och balanser) måste importeras via SIE-fil innan kunder, leverantörer och fakturor kan hämtas. Exportera en SIE-fil från {ARCIM_PROVIDERS.find(p => p.id === preview.consent.provider)?.name ?? 'ditt bokföringssystem'} och ladda upp den i gnubok.
|
||||
Bokföringsdata (kontoplan, verifikationer och balanser) måste importeras via SIE-fil innan kunder, leverantörer och fakturor kan hämtas. Exportera en SIE-fil från {ARCIM_PROVIDERS.find(p => p.id === preview.consent.provider)?.name ?? 'ditt bokföringssystem'} och ladda upp den i {branding.appName.toLowerCase()}.
|
||||
</p>
|
||||
<Link
|
||||
href="/import?mode=sie"
|
||||
@@ -912,7 +915,7 @@ function OptionsStep({
|
||||
}}
|
||||
isSubmitting={false}
|
||||
title="Starta migrering"
|
||||
warningText="Bokföringsdata, kunder, leverantörer och fakturor importeras till gnubok. Se till att ingen annan import pågår."
|
||||
warningText={`Bokföringsdata, kunder, leverantörer och fakturor importeras till ${branding.appName.toLowerCase()}. Se till att ingen annan import pågår.`}
|
||||
confirmLabel="Starta migrering"
|
||||
>
|
||||
<div className="space-y-2">
|
||||
|
||||
@@ -9,6 +9,9 @@ import { useToast } from '@/components/ui/use-toast'
|
||||
import { switchCompany, createCompanyFromTicRole } from '@/lib/company/actions'
|
||||
import { mapEntityType } from '@/lib/company-lookup/entity-type-map'
|
||||
import type { CompanyLookupResult, EnrichmentCompanyRole } from '@/lib/company-lookup/types'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
|
||||
export interface MemberCompany {
|
||||
id: string
|
||||
@@ -280,7 +283,7 @@ export default function BankIdCompanyPicker({
|
||||
{memberCompanies.length > 0 && (
|
||||
<section>
|
||||
<h2 className="text-xs uppercase tracking-[0.08em] text-muted-foreground mb-3">
|
||||
Dina företag i gnubok
|
||||
Dina företag i {branding.appName.toLowerCase()}
|
||||
</h2>
|
||||
<ul className="space-y-2">
|
||||
{memberCompanies.map((c) => {
|
||||
@@ -348,7 +351,7 @@ export default function BankIdCompanyPicker({
|
||||
</p>
|
||||
</div>
|
||||
<span className="text-[10px] uppercase tracking-wide text-muted-foreground flex-shrink-0">
|
||||
Finns redan i gnubok
|
||||
Finns redan i {branding.appName.toLowerCase()}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground/70 mt-2">
|
||||
|
||||
@@ -10,6 +10,9 @@ import {
|
||||
} from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { ENABLED_EXTENSION_IDS } from '@/lib/extensions/_generated/enabled-extensions'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
|
||||
interface NewUserChecklistProps {
|
||||
onFreshStart: () => void
|
||||
@@ -29,7 +32,7 @@ export default function NewUserChecklist({
|
||||
{/* Header */}
|
||||
<div className="text-center mb-8 md:mb-12">
|
||||
<h1 className="font-display text-2xl md:text-3xl font-medium tracking-tight">
|
||||
Välkommen till gnubok
|
||||
Välkommen till {branding.appName.toLowerCase()}
|
||||
</h1>
|
||||
<p className="text-muted-foreground text-sm md:text-base leading-relaxed max-w-md mx-auto mt-3">
|
||||
Börja med att hämta din bokföring, sedan kopplar du banken.
|
||||
|
||||
@@ -11,6 +11,9 @@ import { Label } from '@/components/ui/label'
|
||||
import { Loader2, ArrowRight, ArrowLeft, CheckCircle2, AlertTriangle } from 'lucide-react'
|
||||
import type { EntityType } from '@/types'
|
||||
import type { CompanyLookupResult } from '@/lib/company-lookup/types'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
|
||||
const schema = z.object({
|
||||
company_name: z.string().min(1, 'Företagsnamn krävs'),
|
||||
@@ -238,7 +241,7 @@ export default function Step2CompanyDetails({
|
||||
<div className="flex items-start gap-2 text-sm text-destructive">
|
||||
<AlertTriangle className="h-3.5 w-3.5 mt-0.5 flex-shrink-0" />
|
||||
<span>
|
||||
Det här företaget finns redan i gnubok. Be en befintlig administratör att bjuda in dig.
|
||||
Det här företaget finns redan i {branding.appName.toLowerCase()}. Be en befintlig administratör att bjuda in dig.
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -18,6 +18,10 @@ import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { DestructiveConfirmDialog, useDestructiveConfirm } from '@/components/ui/destructive-confirm-dialog'
|
||||
import { useToast } from '@/components/ui/use-toast'
|
||||
import { Loader2, Plus, Copy, Check, Trash2, Key, ChevronDown } from 'lucide-react'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
const connectorName = branding.appName.toLowerCase()
|
||||
|
||||
const SCOPE_GROUPS = [
|
||||
{
|
||||
@@ -335,7 +339,7 @@ export function ApiKeysPanel() {
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mb-2">
|
||||
Gå till <strong>Settings → Integrations → Add Integration</strong> och klistra in MCP-serverns URL.
|
||||
Du loggas in via ditt gnubok-konto — ingen API-nyckel behövs.
|
||||
Du loggas in via ditt {connectorName}-konto — ingen API-nyckel behövs.
|
||||
</p>
|
||||
<CopyBlock text={mcpUrl} />
|
||||
</div>
|
||||
@@ -345,7 +349,7 @@ export function ApiKeysPanel() {
|
||||
<p className="text-xs text-muted-foreground mb-2">
|
||||
Kör i terminalen — loggar in via webbläsaren:
|
||||
</p>
|
||||
<CopyBlock text={`claude mcp add gnubok --transport http ${mcpUrl}`} />
|
||||
<CopyBlock text={`claude mcp add ${connectorName} --transport http ${mcpUrl}`} />
|
||||
</div>
|
||||
|
||||
<div className="border-t pt-4">
|
||||
@@ -366,7 +370,7 @@ export function ApiKeysPanel() {
|
||||
</p>
|
||||
<CopyBlock text={`{
|
||||
"mcpServers": {
|
||||
"gnubok": {
|
||||
"${connectorName}": {
|
||||
"command": "npx",
|
||||
"args": ["gnubok-mcp"],
|
||||
"env": {
|
||||
@@ -382,7 +386,7 @@ export function ApiKeysPanel() {
|
||||
<p className="text-xs text-muted-foreground mb-2">
|
||||
Kör i terminalen med en API-nyckel:
|
||||
</p>
|
||||
<CopyBlock text={`claude mcp add gnubok --transport http \\
|
||||
<CopyBlock text={`claude mcp add ${connectorName} --transport http \\
|
||||
--url ${mcpUrl} \\
|
||||
--header "Authorization: Bearer gnubok_sk_..."`} />
|
||||
</div>
|
||||
|
||||
@@ -17,6 +17,9 @@ import {
|
||||
import { RetentionNotice } from '@/components/ui/retention-notice'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { useToast } from '@/components/ui/use-toast'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
const branding = getBranding()
|
||||
|
||||
/**
|
||||
* Danger zone for the currently-active company. Only visible to owners.
|
||||
@@ -106,7 +109,7 @@ export function CompanyDangerZone() {
|
||||
<DialogHeader>
|
||||
<DialogTitle>Radera {company.name}</DialogTitle>
|
||||
<DialogDescription>
|
||||
Företaget döljs från gnubok. Bokföringen behålls säkert i 7 år enligt BFL.
|
||||
Företaget döljs från {branding.appName.toLowerCase()}. Bokföringen behålls säkert i 7 år enligt BFL.
|
||||
Skriv företagets namn exakt för att bekräfta.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import Link from 'next/link'
|
||||
import { AlertTriangle } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
interface RetentionNoticeProps {
|
||||
variant: 'company' | 'account'
|
||||
@@ -20,6 +21,7 @@ interface RetentionNoticeProps {
|
||||
* hides it from the UI and anonymizes PII where applicable.
|
||||
*/
|
||||
export function RetentionNotice({ variant, className }: RetentionNoticeProps) {
|
||||
const { appName } = getBranding()
|
||||
const copy =
|
||||
variant === 'company'
|
||||
? {
|
||||
@@ -27,7 +29,7 @@ export function RetentionNotice({ variant, className }: RetentionNoticeProps) {
|
||||
body: (
|
||||
<>
|
||||
Enligt bokföringslagen (BFL 7 kap. 2§) sparas räkenskapsinformation i 7 år.
|
||||
När du raderar företaget döljs det i gnubok, men verifikationer, dokument och
|
||||
När du raderar företaget döljs det i {appName.toLowerCase()}, men verifikationer, dokument och
|
||||
bokföring behålls säkert tills lagkravet löpt ut. Du kan{' '}
|
||||
<Link
|
||||
href="/settings/backup"
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# Example branding extension
|
||||
|
||||
Copy this folder to start a whitelabel fork:
|
||||
|
||||
```bash
|
||||
cp -r extensions/general/_example-branding extensions/general/your-brand
|
||||
```
|
||||
|
||||
Then:
|
||||
|
||||
1. Edit `your-brand/manifest.json` — set `id`, `exportName`, `entryPoint`, name, description.
|
||||
2. Edit `your-brand/index.ts` — uncomment and set the branding values you want to override.
|
||||
3. Drop your assets in `your-brand/assets/` (logo.svg, favicon.ico, og.png, etc.). Wire up an extension API route to serve them, or set the asset paths in `index.ts` to external CDN URLs.
|
||||
4. Enable the extension in `extensions.config.json`:
|
||||
```json
|
||||
{ "id": "your-brand", "enabled": true }
|
||||
```
|
||||
5. Run `npm run setup:extensions && npm run dev`.
|
||||
|
||||
See `WHITELABEL.md` at the repo root for the full fork checklist (env vars, sync workflow, what NOT to change).
|
||||
|
||||
## Why a separate extension instead of just env vars?
|
||||
|
||||
Both work. Env vars are simpler for scalar overrides (app name, support email). An extension lets you bundle assets (logos, icons) and override values that don't fit cleanly into env vars. You can use both — extension overrides win over env vars.
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { Extension } from '@/lib/extensions/types'
|
||||
import { registerBrandingService } from '@/lib/branding/service'
|
||||
|
||||
// Register the whitelabel branding values immediately when this extension is loaded.
|
||||
// Edit the values below to match your brand. Any field omitted falls back to the
|
||||
// gnubok default (and to whatever you've set via env vars). See WHITELABEL.md.
|
||||
registerBrandingService({
|
||||
// appName: 'YourBrand',
|
||||
// appDescription: 'Bokföring & redovisning',
|
||||
// legalEntity: 'YourBrand AB',
|
||||
// supportEmail: 'support@yourbrand.se',
|
||||
// privacyEmail: 'privacy@yourbrand.se',
|
||||
// securityEmail: 'security@yourbrand.se',
|
||||
// appUrl: 'https://app.yourbrand.se',
|
||||
// logoPath: '/api/extensions/ext/_example-branding/assets/logo.svg',
|
||||
// faviconPath: '/api/extensions/ext/_example-branding/assets/favicon.ico',
|
||||
// appleTouchIconPath: '/api/extensions/ext/_example-branding/assets/apple-touch-icon-192.png',
|
||||
// pwaIconBasePath: '/api/extensions/ext/_example-branding/assets/icons',
|
||||
// themeColor: '#000000',
|
||||
// manifestThemeColor: '#000000',
|
||||
// manifestBackgroundColor: '#ffffff',
|
||||
})
|
||||
|
||||
export const exampleBrandingExtension: Extension = {
|
||||
id: '_example-branding',
|
||||
name: 'Whitelabel branding (example)',
|
||||
version: '1.0.0',
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "_example-branding",
|
||||
"sector": "general",
|
||||
"exportName": "exampleBrandingExtension",
|
||||
"entryPoint": "@/extensions/general/_example-branding",
|
||||
"workspace": null,
|
||||
"requiredEnvVars": [],
|
||||
"optionalEnvVars": [],
|
||||
"npmDependencies": [],
|
||||
"definition": {
|
||||
"name": "Whitelabel branding (example)",
|
||||
"category": "operations",
|
||||
"icon": "Palette",
|
||||
"dataPattern": "core",
|
||||
"readsCoreTables": [],
|
||||
"description": "Copy-paste starter for a whitelabel fork. Disabled by default.",
|
||||
"longDescription": "Template extension for forks that want to rebrand the app. Copy this folder, rename it, edit index.ts with your brand values, drop your logo into assets/, and enable it in extensions.config.json. See WHITELABEL.md for the full fork checklist."
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,17 @@
|
||||
|
||||
import { Resend } from 'resend'
|
||||
import { createLogger } from '@/lib/logger'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
import type { EmailService, SendEmailOptions, SendEmailResult } from '@/lib/email/service'
|
||||
|
||||
const log = createLogger('email')
|
||||
|
||||
const DEFAULT_FROM_EMAIL = process.env.RESEND_FROM_EMAIL || 'noreply@localhost'
|
||||
|
||||
function sanitizeHeaderPart(s: string): string {
|
||||
return s.replace(/[\r\n<>]/g, '').trim()
|
||||
}
|
||||
|
||||
let resendClient: Resend | null = null
|
||||
|
||||
function getResendClient(): Resend {
|
||||
@@ -36,9 +41,15 @@ export class ResendEmailService implements EmailService {
|
||||
return { success: false, error: 'Email service is not configured' }
|
||||
}
|
||||
|
||||
const from = fromName
|
||||
? `${fromName} via Gnubok <${DEFAULT_FROM_EMAIL}>`
|
||||
: `Gnubok <${DEFAULT_FROM_EMAIL}>`
|
||||
// Strip CRLF and angle brackets from name parts to prevent header injection.
|
||||
// Resend's API does its own validation, but defense in depth — both fromName
|
||||
// (user-controlled, from company settings) and appName (admin-controlled,
|
||||
// from branding) flow into the From header.
|
||||
const safeAppName = sanitizeHeaderPart(getBranding().appName)
|
||||
const safeFromName = fromName ? sanitizeHeaderPart(fromName) : null
|
||||
const from = safeFromName
|
||||
? `${safeFromName} via ${safeAppName} <${DEFAULT_FROM_EMAIL}>`
|
||||
: `${safeAppName} <${DEFAULT_FROM_EMAIL}>`
|
||||
|
||||
try {
|
||||
const resend = getResendClient()
|
||||
|
||||
@@ -13,6 +13,7 @@ import { upsertCounterpartyTemplate, findCounterpartyTemplatesBatch, formatCount
|
||||
import { eventBus } from '@/lib/events/bus'
|
||||
import { getVatRules, getAvailableVatRates } from '@/lib/invoices/vat-rules'
|
||||
import { fetchExchangeRate, convertToSEK } from '@/lib/currency/riksbanken'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
import { generateIncomeStatement } from '@/lib/reports/income-statement'
|
||||
import {
|
||||
calculateGrossMargin,
|
||||
@@ -128,7 +129,7 @@ async function stagePendingOperation(
|
||||
return {
|
||||
staged: true,
|
||||
operation_id: data.id,
|
||||
message: 'Operation staged for review. Open the gnubok web app to approve or reject it.',
|
||||
message: `Operation staged for review. Open the ${getBranding().appName.toLowerCase()} web app to approve or reject it.`,
|
||||
preview: previewData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
|
||||
const ENV_KEYS = [
|
||||
'NEXT_PUBLIC_BRANDING_APP_NAME',
|
||||
'NEXT_PUBLIC_BRANDING_APP_DESCRIPTION',
|
||||
'BRANDING_LEGAL_ENTITY',
|
||||
'BRANDING_SUPPORT_EMAIL',
|
||||
'BRANDING_PRIVACY_EMAIL',
|
||||
'BRANDING_SECURITY_EMAIL',
|
||||
'NEXT_PUBLIC_BRANDING_LOGO_PATH',
|
||||
'NEXT_PUBLIC_BRANDING_FAVICON_PATH',
|
||||
'NEXT_PUBLIC_BRANDING_APPLE_ICON_PATH',
|
||||
'NEXT_PUBLIC_BRANDING_PWA_ICON_BASE',
|
||||
'NEXT_PUBLIC_BRANDING_THEME_COLOR',
|
||||
'NEXT_PUBLIC_BRANDING_MANIFEST_THEME_COLOR',
|
||||
'NEXT_PUBLIC_BRANDING_MANIFEST_BG_COLOR',
|
||||
] as const
|
||||
|
||||
describe('branding service', () => {
|
||||
const originalEnv: Record<string, string | undefined> = {}
|
||||
|
||||
beforeEach(() => {
|
||||
for (const key of ENV_KEYS) {
|
||||
originalEnv[key] = process.env[key]
|
||||
delete process.env[key]
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
for (const key of ENV_KEYS) {
|
||||
if (originalEnv[key] === undefined) delete process.env[key]
|
||||
else process.env[key] = originalEnv[key]
|
||||
}
|
||||
const { registerBrandingService } = await import('../service')
|
||||
registerBrandingService({})
|
||||
})
|
||||
|
||||
it('returns gnubok defaults when nothing is overridden', async () => {
|
||||
const { getBranding } = await import('../service')
|
||||
const b = getBranding()
|
||||
expect(b.appName).toBe('Gnubok')
|
||||
expect(b.appDescription).toBe('Ekonomihantering')
|
||||
expect(b.legalEntity).toBe('Arcim')
|
||||
expect(b.supportEmail).toBe('support@gnubok.se')
|
||||
expect(b.privacyEmail).toBe('privacy@gnubok.se')
|
||||
expect(b.securityEmail).toBe('security@arcim.io')
|
||||
expect(b.logoPath).toBe('/gnubokiceon-removebg-preview.png')
|
||||
expect(b.faviconPath).toBe('/favicon.ico')
|
||||
expect(b.appleTouchIconPath).toBe('/icons/icon-192.png')
|
||||
expect(b.pwaIconBasePath).toBe('/icons')
|
||||
expect(b.themeColor).toBe('#304D83')
|
||||
expect(b.manifestThemeColor).toBe('#1a1a1a')
|
||||
expect(b.manifestBackgroundColor).toBe('#ffffff')
|
||||
})
|
||||
|
||||
it('env vars override defaults', async () => {
|
||||
process.env.NEXT_PUBLIC_BRANDING_APP_NAME = 'Holdio'
|
||||
process.env.BRANDING_SUPPORT_EMAIL = 'hello@holdio.se'
|
||||
process.env.NEXT_PUBLIC_BRANDING_LOGO_PATH = '/holdio-logo.svg'
|
||||
const { getBranding } = await import('../service')
|
||||
const b = getBranding()
|
||||
expect(b.appName).toBe('Holdio')
|
||||
expect(b.supportEmail).toBe('hello@holdio.se')
|
||||
expect(b.logoPath).toBe('/holdio-logo.svg')
|
||||
expect(b.appDescription).toBe('Ekonomihantering')
|
||||
})
|
||||
|
||||
it('extension override beats env vars', async () => {
|
||||
process.env.NEXT_PUBLIC_BRANDING_APP_NAME = 'EnvName'
|
||||
const { getBranding, registerBrandingService } = await import('../service')
|
||||
registerBrandingService({ appName: 'ExtensionName' })
|
||||
expect(getBranding().appName).toBe('ExtensionName')
|
||||
})
|
||||
|
||||
it('extension partial override leaves untouched fields at default', async () => {
|
||||
const { getBranding, registerBrandingService } = await import('../service')
|
||||
registerBrandingService({ appName: 'Holdio' })
|
||||
const b = getBranding()
|
||||
expect(b.appName).toBe('Holdio')
|
||||
expect(b.legalEntity).toBe('Arcim')
|
||||
expect(b.supportEmail).toBe('support@gnubok.se')
|
||||
})
|
||||
|
||||
it('empty string env var does not override', async () => {
|
||||
process.env.NEXT_PUBLIC_BRANDING_APP_NAME = ''
|
||||
const { getBranding } = await import('../service')
|
||||
expect(getBranding().appName).toBe('Gnubok')
|
||||
})
|
||||
|
||||
it('clearing extension override returns to env/default resolution', async () => {
|
||||
const { getBranding, registerBrandingService } = await import('../service')
|
||||
registerBrandingService({ appName: 'Holdio' })
|
||||
expect(getBranding().appName).toBe('Holdio')
|
||||
registerBrandingService({})
|
||||
expect(getBranding().appName).toBe('Gnubok')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Branding Service
|
||||
*
|
||||
* Provides whitelabel-friendly branding values (app name, support emails,
|
||||
* asset paths, theme colors) with three-tier resolution:
|
||||
*
|
||||
* defaults < env vars < extension override
|
||||
*
|
||||
* If nothing is set, gnubok defaults are returned — production behaviour
|
||||
* is unchanged. A whitelabel sets env vars (NEXT_PUBLIC_BRANDING_* for
|
||||
* client-readable, BRANDING_* for server-only) or registers a branding
|
||||
* extension via registerBrandingService().
|
||||
*
|
||||
* See WHITELABEL.md for the full env var reference and fork checklist.
|
||||
*/
|
||||
|
||||
export interface BrandingConfig {
|
||||
// Identity
|
||||
appName: string
|
||||
appDescription: string
|
||||
legalEntity: string
|
||||
|
||||
// Contact
|
||||
supportEmail: string
|
||||
privacyEmail: string
|
||||
securityEmail: string
|
||||
|
||||
// URLs
|
||||
appUrl: string
|
||||
|
||||
// Asset paths
|
||||
logoPath: string
|
||||
faviconPath: string
|
||||
appleTouchIconPath: string
|
||||
pwaIconBasePath: string
|
||||
|
||||
// Colors
|
||||
themeColor: string
|
||||
manifestThemeColor: string
|
||||
manifestBackgroundColor: string
|
||||
}
|
||||
|
||||
const DEFAULT_BRANDING: BrandingConfig = {
|
||||
appName: 'Gnubok',
|
||||
appDescription: 'Ekonomihantering',
|
||||
legalEntity: 'Arcim',
|
||||
supportEmail: 'support@gnubok.se',
|
||||
privacyEmail: 'privacy@gnubok.se',
|
||||
securityEmail: 'security@arcim.io',
|
||||
appUrl: process.env.NEXT_PUBLIC_APP_URL || 'https://app.gnubok.se',
|
||||
logoPath: '/gnubokiceon-removebg-preview.png',
|
||||
faviconPath: '/favicon.ico',
|
||||
appleTouchIconPath: '/icons/icon-192.png',
|
||||
pwaIconBasePath: '/icons',
|
||||
themeColor: '#304D83',
|
||||
manifestThemeColor: '#1a1a1a',
|
||||
manifestBackgroundColor: '#ffffff',
|
||||
}
|
||||
|
||||
let _override: Partial<BrandingConfig> = {}
|
||||
|
||||
export function registerBrandingService(partial: Partial<BrandingConfig>): void {
|
||||
_override = { ...partial }
|
||||
}
|
||||
|
||||
export function getBranding(): BrandingConfig {
|
||||
return {
|
||||
...DEFAULT_BRANDING,
|
||||
...readEnvOverrides(),
|
||||
..._override,
|
||||
}
|
||||
}
|
||||
|
||||
function readEnvOverrides(): Partial<BrandingConfig> {
|
||||
const env = process.env
|
||||
const o: Partial<BrandingConfig> = {}
|
||||
if (env.NEXT_PUBLIC_BRANDING_APP_NAME) o.appName = env.NEXT_PUBLIC_BRANDING_APP_NAME
|
||||
if (env.NEXT_PUBLIC_BRANDING_APP_DESCRIPTION) o.appDescription = env.NEXT_PUBLIC_BRANDING_APP_DESCRIPTION
|
||||
if (env.BRANDING_LEGAL_ENTITY) o.legalEntity = env.BRANDING_LEGAL_ENTITY
|
||||
if (env.BRANDING_SUPPORT_EMAIL) o.supportEmail = env.BRANDING_SUPPORT_EMAIL
|
||||
if (env.BRANDING_PRIVACY_EMAIL) o.privacyEmail = env.BRANDING_PRIVACY_EMAIL
|
||||
if (env.BRANDING_SECURITY_EMAIL) o.securityEmail = env.BRANDING_SECURITY_EMAIL
|
||||
if (env.NEXT_PUBLIC_APP_URL) o.appUrl = env.NEXT_PUBLIC_APP_URL
|
||||
if (env.NEXT_PUBLIC_BRANDING_LOGO_PATH) o.logoPath = env.NEXT_PUBLIC_BRANDING_LOGO_PATH
|
||||
if (env.NEXT_PUBLIC_BRANDING_FAVICON_PATH) o.faviconPath = env.NEXT_PUBLIC_BRANDING_FAVICON_PATH
|
||||
if (env.NEXT_PUBLIC_BRANDING_APPLE_ICON_PATH) o.appleTouchIconPath = env.NEXT_PUBLIC_BRANDING_APPLE_ICON_PATH
|
||||
if (env.NEXT_PUBLIC_BRANDING_PWA_ICON_BASE) o.pwaIconBasePath = env.NEXT_PUBLIC_BRANDING_PWA_ICON_BASE
|
||||
if (env.NEXT_PUBLIC_BRANDING_THEME_COLOR) o.themeColor = env.NEXT_PUBLIC_BRANDING_THEME_COLOR
|
||||
if (env.NEXT_PUBLIC_BRANDING_MANIFEST_THEME_COLOR) o.manifestThemeColor = env.NEXT_PUBLIC_BRANDING_MANIFEST_THEME_COLOR
|
||||
if (env.NEXT_PUBLIC_BRANDING_MANIFEST_BG_COLOR) o.manifestBackgroundColor = env.NEXT_PUBLIC_BRANDING_MANIFEST_BG_COLOR
|
||||
return o
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
export interface ConsentExpiryEmailData {
|
||||
bankName: string
|
||||
daysUntilExpiry: number
|
||||
@@ -11,6 +13,7 @@ export interface ConsentExpiryEmailData {
|
||||
*/
|
||||
export function generateConsentExpiryEmailHtml(data: ConsentExpiryEmailData): string {
|
||||
const { bankName, daysUntilExpiry, renewalUrl, companyName, isExpired } = data
|
||||
const { appName } = getBranding()
|
||||
const headerColor = isExpired ? '#dc2626' : '#ea580c'
|
||||
const title = isExpired
|
||||
? 'Banksynkronisering har stoppats'
|
||||
@@ -64,7 +67,7 @@ export function generateConsentExpiryEmailHtml(data: ConsentExpiryEmailData): st
|
||||
<div style="padding-top: 20px; border-top: 1px solid #e5e7eb;">
|
||||
<p style="margin: 0; color: #666; font-size: 14px;">
|
||||
Med vänliga hälsningar,<br>
|
||||
<strong>${companyName || 'gnubok'}</strong>
|
||||
<strong>${companyName || appName.toLowerCase()}</strong>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,6 +82,7 @@ export function generateConsentExpiryEmailHtml(data: ConsentExpiryEmailData): st
|
||||
*/
|
||||
export function generateConsentExpiryEmailText(data: ConsentExpiryEmailData): string {
|
||||
const { bankName, daysUntilExpiry, renewalUrl, companyName, isExpired } = data
|
||||
const { appName } = getBranding()
|
||||
|
||||
let text = ''
|
||||
|
||||
@@ -97,7 +101,7 @@ export function generateConsentExpiryEmailText(data: ConsentExpiryEmailData): st
|
||||
|
||||
text += `Hantera bankanslutningar: ${renewalUrl}\n\n`
|
||||
text += `Med vänliga hälsningar,\n`
|
||||
text += `${companyName || 'gnubok'}\n`
|
||||
text += `${companyName || appName.toLowerCase()}\n`
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
export interface InviteEmailData {
|
||||
companyName: string
|
||||
inviterEmail: string
|
||||
@@ -5,11 +7,13 @@ export interface InviteEmailData {
|
||||
}
|
||||
|
||||
export function generateInviteEmailSubject(data: InviteEmailData): string {
|
||||
return `Du har bjudits in till ${data.companyName} på gnubok`
|
||||
const { appName } = getBranding()
|
||||
return `Du har bjudits in till ${data.companyName} på ${appName.toLowerCase()}`
|
||||
}
|
||||
|
||||
export function generateInviteEmailHtml(data: InviteEmailData): string {
|
||||
const { companyName, inviterEmail, inviteUrl } = data
|
||||
const { appName } = getBranding()
|
||||
|
||||
return `
|
||||
<!DOCTYPE html>
|
||||
@@ -24,12 +28,12 @@ export function generateInviteEmailHtml(data: InviteEmailData): string {
|
||||
<div style="background: #ffffff; border-radius: 12px; padding: 40px 32px; border: 1px solid #e5e5e5;">
|
||||
<!-- Header -->
|
||||
<div style="margin-bottom: 28px;">
|
||||
<p style="margin: 0 0 4px 0; font-size: 13px; color: #888; letter-spacing: 0.05em;">GNUBOK</p>
|
||||
<p style="margin: 0 0 4px 0; font-size: 13px; color: #888; letter-spacing: 0.05em;">${appName.toUpperCase()}</p>
|
||||
<h1 style="margin: 0 0 8px 0; font-size: 22px; font-weight: 600; color: #111;">
|
||||
Du har blivit inbjuden
|
||||
</h1>
|
||||
<p style="margin: 0; color: #666; font-size: 15px;">
|
||||
<strong>${inviterEmail}</strong> har bjudit in dig till <strong>${companyName}</strong> på gnubok.
|
||||
<strong>${inviterEmail}</strong> har bjudit in dig till <strong>${companyName}</strong> på ${appName.toLowerCase()}.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -51,7 +55,8 @@ export function generateInviteEmailHtml(data: InviteEmailData): string {
|
||||
}
|
||||
|
||||
export function generateInviteEmailText(data: InviteEmailData): string {
|
||||
return `Du har bjudits in till ${data.companyName} på gnubok av ${data.inviterEmail}.
|
||||
const { appName } = getBranding()
|
||||
return `Du har bjudits in till ${data.companyName} på ${appName.toLowerCase()} av ${data.inviterEmail}.
|
||||
|
||||
Acceptera inbjudan: ${data.inviteUrl}
|
||||
|
||||
@@ -68,11 +73,13 @@ export interface TeamInviteEmailData {
|
||||
}
|
||||
|
||||
export function generateTeamInviteEmailSubject(): string {
|
||||
return 'Du har bjudits in till ett team på gnubok'
|
||||
const { appName } = getBranding()
|
||||
return `Du har bjudits in till ett team på ${appName.toLowerCase()}`
|
||||
}
|
||||
|
||||
export function generateTeamInviteEmailHtml(data: TeamInviteEmailData): string {
|
||||
const { inviterEmail, inviteUrl } = data
|
||||
const { appName } = getBranding()
|
||||
|
||||
return `
|
||||
<!DOCTYPE html>
|
||||
@@ -87,7 +94,7 @@ export function generateTeamInviteEmailHtml(data: TeamInviteEmailData): string {
|
||||
<div style="background: #ffffff; border-radius: 12px; padding: 40px 32px; border: 1px solid #e5e5e5;">
|
||||
<!-- Header -->
|
||||
<div style="margin-bottom: 28px;">
|
||||
<p style="margin: 0 0 4px 0; font-size: 13px; color: #888; letter-spacing: 0.05em;">GNUBOK</p>
|
||||
<p style="margin: 0 0 4px 0; font-size: 13px; color: #888; letter-spacing: 0.05em;">${appName.toUpperCase()}</p>
|
||||
<h1 style="margin: 0 0 8px 0; font-size: 22px; font-weight: 600; color: #111;">
|
||||
Du har blivit inbjuden till ett team
|
||||
</h1>
|
||||
@@ -114,7 +121,8 @@ export function generateTeamInviteEmailHtml(data: TeamInviteEmailData): string {
|
||||
}
|
||||
|
||||
export function generateTeamInviteEmailText(data: TeamInviteEmailData): string {
|
||||
return `Du har bjudits in som konsult till ett team på gnubok av ${data.inviterEmail}. Du får tillgång till alla företag i teamet.
|
||||
const { appName } = getBranding()
|
||||
return `Du har bjudits in som konsult till ett team på ${appName.toLowerCase()} av ${data.inviterEmail}. Du får tillgång till alla företag i teamet.
|
||||
|
||||
Acceptera inbjudan: ${data.inviteUrl}
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ describe('sectors registry', () => {
|
||||
expect(SECTORS.length).toBe(1)
|
||||
})
|
||||
|
||||
it('should have 12 total extensions', () => {
|
||||
expect(getAllExtensions().length).toBe(12)
|
||||
it('should have 13 total extensions', () => {
|
||||
expect(getAllExtensions().length).toBe(13)
|
||||
})
|
||||
|
||||
it('should have unique slugs within each sector', () => {
|
||||
@@ -94,7 +94,7 @@ describe('sectors registry', () => {
|
||||
|
||||
it('getExtensionsBySector returns extensions for a sector', () => {
|
||||
const extensions = getExtensionsBySector('general')
|
||||
expect(extensions.length).toBe(12)
|
||||
expect(extensions.length).toBe(13)
|
||||
})
|
||||
|
||||
it('all extensions have required fields', () => {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { generateJournalRegister } from './journal-register'
|
||||
import { calculateVatDeclaration } from './vat-declaration'
|
||||
import { getAuditLog } from '@/lib/core/audit/audit-service'
|
||||
import { fetchAllRows } from '@/lib/supabase/fetch-all'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
import type { AuditLogEntry } from '@/types'
|
||||
|
||||
export type FullArchiveOptions =
|
||||
@@ -689,11 +690,12 @@ async function buildSystemDoc(
|
||||
voucherSeriesQuery,
|
||||
])
|
||||
|
||||
const branding = getBranding()
|
||||
return {
|
||||
system: {
|
||||
name: 'gnubok',
|
||||
name: branding.appName.toLowerCase(),
|
||||
description: 'Bokforingssystem for enskild firma och aktiebolag',
|
||||
url: process.env.NEXT_PUBLIC_APP_URL || '',
|
||||
url: branding.appUrl,
|
||||
},
|
||||
kontoplan: {
|
||||
standard: 'BAS 2026',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
import type {
|
||||
INK2Declaration,
|
||||
INK2RSRUCode,
|
||||
@@ -24,7 +25,6 @@ import {
|
||||
*/
|
||||
|
||||
const CRLF = '\r\n'
|
||||
const PROGRAM_NAME = 'gnubok'
|
||||
const PROGRAM_VERSION = '1.0'
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ function generateInfoSru(declaration: INK2Declaration, now: Date): string {
|
||||
lines.push('#DATABESKRIVNING_START')
|
||||
lines.push('#PRODUKT SRU')
|
||||
lines.push(`#SKAPAD ${formatDate(now)} ${formatTime(now)}`)
|
||||
lines.push(`#PROGRAM ${PROGRAM_NAME} ${PROGRAM_VERSION}`)
|
||||
lines.push(`#PROGRAM ${sanitizeString(getBranding().appName.toLowerCase())} ${PROGRAM_VERSION}`)
|
||||
lines.push('#FILNAMN BLANKETTER.SRU')
|
||||
lines.push('#DATABESKRIVNING_SLUT')
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { decryptPersonnummer } from '../personnummer'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
/**
|
||||
* AGI XML generator — Arbetsgivardeklaration på individnivå.
|
||||
@@ -186,7 +187,7 @@ export function generateAGIXml(
|
||||
|
||||
// ── Avsandare (komponent namespace) ──────────────────────────
|
||||
lines.push(' <gem:Avsandare>')
|
||||
lines.push(' <gem:Programnamn>gnubok</gem:Programnamn>')
|
||||
lines.push(` <gem:Programnamn>${escapeXml(getBranding().appName.toLowerCase())}</gem:Programnamn>`)
|
||||
lines.push(` <gem:Organisationsnummer>${orgIdentitet}</gem:Organisationsnummer>`)
|
||||
lines.push(' <gem:TekniskKontaktperson>')
|
||||
lines.push(` <gem:Namn>${escapeXml(company.contactName)}</gem:Namn>`)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { decryptPersonnummer } from '../personnummer'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
/**
|
||||
* KU10 (Kontrolluppgift) — Annual employee income statement.
|
||||
@@ -56,7 +57,7 @@ export function generateKU10Xml(
|
||||
|
||||
// Avsändare
|
||||
lines.push(' <Avsandare>')
|
||||
lines.push(' <Programnamn>gnubok</Programnamn>')
|
||||
lines.push(` <Programnamn>${escapeXml(getBranding().appName.toLowerCase())}</Programnamn>`)
|
||||
lines.push(` <Organisationsnummer>${orgNr}</Organisationsnummer>`)
|
||||
lines.push(' <TekniskKontaktperson>')
|
||||
lines.push(` <Namn>${escapeXml(company.contactName)}</Namn>`)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
/**
|
||||
* Pay slip PDF template (Lönespecifikation).
|
||||
@@ -388,7 +389,7 @@ export function PayslipPDF({ data }: { data: PayslipData }) {
|
||||
|
||||
{/* Footer */}
|
||||
<Text style={styles.footer}>
|
||||
{data.companyName} · Org.nr {data.companyOrgNumber} · Lönespecifikation {periodLabel} · Genererad av gnubok
|
||||
{data.companyName} · Org.nr {data.companyOrgNumber} · Lönespecifikation {periodLabel} · Genererad av {getBranding().appName.toLowerCase()}
|
||||
</Text>
|
||||
</Page>
|
||||
</Document>
|
||||
|
||||
+9
-1
@@ -1,5 +1,13 @@
|
||||
/**
|
||||
* Support recipient — server-side only.
|
||||
* Used by the /api/support/contact route. Never exposed to the client.
|
||||
*
|
||||
* Resolution order (evaluated lazily so extensions registered via
|
||||
* ensureInitialized() can override the branding default):
|
||||
* SUPPORT_RECIPIENT_EMAIL env var → branding service
|
||||
*/
|
||||
export const SUPPORT_RECIPIENT_EMAIL = process.env.SUPPORT_RECIPIENT_EMAIL || 'support@gnubok.se'
|
||||
import { getBranding } from '@/lib/branding/service'
|
||||
|
||||
export function getSupportRecipientEmail(): string {
|
||||
return process.env.SUPPORT_RECIPIENT_EMAIL || getBranding().supportEmail
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
{
|
||||
"name": "Gnubok",
|
||||
"short_name": "Gnubok",
|
||||
"description": "Ekonomihantering",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#ffffff",
|
||||
"theme_color": "#1a1a1a",
|
||||
"orientation": "portrait-primary",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icons/icon-72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-152.png",
|
||||
"sizes": "152x152",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
}
|
||||
],
|
||||
"categories": ["business", "finance", "productivity"],
|
||||
"lang": "sv-SE"
|
||||
}
|
||||
Reference in New Issue
Block a user