MCPcopy
hub / github.com/grafana/k6 / decode

Function decode

examples/jwt.js:28–37  ·  view source on GitHub ↗
(token, secret, algorithm)

Source from the content-addressed store, hash-verified

26}
27
28function decode(token, secret, algorithm) {
29 let parts = token.split('.');
30 let header = JSON.parse(encoding.b64decode(parts[0], "rawurl", "s"));
31 let payload = JSON.parse(encoding.b64decode(parts[1], "rawurl", "s"));
32 algorithm = algorithm || algToHash[header.alg];
33 if (sign(parts[0] + "." + parts[1], algorithm, secret) != parts[2]) {
34 throw Error("JWT signature verification failed");
35 }
36 return payload;
37}
38
39export default function() {
40 let message = { key2: "value2" };

Callers 1

jwt.jsFile · 0.85

Calls 3

signFunction · 0.70
ErrorStruct · 0.50
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…