Skip to content

feat(backend-js): add a Node.js implementation of the Quickstart backend - #1

Open
fernandomg wants to merge 23 commits into
mainfrom
js-parity
Open

fernandomg wants to merge 23 commits into
mainfrom
js-parity

Conversation

@fernandomg

Copy link
Copy Markdown
Member

Close digital-asset#156

Summary

  • Adds a Node.js / TypeScript / Fastify backend that mirrors the Java backend's HTTP API surface, selectable at build time via BACKEND=js (persisted in .env.local by make setup).
  • Both backends share the same OpenAPI contract, env files, onboarding volume, listening port, and cookie/CSRF auth surface (OAuth2 and shared-secret). The JS backend talks to Canton via the JSON Ledger API on port 3975 instead of gRPC, reads PQS Postgres directly, and uses the dpm codegen-js Daml bindings for typed command construction. The Compose stack swaps in the JS service via an override file when BACKEND=js.

Test plan

  • Ran make clean-all && make setup and answered js to the new interactive Backend prompt — alongside the existing prompts for AUTH_MODE, OBSERVABILITY_ENABLED, TEST_MODE, and PARTY_HINT. The selection is written to .env.local as BACKEND=js, so every subsequent make start / make restart-backend / make stop automatically targets the JS service without needing to repeat the flag. Re-ran make setup and chose java to confirm the prompt round-trips and that the stack swaps back to the Java backend cleanly. Verified under both AUTH_MODE=oauth2 and AUTH_MODE=shared-secret.
  • Walked through the entire flow described in the Explore the Demo guide (https://docs.digitalasset.com/build/3.5/quickstart/operate/explore-the-demo.html): App User and App Provider login, tenant pre-registration via register-app-user-tenant, AppInstallRequest accept/reject, License issuance, the renewal flow with wallet allocation, and license expiry. Each step produced behaviour identical to the Java backend.

Deferred to follow-up

The items below were surfaced during review and consciously left out of this PR. Each one is either parity-equal with the Java backend (so a JS-only fix would create drift) or a production-hardening concern that needs a cross-cutting design touching both backends. They should be tracked in a follow-up issue against both implementations.

# Issue Why deferred
1 SESSION_SECRET falls back to random bytes per restart in backend-js/src/auth/session.ts, invalidating signed session cookies. Java's in-memory HttpSession produces the same observable behaviour: every restart logs all users out (signature mismatch in JS, lost server-side state in Java). Fix needs a stable signing secret and a persistent session store applied to both backends.
2 Raw Canton ledger error text is forwarded to HTTP clients (party IDs, template IDs, choice arguments). Java's application.yml explicitly enables include-message: always, include-stacktrace: always, include-exception: true for dev — leaks at least as much, with stacktraces. A sanitising error mapper needs to land on both backends together.
3 Malformed duration strings throw → HTTP 500 where 400 would be the correct status. Same behaviour in Java: Duration.parse throws DateTimeParseException and there is no @ControllerAdvice mapping it to 400. Fix on both sides in one PR.
4 DELETE /admin/tenant-registrations/:tenantId removes the OAuth2 registry entry before the tenant repo entry; if step 2 fails the registry is gone but the tenant remains. Java's deleteTenantRegistration uses the same ordering and has the same risk window. Proper transactional/rollback handling needs to land on both backends.
5 The 201 response body for AppInstallRequest_Accept does not include the new AppInstall's contractId. Same omission in Java's AppInstallRequestsApiImpl#acceptAppInstallRequest. The OpenAPI response shape and the choice-result extraction need to be updated together on both sides.

dependabot Bot and others added 16 commits October 7, 2026 10:13
…digital-asset#387)

Bumps [axios](https://github.com/axios/axios) from 1.18.1 to 1.20.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](axios/axios@v1.18.1...v1.20.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.20.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…al-asset#394)

Bumps [certifi](https://github.com/certifi/python-certifi) from 2026.2.25 to 2026.10.19.
- [Commits](certifi/python-certifi@2026.02.25...2026.10.19)

---
updated-dependencies:
- dependency-name: certifi
  dependency-version: 2026.10.19
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.7.0 to 2.8.0.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.7.0...2.8.0)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.8.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…mbing

Adds BACKEND=java|js as a make-level selector, persisted in .env.local
via make setup, with a compose override, Dockerfile, and start.sh for
the JS service. The :daml gradle build emits both Java and TS codegen
and skips the irrelevant one per active BACKEND. Root .gitignore gains
an npm-prevention block to keep package.json/lock from leaking up to
the repo root.

Co-Authored-By: Gabito Esmiapodo <4015436+gabitoesmiapodo@users.noreply.github.com>
Project skeleton: package + lockfile, NodeNext tsconfig, runtime config
loader, server entrypoint, app builder with ErrorResponse-shaped error
handler and an empty-body JSON parser to accept the frontend's logout
post.

Co-Authored-By: Gabito Esmiapodo <4015436+gabitoesmiapodo@users.noreply.github.com>
Wires session, CSRF, and cookie middleware; OAuth2 (with plain-HTTP
issuer opt-in for local Keycloak, JWKS cache per issuer, partyId
resolved from the tenant repository); shared-secret form login that
resolves the username against the tenant repository and seeds the
AppProvider tenant with admin users; CSRF bypass for Bearer-
authenticated service traffic; TEST_MODE party_id override applied at
session population; admin-gate distinguishing 401/403 by Bearer or
session presence; and the /admin, /user, and /login-links routes that
sit on top of all of it.

Co-Authored-By: Gabito Esmiapodo <4015436+gabitoesmiapodo@users.noreply.github.com>
Adds the read-side data access used by the licensing routes: a pg
connection pool, a typed contract row helper that decodes the JSONB
payload, and a licensing repository that finds active contracts by id
and lists them by predicate.

Co-Authored-By: Gabito Esmiapodo <4015436+gabitoesmiapodo@users.noreply.github.com>
…nd bindings

Adds the write-side ledger access: a client-credentials token provider
with a 30s expiry buffer, a JSON Ledger API client wrapping submit-and-
wait-for-transaction, and command builders typed via the dpm codegen-js
output (damlTypes.Template/Choice). Template ids carry the
'#<package-name>:' prefix the JSON Ledger API requires, every submit is
wrapped in the JsCommands envelope, and userId is matched to the JWT
subject claim. A token-standard client adds the registry admin id and
allocation transfer context lookup.

Co-Authored-By: Gabito Esmiapodo <4015436+gabitoesmiapodo@users.noreply.github.com>
Adds the business surface exposed over the OpenAPI contract: a
licensing service that orchestrates PQS reads and ledger writes,
mappers that mirror the Java backend's DTO shapes, and the routes for
feature-flags, app-install-requests, app-installs, licenses, and
license-renewal-requests. Daml-choice routes register one wildcard per
resource to dodge find-my-way's colon-route limitation while preserving
the URL contract. Microsecond-precision timestamps are emitted on
License_Renew, the new License contract id is read from the
CreatedEvent walk (since submit-and-wait returns ACS_DELTA events
without exerciseResult), and admin-only choice endpoints are gated by
checkAdmin.

Co-Authored-By: Gabito Esmiapodo <4015436+gabitoesmiapodo@users.noreply.github.com>
Adds a Backend implementations section that contrasts the Java and JS
backends, documents the BACKEND selector and switching workflow, and
notes the Java-only debug port and the per-backend codegen behaviour.

Co-Authored-By: Gabito Esmiapodo <4015436+gabitoesmiapodo@users.noreply.github.com>
An invalid token no longer falls back to the session.
dependabot Bot and others added 7 commits November 5, 2026 16:03
…sset#395)

Bumps [setuptools](https://github.com/pypa/setuptools) from 83.0.0 to 84.1.0.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](pypa/setuptools@v83.0.0...v84.1.0)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-version: 84.1.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
digital-asset#396)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.2 to 6.4.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.4.5/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.4.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.4.5
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…-asset#398)

Developers and AI agents who only need a running network for their own
Daml code had to work out a docker compose command from the Makefile,
or ran make build for a demo they didn't need.

- Makefile: add start-localnet, stop-localnet, clean-localnet and
  status-localnet. They start only the Splice LocalNet module (sv,
  app-provider, app-user profiles) and need only Docker: no make setup,
  no .env.local, no build. They use LocalNet's own resource-constraints
  file, since RESOURCE_CONSTRAINT_CONFIG also lists application modules.
- AGENTS.md: where the docs are (llms.txt, MCP server, version
  dashboard), which path to take for which task, LocalNet ports, auth
  and readiness checks, and common Daml/Ledger API pitfalls.
- README: the stack is open source and needs no Daml Enterprise
  license; add a LocalNet-only section and a note on the version pins in
  quickstart/.env; link the LocalNet docs page instead of docs.sync.global.

Signed-off-by: 8bitpal <elias@zerolimit.es>
digital-asset#404)

* update on all versions

* Rename SCRIBE_* env vars and image to PQS_* / participant-query-store.

Align Quickstart LocalNet and DevNet with Canton 3.6+ PQS naming so config uses the supported PQS_ prefix instead of the deprecated SCRIBE_ fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>

* minor fix

* Fix script-service.jar path handling in dpm.nix

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Brian Healey <brian.healey@daml.com>
…sset#397)

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.16.0 to 1.16.2.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.16.0...v1.16.2)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-version: 1.16.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* ci: 👷 Replace CircleCI with GitHub Actions

Run Daml tests, the docs preview, the frontend build, and the
Playwright integration test on GitHub-hosted runners. Fork pull
requests skip the JUnit check run, and workflow or lockfile edits
are flagged for review without failing the check.

* ci: 👷 Keep the frontend action out of the build ignore

.gitignore ignores every build directory, so the frontend composite
action lives at .github/actions/frontend-build.

* ci: 👷 Run the integration test on Ubuntu 24.04

ubuntu-latest is Ubuntu 26.04, and Playwright 1.59.1 has no Chromium
build for that release. The 24.04 image is the one CircleCI used.

* build: ⬆️ Bump Playwright to 1.63.0

ubuntu-latest is Ubuntu 26.04. Playwright 1.59.1 has no Chromium
build for that release; 1.63.0 does.

* ci: 👷 Run the integration test on ubuntu-latest

Playwright 1.63.0 installs Chromium on Ubuntu 26.04, so the
integration job no longer needs the Ubuntu 24.04 image.

* ci: 👷 Rebuild the docs environment when its interpreter cannot run

The docs cache key now includes the Python patch version from
setup-python. poetry-install still skips a usable sdk/.venv, and
installs again when that interpreter is missing or cannot start.

* ci: 👷 Run Daml tests when their runner inputs change

A pull request that only edits the test-daml recipe, or the shared
Gradle files that recipe runs, now runs the Daml job. Documentation
and frontend paths stay on their own filters.

* ci: 👷 Flag the old path when a fork renames a workflow or lockfile

Both fork-policy file lists now include filename and previous_filename,
with duplicates removed, before the existing path filter.

* ci: 👷 Stop the docs install when Poetry fails

poetry-install runs in one shell. set -e makes a failed
poetry install stop the recipe before poetry debug info.
Resolve the README.md conflict by keeping both new sections.
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.

Add a Node.js backend example to the QS

5 participants