maskinporten-mock
v0.1.1
Published
Credential-free local mock of Norway's Maskinporten token endpoint (+ JWKS, Altinn exchange, error scenarios). Docker + npx.
Maintainers
Readme
maskinporten-mock
Credential-free local mock of Norway's Maskinporten token endpoint. It lets apps and CI test JWT-grant token flows without a Norwegian organization, real client, or private production key.
Run
npx maskinporten-mockThe default local endpoint is:
http://localhost:6969/tokenA Docker image is also intended for CI and language-agnostic tests.
Use with the client
import { generateKeyPairSync } from 'node:crypto';
import { createMaskinportenClient } from 'maskinporten';
const { privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048 });
const pem = privateKey.export({ type: 'pkcs1', format: 'pem' }) as string;
const client = createMaskinportenClient({
env: 'test',
clientId: 'local-dev-client',
scope: 'demo:read',
key: { pem, kid: 'local-dev-key' },
tokenEndpointOverride: 'http://localhost:6969/token',
audienceOverride: 'http://localhost:6969/',
});
const token = await client.getToken();The mock is for development and automated tests. It is not a substitute for a final smoke test against test.maskinporten.no when you operate a real integration.
