volks_123
04/15/2023, 7:40 PMauth/jwt/jwk.json
but I am calling this from my backend, so do I have to send a request to localhost? Also, do these keys rotate, do I need to refetch them on every request or can I store them for later use?volks_123
04/15/2023, 7:40 PMimport jwkToPem from 'jwk-to-pem';
import axios from 'axios';
import { exit } from 'process';
async function fetchJWK(): Promise<any> {
try {
const response = await axios.get(`http://localhost/auth/jwt/jwks.json`);
if (response.data.keys.length === 0) {
console.error('No JWK found');
exit(1);
}
return response.data.keys[0];
} catch (error) {
console.error('Error fetching JWK:', error);
throw error;
}
}
const jwk = await fetchJWK();
const certString = jwkToPem(jwk);
process.env.JWKCERT = certString;
console.log('CERT String:', certString);
rp_st
04/16/2023, 8:08 AMrp_st
04/16/2023, 8:08 AMrp_st
04/16/2023, 8:09 AM