File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @powersync/service-image ' : patch
3+ ---
4+
5+ Fix websockets not being closed on authentication error
Original file line number Diff line number Diff line change @@ -85,28 +85,29 @@ export async function startServer(runnerConfig: core.utils.RunnerConfig) {
8585 const { token } = core . routes . RSocketContextMeta . decode ( deserialize ( data ) as any ) ;
8686
8787 if ( ! token ) {
88- throw new errors . ValidationError ( 'No token provided in context ' ) ;
88+ throw new errors . AuthorizationError ( 'No token provided' ) ;
8989 }
9090
9191 try {
9292 const extracted_token = core . routes . auth . getTokenFromHeader ( token ) ;
9393 if ( extracted_token != null ) {
94- const { context, errors } = await core . routes . auth . generateContext ( system , extracted_token ) ;
94+ const { context, errors : token_errors } = await core . routes . auth . generateContext ( system , extracted_token ) ;
95+ if ( context ?. token_payload == null ) {
96+ throw new errors . AuthorizationError ( token_errors ?? 'Authentication required' ) ;
97+ }
9598 return {
9699 token,
97100 ...context ,
98- token_errors : errors ,
101+ token_errors : token_errors ,
99102 system
100103 } ;
104+ } else {
105+ throw new errors . AuthorizationError ( 'No token provided' ) ;
101106 }
102107 } catch ( ex ) {
103108 logger . error ( ex ) ;
109+ throw ex ;
104110 }
105-
106- return {
107- token,
108- system
109- } ;
110111 } ,
111112 endpoints : [ core . routes . endpoints . syncStreamReactive ( SocketRouter ) ] ,
112113 metaDecoder : async ( meta : Buffer ) => {
You can’t perform that action at this time.
0 commit comments