parse, validate and verify signature by public key
JWT
Public Key
import * as crypto from "crypto";
let parser = crypto.newJwtParser();
let [header, payload] = parser.parse(token, pk);
get PEM public key from jwks
import * as crypto from "crypto";
let parser = crypto.newJwtParser();
let [header, payload] = parser.ParseWithoutVerify(token)
let url = payload['iss'] + '.well-known/jwks.json'
let resp = http.newClient().get(url)
let pub = parser.parsePublicKeyFromJwks(resp.body, kid)
parse, validate and verify by JWKS
import * as crypto from "crypto";
let parser = crypto.newJwtParser();
let [header, payload] = parser.parseWithoutVerify(token)
let url = payload['iss'] + '.well-known/jwks.json'
let resp = http.newClient().get(url)
let [header, payload] = parser.parseWithJwks(token);
parse without valid and verify
JWT
import * as crypto from "crypto";
let parser = crypto.newJwtParser();
let [header, payload] = parser.parseWithoutVerify(token);
verify signature by JWKS
import * as crypto from "crypto";
let parser = crypto.newJwtParser();
let [header, payload] = parser.ParseWithoutVerify(token)
let url = payload['iss'] + '.well-known/jwks.json'
let resp = http.newClient().get(url)
if (!parser.verifyWithJwks(token, resp.body)) {
throw new Error("invalid signature")
}
JwtParser parse jwt token, handle with jwk