Webhook decoder not working

hello guys , i installed the npm package @kinde/webhooks to decode my JWT , in the docs it says to use const decodedWebhook = decodeWebhook("eyJhbGc..."); if (decodedWebhook.type === WebhookEventType.userCreated) { // decodedWebhook is type safe userCreated event } the problem is i'm getting this error Property 'type' does not exist on type 'Promise<WebhookEvent | null> and i'm getting undefined result, in my console logs :
import { Hono } from "hono";
import { decodeWebhook } from "@kinde/webhooks";

const app = new Hono();

app.post("/api/auth", async (c) => {
const jwt = await c.req.raw.text();
console.log("Received JWT:", jwt);

const decoded = decodeWebhook(jwt);
console.log("Decoded webhook type:", decoded?.type);

if (!decoded) {
return c.text("Invalid webhook").status(400);
}

if (decoded.type === "user.created") {
console.log("Handling user.created event:", decoded.data);
// Your logic here...
} else {
console.log("Received unhandled event type:", decoded.type);
}

return c.text("OK").status(200);
});

app.get("/", (c) => c.text("Hello Home!"));

export default app;
import { Hono } from "hono";
import { decodeWebhook } from "@kinde/webhooks";

const app = new Hono();

app.post("/api/auth", async (c) => {
const jwt = await c.req.raw.text();
console.log("Received JWT:", jwt);

const decoded = decodeWebhook(jwt);
console.log("Decoded webhook type:", decoded?.type);

if (!decoded) {
return c.text("Invalid webhook").status(400);
}

if (decoded.type === "user.created") {
console.log("Handling user.created event:", decoded.data);
// Your logic here...
} else {
console.log("Received unhandled event type:", decoded.type);
}

return c.text("OK").status(200);
});

app.get("/", (c) => c.text("Hello Home!"));

export default app;
is the decoder not supported anymore and i should use an other one ?
1 Reply
Koosha-Kinde
Koosha-Kinde3w ago
Hi Adam, Thank you for reaching out. The @kinde/webhooks package is still supported, but there are two issues in your implementation: Missing await: The decodeWebhook function is asynchronous and returns a Promise Missing domain parameter: The function requires a domain parameter for token validation It should be const decoded = await decodeWebhook(jwt, "https://your-subdomain.kinde.com"); I think we need to update the Readme file. Thank you again for bringing this to our attention. Please let me know if you have any more questions.

Did you find this page helpful?