@oxyhq/services 5.9.2 → 5.9.4

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 (202) hide show
  1. package/README.md +1 -33
  2. package/lib/commonjs/core/OxyServices.js +322 -0
  3. package/lib/commonjs/core/OxyServices.js.map +1 -0
  4. package/lib/commonjs/core/OxyServicesMain.js +51 -0
  5. package/lib/commonjs/core/OxyServicesMain.js.map +1 -0
  6. package/lib/commonjs/core/analytics/AnalyticsService.js +67 -0
  7. package/lib/commonjs/core/analytics/AnalyticsService.js.map +1 -0
  8. package/lib/commonjs/core/auth/AuthService.js +526 -0
  9. package/lib/commonjs/core/auth/AuthService.js.map +1 -0
  10. package/lib/commonjs/core/devices/DeviceService.js +61 -0
  11. package/lib/commonjs/core/devices/DeviceService.js.map +1 -0
  12. package/lib/commonjs/core/files/FileService.js +176 -0
  13. package/lib/commonjs/core/files/FileService.js.map +1 -0
  14. package/lib/commonjs/core/index.js +103 -1701
  15. package/lib/commonjs/core/index.js.map +1 -1
  16. package/lib/commonjs/core/karma/KarmaService.js +100 -0
  17. package/lib/commonjs/core/karma/KarmaService.js.map +1 -0
  18. package/lib/commonjs/core/locations/LocationService.js +131 -0
  19. package/lib/commonjs/core/locations/LocationService.js.map +1 -0
  20. package/lib/commonjs/core/payments/PaymentService.js +124 -0
  21. package/lib/commonjs/core/payments/PaymentService.js.map +1 -0
  22. package/lib/commonjs/core/users/UserService.js +234 -0
  23. package/lib/commonjs/core/users/UserService.js.map +1 -0
  24. package/lib/commonjs/index.js +164 -3
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/models/session.js +2 -0
  27. package/lib/commonjs/{types/middleware.js.map → models/session.js.map} +1 -1
  28. package/lib/commonjs/ui/context/OxyContext.js +28 -24
  29. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  30. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +2 -2
  31. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  32. package/lib/commonjs/ui/screens/FileManagementScreen.js +12 -12
  33. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  34. package/lib/commonjs/ui/screens/ProfileScreen.js +2 -2
  35. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  36. package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
  37. package/lib/commonjs/ui/screens/SignInScreen.js +1 -1
  38. package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
  39. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +1 -1
  40. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  41. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
  42. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  43. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +1 -1
  44. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  45. package/lib/commonjs/ui/stores/followStore.js +4 -4
  46. package/lib/commonjs/ui/stores/followStore.js.map +1 -1
  47. package/lib/commonjs/utils/apiUtils.js +93 -0
  48. package/lib/commonjs/utils/apiUtils.js.map +1 -0
  49. package/lib/commonjs/utils/asyncUtils.js +219 -0
  50. package/lib/commonjs/utils/asyncUtils.js.map +1 -0
  51. package/lib/commonjs/utils/errorUtils.js +148 -0
  52. package/lib/commonjs/utils/errorUtils.js.map +1 -0
  53. package/lib/commonjs/utils/hookUtils.js +399 -0
  54. package/lib/commonjs/utils/hookUtils.js.map +1 -0
  55. package/lib/commonjs/utils/loggerUtils.js +160 -0
  56. package/lib/commonjs/utils/loggerUtils.js.map +1 -0
  57. package/lib/commonjs/utils/validationUtils.js +174 -0
  58. package/lib/commonjs/utils/validationUtils.js.map +1 -0
  59. package/lib/module/core/OxyServices.js +316 -0
  60. package/lib/module/core/OxyServices.js.map +1 -0
  61. package/lib/module/core/OxyServicesMain.js +47 -0
  62. package/lib/module/core/OxyServicesMain.js.map +1 -0
  63. package/lib/module/core/analytics/AnalyticsService.js +62 -0
  64. package/lib/module/core/analytics/AnalyticsService.js.map +1 -0
  65. package/lib/module/core/auth/AuthService.js +521 -0
  66. package/lib/module/core/auth/AuthService.js.map +1 -0
  67. package/lib/module/core/devices/DeviceService.js +57 -0
  68. package/lib/module/core/devices/DeviceService.js.map +1 -0
  69. package/lib/module/core/files/FileService.js +171 -0
  70. package/lib/module/core/files/FileService.js.map +1 -0
  71. package/lib/module/core/index.js +25 -1690
  72. package/lib/module/core/index.js.map +1 -1
  73. package/lib/module/core/karma/KarmaService.js +95 -0
  74. package/lib/module/core/karma/KarmaService.js.map +1 -0
  75. package/lib/module/core/locations/LocationService.js +127 -0
  76. package/lib/module/core/locations/LocationService.js.map +1 -0
  77. package/lib/module/core/payments/PaymentService.js +119 -0
  78. package/lib/module/core/payments/PaymentService.js.map +1 -0
  79. package/lib/module/core/users/UserService.js +230 -0
  80. package/lib/module/core/users/UserService.js.map +1 -0
  81. package/lib/module/index.js +8 -4
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/models/session.js +2 -0
  84. package/lib/module/{types/middleware.js.map → models/session.js.map} +1 -1
  85. package/lib/module/ui/context/OxyContext.js +28 -24
  86. package/lib/module/ui/context/OxyContext.js.map +1 -1
  87. package/lib/module/ui/screens/AccountSwitcherScreen.js +2 -2
  88. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  89. package/lib/module/ui/screens/FileManagementScreen.js +12 -12
  90. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  91. package/lib/module/ui/screens/ProfileScreen.js +2 -2
  92. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  93. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  94. package/lib/module/ui/screens/SignInScreen.js +1 -1
  95. package/lib/module/ui/screens/SignInScreen.js.map +1 -1
  96. package/lib/module/ui/screens/karma/KarmaCenterScreen.js +1 -1
  97. package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  98. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
  99. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  100. package/lib/module/ui/screens/karma/KarmaRulesScreen.js +1 -1
  101. package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  102. package/lib/module/ui/stores/followStore.js +4 -4
  103. package/lib/module/ui/stores/followStore.js.map +1 -1
  104. package/lib/module/utils/apiUtils.js +85 -0
  105. package/lib/module/utils/apiUtils.js.map +1 -0
  106. package/lib/module/utils/asyncUtils.js +202 -0
  107. package/lib/module/utils/asyncUtils.js.map +1 -0
  108. package/lib/module/utils/errorUtils.js +139 -0
  109. package/lib/module/utils/errorUtils.js.map +1 -0
  110. package/lib/module/utils/hookUtils.js +381 -0
  111. package/lib/module/utils/hookUtils.js.map +1 -0
  112. package/lib/module/utils/loggerUtils.js +149 -0
  113. package/lib/module/utils/loggerUtils.js.map +1 -0
  114. package/lib/module/utils/validationUtils.js +154 -0
  115. package/lib/module/utils/validationUtils.js.map +1 -0
  116. package/lib/typescript/core/OxyServices.d.ts +99 -0
  117. package/lib/typescript/core/OxyServices.d.ts.map +1 -0
  118. package/lib/typescript/core/OxyServicesMain.d.ts +33 -0
  119. package/lib/typescript/core/OxyServicesMain.d.ts.map +1 -0
  120. package/lib/typescript/core/analytics/AnalyticsService.d.ts +26 -0
  121. package/lib/typescript/core/analytics/AnalyticsService.d.ts.map +1 -0
  122. package/lib/typescript/core/auth/AuthService.d.ts +165 -0
  123. package/lib/typescript/core/auth/AuthService.d.ts.map +1 -0
  124. package/lib/typescript/core/devices/DeviceService.d.ts +20 -0
  125. package/lib/typescript/core/devices/DeviceService.d.ts.map +1 -0
  126. package/lib/typescript/core/files/FileService.d.ts +59 -0
  127. package/lib/typescript/core/files/FileService.d.ts.map +1 -0
  128. package/lib/typescript/core/index.d.ts +19 -656
  129. package/lib/typescript/core/index.d.ts.map +1 -1
  130. package/lib/typescript/core/karma/KarmaService.d.ts +50 -0
  131. package/lib/typescript/core/karma/KarmaService.d.ts.map +1 -0
  132. package/lib/typescript/core/locations/LocationService.d.ts +39 -0
  133. package/lib/typescript/core/locations/LocationService.d.ts.map +1 -0
  134. package/lib/typescript/core/payments/PaymentService.d.ts +50 -0
  135. package/lib/typescript/core/payments/PaymentService.d.ts.map +1 -0
  136. package/lib/typescript/core/users/UserService.d.ts +111 -0
  137. package/lib/typescript/core/users/UserService.d.ts.map +1 -0
  138. package/lib/typescript/index.d.ts +7 -3
  139. package/lib/typescript/index.d.ts.map +1 -1
  140. package/lib/typescript/models/{secureSession.d.ts → session.d.ts} +4 -4
  141. package/lib/typescript/models/session.d.ts.map +1 -0
  142. package/lib/typescript/ui/context/OxyContext.d.ts +2 -2
  143. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  144. package/lib/typescript/utils/apiUtils.d.ts +61 -0
  145. package/lib/typescript/utils/apiUtils.d.ts.map +1 -0
  146. package/lib/typescript/utils/asyncUtils.d.ts +64 -0
  147. package/lib/typescript/utils/asyncUtils.d.ts.map +1 -0
  148. package/lib/typescript/utils/errorUtils.d.ts +45 -0
  149. package/lib/typescript/utils/errorUtils.d.ts.map +1 -0
  150. package/lib/typescript/utils/hookUtils.d.ts +102 -0
  151. package/lib/typescript/utils/hookUtils.d.ts.map +1 -0
  152. package/lib/typescript/utils/loggerUtils.d.ts +49 -0
  153. package/lib/typescript/utils/loggerUtils.d.ts.map +1 -0
  154. package/lib/typescript/utils/validationUtils.d.ts +80 -0
  155. package/lib/typescript/utils/validationUtils.d.ts.map +1 -0
  156. package/package.json +2 -8
  157. package/src/core/OxyServices.ts +351 -0
  158. package/src/core/OxyServicesMain.ts +57 -0
  159. package/src/core/analytics/AnalyticsService.ts +64 -0
  160. package/src/core/auth/AuthService.ts +544 -0
  161. package/src/core/devices/DeviceService.ts +55 -0
  162. package/src/core/files/FileService.ts +194 -0
  163. package/src/core/index.ts +27 -1765
  164. package/src/core/karma/KarmaService.ts +104 -0
  165. package/src/core/locations/LocationService.ts +141 -0
  166. package/src/core/payments/PaymentService.ts +133 -0
  167. package/src/core/users/UserService.ts +241 -0
  168. package/src/index.ts +29 -8
  169. package/src/models/{secureSession.ts → session.ts} +5 -5
  170. package/src/ui/context/OxyContext.tsx +34 -30
  171. package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
  172. package/src/ui/screens/FileManagementScreen.tsx +12 -12
  173. package/src/ui/screens/ProfileScreen.tsx +3 -3
  174. package/src/ui/screens/SessionManagementScreen.tsx +2 -2
  175. package/src/ui/screens/SignInScreen.tsx +1 -1
  176. package/src/ui/screens/karma/KarmaCenterScreen.tsx +2 -2
  177. package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +3 -3
  178. package/src/ui/screens/karma/KarmaRulesScreen.tsx +3 -3
  179. package/src/ui/stores/followStore.ts +4 -4
  180. package/src/utils/apiUtils.ts +102 -0
  181. package/src/utils/asyncUtils.ts +265 -0
  182. package/src/utils/errorUtils.ts +172 -0
  183. package/src/utils/hookUtils.ts +397 -0
  184. package/src/utils/loggerUtils.ts +153 -0
  185. package/src/utils/validationUtils.ts +158 -0
  186. package/lib/commonjs/middleware.js +0 -17
  187. package/lib/commonjs/middleware.js.map +0 -1
  188. package/lib/commonjs/models/secureSession.js +0 -2
  189. package/lib/commonjs/models/secureSession.js.map +0 -1
  190. package/lib/commonjs/types/middleware.js +0 -6
  191. package/lib/module/middleware.js +0 -12
  192. package/lib/module/middleware.js.map +0 -1
  193. package/lib/module/models/secureSession.js +0 -2
  194. package/lib/module/models/secureSession.js.map +0 -1
  195. package/lib/module/types/middleware.js +0 -4
  196. package/lib/typescript/middleware.d.ts +0 -9
  197. package/lib/typescript/middleware.d.ts.map +0 -1
  198. package/lib/typescript/models/secureSession.d.ts.map +0 -1
  199. package/lib/typescript/types/middleware.d.ts +0 -19
  200. package/lib/typescript/types/middleware.d.ts.map +0 -1
  201. package/src/middleware.ts +0 -11
  202. package/src/types/middleware.ts +0 -20
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.USERNAME_REGEX = exports.PASSWORD_REGEX = exports.EMAIL_REGEX = void 0;
7
+ exports.isRequiredBoolean = isRequiredBoolean;
8
+ exports.isRequiredNumber = isRequiredNumber;
9
+ exports.isRequiredString = isRequiredString;
10
+ exports.isValidArray = isValidArray;
11
+ exports.isValidDate = isValidDate;
12
+ exports.isValidEmail = isValidEmail;
13
+ exports.isValidFileSize = isValidFileSize;
14
+ exports.isValidFileType = isValidFileType;
15
+ exports.isValidObject = isValidObject;
16
+ exports.isValidPassword = isValidPassword;
17
+ exports.isValidURL = isValidURL;
18
+ exports.isValidUUID = isValidUUID;
19
+ exports.isValidUsername = isValidUsername;
20
+ exports.sanitizeHTML = sanitizeHTML;
21
+ exports.sanitizeString = sanitizeString;
22
+ exports.validateAndSanitizeUserInput = validateAndSanitizeUserInput;
23
+ /**
24
+ * Validation utilities for common data validation patterns
25
+ */
26
+
27
+ /**
28
+ * Email validation regex
29
+ */
30
+ const EMAIL_REGEX = exports.EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
31
+
32
+ /**
33
+ * Username validation regex (alphanumeric, underscore, dash, 3-30 chars)
34
+ */
35
+ const USERNAME_REGEX = exports.USERNAME_REGEX = /^[a-zA-Z0-9_-]{3,30}$/;
36
+
37
+ /**
38
+ * Password validation regex (at least 8 chars, 1 uppercase, 1 lowercase, 1 number)
39
+ */
40
+ const PASSWORD_REGEX = exports.PASSWORD_REGEX = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d@$!%*?&]{8,}$/;
41
+
42
+ /**
43
+ * Validate email format
44
+ */
45
+ function isValidEmail(email) {
46
+ return EMAIL_REGEX.test(email);
47
+ }
48
+
49
+ /**
50
+ * Validate username format
51
+ */
52
+ function isValidUsername(username) {
53
+ return USERNAME_REGEX.test(username);
54
+ }
55
+
56
+ /**
57
+ * Validate password strength
58
+ */
59
+ function isValidPassword(password) {
60
+ return PASSWORD_REGEX.test(password);
61
+ }
62
+
63
+ /**
64
+ * Validate required string
65
+ */
66
+ function isRequiredString(value) {
67
+ return typeof value === 'string' && value.trim().length > 0;
68
+ }
69
+
70
+ /**
71
+ * Validate required number
72
+ */
73
+ function isRequiredNumber(value) {
74
+ return typeof value === 'number' && !isNaN(value);
75
+ }
76
+
77
+ /**
78
+ * Validate required boolean
79
+ */
80
+ function isRequiredBoolean(value) {
81
+ return typeof value === 'boolean';
82
+ }
83
+
84
+ /**
85
+ * Validate array
86
+ */
87
+ function isValidArray(value) {
88
+ return Array.isArray(value);
89
+ }
90
+
91
+ /**
92
+ * Validate object
93
+ */
94
+ function isValidObject(value) {
95
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
96
+ }
97
+
98
+ /**
99
+ * Validate UUID format
100
+ */
101
+ function isValidUUID(uuid) {
102
+ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
103
+ return UUID_REGEX.test(uuid);
104
+ }
105
+
106
+ /**
107
+ * Validate URL format
108
+ */
109
+ function isValidURL(url) {
110
+ try {
111
+ new URL(url);
112
+ return true;
113
+ } catch {
114
+ return false;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Validate date string
120
+ */
121
+ function isValidDate(dateString) {
122
+ const date = new Date(dateString);
123
+ return !isNaN(date.getTime());
124
+ }
125
+
126
+ /**
127
+ * Validate file size (in bytes)
128
+ */
129
+ function isValidFileSize(size, maxSize) {
130
+ return size > 0 && size <= maxSize;
131
+ }
132
+
133
+ /**
134
+ * Validate file type
135
+ */
136
+ function isValidFileType(filename, allowedTypes) {
137
+ const extension = filename.split('.').pop()?.toLowerCase();
138
+ return extension ? allowedTypes.includes(extension) : false;
139
+ }
140
+
141
+ /**
142
+ * Sanitize string input
143
+ */
144
+ function sanitizeString(input) {
145
+ return input.trim().replace(/[<>]/g, '');
146
+ }
147
+
148
+ /**
149
+ * Sanitize HTML input
150
+ */
151
+ function sanitizeHTML(input) {
152
+ return input.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;');
153
+ }
154
+
155
+ /**
156
+ * Validate and sanitize user input
157
+ */
158
+ function validateAndSanitizeUserInput(input, type) {
159
+ if (typeof input !== 'string') {
160
+ return null;
161
+ }
162
+ const sanitized = sanitizeString(input);
163
+ switch (type) {
164
+ case 'email':
165
+ return isValidEmail(sanitized) ? sanitized : null;
166
+ case 'username':
167
+ return isValidUsername(sanitized) ? sanitized : null;
168
+ case 'string':
169
+ return isRequiredString(sanitized) ? sanitized : null;
170
+ default:
171
+ return null;
172
+ }
173
+ }
174
+ //# sourceMappingURL=validationUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EMAIL_REGEX","exports","USERNAME_REGEX","PASSWORD_REGEX","isValidEmail","email","test","isValidUsername","username","isValidPassword","password","isRequiredString","value","trim","length","isRequiredNumber","isNaN","isRequiredBoolean","isValidArray","Array","isArray","isValidObject","isValidUUID","uuid","UUID_REGEX","isValidURL","url","URL","isValidDate","dateString","date","Date","getTime","isValidFileSize","size","maxSize","isValidFileType","filename","allowedTypes","extension","split","pop","toLowerCase","includes","sanitizeString","input","replace","sanitizeHTML","validateAndSanitizeUserInput","type","sanitized"],"sourceRoot":"../../../src","sources":["utils/validationUtils.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,4BAA4B;;AAEvD;AACA;AACA;AACO,MAAME,cAAc,GAAAD,OAAA,CAAAC,cAAA,GAAG,uBAAuB;;AAErD;AACA;AACA;AACO,MAAMC,cAAc,GAAAF,OAAA,CAAAE,cAAA,GAAG,uDAAuD;;AAErF;AAC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B,OAAO,IAAI;EACb;EAEA,MAAMK,SAAS,GAAGN,cAAc,CAACC,KAAK,CAAC;EAEvC,QAAQI,IAAI;IACV,KAAK,OAAO;MACV,OAAO7C,YAAY,CAAC8C,SAAS,CAAC,GAAGA,SAAS,GAAG,IAAI;IACnD,KAAK,UAAU;MACb,OAAO3C,eAAe,CAAC2C,SAAS,CAAC,GAAGA,SAAS,GAAG,IAAI;IACtD,KAAK,QAAQ;MACX,OAAOvC,gBAAgB,CAACuC,SAAS,CAAC,GAAGA,SAAS,GAAG,IAAI;IACvD;MACE,OAAO,IAAI;EACf;AACF","ignoreList":[]}
@@ -0,0 +1,316 @@
1
+ "use strict";
2
+
3
+ import axios from 'axios';
4
+ import { jwtDecode } from 'jwt-decode';
5
+ import { handleHttpError } from '../utils/errorUtils';
6
+ /**
7
+ * OxyServices - Base client library for interacting with the Oxy API
8
+ *
9
+ * This class provides the core HTTP client setup, token management, and error handling.
10
+ * Specific functionality is delegated to focused service modules.
11
+ */
12
+ export class OxyServices {
13
+ accessToken = null;
14
+ refreshToken = null;
15
+
16
+ /**
17
+ * Creates a new instance of the OxyServices client
18
+ * @param config - Configuration for the client
19
+ */
20
+ constructor(config) {
21
+ this.client = axios.create({
22
+ baseURL: config.baseURL,
23
+ timeout: 10000 // 10 second timeout
24
+ });
25
+ this.setupInterceptors();
26
+ }
27
+
28
+ /**
29
+ * Setup axios interceptors for authentication and error handling
30
+ */
31
+ setupInterceptors() {
32
+ // Request interceptor for adding auth header and handling token refresh
33
+ this.client.interceptors.request.use(async req => {
34
+ if (!this.accessToken) {
35
+ return req;
36
+ }
37
+
38
+ // Check if token is expired and refresh if needed
39
+ try {
40
+ const decoded = jwtDecode(this.accessToken);
41
+ const currentTime = Math.floor(Date.now() / 1000);
42
+
43
+ // If token expires in less than 60 seconds, refresh it
44
+ if (decoded.exp - currentTime < 60) {
45
+ // For session-based tokens, get a new token from the session
46
+ if (decoded.sessionId) {
47
+ try {
48
+ const res = await this.client.get(`/session/token/${decoded.sessionId}`);
49
+ this.accessToken = res.data.accessToken;
50
+ } catch (refreshError) {
51
+ // If refresh fails, clear tokens
52
+ this.clearTokens();
53
+ }
54
+ }
55
+ }
56
+
57
+ // Add authorization header
58
+ req.headers.Authorization = `Bearer ${this.accessToken}`;
59
+ } catch (error) {
60
+ // If token is invalid, clear it
61
+ this.clearTokens();
62
+ }
63
+ return req;
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Get the configured base URL
69
+ */
70
+ getBaseURL() {
71
+ return this.client.defaults.baseURL || '';
72
+ }
73
+
74
+ /**
75
+ * Set authentication tokens
76
+ */
77
+ setTokens(accessToken, refreshToken = '') {
78
+ this.accessToken = accessToken;
79
+ this.refreshToken = refreshToken;
80
+ }
81
+
82
+ /**
83
+ * Clear stored authentication tokens
84
+ */
85
+ clearTokens() {
86
+ this.accessToken = null;
87
+ this.refreshToken = null;
88
+ }
89
+
90
+ /**
91
+ * Get the current user ID from the access token
92
+ */
93
+ getCurrentUserId() {
94
+ if (!this.accessToken) {
95
+ return null;
96
+ }
97
+ try {
98
+ const decoded = jwtDecode(this.accessToken);
99
+ return decoded.userId || decoded.id || null;
100
+ } catch (error) {
101
+ return null;
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Check if the client has a valid access token
107
+ */
108
+ hasAccessToken() {
109
+ return !!this.accessToken;
110
+ }
111
+
112
+ /**
113
+ * Validate the current access token with the server
114
+ */
115
+ async validate() {
116
+ if (!this.hasAccessToken()) {
117
+ return false;
118
+ }
119
+ try {
120
+ const res = await this.client.get('/auth/validate');
121
+ return res.data.valid === true;
122
+ } catch (error) {
123
+ return false;
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Get the HTTP client instance (protected for use by service modules)
129
+ */
130
+ getClient() {
131
+ return this.client;
132
+ }
133
+
134
+ /**
135
+ * Centralized error handling
136
+ */
137
+ handleError(error) {
138
+ return handleHttpError(error);
139
+ }
140
+
141
+ /**
142
+ * Health check endpoint
143
+ */
144
+ async healthCheck() {
145
+ try {
146
+ const res = await this.client.get('/health');
147
+ return res.data;
148
+ } catch (error) {
149
+ throw this.handleError(error);
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Simple Express.js authentication middleware
155
+ *
156
+ * Built-in authentication middleware that validates JWT tokens and adds user data to requests.
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * // Basic usage - just add it to your routes
161
+ * app.use('/api/protected', oxyServices.auth());
162
+ *
163
+ * // With debug logging
164
+ * app.use('/api/protected', oxyServices.auth({ debug: true }));
165
+ *
166
+ * // With custom error handling
167
+ * app.use('/api/protected', oxyServices.auth({
168
+ * onError: (error) => console.error('Auth failed:', error)
169
+ * }));
170
+ *
171
+ * // Load full user data
172
+ * app.use('/api/protected', oxyServices.auth({ loadUser: true }));
173
+ * ```
174
+ *
175
+ * @param options Optional configuration
176
+ * @param options.debug Enable debug logging (default: false)
177
+ * @param options.onError Custom error handler
178
+ * @param options.loadUser Load full user data (default: false for performance)
179
+ * @param options.session Use session-based validation (default: false)
180
+ * @returns Express middleware function
181
+ */
182
+ auth(options = {}) {
183
+ const {
184
+ debug = false,
185
+ onError,
186
+ loadUser = false,
187
+ session = false
188
+ } = options;
189
+ return async (req, res, next) => {
190
+ try {
191
+ // Extract token from Authorization header
192
+ const authHeader = req.headers['authorization'];
193
+ const token = authHeader?.startsWith('Bearer ') ? authHeader.substring(7) : null;
194
+ if (debug) {
195
+ console.log(`🔐 Auth: Processing ${req.method} ${req.path}`);
196
+ console.log(`🔐 Auth: Token present: ${!!token}`);
197
+ }
198
+ if (!token) {
199
+ const error = {
200
+ message: 'Access token required',
201
+ code: 'MISSING_TOKEN',
202
+ status: 401
203
+ };
204
+ if (debug) console.log(`❌ Auth: Missing token`);
205
+ if (onError) return onError(error);
206
+ return res.status(401).json(error);
207
+ }
208
+
209
+ // Decode and validate token
210
+ let decoded;
211
+ try {
212
+ decoded = jwtDecode(token);
213
+ if (debug) {
214
+ console.log(`🔐 Auth: Token decoded, User ID: ${decoded.userId || decoded.id}`);
215
+ }
216
+ } catch (decodeError) {
217
+ const error = {
218
+ message: 'Invalid token format',
219
+ code: 'INVALID_TOKEN_FORMAT',
220
+ status: 403
221
+ };
222
+ if (debug) console.log(`❌ Auth: Token decode failed`);
223
+ if (onError) return onError(error);
224
+ return res.status(403).json(error);
225
+ }
226
+ const userId = decoded.userId || decoded.id;
227
+ if (!userId) {
228
+ const error = {
229
+ message: 'Token missing user ID',
230
+ code: 'INVALID_TOKEN_PAYLOAD',
231
+ status: 403
232
+ };
233
+ if (debug) console.log(`❌ Auth: Token missing user ID`);
234
+ if (onError) return onError(error);
235
+ return res.status(403).json(error);
236
+ }
237
+
238
+ // Check token expiration
239
+ if (decoded.exp && decoded.exp < Math.floor(Date.now() / 1000)) {
240
+ const error = {
241
+ message: 'Token expired',
242
+ code: 'TOKEN_EXPIRED',
243
+ status: 403
244
+ };
245
+ if (debug) console.log(`❌ Auth: Token expired`);
246
+ if (onError) return onError(error);
247
+ return res.status(403).json(error);
248
+ }
249
+
250
+ // Session-based validation if requested
251
+ if (session && decoded.sessionId) {
252
+ try {
253
+ if (debug) console.log(`🔐 Auth: Validating session ${decoded.sessionId}`);
254
+ const sessionRes = await this.client.get(`/session/validate/${decoded.sessionId}`);
255
+ const sessionData = sessionRes.data;
256
+ if (!sessionData.valid) {
257
+ const error = {
258
+ message: 'Invalid session',
259
+ code: 'INVALID_SESSION',
260
+ status: 403
261
+ };
262
+ if (debug) console.log(`❌ Auth: Session validation failed`);
263
+ if (onError) return onError(error);
264
+ return res.status(403).json(error);
265
+ }
266
+ if (debug) console.log(`✅ Auth: Session validation successful`);
267
+ } catch (sessionError) {
268
+ const error = {
269
+ message: 'Session validation failed',
270
+ code: 'SESSION_VALIDATION_ERROR',
271
+ status: 403
272
+ };
273
+ if (debug) console.log(`❌ Auth: Session validation error`);
274
+ if (onError) return onError(error);
275
+ return res.status(403).json(error);
276
+ }
277
+ }
278
+
279
+ // Set request properties
280
+ req.userId = userId;
281
+ req.accessToken = token;
282
+
283
+ // Load user data if requested
284
+ if (loadUser) {
285
+ try {
286
+ const userRes = await this.client.get(`/users/${userId}`);
287
+ req.user = userRes.data;
288
+ } catch (userError) {
289
+ // If user loading fails, just use minimal user data
290
+ req.user = {
291
+ id: userId
292
+ };
293
+ if (debug) console.log(`⚠️ Auth: Failed to load user data, using minimal data`);
294
+ }
295
+ } else {
296
+ // Use minimal user data for performance
297
+ req.user = {
298
+ id: userId
299
+ };
300
+ }
301
+ if (debug) {
302
+ console.log(`✅ Auth: Authentication successful for user ${userId}`);
303
+ }
304
+ next();
305
+ } catch (error) {
306
+ const apiError = this.handleError(error);
307
+ if (debug) {
308
+ console.log(`❌ Auth: Unexpected error:`, apiError);
309
+ }
310
+ if (onError) return onError(apiError);
311
+ return res.status(apiError.status || 500).json(apiError);
312
+ }
313
+ };
314
+ }
315
+ }
316
+ //# sourceMappingURL=OxyServices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["axios","jwtDecode","handleHttpError","OxyServices","accessToken","refreshToken","constructor","config","client","create","baseURL","timeout","setupInterceptors","interceptors","request","use","req","decoded","currentTime","Math","floor","Date","now","exp","sessionId","res","get","data","refreshError","clearTokens","headers","Authorization","error","getBaseURL","defaults","setTokens","getCurrentUserId","userId","id","hasAccessToken","validate","valid","getClient","handleError","healthCheck","auth","options","debug","onError","loadUser","session","next","authHeader","token","startsWith","substring","console","log","method","path","message","code","status","json","decodeError","sessionRes","sessionData","sessionError","userRes","user","userError","apiError"],"sourceRoot":"../../../src","sources":["core/OxyServices.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAqD,OAAO;AACxE,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,eAAe,QAAQ,qBAAqB;AAQrD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,CAAC;EAEfC,WAAW,GAAkB,IAAI;EACjCC,YAAY,GAAkB,IAAI;;EAE1C;AACF;AACA;AACA;EACEC,WAAWA,CAACC,MAAiB,EAAE;IAC7B,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IAAIvB,OAAO,EAAE,OAAOA,OAAO,CAACuB,QAAQ,CAAC;QACrC,OAAO9C,GAAG,CAACqC,MAAM,CAACS,QAAQ,CAACT,MAAM,IAAI,GAAG,CAAC,CAACC,IAAI,CAACQ,QAAQ,CAAC;MAC1D;IACF,CAAC;EACH;AACF","ignoreList":[]}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ import { AuthService } from './auth/AuthService';
4
+ import { UserService } from './users/UserService';
5
+ import { PaymentService } from './payments/PaymentService';
6
+ import { KarmaService } from './karma/KarmaService';
7
+ import { FileService, OXY_CLOUD_URL } from './files/FileService';
8
+ import { LocationService } from './locations/LocationService';
9
+ import { AnalyticsService } from './analytics/AnalyticsService';
10
+ import { DeviceService } from './devices/DeviceService';
11
+
12
+ /**
13
+ * Main OxyServices class that combines all individual services
14
+ *
15
+ * This class provides a unified interface to all Oxy API services while maintaining
16
+ * backward compatibility with the original monolithic structure.
17
+ */
18
+ export class OxyServicesMain extends AuthService {
19
+ // Service instances
20
+
21
+ constructor(config) {
22
+ super(config);
23
+
24
+ // Initialize all service instances
25
+ this.users = new UserService(config);
26
+ this.payments = new PaymentService(config);
27
+ this.karma = new KarmaService(config);
28
+ this.files = new FileService(config);
29
+ this.locations = new LocationService(config);
30
+ this.analytics = new AnalyticsService(config);
31
+ this.devices = new DeviceService(config);
32
+ }
33
+
34
+ // Re-export OXY_CLOUD_URL for convenience
35
+ static OXY_CLOUD_URL = OXY_CLOUD_URL;
36
+
37
+ // Additional utility methods that span multiple services
38
+ async fetchLinkMetadata(url) {
39
+ try {
40
+ const res = await this.getClient().get(`/link-metadata?url=${encodeURIComponent(url)}`);
41
+ return res.data;
42
+ } catch (error) {
43
+ throw this.handleError(error);
44
+ }
45
+ }
46
+ }
47
+ //# sourceMappingURL=OxyServicesMain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AuthService","UserService","PaymentService","KarmaService","FileService","OXY_CLOUD_URL","LocationService","AnalyticsService","DeviceService","OxyServicesMain","constructor","config","users","payments","karma","files","locations","analytics","devices","fetchLinkMetadata","url","res","getClient","get","encodeURIComponent","data","error","handleError"],"sourceRoot":"../../../src","sources":["core/OxyServicesMain.ts"],"mappings":";;AACA,SAASA,WAAW,QAAQ,oBAAoB;AAChD,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,cAAc,QAAQ,2BAA2B;AAC1D,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,WAAW,EAAEC,aAAa,QAAQ,qBAAqB;AAChE,SAASC,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,SAASC,aAAa,QAAQ,yBAAyB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,SAAST,WAAW,CAAC;EAC/C;;EASAU,WAAWA,CAACC,MAAiB,EAAE;IAC7B,KAAK,CAACA,MAAM,CAAC;;IAEb;IACA,IAAI,CAACC,KAAK,GAAG,IAAIX,WAAW,CAACU,MAAM,CAAC;IACpC,IAAI,CAACE,QAAQ,GAAG,IAAIX,cAAc,CAACS,MAAM,CAAC;IAC1C,IAAI,CAACG,KAAK,GAAG,IAAIX,YAAY,CAACQ,MAAM,CAAC;IACrC,IAAI,CAACI,KAAK,GAAG,IAAIX,WAAW,CAACO,MAAM,CAAC;IACpC,IAAI,CAACK,SAAS,GAAG,IAAIV,eAAe,CAACK,MAAM,CAAC;IAC5C,IAAI,CAACM,SAAS,GAAG,IAAIV,gBAAgB,CAACI,MAAM,CAAC;IAC7C,IAAI,CAACO,OAAO,GAAG,IAAIV,aAAa,CAACG,MAAM,CAAC;EAC1C;;EAEA;EACA,OAAgBN,aAAa,GAAGA,aAAa;;EAE7C;EACA,MAAMc,iBAAiBA,CAACC,GAAW,EAKhC;IACD,IAAI;MACF,MAAMC,GAAG,GAAG,MAAM,IAAI,CAACC,SAAS,CAAC,CAAC,CAACC,GAAG,CAAC,sBAAsBC,kBAAkB,CAACJ,GAAG,CAAC,EAAE,CAAC;MACvF,OAAOC,GAAG,CAACI,IAAI;IACjB,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;IAC/B;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ import { OxyServices } from '../OxyServices';
4
+ /**
5
+ * Analytics service for handling analytics and content viewer operations
6
+ */
7
+ export class AnalyticsService extends OxyServices {
8
+ /**
9
+ * Get analytics data for user
10
+ */
11
+ async getAnalytics(userId, period) {
12
+ try {
13
+ const params = new URLSearchParams();
14
+ if (period) params.append('period', period);
15
+ const res = await this.getClient().get(`/analytics/users/${userId}?${params.toString()}`);
16
+ return res.data;
17
+ } catch (error) {
18
+ throw this.handleError(error);
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Update analytics data
24
+ */
25
+ async updateAnalytics(userId, type, data) {
26
+ try {
27
+ const res = await this.getClient().put(`/analytics/users/${userId}/${type}`, data);
28
+ return res.data;
29
+ } catch (error) {
30
+ throw this.handleError(error);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Get content viewers for user
36
+ */
37
+ async getContentViewers(userId, period) {
38
+ try {
39
+ const params = new URLSearchParams();
40
+ if (period) params.append('period', period);
41
+ const res = await this.getClient().get(`/analytics/users/${userId}/viewers?${params.toString()}`);
42
+ return res.data;
43
+ } catch (error) {
44
+ throw this.handleError(error);
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Get follower details for user
50
+ */
51
+ async getFollowerDetails(userId, period) {
52
+ try {
53
+ const params = new URLSearchParams();
54
+ if (period) params.append('period', period);
55
+ const res = await this.getClient().get(`/analytics/users/${userId}/followers?${params.toString()}`);
56
+ return res.data;
57
+ } catch (error) {
58
+ throw this.handleError(error);
59
+ }
60
+ }
61
+ }
62
+ //# sourceMappingURL=AnalyticsService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OxyServices","AnalyticsService","getAnalytics","userId","period","params","URLSearchParams","append","res","getClient","get","toString","data","error","handleError","updateAnalytics","type","put","getContentViewers","getFollowerDetails"],"sourceRoot":"../../../../src","sources":["core/analytics/AnalyticsService.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAG5C;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,SAASD,WAAW,CAAC;EAChD;AACF;AACA;EACE,MAAME,YAAYA,CAACC,MAAc,EAAEC,MAAe,EAA0B;IAC1E,IAAI;MACF,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAAC,CAAC;MACpC,IAAIF,MAAM,EAAEC,MAAM,CAACE,MAAM,CAAC,QAAQ,EAAEH,MAAM,CAAC;MAE3C,MAAMI,GAAG,GAAG,MAAM,IAAI,CAACC,SAAS,CAAC,CAAC,CAACC,GAAG,CAAC,oBAAoBP,MAAM,IAAIE,MAAM,CAACM,QAAQ,CAAC,CAAC,EAAE,CAAC;MACzF,OAAOH,GAAG,CAACI,IAAI;IACjB,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;IAC/B;EACF;;EAEA;AACF;AACA;EACE,MAAME,eAAeA,CAACZ,MAAc,EAAEa,IAAY,EAAEJ,IAAyB,EAAgC;IAC3G,IAAI;MACF,MAAMJ,GAAG,GAAG,MAAM,IAAI,CAACC,SAAS,CAAC,CAAC,CAACQ,GAAG,CAAC,oBAAoBd,MAAM,IAAIa,IAAI,EAAE,EAAEJ,IAAI,CAAC;MAClF,OAAOJ,GAAG,CAACI,IAAI;IACjB,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;IAC/B;EACF;;EAEA;AACF;AACA;EACE,MAAMK,iBAAiBA,CAACf,MAAc,EAAEC,MAAe,EAA4B;IACjF,IAAI;MACF,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAAC,CAAC;MACpC,IAAIF,MAAM,EAAEC,MAAM,CAACE,MAAM,CAA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