33 * before establishing a full WebBridge connection.
44 *
55 * This is used by the ConnectForm to provide fast, specific error
6- * messages (wrong host? wrong token ?) before attempting the heavier
6+ * messages (wrong host? wrong password ?) before attempting the heavier
77 * SSE connection.
88 */
99
1010import { fetchWithTimeout , resolveBaseUrl } from './utils' ;
1111
1212/**
13- * Test whether a host is reachable and the token is valid.
13+ * Test whether a host is reachable and the password is valid.
1414 *
1515 * Returns a human-readable error message on failure, or null on success.
1616 * Performs two sequential checks:
1717 * 1. Health endpoint (unauthenticated) — tests reachability
1818 * 2. Session endpoint (authenticated) — tests credentials
1919 */
20- export async function testConnection ( host : string , token : string ) : Promise < string | null > {
20+ export async function testConnection ( host : string , password : string ) : Promise < string | null > {
2121 const baseUrl = resolveBaseUrl ( host ) ;
2222
2323 // 1. Test host reachability (health endpoint — no auth)
@@ -38,11 +38,11 @@ export async function testConnection(host: string, token: string): Promise<strin
3838 // 2. Test authentication (session endpoint — requires auth)
3939 try {
4040 const res = await fetchWithTimeout ( `${ baseUrl } /session` , {
41- headers : { 'Authorization' : `Bearer ${ token } ` } ,
41+ headers : { 'Authorization' : `Bearer ${ password } ` } ,
4242 } ) ;
4343 if ( ! res . ok ) {
4444 return ( res . status === 401 || res . status === 403 )
45- ? 'Authentication failed. Check your password or token .'
45+ ? 'Authentication failed. Check your password.'
4646 : `Session check failed (${ res . status } ).` ;
4747 }
4848 } catch ( err : any ) {
0 commit comments