feat: add password authentication support (closes #7)

Add token/password auth mode toggle on the login screen.
When password mode is selected, sends { password } instead of
{ token } in the WebSocket connect handshake.

Also adds clipboard utility tests and fixes credential test
to include authMode field.
This commit is contained in:
Nicolas Varrot
2026-02-18 22:07:06 +00:00
parent 16db1cf811
commit 5c47dd2aeb
9 changed files with 745 additions and 21 deletions

View File

@@ -1,6 +1,15 @@
const STORAGE_KEY = 'pinchchat_credentials';
export function getStoredCredentials(): { url: string; token: string } | null {
export type AuthMode = 'token' | 'password';
export interface StoredCredentials {
url: string;
token: string;
/** Auth mode — defaults to 'token' for backward compatibility */
authMode?: AuthMode;
}
export function getStoredCredentials(): StoredCredentials | null {
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) return null;
@@ -12,8 +21,8 @@ export function getStoredCredentials(): { url: string; token: string } | null {
return null;
}
export function storeCredentials(url: string, token: string) {
localStorage.setItem(STORAGE_KEY, JSON.stringify({ url, token }));
export function storeCredentials(url: string, token: string, authMode: AuthMode = 'token') {
localStorage.setItem(STORAGE_KEY, JSON.stringify({ url, token, authMode }));
}
export function clearCredentials() {