Bearer Plugin

Plugin for @teakit/core for retrieving the Bearer token.

Install with:

bun add @teakit/plugin-bearer

Then use it:

import { Application } from "@teakit/core";
import { pluginBearer } from "@teakit/plugin-bearer";
const app = new Application()
.get("/sign", ({ bearer }) => bearer, {
beforeHandle({ bearer, set }) {
if (!bearer) {
set.status = 400;
set.headers["WWW-Authenticate"] = `Bearer realm='sign', error="invalid_request"`;
return "Unauthorized";

This plugin is for retrieving a Bearer token specified in RFC6750.

This plugin DOES NOT handle authentication validation for your server, rather the plugin leaves the decision for developers to apply logic for handle validation check themself.