@oxyhq/core 10.2.0 → 11.0.1

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.
Files changed (103) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/boot/sessionColdBoot.js +3 -3
  3. package/dist/cjs/crypto/keyManager.js +68 -69
  4. package/dist/cjs/crypto/signatureService.js +2 -2
  5. package/dist/cjs/index.js +17 -20
  6. package/dist/cjs/logger/index.js +149 -0
  7. package/dist/cjs/mixins/OxyServices.assets.js +4 -4
  8. package/dist/cjs/mixins/OxyServices.auth.js +104 -2
  9. package/dist/cjs/mixins/OxyServices.language.js +3 -5
  10. package/dist/cjs/mixins/OxyServices.privacy.js +2 -4
  11. package/dist/cjs/mixins/OxyServices.security.js +7 -11
  12. package/dist/cjs/mixins/OxyServices.topics.js +25 -15
  13. package/dist/cjs/mixins/OxyServices.user.js +4 -4
  14. package/dist/cjs/mixins/OxyServices.utility.js +18 -18
  15. package/dist/cjs/session/SessionClient.js +17 -17
  16. package/dist/cjs/session/accountDialogController.js +12 -12
  17. package/dist/cjs/session/authStateStore.js +5 -5
  18. package/dist/cjs/session/refresh.js +4 -4
  19. package/dist/cjs/session/socketLoader.js +2 -2
  20. package/dist/cjs/utils/asyncUtils.js +2 -2
  21. package/dist/cjs/utils/avatarUtils.js +2 -1
  22. package/dist/cjs/utils/deviceManager.js +7 -5
  23. package/dist/cjs/utils/errorUtils.js +3 -3
  24. package/dist/cjs/utils/oauthPkce.js +3 -3
  25. package/dist/cjs/utils/requestUtils.js +1 -1
  26. package/dist/cjs/utils/webauthnOrigin.js +51 -0
  27. package/dist/esm/.tsbuildinfo +1 -1
  28. package/dist/esm/boot/sessionColdBoot.js +1 -1
  29. package/dist/esm/crypto/keyManager.js +1 -2
  30. package/dist/esm/crypto/signatureService.js +1 -1
  31. package/dist/esm/index.js +6 -3
  32. package/dist/esm/logger/index.js +140 -0
  33. package/dist/esm/mixins/OxyServices.assets.js +2 -2
  34. package/dist/esm/mixins/OxyServices.auth.js +103 -1
  35. package/dist/esm/mixins/OxyServices.language.js +3 -5
  36. package/dist/esm/mixins/OxyServices.privacy.js +2 -4
  37. package/dist/esm/mixins/OxyServices.security.js +7 -11
  38. package/dist/esm/mixins/OxyServices.topics.js +25 -15
  39. package/dist/esm/mixins/OxyServices.user.js +1 -1
  40. package/dist/esm/mixins/OxyServices.utility.js +1 -1
  41. package/dist/esm/session/SessionClient.js +1 -1
  42. package/dist/esm/session/accountDialogController.js +1 -1
  43. package/dist/esm/session/authStateStore.js +1 -1
  44. package/dist/esm/session/refresh.js +1 -1
  45. package/dist/esm/session/socketLoader.js +1 -1
  46. package/dist/esm/utils/asyncUtils.js +1 -1
  47. package/dist/esm/utils/avatarUtils.js +2 -1
  48. package/dist/esm/utils/deviceManager.js +7 -5
  49. package/dist/esm/utils/errorUtils.js +1 -1
  50. package/dist/esm/utils/oauthPkce.js +1 -1
  51. package/dist/esm/utils/requestUtils.js +1 -1
  52. package/dist/esm/utils/webauthnOrigin.js +48 -0
  53. package/dist/types/.tsbuildinfo +1 -1
  54. package/dist/types/index.d.ts +4 -4
  55. package/dist/types/logger/index.d.ts +104 -0
  56. package/dist/types/mixins/OxyServices.auth.d.ts +58 -0
  57. package/dist/types/mixins/OxyServices.topics.d.ts +3 -3
  58. package/dist/types/models/Topic.d.ts +10 -0
  59. package/dist/types/utils/requestUtils.d.ts +1 -1
  60. package/dist/types/utils/webauthnOrigin.d.ts +32 -0
  61. package/package.json +17 -2
  62. package/src/boot/sessionColdBoot.ts +1 -1
  63. package/src/crypto/keyManager.ts +1 -2
  64. package/src/crypto/signatureService.ts +1 -1
  65. package/src/index.ts +22 -19
  66. package/src/logger/__tests__/logger.test.ts +207 -0
  67. package/src/logger/index.ts +217 -0
  68. package/src/mixins/OxyServices.assets.ts +3 -3
  69. package/src/mixins/OxyServices.auth.ts +134 -1
  70. package/src/mixins/OxyServices.language.ts +3 -5
  71. package/src/mixins/OxyServices.privacy.ts +2 -4
  72. package/src/mixins/OxyServices.security.ts +7 -11
  73. package/src/mixins/OxyServices.topics.ts +47 -17
  74. package/src/mixins/OxyServices.user.ts +1 -1
  75. package/src/mixins/OxyServices.utility.ts +1 -1
  76. package/src/mixins/__tests__/discoveryErrorHandling.test.ts +1 -1
  77. package/src/mixins/__tests__/topics.test.ts +156 -0
  78. package/src/mixins/__tests__/webauthnAuth.test.ts +206 -0
  79. package/src/models/Topic.ts +11 -0
  80. package/src/session/SessionClient.ts +1 -1
  81. package/src/session/__tests__/SessionClient.diagnostics.test.ts +1 -1
  82. package/src/session/__tests__/accountDialogController.test.ts +1 -1
  83. package/src/session/accountDialogController.ts +1 -1
  84. package/src/session/authStateStore.ts +1 -1
  85. package/src/session/refresh.ts +1 -1
  86. package/src/session/socketLoader.ts +1 -1
  87. package/src/utils/__tests__/webauthnOrigin.test.ts +83 -0
  88. package/src/utils/asyncUtils.ts +1 -1
  89. package/src/utils/avatarUtils.ts +3 -1
  90. package/src/utils/deviceManager.ts +8 -5
  91. package/src/utils/errorUtils.ts +1 -1
  92. package/src/utils/oauthPkce.ts +1 -1
  93. package/src/utils/requestUtils.ts +1 -1
  94. package/src/utils/webauthnOrigin.ts +52 -0
  95. package/dist/cjs/shared/utils/debugUtils.js +0 -80
  96. package/dist/cjs/utils/loggerUtils.js +0 -126
  97. package/dist/esm/shared/utils/debugUtils.js +0 -72
  98. package/dist/esm/utils/loggerUtils.js +0 -115
  99. package/dist/types/shared/utils/debugUtils.d.ts +0 -48
  100. package/dist/types/utils/loggerUtils.d.ts +0 -48
  101. package/src/shared/utils/__tests__/debugUtils.test.ts +0 -55
  102. package/src/shared/utils/debugUtils.ts +0 -78
  103. package/src/utils/loggerUtils.ts +0 -153
