I used Plug and Play swift SDK… And the code has been working for weeks.
But suddenly today, when my server tries to verify the token, it throws error.
Swift code:
web3Auth = await Web3Auth(.init(clientId: clientID, network: network, buildEnv: buildEnv, useCoreKitKey: useCoreKit))
try await web3Auth?.login(W3ALoginParams(loginProvider: provider, mfaLevel: .NONE))
idToken = try web3Auth?.getUserInfo().idToken
Then client will pass up idToken to server.
Then on server:
// Get the JWK set used to sign the JWT issued by Web3Auth
const jwks = jose.createRemoteJWKSet(new URL("https://api-auth.web3auth.io/jwks"))
// Verify the JWT using Web3Auth's JWKS
let publicKey
try {
const jwtDecoded = await jose.jwtVerify(idToken, jwks, { algorithms: ["ES256"] })
console.log(jwtDecoded)
publicKey = (jwtDecoded.payload as any).wallets[0].public_key
} catch (err) {
console.log(err)
}
Server side produced the error:
JWKSNoMatchingKey: no applicable key found in the JSON Web Key Set
at RemoteJWKSet.getKey (.../node_modules/jose/dist/node/cjs/jwks/local.js:85:19)
at RemoteJWKSet.getKey (.../node_modules/jose/dist/node/cjs/jwks/remote.js:55:32)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async flattenedVerify (.../node_modules/jose/dist/node/cjs/jws/flattened/verify.js:75:15)
at async compactVerify (.../node_modules/jose/dist/node/cjs/jws/compact/verify.js:18:22)
at async Object.jwtVerify (.../node_modules/jose/dist/node/cjs/jwt/verify.js:8:22) {
code: 'ERR_JWKS_NO_MATCHING_KEY'
}
Please help me on what I should do here?
The code has been working for a couple of weeks. So it won’t be because the client side token expiry issue (the token expiry is 1 day according to web3auth)…