Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
DPoP
✓ import * as DPoP from 'dpop';
✗ const DPoP = require('dpop');
Since v2.0.0, the package primarily uses named exports. Using `import * as DPoP` is the recommended way to import all functionalities. CommonJS `require('dpop')` is only fully supported in Node.js versions where `require(esm)` is enabled by default (e.g., ^20.19.0 || ^22.12.0 || >= 23.0.0).
generateKeyPair, generateProof
✓ import { generateKeyPair, generateProof } from 'dpop';
✗ import DPoP, { generateKeyPair, generateProof } from 'dpop';
As of v2.0.0, the library moved to named exports exclusively. Functions like `generateKeyPair` and `generateProof` must be destructured from the 'dpop' module. Attempting a default import will result in `undefined`.
calculateThumbprint
✓ import { calculateThumbprint } from 'dpop';
✗ import * as DPoP from 'dpop'; const dpop_jkt = await DPoP.dpop_jkt(publicKey);
The `calculateThumbprint` function, introduced in v2.1.0, is specifically for computing the `dpop_jkt`. It is a named export and should be imported directly or accessed via `DPoP.calculateThumbprint` after a `* as DPoP` import. There is no top-level `dpop_jkt` function.
Demonstrates DPoP key pair generation, dpop_jkt calculation, and DPoP proof generation for both Authorization Server token requests and Resource Server API calls.
import * as DPoP from 'dpop';
async function runDPoPExample() {
console.log('Starting DPoP example...');
// 1. Generate a DPoP Key Pair (e.g., ES256 algorithm)
// The 'extractable: false' option is good practice for non-exportable keys
const keyPair = await DPoP.generateKeyPair('ES256', { extractable: false });
console.log('DPoP Key Pair generated using ES256.');
// 2. Calculate the dpop_jkt (Key Thumbprint) for authorization code binding
// This identifies the public key associated with the DPoP proof
const dpop_jkt = await DPoP.calculateThumbprint(keyPair.publicKey);
console.log('Calculated dpop_jkt:', dpop_jkt);
// 3. Generate a DPoP proof for an Authorization Server (AS) token request
// This proof is sent with the token request to the AS
const asTokenUrl = 'https://as.example.com/token';
const asProof = await DPoP.generateProof(keyPair, asTokenUrl, 'POST');
console.log('DPoP Proof for AS Token Request:', asProof.slice(0, 100), '...'); // Truncate for display
// 4. Simulate an Access Token from the AS and generate a DPoP proof for a Resource Server (RS) API request
// The access token is bound to the DPoP key when making requests to the RS
const rsApiUrl = 'https://rs.example.com/api/data';
const accessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJhY2Nlc3NfdG9rZW4iOnRydWV9.SflKxwRJSMeKKF2F8DGD_dPOk_W5dZg_qkX-zHjN_W0'; // Example dummy token
const nonceFromRS = undefined; // In a real scenario, this might come from a 'DPoP-Nonce' header
const rsProof = await DPoP.generateProof(
keyPair,
rsApiUrl,
'GET',
nonceFromRS,
accessToken
);
console.log('DPoP Proof for RS API Request:', rsProof.slice(0, 100), '...'); // Truncate for display
}
runDPoPExample().catch(console.error);
Errors
Common errors & fixes
TypeError: DPoP.generateKeyPair is not a function
Attempting to call functions as properties of a default import, but `dpop` uses named exports since v2.0.0.
fixChange your import from `import DPoP from 'dpop';` to `import * as DPoP from 'dpop';` or `import { generateKeyPair } from 'dpop';`. ReferenceError: generateKeyPair is not defined
Trying to use a named export function without importing it explicitly or via a namespace import.
fixEnsure `generateKeyPair` is properly imported: `import { generateKeyPair } from 'dpop';` or accessed via a namespace: `import * as DPoP from 'dpop'; DPoP.generateKeyPair(...)`. Error: 'modulusLength' option is not supported for key generation.
Using the `modulusLength` option in `generateKeyPair` after it was removed in v2.0.0.
fixRemove the `modulusLength` option from your `generateKeyPair` call. The library no longer supports it.
Audit
Dependencies
No dependency data recorded yet.