Skip to content

feat: implement sql dump encryption - #3510

Open
oripka wants to merge 24 commits into
nuxt:mainfrom
oripka:feat-encrypted-sql-dumps
Open

feat: implement sql dump encryption#3510
oripka wants to merge 24 commits into
nuxt:mainfrom
oripka:feat-encrypted-sql-dumps

Conversation

@oripka

Copy link
Copy Markdown
Contributor

Description

This PR introduces encrypted SQL dumps to Nuxt Content v3, allowing prerendered content dumps to be safely hosted on a CDN or static platform without exposing raw .sql data.

When enabled, dumps are AES-256-GCM encrypted at build time and decrypted in the browser only after the client requests a short-lived key from your app (post-authentication).

Key points

  • 🔒 New content.encryption option in nuxt.config.ts

    • enabled: true enables encrypted dumps and key endpoint
    • masterKey (optional) – base64(32 bytes); if omitted, one is generated at build time
  • ✨ Adds runtime API endpoints:

    • GET /__nuxt_content/:collection/sql_dump.enc → encrypted dump
    • GET /api/__nuxt_content/:collection/key → returns derived AES key (must be protected by your auth middleware)
    • Legacy sql_dump.txt routes remain available if encryption is disabled
  • 🧩 Middleware example added for access control of private collections

  • 📚 Documentation updated with new guides:

    • docs/content/docs/1.getting-started/3.configuration.md (content.encryption)
    • docs/content/docs/8.advanced/9.private.md (full guide on encrypted dumps)
  • 🛠 Internal changes:

    • New runtime/internal/encryption.ts utilities (HKDF, AES-GCM, envelope handling)
    • Client & server loaders updated to support decrypt-and-hydrate flow
    • Shared dumps preset (src/presets/shared-dumps.ts) ensures consistent handling across Node, Cloudflare, and NuxtHub

Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • ⚠️ Breaking change

Checklist

  • Added docs for new config (content.encryption)
  • Updated presets (node, cloudflare, nuxthub) to support encrypted dumps
  • Added runtime encryption/decryption logic
  • Ensured backwards compatibility with legacy .sql dumps

@vercel

vercelBot commented Aug 19, 2025

Copy link
Copy Markdown

@oripka is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@oripkaoripka changed the title feat: implement collection encryptionfeat: implement sql dump encryptionAug 19, 2025
@pkg-pr-new

pkg-pr-newBot commented Aug 19, 2025

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/content@3510

commit: 0e20684

@oripka
oripkaforce-pushed the feat-encrypted-sql-dumps branch 2 times, most recently from 48d54ae to 28d88ddCompareSeptember 21, 2025 13:57
@oripka
oripkaforce-pushed the feat-encrypted-sql-dumps branch from 28d88dd to 4ccffc7CompareSeptember 21, 2025 13:59
Comment threadsrc/runtime/presets/node/database-handler.ts
Comment threadsrc/runtime/internal/dump.ts Outdated
…mps-3.9.0
Resolved conflicts in package.json, src/presets/nuxthub.ts, src/runtime/presets/cloudflare/database-handler.ts
Fixed type error in src/runtime/internal/database.server.ts
@lndmanh

lndmanh commented Aug 29, 2026

Copy link
Copy Markdown

Hi everyone, I’m writing to follow up on this. Is there any chance that this will be approved as an official feature in the upcoming updates?

@oripka

Copy link
Copy Markdown
ContributorAuthor

Prolly not. But fork and npm package is available

@lndmanh

Copy link
Copy Markdown

Well, bundle it into a separate addon for nuxt/content might be a good idea too :D

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@oripka@lndmanh