fix(debugger): properly decode base64url public key from JWKS
The public key decoding from JWKS was missing base64url padding, causing JWT signature verification to fail with "invalid jwt token" errors in production. The `jwk.x` value needs proper padding before base64 decoding. Fixed by using the existing `base64urlDecode` helper function which correctly adds padding, instead of manually doing the conversion. This resolves JWT verification failures when REQUIRE_SIGNED_DEBUG_REQUESTS is enabled. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -213,7 +213,7 @@ async function getPublicKey(): Promise<CryptoKey | null> {
|
||||
}
|
||||
|
||||
// Decode the public key from base64url
|
||||
const publicKeyBytes = Uint8Array.from(atob(jwk.x.replace(/-/g, '+').replace(/_/g, '/')), c => c.charCodeAt(0))
|
||||
const publicKeyBytes = base64urlDecode(jwk.x)
|
||||
|
||||
// Import as Ed25519 public key
|
||||
const key = await crypto.subtle.importKey(
|
||||
|
||||
@@ -186,7 +186,7 @@ async function getPublicKey(): Promise<CryptoKey | null> {
|
||||
}
|
||||
|
||||
// Decode the public key from base64url
|
||||
const publicKeyBytes = Uint8Array.from(atob(jwk.x.replace(/-/g, '+').replace(/_/g, '/')), c => c.charCodeAt(0))
|
||||
const publicKeyBytes = base64urlDecode(jwk.x)
|
||||
|
||||
// Import as Ed25519 public key
|
||||
const key = await crypto.subtle.importKey(
|
||||
|
||||
Reference in New Issue
Block a user