postman-util-lib
postman-util-lib copied to clipboard
There was an error in evaluating the Pre-request Script:Error: [jwtSign] t.indexOf is not a function
I set Pre-request Script, after run this script it shows "[jwtSign] t.indexOf is not a function". Since the jwk is secret, I cleared it in the demo code.
eval(pm.globals.get('pmlib_code'));
const uuid = require('uuid');
var header = {
"alg": "" //jwk.alg
};
var payload = {
"iss": "",
"aud": "",
"sub": "xxx",
"jti": uuid.v4()
};
const jwk = {
"kty": "",
"d": "",
"use": "",
"crv": "",
"kid": "",
"x": ""
}
// Create a signed jwt (JWS)
const jws = pmlib.jwtSign(jwk,payload, header, 10, 'EdDSA');
console.log('Signed JWT: ' +jws);
pm.environment.set('actor_token',jws);
any update on this ? I have the same issue
I don´t see any error in the code but the error about "[jwtSign] t.indexOf is not a function" maybe means that library have not been loaded correctly so please use this postman collections as starting point https://github.com/joolfe/postman-util-lib/tree/master/postman.
The jwtSign method works perfectly on this examples and maybe you can find what is causing the error on your end.
Best regards.