@@ -10,7 +10,7 @@ exports.OxyServicesUtilityMixin = OxyServicesUtilityMixin;
10
10
  const jwt_decode_1 = require("jwt-decode");
11
11
  const protocol_1 = require("@oxyhq/protocol");
12
12
  const apiUtils_1 = require("../utils/apiUtils");
13
- const loggerUtils_1 = require("../utils/loggerUtils");
13
+ const logger_1 = require("../logger");
14
14
  /**
15
15
  * Expected JWT audience for tokens issued by the Oxy auth service.
16
16
  */
@@ -91,7 +91,7 @@ function OxyServicesUtilityMixin(Base) {
91
91
  return verified;
92
92
  }
93
93
  catch (error) {
94
- loggerUtils_1.logger.warn('[oxy.auth] verifyServiceActingAs lookup failed — caching negative result', {
94
+ logger_1.logger.warn('[oxy.auth] verifyServiceActingAs lookup failed — caching negative result', {
95
95
  component: 'auth',
96
96
  method: 'verifyServiceActingAs',
97
97
  appId,
@@ -191,7 +191,7 @@ function OxyServicesUtilityMixin(Base) {
191
191
  const authHeader = Array.isArray(rawAuthHeader) ? rawAuthHeader[0] : rawAuthHeader;
192
192
  const token = authHeader?.startsWith('Bearer ') ? authHeader.substring(7) : null;
193
193
  if (debug) {
194
- loggerUtils_1.logger.debug(`[oxy.auth] ${req.method} ${req.path} | token: ${!!token}`, {
194
+ logger_1.logger.debug(`[oxy.auth] ${req.method} ${req.path} | token: ${!!token}`, {
195
195
  component: 'auth',
196
196
  method: 'auth',
197
197
  });
@@ -219,7 +219,7 @@ function OxyServicesUtilityMixin(Base) {
219
219
  }
220
220
  catch (decodeError) {
221
221
  if (debug) {
222
- loggerUtils_1.logger.debug('[oxy.auth] Token decode failed', {
222
+ logger_1.logger.debug('[oxy.auth] Token decode failed', {
223
223
  component: 'auth',
224
224
  method: 'auth',
225
225
  }, decodeError);
@@ -282,7 +282,7 @@ function OxyServicesUtilityMixin(Base) {
282
282
  verifyError instanceof ServiceTokenSignatureError ||
283
283
  verifyError instanceof ServiceTokenClaimError) {
284
284
  if (debug) {
285
- loggerUtils_1.logger.debug('[oxy.auth] Service token rejected', {
285
+ logger_1.logger.debug('[oxy.auth] Service token rejected', {
286
286
  component: 'auth',
287
287
  method: 'auth.serviceToken',
288
288
  reason: verifyError.name,
@@ -309,7 +309,7 @@ function OxyServicesUtilityMixin(Base) {
309
309
  return onError(error);
310
310
  return res.status(401).json(error);
311
311
  }
312
- loggerUtils_1.logger.error('[oxy.auth] Unexpected error during service token verification', verifyError, {
312
+ logger_1.logger.error('[oxy.auth] Unexpected error during service token verification', verifyError, {
313
313
  component: 'auth',
314
314
  method: 'auth.serviceToken',
315
315
  });
@@ -360,7 +360,7 @@ function OxyServicesUtilityMixin(Base) {
360
360
  if (oxyUserId) {
361
361
  const grant = await oxyInstance.verifyServiceActingAs(appId, oxyUserId);
362
362
  if (!grant || !grant.authorized) {
363
- loggerUtils_1.logger.warn('[oxy.auth] Service token rejected — no delegation grant', {
363
+ logger_1.logger.warn('[oxy.auth] Service token rejected — no delegation grant', {
364
364
  component: 'auth',
365
365
  method: 'auth.serviceToken',
366
366
  appId,
@@ -393,7 +393,7 @@ function OxyServicesUtilityMixin(Base) {
393
393
  scopes: Array.isArray(decoded.scopes) ? decoded.scopes : [],
394
394
  };
395
395
  if (debug) {
396
- loggerUtils_1.logger.debug(`[oxy.auth] Service token OK app=${decoded.appName} delegateUser=${oxyUserId || '(none)'}`, {
396
+ logger_1.logger.debug(`[oxy.auth] Service token OK app=${decoded.appName} delegateUser=${oxyUserId || '(none)'}`, {
397
397
  component: 'auth',
398
398
  method: 'auth.serviceToken',
399
399
  });
@@ -470,7 +470,7 @@ function OxyServicesUtilityMixin(Base) {
470
470
  req.user = { id: userId };
471
471
  }
472
472
  if (debug) {
473
- loggerUtils_1.logger.debug(`[oxy.auth] OK user=${userId} session=${decoded.sessionId}`, {
473
+ logger_1.logger.debug(`[oxy.auth] OK user=${userId} session=${decoded.sessionId}`, {
474
474
  component: 'auth',
475
475
  method: 'auth',
476
476
  });
@@ -479,7 +479,7 @@ function OxyServicesUtilityMixin(Base) {
479
479
  }
480
480
  catch (validationError) {
481
481
  if (debug) {
482
- loggerUtils_1.logger.debug('[oxy.auth] Session validation failed', {
482
+ logger_1.logger.debug('[oxy.auth] Session validation failed', {
483
483
  component: 'auth',
484
484
  method: 'auth',
485
485
  }, validationError);
@@ -526,7 +526,7 @@ function OxyServicesUtilityMixin(Base) {
526
526
  // Loading the full user is best-effort here; the basic { id }
527
527
  // object is already attached. Log so misconfigured deployments
528
528
  // can be diagnosed instead of silently failing.
529
- loggerUtils_1.logger.warn('[oxy.auth] loadUser fallback — could not fetch full profile', {
529
+ logger_1.logger.warn('[oxy.auth] loadUser fallback — could not fetch full profile', {
530
530
  component: 'auth',
531
531
  method: 'auth.loadUser',
532
532
  userId,
@@ -534,7 +534,7 @@ function OxyServicesUtilityMixin(Base) {
534
534
  }
535
535
  }
536
536
  if (debug) {
537
- loggerUtils_1.logger.debug(`[oxy.auth] OK user=${userId} (no session)`, {
537
+ logger_1.logger.debug(`[oxy.auth] OK user=${userId} (no session)`, {
538
538
  component: 'auth',
539
539
  method: 'auth',
540
540
  });
@@ -550,7 +550,7 @@ function OxyServicesUtilityMixin(Base) {
550
550
  details: handled.details,
551
551
  };
552
552
  if (debug) {
553
- loggerUtils_1.logger.debug('[oxy.auth] Error', {
553
+ logger_1.logger.debug('[oxy.auth] Error', {
554
554
  component: 'auth',
555
555
  method: 'auth',
556
556
  }, apiError);
@@ -601,7 +601,7 @@ function OxyServicesUtilityMixin(Base) {
601
601
  }
602
602
  catch (decodeError) {
603
603
  if (debug) {
604
- loggerUtils_1.logger.debug('[oxy.authSocket] Token decode failed', {
604
+ logger_1.logger.debug('[oxy.authSocket] Token decode failed', {
605
605
  component: 'auth',
606
606
  method: 'authSocket',
607
607
  }, decodeError);
@@ -641,7 +641,7 @@ function OxyServicesUtilityMixin(Base) {
641
641
  }
642
642
  catch (validateErr) {
643
643
  if (debug) {
644
- loggerUtils_1.logger.debug('[oxy.authSocket] Session validation failed', {
644
+ logger_1.logger.debug('[oxy.authSocket] Session validation failed', {
645
645
  component: 'auth',
646
646
  method: 'authSocket',
647
647
  }, validateErr);
@@ -658,7 +658,7 @@ function OxyServicesUtilityMixin(Base) {
658
658
  socket.data.token = token;
659
659
  socket.user = { id: userId, userId, sessionId: decoded.sessionId };
660
660
  if (debug) {
661
- loggerUtils_1.logger.debug(`[oxy.authSocket] OK user=${userId}`, {
661
+ logger_1.logger.debug(`[oxy.authSocket] OK user=${userId}`, {
662
662
  component: 'auth',
663
663
  method: 'authSocket',
664
664
  });
@@ -667,7 +667,7 @@ function OxyServicesUtilityMixin(Base) {
667
667
  }
668
668
  catch (err) {
669
669
  if (debug) {
670
- loggerUtils_1.logger.debug('[oxy.authSocket] Error', {
670
+ logger_1.logger.debug('[oxy.authSocket] Error', {
671
671
  component: 'auth',
672
672
  method: 'authSocket',
673
673
  }, err);
@@ -752,7 +752,7 @@ function OxyServicesUtilityMixin(Base) {
752
752
  next();
753
753
  return;
754
754
  }
755
- loggerUtils_1.logger.warn('[oxy.auth] Service token missing required scope', {
755
+ logger_1.logger.warn('[oxy.auth] Service token missing required scope', {
756
756
  component: 'auth',
757
757
  method: 'requireScope',
758
758
  appId: req.serviceApp.appId,
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SessionClient = void 0;
4
4
  const contracts_1 = require("@oxyhq/contracts");
5
- const loggerUtils_1 = require("../utils/loggerUtils");
5
+ const logger_1 = require("../logger");
6
6
  const socketLoader_1 = require("./socketLoader");
7
7
  /**
8
8
  * Same-origin `BroadcastChannel` name for instant, network-free session-state
@@ -68,7 +68,7 @@ class SessionClient {
68
68
  listener(payload);
69
69
  }
70
70
  catch (error) {
71
- loggerUtils_1.logger.warn('[SessionClient] server-event listener threw', { component: 'SessionClient' }, error);
71
+ logger_1.logger.warn('[SessionClient] server-event listener threw', { component: 'SessionClient' }, error);
72
72
  }
73
73
  }
74
74
  });
@@ -79,7 +79,7 @@ class SessionClient {
79
79
  listener(this.state);
80
80
  }
81
81
  catch (error) {
82
- loggerUtils_1.logger.error('[SessionClient] subscriber threw', error);
82
+ logger_1.logger.error('[SessionClient] subscriber threw', error);
83
83
  }
84
84
  }
85
85
  }
@@ -87,7 +87,7 @@ class SessionClient {
87
87
  applyState(raw, origin = 'push') {
88
88
  const next = (0, contracts_1.safeParseContract)(contracts_1.deviceSessionStateSchema, raw);
89
89
  if (!next) {
90
- loggerUtils_1.logger.warn('[SessionClient] discarded invalid session state');
90
+ logger_1.logger.warn('[SessionClient] discarded invalid session state');
91
91
  return false;
92
92
  }
93
93
  // The revision is monotone ONLY within a single deviceId. When the incoming
@@ -111,20 +111,20 @@ class SessionClient {
111
111
  this.options.onUnauthenticated(origin);
112
112
  }
113
113
  catch (error) {
114
- loggerUtils_1.logger.error('[SessionClient] onUnauthenticated threw', error);
114
+ logger_1.logger.error('[SessionClient] onUnauthenticated threw', error);
115
115
  }
116
116
  }
117
117
  };
118
118
  if (needsMintBeforeNotify) {
119
119
  void transport.ensureActiveToken(next).then(finishApply).catch((error) => {
120
- loggerUtils_1.logger.warn('[SessionClient] ensureActiveToken failed', { component: 'SessionClient' }, error);
120
+ logger_1.logger.warn('[SessionClient] ensureActiveToken failed', { component: 'SessionClient' }, error);
121
121
  finishApply();
122
122
  });
123
123
  }
124
124
  else {
125
125
  if (transport) {
126
126
  void transport.ensureActiveToken(next).catch((error) => {
127
- loggerUtils_1.logger.warn('[SessionClient] ensureActiveToken failed', { component: 'SessionClient' }, error);
127
+ logger_1.logger.warn('[SessionClient] ensureActiveToken failed', { component: 'SessionClient' }, error);
128
128
  });
129
129
  }
130
130
  finishApply();
@@ -151,7 +151,7 @@ class SessionClient {
151
151
  ? { path: issue.path.join('.'), code: issue.code, expected: issue.expected, received: issue.received }
152
152
  : { path: issue.path.join('.'), code: issue.code });
153
153
  const keys = raw && typeof raw === 'object' ? Object.keys(raw) : [];
154
- loggerUtils_1.logger.warn('[SessionClient] discarded invalid session sync', { component: 'SessionClient', issues, keys });
154
+ logger_1.logger.warn('[SessionClient] discarded invalid session sync', { component: 'SessionClient', issues, keys });
155
155
  return;
156
156
  }
157
157
  // A `sync` is always the response to a direct REST call this client made
@@ -231,7 +231,7 @@ class SessionClient {
231
231
  await this.bootstrap();
232
232
  }
233
233
  catch (error) {
234
- loggerUtils_1.logger.warn('[SessionClient] bootstrap during start failed (non-fatal)', { component: 'SessionClient' }, error);
234
+ logger_1.logger.warn('[SessionClient] bootstrap during start failed (non-fatal)', { component: 'SessionClient' }, error);
235
235
  }
236
236
  }
237
237
  await this.connectSocket();
@@ -248,7 +248,7 @@ class SessionClient {
248
248
  this.channel.close();
249
249
  }
250
250
  catch (error) {
251
- loggerUtils_1.logger.debug('[SessionClient] BroadcastChannel close failed', { component: 'SessionClient' }, error);
251
+ logger_1.logger.debug('[SessionClient] BroadcastChannel close failed', { component: 'SessionClient' }, error);
252
252
  }
253
253
  this.channel = null;
254
254
  }
@@ -264,7 +264,7 @@ class SessionClient {
264
264
  // if THAT yields nothing — only when no factory was injected.
265
265
  const io = this.options.socketFactory ?? (await (0, socketLoader_1.getSocketIO)());
266
266
  if (!io) {
267
- loggerUtils_1.logger.warn('[SessionClient] no socket.io-client; running REST-only (no realtime sync)', { component: 'SessionClient' });
267
+ logger_1.logger.warn('[SessionClient] no socket.io-client; running REST-only (no realtime sync)', { component: 'SessionClient' });
268
268
  return;
269
269
  }
270
270
  if (!this.started)
@@ -307,7 +307,7 @@ class SessionClient {
307
307
  const active = this.state?.activeAccountId ?? null;
308
308
  if (active && active !== this.host.getCurrentAccountId() && this.host.getAccessToken()) {
309
309
  void this.bootstrap().catch((error) => {
310
- loggerUtils_1.logger.warn('[SessionClient] post-push token fetch failed', { component: 'SessionClient' }, error);
310
+ logger_1.logger.warn('[SessionClient] post-push token fetch failed', { component: 'SessionClient' }, error);
311
311
  });
312
312
  }
313
313
  });
@@ -340,7 +340,7 @@ class SessionClient {
340
340
  onSessionAccountsChanged(payload) {
341
341
  const event = (0, contracts_1.safeParseContract)(contracts_1.sessionAccountsChangedEventSchema, payload);
342
342
  if (!event) {
343
- loggerUtils_1.logger.warn('[SessionClient] discarded invalid session_accounts_changed', { component: 'SessionClient' });
343
+ logger_1.logger.warn('[SessionClient] discarded invalid session_accounts_changed', { component: 'SessionClient' });
344
344
  return;
345
345
  }
346
346
  // The socket is in `user:<activeUserId>` for the planted bearer, so this should
@@ -350,7 +350,7 @@ class SessionClient {
350
350
  if (!this.host.getAccessToken())
351
351
  return;
352
352
  void this.bootstrap().catch((error) => {
353
- loggerUtils_1.logger.warn('[SessionClient] session_accounts_changed refetch failed', { component: 'SessionClient' }, error);
353
+ logger_1.logger.warn('[SessionClient] session_accounts_changed refetch failed', { component: 'SessionClient' }, error);
354
354
  });
355
355
  }
356
356
  /**
@@ -371,7 +371,7 @@ class SessionClient {
371
371
  channel = new Ctor(SESSION_BROADCAST_CHANNEL);
372
372
  }
373
373
  catch (error) {
374
- loggerUtils_1.logger.debug('[SessionClient] BroadcastChannel unavailable', { component: 'SessionClient' }, error);
374
+ logger_1.logger.debug('[SessionClient] BroadcastChannel unavailable', { component: 'SessionClient' }, error);
375
375
  return;
376
376
  }
377
377
  channel.onmessage = (event) => {
@@ -384,7 +384,7 @@ class SessionClient {
384
384
  // re-sync does not re-post, so there is no cross-tab ping loop.
385
385
  if (this.host.getAccessToken()) {
386
386
  void this.bootstrap().catch((error) => {
387
- loggerUtils_1.logger.warn('[SessionClient] broadcast re-sync failed', { component: 'SessionClient' }, error);
387
+ logger_1.logger.warn('[SessionClient] broadcast re-sync failed', { component: 'SessionClient' }, error);
388
388
  });
389
389
  }
390
390
  };
@@ -404,7 +404,7 @@ class SessionClient {
404
404
  this.channel.postMessage({ type: 'commit', at: Date.now() });
405
405
  }
406
406
  catch (error) {
407
- loggerUtils_1.logger.debug('[SessionClient] BroadcastChannel post failed', { component: 'SessionClient' }, error);
407
+ logger_1.logger.debug('[SessionClient] BroadcastChannel post failed', { component: 'SessionClient' }, error);
408
408
  }
409
409
  }
410
410
  }
@@ -29,7 +29,7 @@
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.AccountDialogController = void 0;
31
31
  exports.createAccountDialogController = createAccountDialogController;
32
- const loggerUtils_1 = require("../utils/loggerUtils");
32
+ const logger_1 = require("../logger");
33
33
  const errorUtils_1 = require("../utils/errorUtils");
34
34
  const authWebUrl_1 = require("../utils/authWebUrl");
35
35
  const oauthPkce_1 = require("../utils/oauthPkce");
@@ -277,11 +277,11 @@ class AccountDialogController {
277
277
  // malformed) IS unexpected: surface it and warn while keeping the prior graph
278
278
  // so device rows still render.
279
279
  if ((0, errorUtils_1.extractErrorStatus)(error) === 401) {
280
- loggerUtils_1.logger.debug('[AccountDialogController] listAccounts unauthorized (signed out)', { component: 'AccountDialogController' }, error);
280
+ logger_1.logger.debug('[AccountDialogController] listAccounts unauthorized (signed out)', { component: 'AccountDialogController' }, error);
281
281
  }
282
282
  else {
283
283
  this.error = errorMessage(error);
284
- loggerUtils_1.logger.warn('[AccountDialogController] listAccounts failed', { component: 'AccountDialogController' }, error);
284
+ logger_1.logger.warn('[AccountDialogController] listAccounts failed', { component: 'AccountDialogController' }, error);
285
285
  }
286
286
  }
287
287
  if (seq !== this.refreshSeq)
@@ -327,10 +327,10 @@ class AccountDialogController {
327
327
  // OTHER error here is an unexpected total failure worth a warn. Either way keep
328
328
  // the prior profile map.
329
329
  if ((0, errorUtils_1.extractErrorStatus)(error) === 401) {
330
- loggerUtils_1.logger.debug('[AccountDialogController] getUsersByIds unauthorized (signed out)', { component: 'AccountDialogController' }, error);
330
+ logger_1.logger.debug('[AccountDialogController] getUsersByIds unauthorized (signed out)', { component: 'AccountDialogController' }, error);
331
331
  }
332
332
  else {
333
- loggerUtils_1.logger.warn('[AccountDialogController] getUsersByIds failed', { component: 'AccountDialogController' }, error);
333
+ logger_1.logger.warn('[AccountDialogController] getUsersByIds failed', { component: 'AccountDialogController' }, error);
334
334
  }
335
335
  return;
336
336
  }
@@ -419,7 +419,7 @@ class AccountDialogController {
419
419
  catch (error) {
420
420
  // Shared-key mint failed — log and fall through to the QR handoff rather
421
421
  // than dead-ending the sign-in.
422
- loggerUtils_1.logger.warn('[AccountDialogController] signInWithSharedIdentity failed', { component: 'AccountDialogController' }, error);
422
+ logger_1.logger.warn('[AccountDialogController] signInWithSharedIdentity failed', { component: 'AccountDialogController' }, error);
423
423
  }
424
424
  await this.showQr();
425
425
  }
@@ -477,7 +477,7 @@ class AccountDialogController {
477
477
  }
478
478
  }
479
479
  catch (error) {
480
- loggerUtils_1.logger.debug('[AccountDialogController] Commons deep-link probe failed (QR fallback active)', { component: 'AccountDialogController' }, error);
480
+ logger_1.logger.debug('[AccountDialogController] Commons deep-link probe failed (QR fallback active)', { component: 'AccountDialogController' }, error);
481
481
  }
482
482
  }
483
483
  /** Tear down the active sign-in device flow (timers + socket + token) and reset to idle. */
@@ -576,7 +576,7 @@ class AccountDialogController {
576
576
  }
577
577
  catch (error) {
578
578
  // Transient poll error — the next tick retries. Logged, never thrown.
579
- loggerUtils_1.logger.debug('[AccountDialogController] poll error (will retry)', { component: 'AccountDialogController' }, error);
579
+ logger_1.logger.debug('[AccountDialogController] poll error (will retry)', { component: 'AccountDialogController' }, error);
580
580
  }
581
581
  if (this.signInToken === sessionToken) {
582
582
  this.scheduleNextPoll(sessionToken);
@@ -695,7 +695,7 @@ class AccountDialogController {
695
695
  }
696
696
  catch (error) {
697
697
  // Socket unavailable — the fallback poll still completes the flow.
698
- loggerUtils_1.logger.debug('[AccountDialogController] auth-session socket create failed (poll fallback)', { component: 'AccountDialogController' }, error);
698
+ logger_1.logger.debug('[AccountDialogController] auth-session socket create failed (poll fallback)', { component: 'AccountDialogController' }, error);
699
699
  return;
700
700
  }
701
701
  const join = () => {
@@ -705,7 +705,7 @@ class AccountDialogController {
705
705
  socket.emit('join', sessionToken);
706
706
  }
707
707
  catch (error) {
708
- loggerUtils_1.logger.debug('[AccountDialogController] auth-session join failed', { component: 'AccountDialogController' }, error);
708
+ logger_1.logger.debug('[AccountDialogController] auth-session join failed', { component: 'AccountDialogController' }, error);
709
709
  }
710
710
  };
711
711
  socket.on('connect', join);
@@ -731,7 +731,7 @@ class AccountDialogController {
731
731
  socket.disconnect();
732
732
  }
733
733
  catch (error) {
734
- loggerUtils_1.logger.debug('[AccountDialogController] auth-session socket close failed', { component: 'AccountDialogController' }, error);
734
+ logger_1.logger.debug('[AccountDialogController] auth-session socket close failed', { component: 'AccountDialogController' }, error);
735
735
  }
736
736
  }
737
737
  // =========================================================================
@@ -767,7 +767,7 @@ class AccountDialogController {
767
767
  listener(this.snapshot);
768
768
  }
769
769
  catch (error) {
770
- loggerUtils_1.logger.error('[AccountDialogController] subscriber threw', error);
770
+ logger_1.logger.error('[AccountDialogController] subscriber threw', error);
771
771
  }
772
772
  }
773
773
  }
@@ -22,7 +22,7 @@ exports.AUTH_STATE_TOKEN_STORAGE_KEY = exports.AUTH_STATE_STORAGE_KEY = void 0;
22
22
  exports.createMemoryAuthStateStore = createMemoryAuthStateStore;
23
23
  exports.createWebAuthStateStore = createWebAuthStateStore;
24
24
  exports.createNativeAuthStateStore = createNativeAuthStateStore;
25
- const loggerUtils_1 = require("../utils/loggerUtils");
25
+ const logger_1 = require("../logger");
26
26
  /**
27
27
  * Versioned DURABLE storage key. Holds ONLY the small, re-mint-critical fields
28
28
  * (`sessionId`, `userId`, `deviceId`, `deviceSecret`) — never the large JWT
@@ -274,11 +274,11 @@ function createWebAuthStateStore() {
274
274
  storage.setItem(exports.AUTH_STATE_STORAGE_KEY, durableJson);
275
275
  durablePersisted = storage.getItem(exports.AUTH_STATE_STORAGE_KEY) === durableJson;
276
276
  if (!durablePersisted) {
277
- loggerUtils_1.logger.error('[authStateStore] durable credential read-back mismatch after save — the device credential did not persist; the session survives this process via the in-memory mirror but will be lost on reload', undefined, { component: 'authStateStore' });
277
+ logger_1.logger.error('[authStateStore] durable credential read-back mismatch after save — the device credential did not persist; the session survives this process via the in-memory mirror but will be lost on reload', undefined, { component: 'authStateStore' });
278
278
  }
279
279
  }
280
280
  catch (error) {
281
- loggerUtils_1.logger.error('[authStateStore] durable credential persist threw — the device credential did not persist; the session survives this process via the in-memory mirror but will be lost on reload', error, { component: 'authStateStore' });
281
+ logger_1.logger.error('[authStateStore] durable credential persist threw — the device credential did not persist; the session survives this process via the in-memory mirror but will be lost on reload', error, { component: 'authStateStore' });
282
282
  }
283
283
  // Warm token AFTER, best-effort. Its failure is genuinely non-fatal (the
284
284
  // durable credential re-mints a fresh token) and must never abort or
@@ -360,11 +360,11 @@ function createNativeAuthStateStore(storage) {
360
360
  await storage.setItem(exports.AUTH_STATE_STORAGE_KEY, durableJson);
361
361
  durablePersisted = (await storage.getItem(exports.AUTH_STATE_STORAGE_KEY)) === durableJson;
362
362
  if (!durablePersisted) {
363
- loggerUtils_1.logger.error('[authStateStore] durable credential read-back mismatch after save — the device credential did not persist (likely oversize SecureStore value); the session survives this app run via the in-memory mirror but will be lost on cold restart', undefined, { component: 'authStateStore' });
363
+ logger_1.logger.error('[authStateStore] durable credential read-back mismatch after save — the device credential did not persist (likely oversize SecureStore value); the session survives this app run via the in-memory mirror but will be lost on cold restart', undefined, { component: 'authStateStore' });
364
364
  }
365
365
  }
366
366
  catch (error) {
367
- loggerUtils_1.logger.error('[authStateStore] durable credential persist threw — the device credential did not persist; the session survives this app run via the in-memory mirror but will be lost on cold restart', error, { component: 'authStateStore' });
367
+ logger_1.logger.error('[authStateStore] durable credential persist threw — the device credential did not persist; the session survives this app run via the in-memory mirror but will be lost on cold restart', error, { component: 'authStateStore' });
368
368
  }
369
369
  // Warm token AFTER, best-effort. Its failure is genuinely non-fatal (the
370
370
  // durable credential re-mints a fresh token) and must never abort or
@@ -8,7 +8,7 @@ exports.installAuthRefreshHandler = installAuthRefreshHandler;
8
8
  exports.startTokenRefreshScheduler = startTokenRefreshScheduler;
9
9
  const platform_1 = require("../utils/platform");
10
10
  const errorUtils_1 = require("../utils/errorUtils");
11
- const loggerUtils_1 = require("../utils/loggerUtils");
11
+ const logger_1 = require("../logger");
12
12
  /**
13
13
  * Lead time (ms) before access-token expiry at which the proactive scheduler
14
14
  * re-mints. Mirrors `HttpService`'s per-request `TOKEN_REFRESH_LEAD_SECONDS`
@@ -125,14 +125,14 @@ async function refreshPersistedSession(deps) {
125
125
  case 'ok':
126
126
  return arm1.token;
127
127
  case 'transient':
128
- loggerUtils_1.logger.debug('Persisted deviceSecret mint failed (transient) — keeping store', { component: 'refresh', method: 'refreshPersistedSession' });
128
+ logger_1.logger.debug('Persisted deviceSecret mint failed (transient) — keeping store', { component: 'refresh', method: 'refreshPersistedSession' });
129
129
  return null;
130
130
  case 'persist-failed':
131
131
  // The server rotated the secret but it did not durably persist. Do NOT fall
132
132
  // to shared-key and do NOT plant — a later attempt re-mints (the process
133
133
  // mirror still holds the rotated secret the server accepts) and can persist
134
134
  // once storage recovers. Never advertise a session on an unsaved secret.
135
- loggerUtils_1.logger.error('Device-secret mint rotated the secret but it could not be durably persisted — refusing to plant (a later attempt re-mints)', undefined, { component: 'refresh', method: 'refreshPersistedSession' });
135
+ logger_1.logger.error('Device-secret mint rotated the secret but it could not be durably persisted — refusing to plant (a later attempt re-mints)', undefined, { component: 'refresh', method: 'refreshPersistedSession' });
136
136
  return null;
137
137
  case 'invalid-secret':
138
138
  case 'no-session': {
@@ -172,7 +172,7 @@ async function refreshPersistedSession(deps) {
172
172
  }
173
173
  }
174
174
  catch (error) {
175
- loggerUtils_1.logger.debug('Shared-key re-mint fallback failed', { component: 'refresh', method: 'refreshPersistedSession' }, error);
175
+ logger_1.logger.debug('Shared-key re-mint fallback failed', { component: 'refresh', method: 'refreshPersistedSession' }, error);
176
176
  }
177
177
  }
178
178
  return null;
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.getSocketIO = getSocketIO;
37
- const loggerUtils_1 = require("../utils/loggerUtils");
37
+ const logger_1 = require("../logger");
38
38
  let cachedFactory = null;
39
39
  let loadAttempted = false;
40
40
  async function getSocketIO() {
@@ -49,7 +49,7 @@ async function getSocketIO() {
49
49
  return cachedFactory;
50
50
  }
51
51
  catch (error) {
52
- loggerUtils_1.logger.warn('[SessionClient] socket.io-client import failed; realtime session sync disabled', { component: 'SessionClient' }, error);
52
+ logger_1.logger.warn('[SessionClient] socket.io-client import failed; realtime session sync disabled', { component: 'SessionClient' }, error);
53
53
  return null;
54
54
  }
55
55
  }
@@ -15,7 +15,7 @@ exports.createCancellableAsync = createCancellableAsync;
15
15
  exports.withTimeout = withTimeout;
16
16
  exports.withLoadingState = withLoadingState;
17
17
  exports.retryOnError = retryOnError;
18
- const loggerUtils_1 = require("./loggerUtils");
18
+ const logger_1 = require("../logger");
19
19
  /**
20
20
  * Wrapper for async operations with automatic error handling
21
21
  * Returns null on error instead of throwing
@@ -29,7 +29,7 @@ async function withErrorHandling(operation, errorHandler, context) {
29
29
  errorHandler(error);
30
30
  }
31
31
  else {
32
- loggerUtils_1.logger.error(`Error in ${context || 'operation'}`, error instanceof Error ? error : new Error(String(error)), {
32
+ logger_1.logger.error(`Error in ${context || 'operation'}`, error instanceof Error ? error : new Error(String(error)), {
33
33
  component: 'asyncUtils',
34
34
  method: 'withErrorHandling',
35
35
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateAvatarVisibility = updateAvatarVisibility;
4
+ const logger_1 = require("../logger");
4
5
  /**
5
6
  * Updates file visibility to public for avatar use.
6
7
  * Logs non-404 errors to help debug upload issues.
@@ -22,7 +23,7 @@ async function updateAvatarVisibility(fileId, oxyServices, contextName = 'Avatar
22
23
  ? visError.status
23
24
  : undefined;
24
25
  if (status !== 404) {
25
- console.error(`[${contextName}] Failed to update avatar visibility for ${fileId}:`, visError);
26
+ logger_1.logger.error(`[${contextName}] Failed to update avatar visibility for ${fileId}`, visError, { component: contextName });
26
27
  }
27
28
  }
28
29
  }
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceManager = void 0;
4
4
  const protocol_1 = require("@oxyhq/protocol");
5
+ const logger_1 = require("../logger");
6
+ const log = (0, logger_1.createLogger)('DeviceManager');
5
7
  /**
6
8
  * Client-side device management utility
7
9
  * Handles persistent device identification across app sessions
@@ -31,7 +33,7 @@ class DeviceManager {
31
33
  };
32
34
  }
33
35
  catch (error) {
34
- console.error('AsyncStorage not available in React Native:', error);
36
+ log.error('AsyncStorage not available in React Native', error);
35
37
  throw new Error('AsyncStorage is required in React Native environment');
36
38
  }
37
39
  }
@@ -82,7 +84,7 @@ class DeviceManager {
82
84
  return await this.createNewDeviceInfo();
83
85
  }
84
86
  catch (error) {
85
- console.error('Error getting device info:', error);
87
+ log.error('Error getting device info', error);
86
88
  return await this.createNewDeviceInfo();
87
89
  }
88
90
  }
@@ -108,7 +110,7 @@ class DeviceManager {
108
110
  await storage.setItem(this.DEVICE_KEY, JSON.stringify(deviceInfo));
109
111
  }
110
112
  catch (error) {
111
- console.error('Error saving device info:', error);
113
+ log.error('Error saving device info', error);
112
114
  }
113
115
  }
114
116
  /**
@@ -121,7 +123,7 @@ class DeviceManager {
121
123
  await this.saveDeviceInfo(deviceInfo);
122
124
  }
123
125
  catch (error) {
124
- console.error('Error updating device name:', error);
126
+ log.error('Error updating device name', error);
125
127
  }
126
128
  }
127
129
  /**
@@ -133,7 +135,7 @@ class DeviceManager {
133
135
  await storage.removeItem(this.DEVICE_KEY);
134
136
  }
135
137
  catch (error) {
136
- console.error('Error clearing device info:', error);
138
+ log.error('Error clearing device info', error);
137
139
  }
138
140
  }
139
141
  /**
@@ -7,7 +7,7 @@ exports.getErrorCodeFromStatus = getErrorCodeFromStatus;
7
7
  exports.extractErrorStatus = extractErrorStatus;
8
8
  exports.validateRequiredFields = validateRequiredFields;
9
9
  exports.logError = logError;
10
- const loggerUtils_1 = require("./loggerUtils");
10
+ const logger_1 = require("../logger");
11
11
  /**
12
12
  * Error handling utilities for consistent error processing
13
13
  */
@@ -164,14 +164,14 @@ function validateRequiredFields(data, fields) {
164
164
  */
165
165
  function logError(error, context) {
166
166
  if (error instanceof Error) {
167
- loggerUtils_1.logger.error(error.message, {
167
+ logger_1.logger.error(error.message, {
168
168
  component: context || 'errorUtils',
169
169
  method: 'logError',
170
170
  stack: error.stack,
171
171
  });
172
172
  }
173
173
  else {
174
- loggerUtils_1.logger.error(String(error), {
174
+ logger_1.logger.error(String(error), {
175
175
  component: context || 'errorUtils',
176
176
  method: 'logError',
177
177
  });
@@ -27,7 +27,7 @@ exports.persistOAuthHandshake = persistOAuthHandshake;
27
27
  exports.readOAuthHandshake = readOAuthHandshake;
28
28
  exports.clearOAuthHandshake = clearOAuthHandshake;
29
29
  const protocol_1 = require("@oxyhq/protocol");
30
- const loggerUtils_1 = require("./loggerUtils");
30
+ const logger_1 = require("../logger");
31
31
  /** The central Oxy IdP authorization endpoint used by default. */
32
32
  exports.OXY_AUTHORIZE_URL = 'https://auth.oxy.so/authorize';
33
33
  /** Default OAuth scope requested for a "Sign in with Oxy" third-party flow. */
@@ -60,7 +60,7 @@ async function getSecureRandomBytes(byteLength) {
60
60
  return Uint8Array.from(nodeCrypto.randomBytes(byteLength));
61
61
  }
62
62
  catch (error) {
63
- loggerUtils_1.logger.warn('[oxy.oauth] Node crypto unavailable for PKCE random bytes, falling back to Web Crypto', { component: 'oauthPkce' }, error);
63
+ logger_1.logger.warn('[oxy.oauth] Node crypto unavailable for PKCE random bytes, falling back to Web Crypto', { component: 'oauthPkce' }, error);
64
64
  }
65
65
  }
66
66
  const bytes = new Uint8Array(byteLength);
@@ -178,7 +178,7 @@ function persistOAuthHandshake(state, codeVerifier) {
178
178
  return true;
179
179
  }
180
180
  catch (error) {
181
- loggerUtils_1.logger.warn('Could not persist OAuth handshake to sessionStorage', { component: 'oauthPkce' }, error);
181
+ logger_1.logger.warn('Could not persist OAuth handshake to sessionStorage', { component: 'oauthPkce' }, error);
182
182
  return false;
183
183
  }
184
184
  }