Read-only mirror of https://github.com/jeap-admin-ch/jeap-jwe-client — Bundesamt für Informatik und Telekommunikation. Issues & pull requests at the source. Catalog: https://www.opensource.admin.ch/en/softwares/mkdph0 https://www.opensource.admin.ch/en/softwares/mkdph0
  • TypeScript 99.8%
  • JavaScript 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Matthias Fritschi b270671614 Update both npm manifests in one Dependabot pull request
The root package.json and the library manifest were two separate update
entries, so a dependency both of them declare - jose - was proposed twice,
and each pull request was turned into its own patch release by the auto
bump. Listing both directories under one entry keeps the group in a single
pull request.
2026-08-26 07:55:44 +02:00
.github Update both npm manifests in one Dependabot pull request 2026-08-26 07:55:44 +02:00
.vscode JEAP-7095 Initial commit and jeap-jwe-client library setup. 2026-06-19 14:28:06 +02:00
docs Update both npm manifests in one Dependabot pull request 2026-08-26 07:55:44 +02:00
projects/jeap-jwe-client Update jose to 6.2.10 2026-08-26 07:29:05 +02:00
.editorconfig JEAP-7095 Initial commit and jeap-jwe-client library setup. 2026-06-19 14:28:06 +02:00
.gitignore JEAP-7096 Remove accidentally committed target directory and ignore it 2026-07-06 09:43:37 +02:00
.npmrc chore: Update CI configuration for compatibility testing and packaging 2026-06-22 18:24:27 +02:00
.prettierignore JEAP-7094 Align JWE client with backend protocol contract, harden runtime/transport security 2026-06-26 07:47:45 +02:00
.prettierrc.json JEAP-7094 Align JWE client with backend protocol contract, harden runtime/transport security 2026-06-26 07:47:45 +02:00
AGENTS.md Update both npm manifests in one Dependabot pull request 2026-08-26 07:55:44 +02:00
angular.json JEAP-7095 Initial commit and jeap-jwe-client library setup. 2026-06-19 14:28:06 +02:00
CONTRIBUTING.md chore: Add initial documentation files for jEAP JWE Client. 2026-06-22 13:43:34 +02:00
eslint.config.mjs JEAP-7094 Align JWE client with backend protocol contract, harden runtime/transport security 2026-06-26 07:47:45 +02:00
jeap-license-check.json JEAP-7398 Do not ship the dependency license texts with the library 2026-08-19 11:26:05 +02:00
LICENSE chore: Add initial documentation files for jEAP JWE Client. 2026-06-22 13:43:34 +02:00
package-lock.json Bump the npm-dependencies group with 14 updates 2026-08-26 07:29:05 +02:00
package.json Bump the npm-dependencies group with 14 updates 2026-08-26 07:29:05 +02:00
publiccode.yml Bump version to 1.3.5 2026-08-26 07:29:05 +02:00
README.md JEAP-7096 Default origin and discovery paths for backend-served frontends 2026-07-06 09:43:37 +02:00
SECURITY.md chore: Add initial documentation files for jEAP JWE Client. 2026-06-22 13:43:34 +02:00
tsconfig.json JEAP-7095 Initial commit and jeap-jwe-client library setup. 2026-06-19 14:28:06 +02:00

jEAP JWE Client

jEAP JWE Client is an Angular library that transparently protects HTTP communication between an Angular frontend and a jEAP backend service using JSON Web Encryption (JWE). It plugs into Angular's functional HttpClient interceptor mechanism, so application code can continue to use ordinary HttpClient requests and typed JSON responses while protected requests are transported as application/jose. It provides:

  • Loading backend JWE configuration from /.well-known/jwe-configuration, including the backend's include/exclude path patterns
  • Loading backend public encryption keys from the configured JWKS endpoint
  • Protecting requests to a configured backend origin using the backend-published include/exclude path patterns as the source of truth — a backend under a servlet context path is protected without local pattern configuration
  • Failing closed: if the backend configuration cannot be loaded, requests to the backend origin that are neither locally excluded nor addressed to the discovery endpoints fail with JWE_CONFIG_LOAD_FAILED instead of being sent unprotected
  • Encrypting JSON request bodies as compact JWE using RSA-OAEP-256 and A256GCM
  • Sending a request-local response content encryption key in the JWE-Response-Key header
  • Setting Accept: application/jose for protected requests
  • Decrypting encrypted backend responses using alg: dir and enc: A256GCM
  • Refreshing JWKS and retrying once when the backend returns JWE_UNKNOWN_KEY_ID
  • Typed client-side errors through JeapJweError
  • Integration tests with a mocked backend and real JWE encryption/decryption

