Archived topic — this may be out of date.
Newman has been replaced by the Postman CLI, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.
Working with an AI coding agent? The Postman plugin lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.
Hello Postmanauts,
I am able to verify jwt signatures in Postman, but am not able to get it to work with Newman.
This works in the normal Postman “Scripts” section:
const CryptoJS = require('crypto-js');
pm.test('JWT Signature is Valid', function () {
let recreatedSignature;
try {
// Generate the hash using HMAC-SHA256 and encode to Base64
recreatedSignature = CryptoJS.HmacSHA256(
`${jwtHeaderEncoded}.${jwtPayloadEncoded}`,
jwtSigningKey
)
.toString(CryptoJS.enc.Base64)
.replace(/=*$/, '');
console.log('recreatedSignature', recreatedSignature);
}
catch(e) {
throw new Error('Could not recreate signature | ' + e)
}
pm.expect(jwtSignature).to.be.a('string').that.equals(recreatedSignature);
});
However, when I run this in Newman, I get the following error:
![]()
When I remove require('crypto-js'), that error goes away.
I found this post here where Daniel Kimmelmann states that crypto.subtle is supported, and not require('crypto-js').
Following this post, I came up with:
pm.test('JWT Signature is Valid', function () {
let recreatedSignature;
try {
const encoder = new TextEncoder();
const data = encoder.encode(`${jwtHeaderEncoded}.${jwtPayloadEncoded}`)
crypto.subtle.importKey('raw', new TextEncoder().encode(jwtSigningKey), {
name: 'HMAC',
hash: 'SHA-256',
}, false, ['sign'])
.then((key) => crypto.subtle.sign('HMAC', key, data))
.then((signature) => {
recreatedSignature = _arrayBufferToBase64(signature);
pm.expect(jwtSignature).to.be.a('string').that.equals(recreatedSignature);
})
.catch((error) => {console.log(error)});
}
catch(e) {
throw new Error('Could not recreate signature | ' + e)
}
});
// https://stackoverflow.com/a/9458996/27294094
function _arrayBufferToBase64( buffer ) {
var binary = '';
var bytes = new Uint8Array( buffer );
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
return btoa( binary );
}
There are 2 issues:
- The computed signature does not match
- The Promise flow breaks the Chai tests - it reports success when there is a failure.
Thank you for taking time to help me out!





