diff --git a/src/App.svelte b/src/App.svelte
index f5debb7..d681688 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -63,6 +63,11 @@
let oauthError = '';
let botCommands: Array<{ id: string; name: string; description: string; permission_level: string; aliases: string[]; tags: string[]; cooldown_seconds: number; cooldown_scope: string; response_template: string; error_template: string | null; enabled: boolean }> = [];
let botCommandError = '';
+ let botSecrets: Array<{ id: string; name: string; description: string; used_by: string[] }> = [];
+ let secretName = '';
+ let secretDescription = '';
+ let secretValue = '';
+ let secretError = '';
let oauthScopes: Record<'streamer' | 'bot', { connected: boolean; missing_scopes: string[]; reauthorization_required: boolean }> = {
streamer: { connected: false, missing_scopes: [], reauthorization_required: false },
bot: { connected: false, missing_scopes: [], reauthorization_required: false },
@@ -116,6 +121,7 @@
await loadOAuthStatus();
await loadCollaboration();
await loadBotCommands();
+ await loadBotSecrets();
await loadStreamInfo();
connectRealtime();
if (!mustReplaceCredentials) password = '';
@@ -529,6 +535,42 @@
}
}
+ async function loadBotSecrets() {
+ try {
+ const response = await fetch(`${serverAddress}/api/v1/bot/secrets`, { headers: { authorization: `Bearer ${sessionToken}` } });
+ if (!response.ok) throw new Error('Secrets could not be loaded.');
+ botSecrets = await response.json();
+ secretError = '';
+ } catch (error) {
+ secretError = error instanceof Error ? error.message : 'Secrets could not be loaded.';
+ }
+ }
+
+ async function createSecret() {
+ secretError = '';
+ try {
+ const response = await fetch(`${serverAddress}/api/v1/bot/secrets`, { method: 'POST', headers: { 'content-type': 'application/json', authorization: `Bearer ${sessionToken}` }, body: JSON.stringify({ name: secretName, description: secretDescription, value: secretValue }) });
+ if (!response.ok) throw new Error('The secret could not be saved.');
+ secretName = '';
+ secretDescription = '';
+ secretValue = '';
+ await loadBotSecrets();
+ } catch (error) {
+ secretError = error instanceof Error ? error.message : 'The secret could not be saved.';
+ }
+ }
+
+ async function deleteSecret(id: string) {
+ secretError = '';
+ try {
+ const response = await fetch(`${serverAddress}/api/v1/bot/secrets/${encodeURIComponent(id)}`, { method: 'DELETE', headers: { authorization: `Bearer ${sessionToken}` } });
+ if (!response.ok) throw new Error('The secret could not be deleted.');
+ await loadBotSecrets();
+ } catch (error) {
+ secretError = error instanceof Error ? error.message : 'The secret could not be deleted.';
+ }
+ }
+
async function revokeOAuth(identity: 'streamer' | 'bot') {
oauthBusy = true;
oauthError = '';
@@ -642,7 +684,7 @@
{:else if activeView === 'Bot'}
-