Compare commits

...

3 Commits

Author SHA1 Message Date
Gregory Schier
c00d2e981f Fix basic auth failing when password field is empty or unset
Handle undefined username/password values by defaulting to empty string,
preventing "undefined" from being encoded in the Authorization header.

Fixes https://feedback.yaak.app/p/strange-basic-auth-behaviour-in-202612

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 15:07:03 -08:00
Gregory Schier
9c45254952 Fix template tag theme colors 2026-01-28 13:08:22 -08:00
Gregory Schier
d031ff231a Bump plugin runtime types 2026-01-28 08:43:19 -08:00
7 changed files with 88 additions and 8 deletions

2
package-lock.json generated
View File

@@ -15721,7 +15721,7 @@
},
"packages/plugin-runtime-types": {
"name": "@yaakapp/api",
"version": "0.7.1",
"version": "0.8.0",
"dependencies": {
"@types/node": "^24.0.13"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@yaakapp/api",
"version": "0.7.1",
"version": "0.8.0",
"keywords": [
"api-client",
"insomnia-alternative",

View File

@@ -11,6 +11,7 @@
"version": "0.1.0",
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev"
"dev": "yaakcli dev",
"test": "vitest --run tests"
}
}

View File

@@ -21,7 +21,8 @@ export const plugin: PluginDefinition = {
},
],
async onApply(_ctx, { values }) {
const { username, password } = values;
const username = values.username ?? '';
const password = values.password ?? '';
const value = `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`;
return { setHeaders: [{ name: 'Authorization', value }] };
},

View File

@@ -0,0 +1,77 @@
import type { Context } from '@yaakapp/api';
import { describe, expect, test } from 'vitest';
import { plugin } from '../src';
const ctx = {} as Context;
describe('auth-basic', () => {
test('Both username and password', async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { username: 'user', password: 'pass' },
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
}),
).toEqual({
setHeaders: [{ name: 'Authorization', value: `Basic ${Buffer.from('user:pass').toString('base64')}` }],
});
});
test('Empty password', async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { username: 'apikey', password: '' },
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
}),
).toEqual({
setHeaders: [{ name: 'Authorization', value: `Basic ${Buffer.from('apikey:').toString('base64')}` }],
});
});
test('Missing password (undefined)', async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { username: 'apikey' },
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
}),
).toEqual({
setHeaders: [{ name: 'Authorization', value: `Basic ${Buffer.from('apikey:').toString('base64')}` }],
});
});
test('Missing username (undefined)', async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { password: 'secret' },
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
}),
).toEqual({
setHeaders: [{ name: 'Authorization', value: `Basic ${Buffer.from(':secret').toString('base64')}` }],
});
});
test('No values (both undefined)', async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: {},
headers: [],
url: 'https://yaak.app',
method: 'POST',
contextId: '111',
}),
).toEqual({
setHeaders: [{ name: 'Authorization', value: `Basic ${Buffer.from(':').toString('base64')}` }],
});
});
});

View File

@@ -101,8 +101,8 @@
.template-tag {
/* Colors */
@apply bg-surface text-text border-border-subtle whitespace-nowrap cursor-default;
@apply hover:border-border-subtle hover:text-text hover:bg-surface-highlight;
@apply bg-surface text-text-subtle border-border-subtle whitespace-nowrap cursor-default;
@apply hover:border-border hover:text-text hover:bg-surface-highlight;
@apply inline border px-1 mx-[0.5px] rounded dark:shadow;

View File

@@ -104,11 +104,12 @@ function templateTagColorVariables(color: YaakColor | null): Partial<CSSVariable
if (color == null) return {};
return {
text: color.lift(0.6).css(),
text: color.lift(0.7).css(),
textSubtle: color.lift(0.4).css(),
textSubtlest: color.css(),
surface: color.lower(0.2).translucify(0.8).css(),
border: color.lower(0.2).translucify(0.2).css(),
border: color.translucify(0.6).css(),
borderSubtle: color.translucify(0.8).css(),
surfaceHighlight: color.lower(0.1).translucify(0.7).css(),
};
}