I am writing below code to get jwt token, which I want to validate with the SMART Health Cards Validation SDK
var jose = require("node-jose");
const {JWS} = require("node-jose");
async function a1(){
try {
const keystore={
keys: [
{
kty: 'EC',
d: 'gLkNmSBFWR67hEu62eVfVWhFbLGl309jOszsocqbexE',
use: 'sig',
crv: 'P-256',
kid: '6d858102402dbbeb0f9bb711e3d13a1229684792db4940db0d0e71c08ca602e1',
x: '5R2yrryD1ztBYnyKyQF5r5kzPUjnVnmR5pMe7H9ykNU',
y: 'VaqqjG0N2rSuijP9P9QiOjX4XEhIl8k8fzA6FZTSMhY',
alg: 'ES256'
}
]
}
const ks = await jose.JWK.asKeyStore(keystore);
const rawKey = ks.get(keystore.keys[0].kid)
const key = await jose.JWK.asKey(rawKey);
const payload =JSON.stringify({ "iss" : "https://spec.smarthealth.cards/examples/issuer", "sub": "1234567890", "name": "John Doe", "iat": 1516239022});
const token =await jose.JWS.createSign( {format: 'compact'},key).update(payload, "utf8").final();
console.log(token);
}catch (err) {
console.log(err);
}
}
a1();
I am getting token:
eyJhbGciOiJFUzI1NiIsImtpZCI6IjZkODU4MTAyNDAyZGJiZWIwZjliYjcxMWUzZDEzYTEyMjk2ODQ3OTJkYjQ5NDBkYjBkMGU3MWMwOGNhNjAyZTEifQ.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkVyaWMgRC4iLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE1MTYyMzkwMjJ9.dbjb9YHFCWaFYGQYyGDDL1iFvqk1Ed9k3-PAhVx4NtvFml1q0VcpW854IXW_J47f6Vf1otm2WeftVQHjY3K4vg
When I use this command:
node . --path C:\Users\User\Documents\Saguaro\health-cards-validation-SDK-main\jws.text --type jws
in sdk file, I get below errors:
Error
│ · JWS header missing 'zip' property.
│ · Error inflating JWS payload. Did you use raw DEFLATE compression?
│ incorrect header check
│ · JWS verification failed: can't find key with 'kid' = 6d858102402dbbeb0f9bb711e3d13a1229684792db4940db0d0e71c08ca602e1 in issuer set
Please let me know what issuer set and how to put kid value in issuer set. Also, what is meant by deflate compression and how to remove this problem. Please note: Above is pseudo code.