bulltrackers-module 1.0.1007 → 1.0.1008

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -194,22 +194,27 @@ function attachVerificationWebSocketServer(server, dependencies, apiConfig = {})
194
194
 
195
195
  const payload = JSON.parse(raw);
196
196
  const firebaseUser = await resolveFirebaseUser(req);
197
- if (!firebaseUser) {
198
- ws.close(1008, 'Authentication required');
199
- return;
200
- }
201
-
202
197
  const services = await getServices();
203
- let userCid = null;
204
- if (firebaseUser.email) {
205
- try {
206
- const lookup = await services.authService.lookupCidByEmail(firebaseUser.email, { isDevTenant: isDevTenantRequest(req) });
207
- if (lookup?.cid != null) userCid = String(lookup.cid);
208
- } catch (_) { }
198
+ let targetUserId = payload.userId || null;
199
+ if (firebaseUser) {
200
+ let userCid = null;
201
+ if (firebaseUser.email) {
202
+ try {
203
+ const lookup = await services.authService.lookupCidByEmail(firebaseUser.email, { isDevTenant: isDevTenantRequest(req) });
204
+ if (lookup?.cid != null) userCid = String(lookup.cid);
205
+ } catch (_) { }
206
+ }
207
+ const resolvedUserId = resolveTargetUserId(firebaseUser, userCid, req);
208
+ if (!resolvedUserId || resolvedUserId !== payload.userId) {
209
+ ws.close(1008, 'Ticket user mismatch');
210
+ return;
211
+ }
212
+ targetUserId = resolvedUserId;
213
+ } else {
214
+ (dependencies.logger || console).warn?.('[VerificationWS] No auth header; using ticket-only auth');
209
215
  }
210
- const targetUserId = resolveTargetUserId(firebaseUser, userCid, req);
211
- if (!targetUserId || targetUserId !== payload.userId) {
212
- ws.close(1008, 'Ticket user mismatch');
216
+ if (!targetUserId) {
217
+ ws.close(1008, 'Invalid ticket user');
213
218
  return;
214
219
  }
215
220
 
@@ -325,6 +330,9 @@ function attachVerificationWebSocketServer(server, dependencies, apiConfig = {})
325
330
 
326
331
  ws.close(1000, 'Verification complete');
327
332
  } catch (err) {
333
+ try {
334
+ (dependencies.logger || console).error?.('[VerificationWS] Unexpected error', err);
335
+ } catch (_) { }
328
336
  try {
329
337
  ws.send(JSON.stringify({
330
338
  type: 'log',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.1007",
3
+ "version": "1.0.1008",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [