Files
yaak-mountain-loop/plugins/auth-bearer/src/index.ts
Gregory Schier b4a1c418bb Run oxfmt across repo, add format script and docs
Add .oxfmtignore to skip generated bindings and wasm-pack output.
Add npm format script, update DEVELOPMENT.md for Vite+ toolchain,
and format all non-generated files with oxfmt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 10:15:49 -07:00

40 lines
1.1 KiB
TypeScript

import type { PluginDefinition } from "@yaakapp/api";
import type { CallHttpAuthenticationRequest } from "@yaakapp-internal/plugins";
export const plugin: PluginDefinition = {
authentication: {
name: "bearer",
label: "Bearer Token",
shortLabel: "Bearer",
args: [
{
type: "text",
name: "token",
label: "Token",
optional: true,
password: true,
},
{
type: "text",
name: "prefix",
label: "Prefix",
optional: true,
placeholder: "",
defaultValue: "Bearer",
description:
'The prefix to use for the Authorization header, which will be of the format "<PREFIX> <TOKEN>".',
},
],
async onApply(_ctx, { values }) {
return { setHeaders: [generateAuthorizationHeader(values)] };
},
},
};
function generateAuthorizationHeader(values: CallHttpAuthenticationRequest["values"]) {
const token = String(values.token || "").trim();
const prefix = String(values.prefix || "").trim();
const value = `${prefix} ${token}`.trim();
return { name: "Authorization", value };
}