Your own backend (Auth)
Xumm xApps yield a JWT that can be used to make subsequent calls from the user context to the Xumm API's. You can also use this JWT for your own backend.
Last updated
Was this helpful?
Was this helpful?
const jwt = require('jsonwebtoken')
const apiKey = '' // Your Xumm API key here
const apiSecret = '' // Your Xumm API secret (BACKEND ONLY!)
const bearer = await xumm.environment.bearer
try {
// If decoded comes back as an object, the JWT is valid.
// Otherwise, the catch block is activated
const decoded = jwt.verify(bearer, apiSecret);
// For extra security, check if the decoded JWT contains
// the client_id of your xApp, e.g. the API Key from the developer console
if(decoded.client_id === apiKey) {
// JWT is valid and signed for this client (client_id matched)
} else {
// Valid JWT, but for another client? There's something
// wrong with an otherwise valid JWT.
}
} catch (error) {
// Handle your error here and inform the user that their access is denied.
}