@@ -5,9 +5,8 @@ import { CoreServiceName } from '@objectstack/spec/system';
55
66/** Browser-safe UUID generator — prefers Web Crypto, falls back to RFC 4122 v4 */
77function randomUUID ( ) : string {
8- const cryptoObj = typeof globalThis !== 'undefined' ? ( globalThis as any ) . crypto : undefined ;
9- if ( cryptoObj && typeof cryptoObj . randomUUID === 'function' ) {
10- return cryptoObj . randomUUID ( ) ;
8+ if ( globalThis . crypto && typeof globalThis . crypto . randomUUID === 'function' ) {
9+ return globalThis . crypto . randomUUID ( ) ;
1110 }
1211 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( / [ x y ] / g, c => {
1312 const r = ( Math . random ( ) * 16 ) | 0 ;
@@ -200,17 +199,10 @@ export class HttpDispatcher {
200199 const data = await broker . call ( 'auth.login' , body , { request : context . request } ) ;
201200 return { handled : true , response : { status : 200 , body : data } } ;
202201 } catch ( error : any ) {
203- // Only fall through to mock when the broker is truly unavailable.
204- const msg = error ?. message || '' ;
202+ // Only fall through to mock when the broker is truly unavailable
203+ // (ensureBroker throws statusCode 500 when kernel.broker is null)
205204 const statusCode = error ?. statusCode ?? error ?. status ;
206- const isBrokerUnavailable =
207- msg . includes ( 'not available' ) ||
208- msg . includes ( 'not found' ) ||
209- msg . includes ( 'not registered' ) ||
210- statusCode === 503 ;
211-
212- if ( ! isBrokerUnavailable ) {
213- // Propagate real auth failures so callers see the correct error
205+ if ( statusCode !== 500 || ! error ?. message ?. includes ( 'Broker not available' ) ) {
214206 throw error ;
215207 }
216208 }
0 commit comments