Merge main into proxy branch (formatting and docs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-03-13 12:09:59 -07:00
parent 3c4035097a
commit 7314aedc71
712 changed files with 13408 additions and 13322 deletions

View File

@@ -1,17 +1,17 @@
{
"name": "@yaak/auth-bearer",
"displayName": "Bearer Authentication",
"version": "0.1.0",
"private": true,
"description": "Authenticate requests using bearer authentication",
"repository": {
"type": "git",
"url": "https://github.com/mountain-loop/yaak.git",
"directory": "plugins/auth-bearer"
},
"private": true,
"version": "0.1.0",
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

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

View File

@@ -1,67 +1,67 @@
import type { Context } from '@yaakapp/api';
import { describe, expect, test } from 'vitest';
import { plugin } from '../src';
import type { Context } from "@yaakapp/api";
import { describe, expect, test } from "vite-plus/test";
import { plugin } from "../src";
const ctx = {} as Context;
describe('auth-bearer', () => {
test('No values', async () => {
describe("auth-bearer", () => {
test("No values", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: {},
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: 'Authorization', value: '' }] });
).toEqual({ setHeaders: [{ name: "Authorization", value: "" }] });
});
test('Only token', async () => {
test("Only token", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { token: 'my-token' },
values: { token: "my-token" },
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: 'Authorization', value: 'my-token' }] });
).toEqual({ setHeaders: [{ name: "Authorization", value: "my-token" }] });
});
test('Only prefix', async () => {
test("Only prefix", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: 'Hello' },
values: { prefix: "Hello" },
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: 'Authorization', value: 'Hello' }] });
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello" }] });
});
test('Prefix and token', async () => {
test("Prefix and token", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: 'Hello', token: 'my-token' },
values: { prefix: "Hello", token: "my-token" },
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: 'Authorization', value: 'Hello my-token' }] });
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello my-token" }] });
});
test('Extra spaces', async () => {
test("Extra spaces", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: '\t Hello ', token: ' \nmy-token ' },
values: { prefix: "\t Hello ", token: " \nmy-token " },
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: 'Authorization', value: 'Hello my-token' }] });
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello my-token" }] });
});
});