Store key_prefix for readable key display instead of masked hash
The last-4 of the SHA-256 hash was meaningless for identification. Now storing the first 12 chars of the plaintext key as key_prefix, displayed as 'sk-aBcDeFgH••••••••' — consistent with what the user sees at creation time and how GitHub/OpenAI handle it.
This commit is contained in:
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client';
|
||||
import axios from 'axios';
|
||||
import './styles.css';
|
||||
|
||||
const maskKey = (key) => `••••••••${key.slice(-4)}`;
|
||||
const displayKey = (prefix) => prefix ? `${prefix}••••••••` : '••••••••••••';
|
||||
|
||||
function authHeaders(token) {
|
||||
return { Authorization: `Bearer ${token}` };
|
||||
@@ -298,7 +298,7 @@ function App() {
|
||||
<tr key={key.id}>
|
||||
<td>{key.id}</td>
|
||||
<td>{key.name}</td>
|
||||
<td>{maskKey(key.key)}</td>
|
||||
<td>{displayKey(key.key_prefix)}</td>
|
||||
<td>{key.is_active ? 'Aktiv' : 'Inaktiv'}</td>
|
||||
<td>{key.expires_at ? new Date(key.expires_at).toLocaleDateString('de-DE', { timeZone: 'Europe/Berlin' }) : '∞'}</td>
|
||||
<td>{key.daily_tokens ?? '∞'}</td>
|
||||
|
||||
Reference in New Issue
Block a user