Skip to content

AINATIVEM-44 AES-256-GCM token encryption and docker-compose ComposeBuilder refactor#10

Merged
youssef-saber-3 merged 4 commits into
masterfrom
AINATIVEM-44
May 14, 2026
Merged

AINATIVEM-44 AES-256-GCM token encryption and docker-compose ComposeBuilder refactor#10
youssef-saber-3 merged 4 commits into
masterfrom
AINATIVEM-44

Conversation

@youssef-saber-3
Copy link
Copy Markdown
Contributor

@youssef-saber-3 youssef-saber-3 commented May 14, 2026

Summary

  • Token encryption at rest: generate src/crypto/encrypt.ts (AES-256-GCM, 12-byte IV, 16-byte auth tag, base64url format). Token repository encrypts on write and decrypts on read. Columns widened from varchar(768) to text to fit ciphertext. ENCRYPTION_KEY added to .env.example with openssl rand -hex 32 hint.
  • Dockerfile hardening: add USER node to generated Dockerfile; add RUN mkdir -p /app/data && chown -R node:node /app/data before the user switch so the SQLite named volume is writable at startup.
  • ComposeBuilder refactor: replace 6 string-assembly functions and indent() with a ComposeBuilder class that accumulates typed ComposeService objects and serializes once via yaml.stringify (eemeli). Follows the existing NodeProjectBuilder builder pattern with .when() conditional chaining.

Test Plan

  • npm test — 131 tests pass
  • Generate postgres app, docker-compose up — backend + db both healthy
  • Generate mysql app, docker-compose up — backend + db both healthy
  • Generate sqlite app, docker-compose up — backend starts, no db container, sqlite_data volume created
  • Confirm ENCRYPTION_KEY missing → server throws on first token write
  • Confirm token values in DB are AES-GCM ciphertext (not plaintext)

@youssef-saber-3 youssef-saber-3 marked this pull request as ready for review May 14, 2026 13:46
Copilot AI review requested due to automatic review settings May 14, 2026 13:46
@youssef-saber-3 youssef-saber-3 changed the title AINATIVEM-44 AES-256-GCM token encryption and ComposeBuilder yaml refactor AINATIVEM-44 AES-256-GCM token encryption and docker-compose ComposeBuilder refactor May 14, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors Node generator Docker Compose output to use a typed builder that serializes via the yaml package, and updates the associated test expectations to match the new YAML serialization behavior.

Changes:

  • Replaced docker-compose.yml string templating/indentation with a ComposeBuilder that assembles typed ComposeService objects and serializes once via yaml.stringify.
  • Updated docker-compose related tests to assert against the new YAML output patterns and added additional ComposeBuilder behavior coverage.
  • Added yaml as a runtime dependency (and lockfile entry) to support YAML serialization.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/generators/node/database.ts Introduces ComposeBuilder + typed compose config/services and switches docker-compose.yml generation to yaml.stringify.
src/generators/node/database.test.ts Updates and expands tests to validate compose output produced by the new builder/serializer.
package.json Adds yaml dependency required by the new compose serialization approach.
package-lock.json Lockfile updates for the new yaml dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 226 to 230
expect(content).toContain('postgres:16');
expect(content).toContain('db_data:/var/lib/postgresql/data');
expect(content).toContain('pg_isready');
expect(content).toContain("'-d', 'test-app'");
expect(content).toContain(`POSTGRES_DB: ${pgOptions.projectName}`);
expect(content).toContain('healthcheck');
@youssef-saber-3 youssef-saber-3 merged commit 409d899 into master May 14, 2026
5 checks passed
@youssef-saber-3 youssef-saber-3 deleted the AINATIVEM-44 branch May 14, 2026 13:53
Sign up for free to 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.

3 participants