feat: add auth:read permission and ability to retrieve auth headers

This commit is contained in:
Niklas Voss
2026-04-01 11:26:12 +02:00
committed by Linus Rath
parent 58968a1cbf
commit 67a0d622bc
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -25,6 +25,7 @@ import {
sidebarAppHooks,
} from './plugin-hooks';
import { toast as appToast } from '@/stores/toast-store';
import { useAuthStore } from '@/stores/auth-store';
// ─── Permission helpers ──────────────────────────────────────
@@ -128,6 +129,9 @@ export interface PluginAPI {
info: (message: string) => void;
warning: (message: string) => void;
};
auth: {
getHeaders: () => Record<string, string>;
};
storage: ReturnType<typeof createPluginStorage>;
log: ReturnType<typeof createPluginLogger>;
admin: {
@@ -640,6 +644,18 @@ export function createPluginAPI(plugin: InstalledPlugin): PluginAPI {
warning: (message: string) => appToast.warning(message),
},
auth: {
getHeaders: (): Record<string, string> => {
requirePermission(plugin, 'auth:read');
const { client } = useAuthStore.getState();
if (!client) return {};
return {
'Authorization': client.getAuthHeader(),
'X-JMAP-Username': client.getUsername(),
};
},
},
storage: createPluginStorage(plugin.id),
log: createPluginLogger(plugin.id),
+1 -1
View File
@@ -401,7 +401,7 @@ export const ALL_PERMISSIONS = [
'vacation:read', 'vacation:write',
'settings:read', 'settings:write',
'security:read',
'auth:observe',
'auth:observe', 'auth:read',
'ui:observe', 'ui:toolbar', 'ui:email-banner', 'ui:email-footer',
'ui:composer-toolbar', 'ui:sidebar-widget', 'ui:settings-section',
'ui:context-menu', 'ui:navigation-rail', 'ui:keyboard',