@oxyhq/core 10.2.0 → 11.0.0

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 (96) 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 +13 -21
  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 +2 -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/esm/.tsbuildinfo +1 -1
  27. package/dist/esm/boot/sessionColdBoot.js +1 -1
  28. package/dist/esm/crypto/keyManager.js +1 -2
  29. package/dist/esm/crypto/signatureService.js +1 -1
  30. package/dist/esm/index.js +2 -3
  31. package/dist/esm/logger/index.js +140 -0
  32. package/dist/esm/mixins/OxyServices.assets.js +2 -2
  33. package/dist/esm/mixins/OxyServices.auth.js +1 -1
  34. package/dist/esm/mixins/OxyServices.language.js +3 -5
  35. package/dist/esm/mixins/OxyServices.privacy.js +2 -4
  36. package/dist/esm/mixins/OxyServices.security.js +7 -11
  37. package/dist/esm/mixins/OxyServices.topics.js +25 -15
  38. package/dist/esm/mixins/OxyServices.user.js +1 -1
  39. package/dist/esm/mixins/OxyServices.utility.js +1 -1
  40. package/dist/esm/session/SessionClient.js +1 -1
  41. package/dist/esm/session/accountDialogController.js +1 -1
  42. package/dist/esm/session/authStateStore.js +1 -1
  43. package/dist/esm/session/refresh.js +1 -1
  44. package/dist/esm/session/socketLoader.js +1 -1
  45. package/dist/esm/utils/asyncUtils.js +1 -1
  46. package/dist/esm/utils/avatarUtils.js +2 -1
  47. package/dist/esm/utils/deviceManager.js +7 -5
  48. package/dist/esm/utils/errorUtils.js +1 -1
  49. package/dist/esm/utils/oauthPkce.js +1 -1
  50. package/dist/esm/utils/requestUtils.js +1 -1
  51. package/dist/types/.tsbuildinfo +1 -1
  52. package/dist/types/index.d.ts +3 -4
  53. package/dist/types/logger/index.d.ts +104 -0
  54. package/dist/types/mixins/OxyServices.topics.d.ts +3 -3
  55. package/dist/types/models/Topic.d.ts +10 -0
  56. package/dist/types/utils/requestUtils.d.ts +1 -1
  57. package/package.json +16 -1
  58. package/src/boot/sessionColdBoot.ts +1 -1
  59. package/src/crypto/keyManager.ts +1 -2
  60. package/src/crypto/signatureService.ts +1 -1
  61. package/src/index.ts +17 -19
  62. package/src/logger/__tests__/logger.test.ts +207 -0
  63. package/src/logger/index.ts +217 -0
  64. package/src/mixins/OxyServices.assets.ts +3 -3
  65. package/src/mixins/OxyServices.auth.ts +1 -1
  66. package/src/mixins/OxyServices.language.ts +3 -5
  67. package/src/mixins/OxyServices.privacy.ts +2 -4
  68. package/src/mixins/OxyServices.security.ts +7 -11
  69. package/src/mixins/OxyServices.topics.ts +47 -17
  70. package/src/mixins/OxyServices.user.ts +1 -1
  71. package/src/mixins/OxyServices.utility.ts +1 -1
  72. package/src/mixins/__tests__/discoveryErrorHandling.test.ts +1 -1
  73. package/src/mixins/__tests__/topics.test.ts +156 -0
  74. package/src/models/Topic.ts +11 -0
  75. package/src/session/SessionClient.ts +1 -1
  76. package/src/session/__tests__/SessionClient.diagnostics.test.ts +1 -1
  77. package/src/session/__tests__/accountDialogController.test.ts +1 -1
  78. package/src/session/accountDialogController.ts +1 -1
  79. package/src/session/authStateStore.ts +1 -1
  80. package/src/session/refresh.ts +1 -1
  81. package/src/session/socketLoader.ts +1 -1
  82. package/src/utils/asyncUtils.ts +1 -1
  83. package/src/utils/avatarUtils.ts +3 -1
  84. package/src/utils/deviceManager.ts +8 -5
  85. package/src/utils/errorUtils.ts +1 -1
  86. package/src/utils/oauthPkce.ts +1 -1
  87. package/src/utils/requestUtils.ts +1 -1
  88. package/dist/cjs/shared/utils/debugUtils.js +0 -80
  89. package/dist/cjs/utils/loggerUtils.js +0 -126
  90. package/dist/esm/shared/utils/debugUtils.js +0 -72
  91. package/dist/esm/utils/loggerUtils.js +0 -115
  92. package/dist/types/shared/utils/debugUtils.d.ts +0 -48
  93. package/dist/types/utils/loggerUtils.d.ts +0 -48
  94. package/src/shared/utils/__tests__/debugUtils.test.ts +0 -55
  95. package/src/shared/utils/debugUtils.ts +0 -78
  96. package/src/utils/loggerUtils.ts +0 -153
