Registry / auth-security / dpop
library0.0.2jsnpmunverified

dpop is a JavaScript library providing a robust implementation of the OAuth 2.0 Demonstration of Proof-of-Possession at the Application Layer (DPoP), as specified by RFC9449. It facilitates the secure generation of DPoP key pairs and proofs, which are crucial for enhancing API security by binding access tokens to the client's cryptographic key. The library is designed for broad compatibility, supporting various JavaScript runtimes including modern browsers, Node.js (v20.x and higher), Bun, Deno, Cloudflare Workers, Electron, and Vercel's Edge Runtime. The current stable version is 2.1.1, with an active development cycle that includes regular feature additions, bug fixes, and adherence to evolving standards. Its primary differentiators are its comprehensive runtime support and strict compliance with RFC9449, ensuring interoperable and reliable DPoP implementations across different environments.

npm install dpop
INSTALL
IMPORT
SIG · DPOP
D
dpop
auth-securityjavascriptv0.0.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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
musl
node 18–226 runs
build_error
glibc
node 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);
Debug
Known issues
breakingVersion 2.0.0 removed default exports in favor of named exports. All functions must now be imported via destructuring (e.g., `import { generateKeyPair } from 'dpop';`) or by importing all as a namespace (e.g., `import * as DPoP from 'dpop';`).
fix
Update your import statements: change `import DPoP from 'dpop';` to `import * as DPoP from 'dpop';` or `import { functionName } from 'dpop';`.
affects: >=2.0.0
breakingThe `modulusLength` option for key generation has been removed in v2.0.0. This option was specific to RSA keys and its removal streamlines the API, focusing on more modern and recommended algorithms.
fix
Remove the `modulusLength` option from your `generateKeyPair` calls. If you need RSA keys with specific modulus lengths, consider generating them externally and importing them, or use algorithms like ES256, Ed25519.
affects: >=2.0.0
breakingSupport for the deprecated EdDSA algorithm was removed in v2.0.0. The library now supports the fully-specified Ed25519 JWS Algorithm.
fix
Migrate any usage of the deprecated EdDSA algorithm to Ed25519 or another supported algorithm like ES256.
affects: >=2.0.0
gotchaNode.js v20.x or higher is required as a baseline runtime environment for `dpop` v2.x. This is due to the library's reliance on modern Web API globals and standard built-in objects.
fix
Ensure your Node.js environment is version 20.x or newer. Use a version manager like `nvm` to upgrade if necessary.
affects: >=2.0.0
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.
fix
Change 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.
fix
Ensure `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.
fix
Remove the `modulusLength` option from your `generateKeyPair` call. The library no longer supports it.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
OpenAI (training)
1
Resources
dpop — npm install dpop · libregistry