{pageTitle}
{#if !auth.toggle}
Password:
{ const res = await fetch('/api/auth', { headers: { 'TAM-PWD': auth.pwd } }); if (res.ok) { auth.toggle = true; const resData = await res.json(); authKeys = [...resData]; curKey = data.authKey; } else { auth.pwd = 'Invalid Password!'; setTimeout(() => (auth.pwd = ''), 3000); } }}>Login
{:else}
AuthKey
Description
Actions
{#each authKeys as key (key.auth_key)}
{'*'.repeat(key.auth_key.length - 4) + key.auth_key.slice(-4)}
{key.description}
{#if curKey == key.auth_key}
(Cur)
{:else}
{ const res = await fetch('/api/settings', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ remote_key: key.auth_key }) }); if (res.ok) { curKey = key.auth_key; } }}>Use
{/if}
{ const res = await fetch(`/api/auth?key_to_del=${key.auth_key}`, { method: 'DELETE', headers: { 'TAM-PWD': auth.pwd } }); if (res.ok) { setTimeout(() => { const newKeys = authKeys.filter((i) => i.auth_key !== key.auth_key); authKeys = [...newKeys]; }, 1); } }}>Delete
{/each}
New
{ if (newDesc) { const res = await fetch('/api/auth', { method: 'POST', headers: { 'TAM-PWD': auth.pwd, 'Content-Type': 'application/json' }, body: JSON.stringify({ description: newDesc }) }); if (res.ok) { newDesc = ''; const data = await res.json(); authKeys = [...authKeys, data]; } } }}>New Key
{/if}