Better HN
topnewbestaskshowjobs
Log inSign up

rohinbharg

1 karma · joined Sep 8, 2022 (4y ago) · 7 submissions

Submissions

comment 7mo ago · link · parent

ForkLaunch is an open-source TypeScript framework. The compliance primitives below live in the framework core (MIT, standalone with MikroORM).

If your code compiles, it's compliant. If not, it doesn't compile.

Type system enforcing data classification. Every DB field must be classified pii, phi, pci, or none. Not a lint rule. tsc fails.

  const User = defineComplianceEntity({
    name: 'User',
    properties: {
      email: fp.string().unique().compliance('pii'),
      ssn: fp.string().nullable().compliance('phi'),
      cardNumber: fp.string().compliance('pci'),
      age: fp.integer().compliance('none'),
    }
  });
defineComplianceEntity wraps defineEntity with a ValidateProperties<T> mapped type. Each property must carry a phantom marker only set by .compliance(). Miss one, call-site error.

fp is a Proxy over MikroORM's property builder. .compliance('pii') injects EncryptedType into the type pipeline. For enums, the Proxy strips the DB CHECK constraint (would reject ciphertext) and moves validation to the app layer.

The encryption tradeoff. Classified fields encrypt at rest via AES-256-GCM. Random IVs are most secure, but we chose deterministic: IV = HMAC-SHA256(key, plaintext)[0:12]. Same plaintext + same key = same ciphertext, so WHERE filtering and UNIQUE constraints still work on encrypted columns.

The downside: equality leaks. We mitigate with per-tenant HKDF-SHA256 key derivation (info=tenantId). Cross-tenant pattern leakage is eliminated; within-tenant leakage remains, but for multi-tenant SaaS this matches what SOC 2, HIPAA, and PCI-DSS actually require. HKDF over PBKDF2 because the master key is already high-entropy.

Mandatory access posture on every route. If a route returning PII forgets its auth check, encryption doesn't save you. Every handler takes a required access field: 'public', 'authenticated', 'protected', or 'internal'. The type narrows: 'protected' requires auth.allowedRoles, 'internal' requires hmac.secretKeys. Those combinations don't typecheck without the peer field.

Every HTTP/WS request emits a structured OpenTelemetry audit entry: userId, tenantId, route, method, SHA-256 body hash (not the body), status, duration, redacted field names, and a discriminated event type (http, ws, auth_failure, rate_limit, rbac_deny, super_admin_bypass). Zero app instrumentation.

Closing the escape hatches.

ORM: em.nativeInsert would bypass the type pipeline. We Proxy the EM and throw EncryptionRequiredError on native ops against encrypted entities.

DB: PostgreSQL RLS (SET LOCAL app.tenant_id) plus ORM global filters auto-appending WHERE organizationId = :tenantId.

Network (platform-deployed): each env gets its own VPC, private-subnet RDS, no public endpoints. KMS keys scoped per region × env.

AsyncLocalStorage + pg pool: enterWith() sets context per async resource, but pg pool callbacks run in the pool's resource, not the request's. Tenant ID disappears; decryption silently uses the wrong key. Fix: Proxy every EM method in AsyncLocalStorage.run() to propagate through pool boundaries.

Also in the framework: GDPR DSAR export/erase walking the entity registry (Art. 20/17), declarative retention, oxc-based CLI audit outputting risk scores and DPIAs, and standards-to-infra mapping (SOC 2 / HIPAA / GDPR / PCI-DSS / ISO 27001 → Pulumi AWS resources).

Thesis: any compliance posture that depends on humans remembering things will fail after MVP. If it's enforced structurally, it doesn't matter who or what writes the code.

Known limits: TS+MikroORM only; within-tenant equality leaks on encrypted columns; manual key rotation.

Docs: https://www.forklaunch.com/docs/compliance/overview Repo: https://github.com/forklaunch/forklaunch

Happy to dig into implementation or tradeoffs.

2.

We made compliance violations compiler errors, not audit findings(forklaunch.com ↗)

4 points · by rohinbharg · 7mo ago · 2 comments

comment 1y ago · link · parent

Thanks for checking this out!

ForkLaunch is a TypeScript-first backend framework and CLI that lets you drop in self-contained services, workers, and libraries directly into your repo, with no boilerplate or devops setup required. Compatible with your favorite frontend framework, handwritten or vibe coded.

Each module is self-contained:

- Generates its own Dockerfile and local environment

- Creates simple integration tests

- Automatically links to shared libraries and manifests

- Can attach and change infra like Redis, S3, Postgres, MongoDB, etc. with simple commands

- Produces typed SDKs and OpenAPI specs for clients

- Emits OpenTelemetry and easily allows for extension

The idea is that every service or worker can run independently or together, all wired through a unified contained backend monorepo. With the framework, it’s incrementally adoptable; you can wrap an existing Express app or generate a full microservice setup from scratch.

Under the hood, ForkLaunch is inspired by Express, and uses Zod/TypeBox, but adds:

- Type-safe routing, validation, and dependency injection

- A unified CLI for services, workers, and libraries

- Deep Docker integration for local development

- Integration with Better Auth and Stripe

- Coming soon: Ejectable Pulumi-based deploy platform to go from "forklaunch add service" to "deploy to AWS" simply

Would love feedback, especially from folks who have never implemented or are experts in service oriented architectures.

4.

Show HN: Instantly drop-in services, workers, and libraries in TypeScript(github.com ↗)

3 points · by rohinbharg · 1y ago · 1 comment

5.

Show HN: ForkLaunch framework: Upgrading Express with a fully typed DSL(github.com ↗)

9 points · by rohinbharg · 1y ago · 1 comment

comment 3y ago · link · parent

Seriously impressive, I'm 27 and I didn't know half the stuff you put in this guide.