I want to verify "firebase JWT token" on "Cloudflare workers" environment.
The problem is firebase-auth doesn't provide the standard /.well-known/jwks.json
,rather they provide x806 public key certificate
(pem) format
I am using the "Webcrypto API" to do the Crypto work, here is what I am up to
// Get CryptoKey
const key = await crypto.subtle.importKey(
"jwk", // it's possible to change this format if the pem can be changed to other standards
jwk, // ?? Here is the missing piece
{ name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
false,
["verify"]
);
// Verify
const success = await crypto.subtle.verify(
"RSASSA-PKCS1-v1_5",
key,
signature, // JWT signature
data // JWT payload
);
I have tried several packages on Github , all the libraries I found either doesn't work or use nodejs API (e.g buffer) which will not work on CF environment
Can someone point me how to
- convert the firebase public-key to JWK or
- convert the the public key to other standards(
"raw" | "pkcs8" | "spki"
) thatimportKey
can accept
NB: we are on "CF Workers" environment so all "nodejs" apis doesn't work
Thanks