Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/witty-cougars-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@powersync/service-core': patch
'@powersync/service-image': patch
---

Fix websocket auth errors not correctly propagating the details, previously resulting in generic "[PSYNC_S2106] Authentication required" messages.
5 changes: 3 additions & 2 deletions packages/service-core/src/routes/configure-rsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ export function configureRSocket(router: ReactiveSocketRouter<Context>, options:
const extracted_token = getTokenFromHeader(token);
if (extracted_token != null) {
const { context, tokenError } = await generateContext(options.service_context, extracted_token);
if (context?.token_payload == null) {
if (tokenError != null) {
throw tokenError;
} else if (context?.token_payload == null) {
throw new errors.AuthorizationError(ErrorCode.PSYNC_S2106, 'Authentication required');
}

return {
token,
user_agent,
...context,
token_error: tokenError,
service_context: service_context as RouterServiceContext,
logger: connectionLogger
};
Expand Down
1 change: 0 additions & 1 deletion packages/service-core/src/routes/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export type Context = {
service_context: RouterServiceContext;

token_payload?: JwtPayload;
token_error?: ServiceError;
/**
* Only on websocket endpoints.
*/
Expand Down