@@ -1,55 +0,0 @@
1
- /**
2
- * Tests for isDev() utility.
3
- *
4
- * These tests manipulate the global __DEV__ and process.env.NODE_ENV
5
- * to verify isDev() works across RN, Node, and browser-like environments.
6
- */
7
-
8
- describe('isDev', () => {
9
- const originalDev = (globalThis as any).__DEV__;
10
- const originalNodeEnv = process.env.NODE_ENV;
11
-
12
- afterEach(() => {
13
- // Restore globals
14
- if (originalDev === undefined) {
15
- delete (globalThis as any).__DEV__;
16
- } else {
17
- (globalThis as any).__DEV__ = originalDev;
18
- }
19
- process.env.NODE_ENV = originalNodeEnv;
20
-
21
- // Clear module cache so isDev re-evaluates
22
- jest.resetModules();
23
- });
24
-
25
- async function loadIsDev() {
26
- const mod = await import('../debugUtils');
27
- return mod.isDev;
28
- }
29
-
30
- it('returns true when __DEV__ is true (React Native)', async () => {
31
- (globalThis as any).__DEV__ = true;
32
- const isDev = await loadIsDev();
33
- expect(isDev()).toBe(true);
34
- });
35
-
36
- it('returns false when __DEV__ is false', async () => {
37
- (globalThis as any).__DEV__ = false;
38
- const isDev = await loadIsDev();
39
- expect(isDev()).toBe(false);
40
- });
41
-
42
- it('falls back to NODE_ENV when __DEV__ is undefined', async () => {
43
- delete (globalThis as any).__DEV__;
44
- process.env.NODE_ENV = 'development';
45
- const isDev = await loadIsDev();
46
- expect(isDev()).toBe(true);
47
- });
48
-
49
- it('returns false when NODE_ENV is production and __DEV__ is undefined', async () => {
50
- delete (globalThis as any).__DEV__;
51
- process.env.NODE_ENV = 'production';
52
- const isDev = await loadIsDev();
53
- expect(isDev()).toBe(false);
54
- });
55
- });
@@ -1,78 +0,0 @@
1
- /**
2
- * Debug Utilities
3
- *
4
- * Provides safe logging functions that only output in development mode.
5
- * All logs are stripped in production builds.
6
- *
7
- * @module shared/utils/debugUtils
8
- */
9
-
10
- /* global __DEV__ */
11
- declare const __DEV__: boolean | undefined;
12
-
13
- /**
14
- * Check if running in development mode
15
- */
16
- export const isDev = (): boolean => {
17
- if (typeof __DEV__ !== 'undefined') return __DEV__;
18
- try {
19
- return typeof process !== 'undefined' && process.env?.NODE_ENV === 'development';
20
- } catch {
21
- return false;
22
- }
23
- };
24
-
25
- /**
26
- * Log a debug message (only in development)
27
- * @param prefix - Log prefix (e.g., '[ColdBoot]')
28
- * @param args - Arguments to log
29
- */
30
- export const debugLog = (prefix: string, ...args: unknown[]): void => {
31
- if (isDev()) {
32
- console.log(prefix, ...args);
33
- }
34
- };
35
-
36
- /**
37
- * Log a debug warning (only in development)
38
- * @param prefix - Log prefix
39
- * @param args - Arguments to log
40
- */
41
- export const debugWarn = (prefix: string, ...args: unknown[]): void => {
42
- if (isDev()) {
43
- console.warn(prefix, ...args);
44
- }
45
- };
46
-
47
- /**
48
- * Log a debug error (only in development)
49
- * @param prefix - Log prefix
50
- * @param args - Arguments to log
51
- */
52
- export const debugError = (prefix: string, ...args: unknown[]): void => {
53
- if (isDev()) {
54
- console.error(prefix, ...args);
55
- }
56
- };
57
-
58
- /**
59
- * Create a namespaced debug logger
60
- * @param namespace - Logger namespace (e.g., 'ColdBoot', 'DeviceAuth')
61
- * @returns Object with log, warn, error methods
62
- *
63
- * @example
64
- * ```ts
65
- * const debug = createDebugLogger('ColdBoot');
66
- * debug.log('Starting authentication');
67
- * debug.warn('Token expires soon');
68
- * debug.error('Authentication failed', error);
69
- * ```
70
- */
71
- export const createDebugLogger = (namespace: string) => {
72
- const prefix = `[${namespace}]`;
73
- return {
74
- log: (...args: unknown[]) => debugLog(prefix, ...args),
75
- warn: (...args: unknown[]) => debugWarn(prefix, ...args),
76
- error: (...args: unknown[]) => debugError(prefix, ...args),
77
- };
78
- };
@@ -1,153 +0,0 @@
1
- /**
2
- * Centralized logging utilities for consistent logging across the application
3
- */
4
-
5
- export enum LogLevel {
6
- DEBUG = 0,
7
- INFO = 1,
8
- WARN = 2,
9
- ERROR = 3,
10
- NONE = 4
11
- }
12
-
13
- export interface LogContext {
14
- component?: string;
15
- method?: string;
16
- userId?: string;
17
- sessionId?: string;
18
- requestId?: string;
19
- [key: string]: unknown;
20
- }
21
-
22
- class Logger {
23
- private level: LogLevel = LogLevel.INFO;
24
- private isDevelopment: boolean = process.env.NODE_ENV === 'development';
25
-
26
- setLevel(level: LogLevel): void {
27
- this.level = level;
28
- }
29
-
30
- private shouldLog(level: LogLevel): boolean {
31
- return level >= this.level;
32
- }
33
-
34
- private formatMessage(level: string, message: string, context?: LogContext): string {
35
- const timestamp = new Date().toISOString();
36
- const contextStr = context ? ` [${Object.entries(context).map(([k, v]) => `${k}:${v}`).join(', ')}]` : '';
37
- return `[${timestamp}] ${level}${contextStr}: ${message}`;
38
- }
39
-
40
- debug(message: string, context?: LogContext, ...args: unknown[]): void {
41
- if (this.shouldLog(LogLevel.DEBUG)) {
42
- const formattedMessage = this.formatMessage('DEBUG', message, context);
43
- if (this.isDevelopment) {
44
- console.log(formattedMessage, ...args);
45
- }
46
- }
47
- }
48
-
49
- info(message: string, context?: LogContext, ...args: unknown[]): void {
50
- if (this.shouldLog(LogLevel.INFO)) {
51
- const formattedMessage = this.formatMessage('INFO', message, context);
52
- console.log(formattedMessage, ...args);
53
- }
54
- }
55
-
56
- warn(message: string, context?: LogContext, ...args: unknown[]): void {
57
- if (this.shouldLog(LogLevel.WARN)) {
58
- const formattedMessage = this.formatMessage('WARN', message, context);
59
- console.warn(formattedMessage, ...args);
60
- }
61
- }
62
-
63
- error(message: string, error?: Error | unknown, context?: LogContext, ...args: unknown[]): void {
64
- if (this.shouldLog(LogLevel.ERROR)) {
65
- const formattedMessage = this.formatMessage('ERROR', message, context);
66
- if (error) {
67
- console.error(formattedMessage, error, ...args);
68
- } else {
69
- console.error(formattedMessage, ...args);
70
- }
71
- }
72
- }
73
-
74
- // Specialized logging methods for common patterns
75
- auth(message: string, context?: LogContext, ...args: unknown[]): void {
76
- this.info(`🔐 ${message}`, { ...context, category: 'auth' }, ...args);
77
- }
78
-
79
- api(message: string, context?: LogContext, ...args: unknown[]): void {
80
- this.info(`🌐 ${message}`, { ...context, category: 'api' }, ...args);
81
- }
82
-
83
- session(message: string, context?: LogContext, ...args: unknown[]): void {
84
- this.info(`📱 ${message}`, { ...context, category: 'session' }, ...args);
85
- }
86
-
87
- user(message: string, context?: LogContext, ...args: unknown[]): void {
88
- this.info(`👤 ${message}`, { ...context, category: 'user' }, ...args);
89
- }
90
-
91
- device(message: string, context?: LogContext, ...args: unknown[]): void {
92
- this.info(`📱 ${message}`, { ...context, category: 'device' }, ...args);
93
- }
94
-
95
- payment(message: string, context?: LogContext, ...args: unknown[]): void {
96
- this.info(`💳 ${message}`, { ...context, category: 'payment' }, ...args);
97
- }
98
-
99
- // Performance logging
100
- performance(operation: string, duration: number, context?: LogContext): void {
101
- const level = duration > 1000 ? LogLevel.WARN : LogLevel.INFO;
102
- const message = `⏱️ ${operation} completed in ${duration}ms`;
103
- if (level === LogLevel.WARN) {
104
- this.warn(message, { ...context, category: 'performance', duration });
105
- } else {
106
- this.info(message, { ...context, category: 'performance', duration });
107
- }
108
- }
109
-
110
- // Error logging with stack trace
111
- errorWithStack(message: string, error: Error, context?: LogContext): void {
112
- this.error(message, error, { ...context, stack: error.stack });
113
- }
114
-
115
- // Group related log messages
116
- group(label: string, fn: () => void): void {
117
- if (this.isDevelopment && this.shouldLog(LogLevel.DEBUG)) {
118
- console.group(label);
119
- fn();
120
- console.groupEnd();
121
- } else {
122
- fn();
123
- }
124
- }
125
- }
126
-
127
- // Create singleton instance
128
- export const logger = new Logger();
129
-
130
- // Convenience functions for common logging patterns
131
- export const logAuth = (message: string, context?: LogContext, ...args: unknown[]) =>
132
- logger.auth(message, context, ...args);
133
-
134
- export const logApi = (message: string, context?: LogContext, ...args: unknown[]) =>
135
- logger.api(message, context, ...args);
136
-
137
- export const logSession = (message: string, context?: LogContext, ...args: unknown[]) =>
138
- logger.session(message, context, ...args);
139
-
140
- export const logUser = (message: string, context?: LogContext, ...args: unknown[]) =>
141
- logger.user(message, context, ...args);
142
-
143
- export const logDevice = (message: string, context?: LogContext, ...args: unknown[]) =>
144
- logger.device(message, context, ...args);
145
-
146
- export const logPayment = (message: string, context?: LogContext, ...args: unknown[]) =>
147
- logger.payment(message, context, ...args);
148
-
149
- export const logError = (message: string, error?: Error | unknown, context?: LogContext, ...args: unknown[]) =>
150
- logger.error(message, error, context, ...args);
151
-
152
- export const logPerformance = (operation: string, duration: number, context?: LogContext) =>
153
- logger.performance(operation, duration, context);