@oxyhq/services 5.9.1 → 5.9.3

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 (195) hide show
  1. package/README.md +1 -33
  2. package/lib/commonjs/core/OxyServices.js +159 -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 -1707
  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 -2
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/models/session.js +2 -0
  27. package/lib/{module/types/middleware.js.map → commonjs/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 +153 -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 -1694
  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/{commonjs/types/middleware.js.map → module/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 +64 -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 -657
  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 +168 -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 +26 -1769
  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/models/secureSession.js +0 -2
  187. package/lib/commonjs/models/secureSession.js.map +0 -1
  188. package/lib/commonjs/types/middleware.js +0 -6
  189. package/lib/module/models/secureSession.js +0 -2
  190. package/lib/module/models/secureSession.js.map +0 -1
  191. package/lib/module/types/middleware.js +0 -4
  192. package/lib/typescript/models/secureSession.d.ts.map +0 -1
  193. package/lib/typescript/types/middleware.d.ts +0 -19
  194. package/lib/typescript/types/middleware.d.ts.map +0 -1
  195. package/src/types/middleware.ts +0 -20
@@ -1,662 +1,24 @@
1
- import { OxyConfig, User, Notification, Wallet, Transaction, TransferFundsRequest, PurchaseRequest, WithdrawalRequest, TransactionResponse, KarmaRule, KarmaHistory, KarmaLeaderboardEntry, KarmaAwardRequest, PaymentMethod, PaymentRequest, PaymentResponse, AnalyticsData, FollowerDetails, ContentViewer, FileMetadata, FileUploadResponse, FileListResponse, FileUpdateRequest, FileDeleteResponse, DeviceSession, DeviceSessionLogoutResponse, UpdateDeviceNameResponse } from '../models/interfaces';
2
- import { SecureLoginResponse } from '../models/secureSession';
3
1
  /**
4
- * Default cloud URL for Oxy services, cloud is where the user files are. (e.g. images, videos, etc.). Not the API.
5
- */
6
- export declare const OXY_CLOUD_URL = "https://cloud.oxy.so";
7
- export { DeviceManager } from '../utils/deviceManager';
8
- export type { DeviceFingerprint, StoredDeviceInfo } from '../utils/deviceManager';
9
- /**
10
- * OxyServices - Client library for interacting with the Oxy API
2
+ * OxyServices Core Module - Modular Architecture
11
3
  *
12
- * Note: For authentication status in UI components, use `isAuthenticated` from useOxy() context
13
- * instead of checking token status directly on this service.
4
+ * This module exports the main OxyServices class and all individual service modules
5
+ * for a clean, maintainable, and focused architecture.
14
6
  */
15
- export declare class OxyServices {
16
- private client;
17
- private accessToken;
18
- private refreshToken;
19
- /**
20
- * Creates a new instance of the OxyServices client
21
- * @param config - Configuration for the client
22
- */
23
- constructor(config: OxyConfig);
24
- /**
25
- * Gets the base URL configured for this OxyServices instance
26
- * @returns The base URL
27
- */
28
- getBaseURL(): string;
29
- /**
30
- * Set authentication tokens manually
31
- * @param accessToken - The access token
32
- * @param refreshToken - The refresh token (optional for session-based auth)
33
- */
34
- setTokens(accessToken: string, refreshToken?: string): void;
35
- /**
36
- * Clear stored authentication tokens
37
- */
38
- clearTokens(): void;
39
- /**
40
- * Get the current user ID from the stored token
41
- * @returns User ID or null if not authenticated
42
- */
43
- getCurrentUserId(): string | null;
44
- /**
45
- * Internal method to check if we have an access token
46
- * @private
47
- * @returns Boolean indicating if access token exists
48
- * @internal - Use `isAuthenticated` from useOxy() context in UI components instead
49
- */
50
- private hasAccessToken;
51
- /**
52
- * Validate current access token
53
- * @returns Boolean indicating if the token is valid
54
- */
55
- validate(): Promise<boolean>;
56
- /**
57
- * Get device sessions for a specific session ID
58
- * @param sessionId - The session ID to get device sessions for
59
- * @param deviceId - Optional device ID filter
60
- * @returns Array of device sessions
61
- */
62
- getDeviceSessions(sessionId: string, deviceId?: string): Promise<DeviceSession[]>;
63
- /**
64
- * Logout all device sessions for a specific device
65
- * @param sessionId - The session ID
66
- * @param deviceId - Optional device ID (uses current session's device if not provided)
67
- * @param excludeCurrent - Whether to exclude the current session from logout
68
- * @returns Logout response
69
- */
70
- logoutAllDeviceSessions(sessionId: string, deviceId?: string, excludeCurrent?: boolean): Promise<DeviceSessionLogoutResponse>;
71
- /**
72
- * Update device name for a session
73
- * @param sessionId - The session ID
74
- * @param deviceName - The new device name
75
- * @returns Update response
76
- */
77
- updateDeviceName(sessionId: string, deviceName: string): Promise<UpdateDeviceNameResponse>;
78
- /**
79
- * Fetch profile by username
80
- * @param username - The username to look up
81
- * @returns User profile data
82
- */
83
- getProfileByUsername(username: string): Promise<User>;
84
- /**
85
- * Search profiles
86
- * @param query - Search query string
87
- * @param limit - Maximum number of results to return
88
- * @param offset - Number of results to skip for pagination
89
- * @returns Array of matching user profiles
90
- */
91
- searchProfiles(query: string, limit?: number, offset?: number): Promise<User[]>;
92
- /**
93
- * Get recommended profiles for the authenticated user
94
- * @returns Array of recommended profiles
95
- */
96
- getProfileRecommendations(): Promise<Array<{
97
- id: string;
98
- username: string;
99
- name?: {
100
- first?: string;
101
- last?: string;
102
- full?: string;
103
- };
104
- description?: string;
105
- _count?: {
106
- followers: number;
107
- following: number;
108
- };
109
- [key: string]: any;
110
- }>>;
111
- /**
112
- * Get general user by ID
113
- * @param userId - The user ID to look up
114
- * @returns User data
115
- */
116
- getUserById(userId: string): Promise<User>;
117
- /**
118
- * Get the currently authenticated user's profile
119
- * @returns User data for the current user
120
- */
121
- getCurrentUser(): Promise<User>;
122
- /**
123
- * Update the authenticated user's profile
124
- * @param updates - Object containing fields to update
125
- * @returns Updated user data
126
- */
127
- updateProfile(updates: Record<string, any>): Promise<User>;
128
- /**
129
- * Update user profile (requires auth)
130
- * @param userId - User ID to update (must match authenticated user or have admin rights)
131
- * @param updates - Object containing fields to update
132
- * @returns Updated user data
133
- */
134
- updateUser(userId: string, updates: Record<string, any>): Promise<User>;
135
- /**
136
- * Follow a user
137
- * @param userId - User ID to follow
138
- * @returns Status of the follow operation
139
- */
140
- followUser(userId: string): Promise<{
141
- success: boolean;
142
- message: string;
143
- }>;
144
- /**
145
- * Unfollow a user
146
- * @param userId - User ID to unfollow
147
- * @returns Status of the unfollow operation
148
- */
149
- unfollowUser(userId: string): Promise<{
150
- success: boolean;
151
- message: string;
152
- }>;
153
- /**
154
- * Get follow status for a user
155
- * @param userId - User ID to check follow status for
156
- * @returns Whether the current user is following the specified user
157
- */
158
- getFollowStatus(userId: string): Promise<{
159
- isFollowing: boolean;
160
- }>;
161
- /**
162
- * Get all followers of a user
163
- * @param userId - User ID to get followers for
164
- * @param limit - Maximum number of followers to return
165
- * @param offset - Number of followers to skip for pagination
166
- * @returns Array of users who follow the specified user and pagination info
167
- */
168
- getUserFollowers(userId: string, limit?: number, offset?: number): Promise<{
169
- followers: User[];
170
- total: number;
171
- hasMore: boolean;
172
- }>;
173
- /**
174
- * Get all users that a user is following
175
- * @param userId - User ID to get following list for
176
- * @param limit - Maximum number of users to return
177
- * @param offset - Number of users to skip for pagination
178
- * @returns Array of users the specified user follows and pagination info
179
- */
180
- getUserFollowing(userId: string, limit?: number, offset?: number): Promise<{
181
- following: User[];
182
- total: number;
183
- hasMore: boolean;
184
- }>;
185
- /**
186
- * Fetch all notifications for the authenticated user
187
- * @returns Array of notifications
188
- */
189
- getNotifications(): Promise<Notification[]>;
190
- /**
191
- * Get count of unread notifications
192
- * @returns Number of unread notifications
193
- */
194
- getUnreadCount(): Promise<number>;
195
- /**
196
- * Create a new notification (admin use)
197
- * @param data - Notification data
198
- * @returns Created notification
199
- */
200
- createNotification(data: Partial<Notification>): Promise<Notification>;
201
- /**
202
- * Mark a single notification as read
203
- * @param notificationId - ID of notification to mark as read
204
- */
205
- markNotificationAsRead(notificationId: string): Promise<void>;
206
- /**
207
- * Mark all notifications as read
208
- */
209
- markAllNotificationsAsRead(): Promise<void>;
210
- /**
211
- * Delete a notification
212
- * @param notificationId - ID of notification to delete
213
- */
214
- deleteNotification(notificationId: string): Promise<void>;
215
- /**
216
- * Process a payment
217
- * @param data - Payment data including user ID, plan, and payment method
218
- * @returns Payment result with transaction ID
219
- */
220
- processPayment(data: PaymentRequest): Promise<PaymentResponse>;
221
- /**
222
- * Validate a payment method
223
- * @param paymentMethod - Payment method to validate
224
- * @returns Object indicating if the payment method is valid
225
- */
226
- validatePaymentMethod(paymentMethod: any): Promise<{
227
- valid: boolean;
228
- }>;
229
- /**
230
- * Get saved payment methods for a user
231
- * @param userId - User ID to get payment methods for
232
- * @returns Array of payment methods
233
- */
234
- getPaymentMethods(userId: string): Promise<PaymentMethod[]>;
235
- /**
236
- * Get analytics data
237
- * @param userId - User ID to get analytics for
238
- * @param period - Time period for analytics (e.g., "day", "week", "month")
239
- * @returns Analytics data
240
- */
241
- getAnalytics(userId: string, period?: string): Promise<AnalyticsData>;
242
- /**
243
- * Update analytics (internal use)
244
- * @param userId - User ID to update analytics for
245
- * @param type - Type of analytics to update
246
- * @param data - Analytics data to update
247
- * @returns Message indicating success
248
- */
249
- updateAnalytics(userId: string, type: string, data: Record<string, any>): Promise<{
250
- message: string;
251
- }>;
252
- /**
253
- * Get content viewers analytics
254
- * @param userId - User ID to get viewer data for
255
- * @param period - Time period for analytics
256
- * @returns Array of content viewer data
257
- */
258
- getContentViewers(userId: string, period?: string): Promise<ContentViewer[]>;
259
- /**
260
- * Get follower analytics details
261
- * @param userId - User ID to get follower data for
262
- * @param period - Time period for follower data
263
- * @returns Follower details
264
- */
265
- getFollowerDetails(userId: string, period?: string): Promise<FollowerDetails>;
266
- /**
267
- * Get wallet info
268
- * @param userId - User ID to get wallet for
269
- * @returns Wallet data
270
- */
271
- getWallet(userId: string): Promise<Wallet>;
272
- /**
273
- * Get transaction history
274
- * @param userId - User ID to get transactions for
275
- * @param limit - Maximum number of transactions to return
276
- * @param offset - Number of transactions to skip for pagination
277
- * @returns Array of transactions and pagination info
278
- */
279
- getTransactionHistory(userId: string, limit?: number, offset?: number): Promise<{
280
- transactions: Transaction[];
281
- total: number;
282
- hasMore: boolean;
283
- }>;
284
- /**
285
- * Get a specific transaction
286
- * @param transactionId - ID of transaction to retrieve
287
- * @returns Transaction data
288
- */
289
- getTransaction(transactionId: string): Promise<Transaction>;
290
- /**
291
- * Transfer funds between users
292
- * @param data - Transfer details including source, destination, and amount
293
- * @returns Transaction response
294
- */
295
- transferFunds(data: TransferFundsRequest): Promise<TransactionResponse>;
296
- /**
297
- * Process a purchase
298
- * @param data - Purchase details including user, item, and amount
299
- * @returns Transaction response
300
- */
301
- processPurchase(data: PurchaseRequest): Promise<TransactionResponse>;
302
- /**
303
- * Request a withdrawal
304
- * @param data - Withdrawal details including user, amount, and address
305
- * @returns Transaction response
306
- */
307
- requestWithdrawal(data: WithdrawalRequest): Promise<TransactionResponse>;
308
- /**
309
- * Get karma leaderboard
310
- * @returns Array of karma leaderboard entries
311
- */
312
- getKarmaLeaderboard(): Promise<KarmaLeaderboardEntry[]>;
313
- /**
314
- * Get karma rules
315
- * @returns Array of karma rules
316
- */
317
- getKarmaRules(): Promise<KarmaRule[]>;
318
- /**
319
- * Get total karma for a user
320
- * @param userId - User ID to get karma for
321
- * @returns Object with total karma points
322
- */
323
- getUserKarmaTotal(userId: string): Promise<{
324
- total: number;
325
- }>;
326
- /**
327
- * Get karma history for a user
328
- * @param userId - User ID to get karma history for
329
- * @param limit - Maximum number of history entries to return
330
- * @param offset - Number of entries to skip for pagination
331
- * @returns Karma history entries and pagination info
332
- */
333
- getUserKarmaHistory(userId: string, limit?: number, offset?: number): Promise<{
334
- history: KarmaHistory[];
335
- total: number;
336
- hasMore: boolean;
337
- }>;
338
- /**
339
- * Award karma points to a user
340
- * @param data - Karma award details
341
- * @returns Karma award response
342
- */
343
- awardKarma(data: KarmaAwardRequest): Promise<{
344
- success: boolean;
345
- message: string;
346
- history: KarmaHistory;
347
- }>;
348
- /**
349
- * Deduct karma points from a user
350
- * @param data - Karma deduction details
351
- * @returns Karma deduction response
352
- */
353
- deductKarma(data: KarmaAwardRequest): Promise<{
354
- success: boolean;
355
- message: string;
356
- history: KarmaHistory;
357
- }>;
358
- /**
359
- * Create or update karma rule (admin)
360
- * @param data - Karma rule data
361
- * @returns Created or updated karma rule
362
- */
363
- createOrUpdateKarmaRule(data: Partial<KarmaRule>): Promise<KarmaRule>;
364
- /**
365
- * Upload a file using GridFS
366
- * @param file - The file to upload (File or Blob in browser, Buffer in Node.js)
367
- * @param filename - The name of the file
368
- * @param metadata - Optional metadata to associate with the file
369
- * @returns File metadata including ID and download URL
370
- */
371
- uploadFile(file: File | Blob | any, // Use 'any' to handle Buffer type in cross-platform scenarios
372
- filename: string, metadata?: Record<string, any>): Promise<FileMetadata>;
373
- /**
374
- * Upload multiple files using GridFS
375
- * @param files - Array of files to upload
376
- * @param filenames - Array of filenames (must match files array length)
377
- * @param metadata - Optional metadata to associate with all files
378
- * @returns Array of file metadata
379
- */
380
- uploadFiles(files: (File | Blob | any)[], filenames: string[], metadata?: Record<string, any>): Promise<FileUploadResponse>;
381
- /**
382
- * Get file metadata by ID
383
- * @param fileId - ID of the file to retrieve metadata for
384
- * @returns File metadata
385
- */
386
- getFileMetadata(fileId: string): Promise<FileMetadata>;
387
- /**
388
- * Update file metadata
389
- * @param fileId - ID of the file to update
390
- * @param updates - Metadata updates to apply
391
- * @returns Updated file metadata
392
- */
393
- updateFileMetadata(fileId: string, updates: FileUpdateRequest): Promise<FileMetadata>;
394
- /**
395
- * Delete a file by ID
396
- * @param fileId - ID of the file to delete
397
- * @returns Status of the delete operation
398
- */
399
- deleteFile(fileId: string): Promise<FileDeleteResponse>;
400
- /**
401
- * Get download URL for a file
402
- * @param fileId - ID of the file to get download URL for
403
- * @returns Full URL to download the file
404
- */
405
- getFileDownloadUrl(fileId: string): string;
406
- /**
407
- * Stream a file (useful for playing audio/video without full download)
408
- * @param fileId - ID of the file to stream
409
- * @returns Full URL to stream the file
410
- */
411
- getFileStreamUrl(fileId: string): string;
412
- /**
413
- * List files for a specific user
414
- * @param userId - User ID to list files for
415
- * @param limit - Maximum number of files to return
416
- * @param offset - Number of files to skip for pagination
417
- * @param filters - Optional filters for the file list (e.g., contentType)
418
- * @returns Array of file metadata and pagination info
419
- */
420
- listUserFiles(userId: string, limit?: number, offset?: number, filters?: Record<string, any>): Promise<FileListResponse>;
421
- /**
422
- * Sign up a new user and create a session
423
- * @param username - Desired username
424
- * @param email - User's email address
425
- * @param password - User's password
426
- * @returns Object containing the message, token and user data
427
- */
428
- signUp(username: string, email: string, password: string): Promise<{
429
- message: string;
430
- token: string;
431
- user: User;
432
- }>;
433
- /**
434
- * Secure login that creates a device-based session
435
- * @param username - User's username or email
436
- * @param password - User's password
437
- * @param deviceName - Optional device name
438
- * @param deviceFingerprint - Optional device fingerprint
439
- * @returns Login response with session data
440
- */
441
- secureLogin(username: string, password: string, deviceName?: string, deviceFingerprint?: any): Promise<SecureLoginResponse>;
442
- /**
443
- * Get full user data by session ID
444
- * @param sessionId - The session ID
445
- * @returns Full user data
446
- */
447
- getUserBySession(sessionId: string): Promise<User>;
448
- /**
449
- * Get access token by session ID (for API calls)
450
- * @param sessionId - The session ID
451
- * @returns Access token and expiry info
452
- */
453
- getTokenBySession(sessionId: string): Promise<{
454
- accessToken: string;
455
- expiresAt: string;
456
- }>;
457
- /**
458
- * Get all active sessions for current user
459
- * @param sessionId - Current session ID
460
- * @returns Array of user sessions
461
- */
462
- getSessionsBySessionId(sessionId: string): Promise<any[]>;
463
- /**
464
- * Logout specific session
465
- * @param sessionId - Current session ID
466
- * @param targetSessionId - Optional target session to logout (defaults to current)
467
- */
468
- logoutSecureSession(sessionId: string, targetSessionId?: string): Promise<void>;
469
- /**
470
- * Logout all sessions for current user
471
- * @param sessionId - Current session ID
472
- */
473
- logoutAllSecureSessions(sessionId: string): Promise<void>;
474
- /**
475
- * Validate session
476
- * @param sessionId - The session ID to validate
477
- * @returns Session validation status with user data
478
- */
479
- validateSession(sessionId: string): Promise<{
480
- valid: boolean;
481
- expiresAt: string;
482
- lastActivity: string;
483
- user: User;
484
- }>;
485
- /**
486
- * Validate session using x-session-id header
487
- * @param sessionId - The session ID to validate (sent as header)
488
- * @param deviceFingerprint - Optional device fingerprint for enhanced security
489
- * @returns Session validation status with user data
490
- */
491
- validateSessionFromHeader(sessionId: string, deviceFingerprint?: string): Promise<{
492
- valid: boolean;
493
- expiresAt: string;
494
- lastActivity: string;
495
- user: User;
496
- sessionId?: string;
497
- }>;
498
- /**
499
- * Validate session using automatic header detection
500
- * The validateSession endpoint will automatically read from x-session-id header
501
- * @param sessionId - The session ID to validate (sent as header)
502
- * @param deviceFingerprint - Optional device fingerprint for enhanced security
503
- * @returns Session validation status with user data
504
- */
505
- validateSessionAuto(sessionId: string, deviceFingerprint?: string): Promise<{
506
- valid: boolean;
507
- expiresAt: string;
508
- lastActivity: string;
509
- user: User;
510
- source?: string;
511
- }>;
512
- /**
513
- * Create authentication middleware for Express.js applications
514
- * This is the recommended way to protect routes in server applications
515
- * @returns Express middleware function
516
- */
517
- createAuthMiddleware(): (req: any, res: any, next: any) => Promise<any>;
518
- /**
519
- * Helper method for validating tokens without Express middleware
520
- * Useful for standalone token validation in various contexts
521
- * @param token - The access token to validate
522
- * @returns Object with validation result and user information
523
- */
524
- authenticateToken(token: string): Promise<{
525
- valid: boolean;
526
- userId?: string;
527
- user?: any;
528
- error?: string;
529
- }>;
530
- /**
531
- * Centralized error handling
532
- * @private
533
- * @param error - Error object from API call
534
- * @returns Formatted API error
535
- */
536
- private handleError;
537
- /**
538
- * Check if a username is available
539
- * @param username - The username to check
540
- * @returns Promise with availability status
541
- */
542
- checkUsernameAvailability(username: string): Promise<{
543
- available: boolean;
544
- message: string;
545
- }>;
546
- /**
547
- * Check if an email is available
548
- * @param email - The email to check
549
- * @returns Promise with availability status
550
- */
551
- checkEmailAvailability(email: string): Promise<{
552
- available: boolean;
553
- message: string;
554
- }>;
555
- /**
556
- * Get user profile by username
557
- * @param username - The username to look up
558
- * @returns Promise with user profile
559
- */
560
- getUserProfileByUsername(username: string): Promise<User>;
561
- /**
562
- * Health check endpoint to verify API connectivity
563
- * @returns Health status and basic server info
564
- */
565
- healthCheck(): Promise<{
566
- status: string;
567
- users?: number;
568
- timestamp?: string;
569
- [key: string]: any;
570
- }>;
571
- /**
572
- * Download file content using authenticated request
573
- * @param fileId - The file ID to download
574
- * @returns Response object for further processing
575
- */
576
- downloadFileContent(fileId: string): Promise<Response>;
577
- /**
578
- * Get file content as text using authenticated request
579
- * @param fileId - The file ID to get content for
580
- * @returns File content as string
581
- */
582
- getFileContentAsText(fileId: string): Promise<string>;
583
- /**
584
- * Get file content as blob using authenticated request
585
- * @param fileId - The file ID to get content for
586
- * @returns File content as blob
587
- */
588
- getFileContentAsBlob(fileId: string): Promise<Blob>;
589
- /**
590
- * Fetch metadata for a URL (title, description, image)
591
- * @param url - The URL to fetch metadata for
592
- * @returns Promise with metadata object
593
- */
594
- fetchLinkMetadata(url: string): Promise<{
595
- url: string;
596
- title: string;
597
- description: string;
598
- image?: string;
599
- }>;
600
- /**
601
- * Search for locations using the enhanced location search API
602
- * @param query - Search query string
603
- * @param limit - Maximum number of results (default: 5)
604
- * @param countrycodes - Optional country codes filter (e.g., "us,ca")
605
- * @returns Promise with array of location results
606
- */
607
- searchLocations(query: string, limit?: number, countrycodes?: string): Promise<any[]>;
608
- /**
609
- * Get detailed information about a specific location by coordinates
610
- * @param lat - Latitude
611
- * @param lon - Longitude
612
- * @returns Promise with detailed location information
613
- */
614
- getLocationDetails(lat: number, lon: number): Promise<any>;
615
- /**
616
- * Find locations near a point using geospatial queries
617
- * @param lat - Latitude
618
- * @param lon - Longitude
619
- * @param maxDistance - Maximum distance in meters (default: 10000)
620
- * @param limit - Maximum number of results (default: 10)
621
- * @param skip - Number of results to skip (default: 0)
622
- * @returns Promise with nearby locations
623
- */
624
- findLocationsNear(lat: number, lon: number, maxDistance?: number, limit?: number, skip?: number): Promise<any>;
625
- /**
626
- * Search locations in database by text
627
- * @param query - Search query
628
- * @param limit - Maximum number of results (default: 10)
629
- * @param skip - Number of results to skip (default: 0)
630
- * @param type - Filter by location type
631
- * @param country - Filter by country
632
- * @param city - Filter by city
633
- * @returns Promise with search results
634
- */
635
- searchLocationsInDB(query: string, limit?: number, skip?: number, type?: string, country?: string, city?: string): Promise<any>;
636
- /**
637
- * Get location statistics
638
- * @returns Promise with location statistics
639
- */
640
- getLocationStats(): Promise<any>;
641
- /**
642
- * Get cache statistics
643
- * @returns Promise with cache statistics
644
- */
645
- getLocationCacheStats(): Promise<any>;
646
- /**
647
- * Clear location cache
648
- * @returns Promise with success status
649
- */
650
- clearLocationCache(): Promise<any>;
651
- /**
652
- * Get performance statistics
653
- * @returns Promise with performance statistics
654
- */
655
- getLocationPerformanceStats(): Promise<any>;
656
- }
657
- export default OxyServices;
7
+ export { OxyServicesMain as OxyServices } from './OxyServicesMain';
8
+ export { AuthService } from './auth/AuthService';
9
+ export { UserService } from './users/UserService';
10
+ export { PaymentService } from './payments/PaymentService';
11
+ export { KarmaService } from './karma/KarmaService';
12
+ export { FileService } from './files/FileService';
13
+ export { LocationService } from './locations/LocationService';
14
+ export { AnalyticsService } from './analytics/AnalyticsService';
15
+ export { DeviceService } from './devices/DeviceService';
16
+ export { OxyServices as BaseOxyServices } from './OxyServices';
17
+ export { OXY_CLOUD_URL } from './files/FileService';
658
18
  export * from '../models/interfaces';
659
- export * from '../models/secureSession';
660
- export type { AuthRequest, SimpleAuthRequest } from '../types/middleware';
661
- export declare const createAuthMiddleware: (oxyServices: OxyServices) => (req: any, res: any, next: any) => Promise<any>;
19
+ export * from '../models/session';
20
+ export { DeviceManager } from '../utils/deviceManager';
21
+ export type { DeviceFingerprint, StoredDeviceInfo } from '../utils/deviceManager';
22
+ import { OxyServicesMain } from './OxyServicesMain';
23
+ export default OxyServicesMain;
662
24
  //# sourceMappingURL=index.d.ts.map