Rider HTTP Client CryptoJS.enc.Base64.stringify

suppose I am trying to do 1 or all of a few different things. currently have a postman lib that I am working to migrate over and am stuck with a pre-request script that builds and signs a JWT token. that script has dependencies on CryptoJS but this lib is not available best of my knowledge 

  1. how do I import / include / ref additional libs in request scripts if possible.
  2. what is the `crypto` alternative to `CryptoJS.enc.Base64.stringify()`

I expected the following code to work as expected but sadly this doesn't result with a usable JWT token :/

This does not create a valid JWT token :(


let header = JSON.stringify({"alg": "HS512"});
let body = JSON.stringify({
"username": request.environment.get('the_big_username'),
"entity": request.environment.get('the_big_entity'),
"datetime": new Date().toISOString()
});

let theBigSecret = request.environment.get("the_big_secret");
let theHeader = crypto.sha512()
.updateWithText(header)
.digest()
.toBase64(true)

let theBody = crypto.sha512()
.updateWithText(body)
.digest()
.toBase64(true)

const content = `${theHeader}.${theBody}`
let theSignature = encodeURIComponent(crypto.hmac.sha512()
.withTextSecret(theBigSecret, )
.updateWithText(content)
.digest()
.toBase64(true))

// pm.globals.set('jws', signedJws);
const allTogetherNow = `${content}.${theSignature}`

// request.variables.set('apexJws', signedJws);
request.variables.set('the_big_token', allTogetherNow);

1

请先登录再写评论。