Documentation

Start with Getting started, then follow the links below. The docs here cover the frontend side; the JWE protocol itself is defined and reviewed in the backend starter's Client integration guide, which is the source of truth for the contract this client implements.

Topic File
Getting started (add the dependency, configure the provider and interceptor) docs/getting-started.md
Development (prerequisites, scripts, pre-commit checks, CI, troubleshooting) docs/development.md
Configuration reference (JeapJweClientConfig, include/exclude, backend config loading) docs/configuration.md
Backend contract — the client's view of what the backend publishes and the one error code it acts on docs/backend-contract.md
Architecture (interceptor, matcher, config service, JWKS cache, encryptor, decryptor) docs/architecture.md
Key rotation and retry behavior (keys[0], refresh, JWE_UNKNOWN_KEY_ID) docs/key-rotation.md
Error handling (JeapJweError, retryable and non-retryable failures) docs/error-handling.md
Testing (unit tests, integration tests, protocol trace for reviews) docs/testing.md
Security considerations (logging, CEKs, JWKs, plaintext, compact JWE values) docs/security-considerations.md
Publishing and versioning (release flow, package metadata, changelog, docs assets) docs/publishing-and-versioning.md
npm publishing setup (npm org, trusted publishing, one-time bootstrap, CI secrets) docs/npm-publishing-setup.md

Usage

Register the client configuration and the functional interceptor in the Angular application. The library does not call provideHttpClient itself: the consuming application owns its HttpClient setup and must register the jeapJweInterceptor alongside provideJeapJweClient, as shown below.

import {ApplicationConfig} from '@angular/core';
import {provideHttpClient, withInterceptors} from '@angular/common/http';
import {
  jeapJweInterceptor,
  provideJeapJweClient,
} from '@jeap/jeap-jwe-client';

export const appConfig: ApplicationConfig = {
  providers: [
    provideJeapJweClient(),
    provideHttpClient(withInterceptors([jeapJweInterceptor])),
  ],
};

Without options, the backend origin defaults to the frontend's own origin and the discovery paths default to the application base path (the Angular base href, which matches the backend's servlet context path when the frontend is served by its backend) plus the well-known paths. For a base href of /myapp/, the client loads:

GET /myapp/.well-known/jwe-configuration
GET /myapp/.well-known/jwks.json

For a cross-origin backend, configure origin (and jweConfigPath for a backend under a context path) explicitly.

Application code keeps using normal Angular HttpClient calls:

http.post<Person>('/api/persons', {
  name: 'Alice',
});

The protected transport request sent to the backend uses JWE:

POST /api/persons
Accept: application/jose
Content-Type: application/jose
JWE-Response-Key: <compact-jwe>

<compact-jwe-request-body>

Workspace

This repository is an Angular workspace containing the publishable library project.

Path Purpose
package.json Workspace dependencies, scripts and development tooling
projects/jeap-jwe-client/package.json Publishable library package metadata and library version
projects/jeap-jwe-client/ng-package.json Angular library packaging configuration
projects/jeap-jwe-client/src/public-api.ts Public API entry point
docs/ Library documentation
dist/jeap-jwe-client/ Built publishable package

The workspace root package is private and is not published. The library version is managed in:

projects/jeap-jwe-client/package.json

The publishable package is built to:

dist/jeap-jwe-client/

Package

The artifact consumers depend on is @jeap/jeap-jwe-client.

Package Purpose
@jeap/jeap-jwe-client Angular library providing the JWE client configuration, interceptor, encryption, decryption, JWKS handling and retry behavior

The package declares Angular and RxJS as peer dependencies. The consuming Angular application provides these dependencies. The jose package is a runtime dependency because the library uses it for JWE encryption and decryption.

Versioning and publishing

The library version is managed in:

projects/jeap-jwe-client/package.json

The workspace root package.json is only used for local development and build tooling. The publishable package is built to:

dist/jeap-jwe-client/

See docs/publishing-and-versioning.md for release flow, versioning rules, changelog handling and package verification.

Changes

This library is versioned using Semantic Versioning where possible and all changes are documented in projects/jeap-jwe-client/CHANGELOG.md following the format defined in Keep a Changelog.

Note

This repository is part of the open source distribution of jEAP. See github.com/jeap-admin-ch/jeap for more information.

License

This repository is Open Source Software licensed under the Apache License 2.0.