feat(api-keys): scopes for triage, tasks and list items (FLAW-07)
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m33s

Keys get scopes when created (webhook:triage, webhook:task,
webhook:list; default triage, old keys become triage). The webhook
ingest learns target task (optional task list) and list_item (needs a
list the owner may write to); /inbox checks the scope of its target as
well; a missing scope answers 403. Keys can no longer open live streams,
which carried all of the owner's events.

The visible key UI lived in the account settings while EcosystemView
was never rendered; it is replaced by ApiKeysPanel in the settings with
scope chips, scope badges per key and a simulator for all three
targets. Examples send the key as X-API-Key header, not in the URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-10-29 14:36:17 +01:00
1 parent 3900c6104e
commit 5c711c2cf7
16 files changed
+644 -518

No files matched your search

+19 -14
View File
@@ -4,6 +4,7 @@ import {
DashboardStats,
Document,
TrashedDocument,
ApiKeyScope,
Backlink,
DocumentBlock,
DocShare,
@@ -1108,10 +1109,10 @@ export const api = {
return ensureArray(res);
},
async createAPIKey(name: string): Promise<APIKey> {
async createAPIKey(name: string, scopes: ApiKeyScope[]): Promise<APIKey> {
return request<APIKey>('/api/v1/keys', {
method: 'POST',
body: JSON.stringify({ name }),
body: JSON.stringify({ name, scopes }),
});
},
@@ -1119,19 +1120,23 @@ export const api = {
await request(`/api/v1/keys/${id}`, { method: 'DELETE' });
},
/** Simulator: sends like an external system would, with the given key or else the own session. */
async testWebhookIngest(
token: string,
title: string,
priority: PriorityLevel,
tags: string[]
): Promise<{ status: string; thought: Thought }> {
return request<{ status: string; thought: Thought }>(
`/api/v1/webhooks/ingest?token=${encodeURIComponent(token)}`,
{
method: 'POST',
body: JSON.stringify({ title, priority, tags }),
}
);
apiKey: string | null,
payload: {
title: string;
priority?: PriorityLevel;
tags?: string[];
target?: 'triage' | 'task' | 'list_item';
taskListId?: string;
listId?: string;
}
): Promise<{ status: string }> {
return request<{ status: string }>('/api/v1/webhooks/ingest', {
method: 'POST',
headers: apiKey ? { 'X-API-Key': apiKey } : {},
body: JSON.stringify(payload),
});
},
async searchAll(q: string): Promise<SearchResults> {