File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,12 +13,20 @@ export class LangfuseService {
1313 private readonly buffers = new Map < string , LangfuseEvent [ ] > ( ) ;
1414
1515 verifyCredentials ( authHeader : string | undefined ) : boolean {
16- if ( ! authHeader ?. startsWith ( 'Basic ' ) ) return false ;
16+ if ( ! authHeader ?. startsWith ( 'Basic ' ) ) {
17+ return false ;
18+ }
19+
1720 const decoded = Buffer . from ( authHeader . slice ( 6 ) , 'base64' ) . toString ( ) ;
1821 const colonIdx = decoded . indexOf ( ':' ) ;
19- if ( colonIdx === - 1 ) return false ;
22+
23+ if ( colonIdx === - 1 ) {
24+ return false ;
25+ }
26+
2027 const pub = decoded . slice ( 0 , colonIdx ) ;
2128 const sec = decoded . slice ( colonIdx + 1 ) ;
29+
2230 return pub === LANGFUSE_PUBLIC_KEY && sec === LANGFUSE_SECRET_KEY ;
2331 }
2432
@@ -27,10 +35,15 @@ export class LangfuseService {
2735 this . subjects . set ( sessionId , new Subject < LangfuseEvent > ( ) ) ;
2836 this . buffers . set ( sessionId , [ ] ) ;
2937 }
38+
3039 const subject = this . subjects . get ( sessionId ) ! ;
3140 const buffer = this . buffers . get ( sessionId ) ! ;
41+
3242 for ( const ev of events ) {
33- if ( buffer . length >= BUFFER_EVENTS ) buffer . shift ( ) ;
43+ if ( buffer . length >= BUFFER_EVENTS ) {
44+ buffer . shift ( ) ;
45+ }
46+
3447 buffer . push ( ev ) ;
3548 subject . next ( ev ) ;
3649 }
You can’t perform that action at this time.
0 commit comments