@oxyhq/services 5.13.15 → 5.13.17

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 (138) hide show
  1. package/README.md +10 -0
  2. package/lib/commonjs/core/OxyServices.base.js +271 -0
  3. package/lib/commonjs/core/OxyServices.base.js.map +1 -0
  4. package/lib/commonjs/core/OxyServices.errors.js +26 -0
  5. package/lib/commonjs/core/OxyServices.errors.js.map +1 -0
  6. package/lib/commonjs/core/OxyServices.js +58 -2168
  7. package/lib/commonjs/core/OxyServices.js.map +1 -1
  8. package/lib/commonjs/core/mixins/OxyServices.analytics.js +60 -0
  9. package/lib/commonjs/core/mixins/OxyServices.analytics.js.map +1 -0
  10. package/lib/commonjs/core/mixins/OxyServices.assets.js +424 -0
  11. package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -0
  12. package/lib/commonjs/core/mixins/OxyServices.auth.js +303 -0
  13. package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -0
  14. package/lib/commonjs/core/mixins/OxyServices.developer.js +115 -0
  15. package/lib/commonjs/core/mixins/OxyServices.developer.js.map +1 -0
  16. package/lib/commonjs/core/mixins/OxyServices.devices.js +119 -0
  17. package/lib/commonjs/core/mixins/OxyServices.devices.js.map +1 -0
  18. package/lib/commonjs/core/mixins/OxyServices.karma.js +117 -0
  19. package/lib/commonjs/core/mixins/OxyServices.karma.js.map +1 -0
  20. package/lib/commonjs/core/mixins/OxyServices.language.js +124 -0
  21. package/lib/commonjs/core/mixins/OxyServices.language.js.map +1 -0
  22. package/lib/commonjs/core/mixins/OxyServices.location.js +55 -0
  23. package/lib/commonjs/core/mixins/OxyServices.location.js.map +1 -0
  24. package/lib/commonjs/core/mixins/OxyServices.payment.js +66 -0
  25. package/lib/commonjs/core/mixins/OxyServices.payment.js.map +1 -0
  26. package/lib/commonjs/core/mixins/OxyServices.privacy.js +174 -0
  27. package/lib/commonjs/core/mixins/OxyServices.privacy.js.map +1 -0
  28. package/lib/commonjs/core/mixins/OxyServices.totp.js +53 -0
  29. package/lib/commonjs/core/mixins/OxyServices.totp.js.map +1 -0
  30. package/lib/commonjs/core/mixins/OxyServices.user.js +388 -0
  31. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -0
  32. package/lib/commonjs/core/mixins/OxyServices.utility.js +161 -0
  33. package/lib/commonjs/core/mixins/OxyServices.utility.js.map +1 -0
  34. package/lib/commonjs/core/mixins/index.js +39 -0
  35. package/lib/commonjs/core/mixins/index.js.map +1 -0
  36. package/lib/commonjs/core/mixins/mixinHelpers.js +62 -0
  37. package/lib/commonjs/core/mixins/mixinHelpers.js.map +1 -0
  38. package/lib/commonjs/ui/context/OxyContext.js +27 -2
  39. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  40. package/lib/module/core/OxyServices.base.js +265 -0
  41. package/lib/module/core/OxyServices.base.js.map +1 -0
  42. package/lib/module/core/OxyServices.errors.js +20 -0
  43. package/lib/module/core/OxyServices.errors.js.map +1 -0
  44. package/lib/module/core/OxyServices.js +43 -2164
  45. package/lib/module/core/OxyServices.js.map +1 -1
  46. package/lib/module/core/mixins/OxyServices.analytics.js +56 -0
  47. package/lib/module/core/mixins/OxyServices.analytics.js.map +1 -0
  48. package/lib/module/core/mixins/OxyServices.assets.js +420 -0
  49. package/lib/module/core/mixins/OxyServices.assets.js.map +1 -0
  50. package/lib/module/core/mixins/OxyServices.auth.js +299 -0
  51. package/lib/module/core/mixins/OxyServices.auth.js.map +1 -0
  52. package/lib/module/core/mixins/OxyServices.developer.js +111 -0
  53. package/lib/module/core/mixins/OxyServices.developer.js.map +1 -0
  54. package/lib/module/core/mixins/OxyServices.devices.js +115 -0
  55. package/lib/module/core/mixins/OxyServices.devices.js.map +1 -0
  56. package/lib/module/core/mixins/OxyServices.karma.js +113 -0
  57. package/lib/module/core/mixins/OxyServices.karma.js.map +1 -0
  58. package/lib/module/core/mixins/OxyServices.language.js +120 -0
  59. package/lib/module/core/mixins/OxyServices.language.js.map +1 -0
  60. package/lib/module/core/mixins/OxyServices.location.js +51 -0
  61. package/lib/module/core/mixins/OxyServices.location.js.map +1 -0
  62. package/lib/module/core/mixins/OxyServices.payment.js +62 -0
  63. package/lib/module/core/mixins/OxyServices.payment.js.map +1 -0
  64. package/lib/module/core/mixins/OxyServices.privacy.js +170 -0
  65. package/lib/module/core/mixins/OxyServices.privacy.js.map +1 -0
  66. package/lib/module/core/mixins/OxyServices.totp.js +49 -0
  67. package/lib/module/core/mixins/OxyServices.totp.js.map +1 -0
  68. package/lib/module/core/mixins/OxyServices.user.js +384 -0
  69. package/lib/module/core/mixins/OxyServices.user.js.map +1 -0
  70. package/lib/module/core/mixins/OxyServices.utility.js +156 -0
  71. package/lib/module/core/mixins/OxyServices.utility.js.map +1 -0
  72. package/lib/module/core/mixins/index.js +36 -0
  73. package/lib/module/core/mixins/index.js.map +1 -0
  74. package/lib/module/core/mixins/mixinHelpers.js +56 -0
  75. package/lib/module/core/mixins/mixinHelpers.js.map +1 -0
  76. package/lib/module/ui/context/OxyContext.js +27 -2
  77. package/lib/module/ui/context/OxyContext.js.map +1 -1
  78. package/lib/typescript/core/OxyServices.base.d.ts +123 -0
  79. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -0
  80. package/lib/typescript/core/OxyServices.d.ts +970 -746
  81. package/lib/typescript/core/OxyServices.d.ts.map +1 -1
  82. package/lib/typescript/core/OxyServices.errors.d.ts +12 -0
  83. package/lib/typescript/core/OxyServices.errors.d.ts.map +1 -0
  84. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts +70 -0
  85. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -0
  86. package/lib/typescript/core/mixins/OxyServices.assets.d.ts +166 -0
  87. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -0
  88. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +168 -0
  89. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -0
  90. package/lib/typescript/core/mixins/OxyServices.developer.d.ts +103 -0
  91. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -0
  92. package/lib/typescript/core/mixins/OxyServices.devices.d.ts +93 -0
  93. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -0
  94. package/lib/typescript/core/mixins/OxyServices.karma.d.ts +89 -0
  95. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -0
  96. package/lib/typescript/core/mixins/OxyServices.language.d.ts +85 -0
  97. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -0
  98. package/lib/typescript/core/mixins/OxyServices.location.d.ts +68 -0
  99. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -0
  100. package/lib/typescript/core/mixins/OxyServices.payment.d.ts +74 -0
  101. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -0
  102. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts +126 -0
  103. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -0
  104. package/lib/typescript/core/mixins/OxyServices.totp.d.ts +69 -0
  105. package/lib/typescript/core/mixins/OxyServices.totp.d.ts.map +1 -0
  106. package/lib/typescript/core/mixins/OxyServices.user.d.ts +189 -0
  107. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -0
  108. package/lib/typescript/core/mixins/OxyServices.utility.d.ts +97 -0
  109. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -0
  110. package/lib/typescript/core/mixins/index.d.ts +899 -0
  111. package/lib/typescript/core/mixins/index.d.ts.map +1 -0
  112. package/lib/typescript/core/mixins/mixinHelpers.d.ts +32 -0
  113. package/lib/typescript/core/mixins/mixinHelpers.d.ts.map +1 -0
  114. package/lib/typescript/models/interfaces.d.ts +10 -0
  115. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  116. package/lib/typescript/ui/context/OxyContext.d.ts +2 -0
  117. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  118. package/package.json +1 -1
  119. package/src/core/OxyServices.base.ts +311 -0
  120. package/src/core/OxyServices.errors.ts +26 -0
  121. package/src/core/OxyServices.ts +43 -2199
  122. package/src/core/mixins/OxyServices.analytics.ts +53 -0
  123. package/src/core/mixins/OxyServices.assets.ts +410 -0
  124. package/src/core/mixins/OxyServices.auth.ts +275 -0
  125. package/src/core/mixins/OxyServices.developer.ts +114 -0
  126. package/src/core/mixins/OxyServices.devices.ts +103 -0
  127. package/src/core/mixins/OxyServices.karma.ts +111 -0
  128. package/src/core/mixins/OxyServices.language.ts +127 -0
  129. package/src/core/mixins/OxyServices.location.ts +46 -0
  130. package/src/core/mixins/OxyServices.payment.ts +59 -0
  131. package/src/core/mixins/OxyServices.privacy.ts +182 -0
  132. package/src/core/mixins/OxyServices.totp.ts +36 -0
  133. package/src/core/mixins/OxyServices.user.ts +384 -0
  134. package/src/core/mixins/OxyServices.utility.ts +187 -0
  135. package/src/core/mixins/index.ts +58 -0
  136. package/src/core/mixins/mixinHelpers.ts +69 -0
  137. package/src/models/interfaces.ts +12 -0
  138. package/src/ui/context/OxyContext.tsx +36 -0
@@ -1,761 +1,985 @@
1
- import type { OxyConfig as OxyConfigBase, ApiError, User, Notification, AssetInitResponse, AssetUrlResponse, AssetVariant, BlockedUser, RestrictedUser } from '../models/interfaces';
2
- import type { LanguageMetadata } from '../utils/languageUtils';
3
1
  /**
4
- * OxyConfig - Configuration for OxyServices
5
- * @property baseURL - The Oxy API base URL (e.g., https://api.oxy.so)
6
- * @property cloudURL - The Oxy Cloud (file storage/CDN) URL (e.g., https://cloud.oxy.so)
7
- */
8
- export interface OxyConfig extends OxyConfigBase {
9
- cloudURL?: string;
10
- }
11
- import type { SessionLoginResponse } from '../models/session';
12
- import { type PaginationParams } from '../utils/apiUtils';
13
- import { HttpClient } from './HttpClient';
14
- /**
15
- * Custom error types for better error handling
2
+ * OxyServices - Unified client for Oxy API and Oxy Cloud
3
+ *
4
+ * # Usage Examples
5
+ *
6
+ * ## Browser (ESM/TypeScript)
7
+ *
8
+ * ```typescript
9
+ * import { OxyServices } from './core/OxyServices';
10
+ *
11
+ * const oxy = new OxyServices({
12
+ * baseURL: 'https://api.oxy.so',
13
+ * cloudURL: 'https://cloud.oxy.so',
14
+ * });
15
+ *
16
+ * // Authenticate and fetch user
17
+ * await oxy.setTokens('ACCESS_TOKEN');
18
+ * const user = await oxy.getCurrentUser();
19
+ *
20
+ * // Upload a file (browser File API)
21
+ * const fileInput = document.querySelector('input[type=file]');
22
+ * const file = fileInput.files[0];
23
+ * await oxy.uploadRawFile(file);
24
+ *
25
+ * // Get a file stream URL for <img src>
26
+ * const url = oxy.getFileStreamUrl('fileId');
27
+ * ```
28
+ *
29
+ * ## Node.js (CommonJS/TypeScript)
30
+ *
31
+ * ```typescript
32
+ * import { OxyServices } from './core/OxyServices';
33
+ * import fs from 'fs';
34
+ *
35
+ * const oxy = new OxyServices({
36
+ * baseURL: 'https://api.oxy.so',
37
+ * cloudURL: 'https://cloud.oxy.so',
38
+ * });
39
+ *
40
+ * // Authenticate and fetch user
41
+ * await oxy.setTokens('ACCESS_TOKEN');
42
+ * const user = await oxy.getCurrentUser();
43
+ *
44
+ * // Upload a file (Node.js Buffer)
45
+ * const buffer = fs.readFileSync('myfile.png');
46
+ * const blob = new Blob([buffer]);
47
+ * await oxy.uploadRawFile(blob, { filename: 'myfile.png' });
48
+ *
49
+ * // Get a file download URL
50
+ * const url = oxy.getFileDownloadUrl('fileId');
51
+ * ```
52
+ *
53
+ * ## Configuration
54
+ * - `baseURL`: Oxy API endpoint (e.g., https://api.oxy.so)
55
+ * - `cloudURL`: Oxy Cloud/CDN endpoint (e.g., https://cloud.oxy.so)
56
+ *
57
+ * See method JSDoc for more details and options.
16
58
  */
17
- export declare class OxyAuthenticationError extends Error {
18
- readonly code: string;
19
- readonly status: number;
20
- constructor(message: string, code?: string, status?: number);
21
- }
22
- export declare class OxyAuthenticationTimeoutError extends OxyAuthenticationError {
23
- constructor(operationName: string, timeoutMs: number);
24
- }
59
+ import { OxyServicesBase, type OxyConfig } from './OxyServices.base';
60
+ import { OxyAuthenticationError, OxyAuthenticationTimeoutError } from './OxyServices.errors';
25
61
  /**
26
62
  * OxyServices - Unified client library for interacting with the Oxy API
27
63
  *
28
64
  * This class provides all API functionality in one simple, easy-to-use interface.
29
- * Architecture:
30
- * - HttpClient: Handles HTTP communication and authentication
31
- * - RequestManager: Handles caching, deduplication, queuing, and retry
32
- * - OxyServices: Provides high-level API methods
65
+ *
66
+ * ## Architecture
67
+ * - **HttpClient**: Handles HTTP communication and authentication
68
+ * - **RequestManager**: Handles caching, deduplication, queuing, and retry
69
+ * - **OxyServices**: Provides high-level API methods
70
+ *
71
+ * ## Mixin Composition
72
+ * The class is composed using TypeScript mixins for better code organization:
73
+ * - **Base**: Core infrastructure (HTTP client, request management, error handling)
74
+ * - **Auth**: Authentication and session management
75
+ * - **User**: User profiles, follow, notifications
76
+ * - **TOTP**: Two-factor authentication enrollment
77
+ * - **Privacy**: Blocked and restricted users
78
+ * - **Language**: Language detection and metadata
79
+ * - **Payment**: Payment processing
80
+ * - **Karma**: Karma system
81
+ * - **Assets**: File upload and asset management
82
+ * - **Developer**: Developer API management
83
+ * - **Location**: Location-based features
84
+ * - **Analytics**: Analytics tracking
85
+ * - **Devices**: Device management
86
+ * - **Utility**: Utility methods and Express middleware
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * const oxy = new OxyServices({
91
+ * baseURL: 'https://api.oxy.so',
92
+ * cloudURL: 'https://cloud.oxy.so'
93
+ * });
94
+ * ```
33
95
  */
34
- export declare class OxyServices {
35
- private httpClient;
36
- private requestManager;
37
- private cloudURL;
38
- private config;
39
- /**
40
- * Creates a new instance of the OxyServices client
41
- * @param config - Configuration for the client
42
- * config.baseURL: Oxy API URL (e.g., https://api.oxy.so)
43
- * config.cloudURL: Oxy Cloud URL (e.g., https://cloud.oxy.so)
44
- */
45
- constructor(config: OxyConfig);
46
- static __resetTokensForTests(): void;
47
- /**
48
- * Make a request with all performance optimizations
49
- * This is the main method for all API calls - ensures authentication and performance features
50
- */
51
- private makeRequest;
52
- /**
53
- * Get the configured Oxy API base URL
54
- */
55
- getBaseURL(): string;
56
- /**
57
- * Get the HTTP client instance
58
- * Useful for advanced use cases where direct access to the HTTP client is needed
59
- */
60
- getClient(): HttpClient;
61
- /**
62
- * Get performance metrics
63
- */
64
- getMetrics(): {
65
- totalRequests: number;
66
- successfulRequests: number;
67
- failedRequests: number;
68
- cacheHits: number;
69
- cacheMisses: number;
70
- averageResponseTime: number;
96
+ declare const OxyServicesComposed: {
97
+ new (...args: any[]): {
98
+ fetchLinkMetadata(url: string): Promise<{
99
+ url: string;
100
+ title: string;
101
+ description: string;
102
+ image?: string;
103
+ }>;
104
+ auth(options?: {
105
+ debug?: boolean;
106
+ onError?: ((error: import(".").ApiError) => any) | undefined;
107
+ loadUser?: boolean;
108
+ session?: boolean;
109
+ }): (req: any, res: any, next: any) => any;
110
+ httpClient: import("./HttpClient").HttpClient;
111
+ requestManager: import("./RequestManager").RequestManager;
112
+ cloudURL: string;
113
+ config: OxyConfig;
114
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
115
+ getBaseURL(): string;
116
+ getClient(): import("./HttpClient").HttpClient;
117
+ getMetrics(): {
118
+ totalRequests: number;
119
+ successfulRequests: number;
120
+ failedRequests: number;
121
+ cacheHits: number;
122
+ cacheMisses: number;
123
+ averageResponseTime: number;
124
+ };
125
+ clearCache(): void;
126
+ clearCacheEntry(key: string): void;
127
+ getCacheStats(): {
128
+ size: number;
129
+ hits: number;
130
+ misses: number;
131
+ hitRate: number;
132
+ };
133
+ getCloudURL(): string;
134
+ setTokens(accessToken: string, refreshToken?: string): void;
135
+ clearTokens(): void;
136
+ getCurrentUserId(): string | null;
137
+ hasValidToken(): boolean;
138
+ getAccessToken(): string | null;
139
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
140
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
141
+ hasAccessToken(): boolean;
142
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
143
+ maxRetries?: number;
144
+ retryDelay?: number;
145
+ authTimeoutMs?: number;
146
+ }): Promise<T>;
147
+ validate(): Promise<boolean>;
148
+ handleError(error: any): Error;
149
+ healthCheck(): Promise<{
150
+ status: string;
151
+ users?: number;
152
+ timestamp?: string;
153
+ [key: string]: any;
154
+ }>;
155
+ };
156
+ __resetTokensForTests(): void;
157
+ } & {
158
+ new (...args: any[]): {
159
+ registerDevice(deviceData: any): Promise<any>;
160
+ getUserDevices(): Promise<any[]>;
161
+ removeDevice(deviceId: string): Promise<void>;
162
+ getDeviceSessions(sessionId: string): Promise<any[]>;
163
+ logoutAllDeviceSessions(sessionId: string, deviceId?: string, excludeCurrent?: boolean): Promise<any>;
164
+ updateDeviceName(sessionId: string, deviceName: string): Promise<any>;
165
+ httpClient: import("./HttpClient").HttpClient;
166
+ requestManager: import("./RequestManager").RequestManager;
167
+ cloudURL: string;
168
+ config: OxyConfig;
169
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
170
+ getBaseURL(): string;
171
+ getClient(): import("./HttpClient").HttpClient;
172
+ getMetrics(): {
173
+ totalRequests: number;
174
+ successfulRequests: number;
175
+ failedRequests: number;
176
+ cacheHits: number;
177
+ cacheMisses: number;
178
+ averageResponseTime: number;
179
+ };
180
+ clearCache(): void;
181
+ clearCacheEntry(key: string): void;
182
+ getCacheStats(): {
183
+ size: number;
184
+ hits: number;
185
+ misses: number;
186
+ hitRate: number;
187
+ };
188
+ getCloudURL(): string;
189
+ setTokens(accessToken: string, refreshToken?: string): void;
190
+ clearTokens(): void;
191
+ getCurrentUserId(): string | null;
192
+ hasValidToken(): boolean;
193
+ getAccessToken(): string | null;
194
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
195
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
196
+ hasAccessToken(): boolean;
197
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
198
+ maxRetries?: number;
199
+ retryDelay?: number;
200
+ authTimeoutMs?: number;
201
+ }): Promise<T>;
202
+ validate(): Promise<boolean>;
203
+ handleError(error: any): Error;
204
+ healthCheck(): Promise<{
205
+ status: string;
206
+ users?: number;
207
+ timestamp?: string;
208
+ [key: string]: any;
209
+ }>;
210
+ };
211
+ __resetTokensForTests(): void;
212
+ } & {
213
+ new (...args: any[]): {
214
+ trackEvent(eventName: string, properties?: Record<string, any>): Promise<void>;
215
+ getAnalytics(startDate?: string, endDate?: string): Promise<any>;
216
+ httpClient: import("./HttpClient").HttpClient;
217
+ requestManager: import("./RequestManager").RequestManager;
218
+ cloudURL: string;
219
+ config: OxyConfig;
220
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
221
+ getBaseURL(): string;
222
+ getClient(): import("./HttpClient").HttpClient;
223
+ getMetrics(): {
224
+ totalRequests: number;
225
+ successfulRequests: number;
226
+ failedRequests: number;
227
+ cacheHits: number;
228
+ cacheMisses: number;
229
+ averageResponseTime: number;
230
+ };
231
+ clearCache(): void;
232
+ clearCacheEntry(key: string): void;
233
+ getCacheStats(): {
234
+ size: number;
235
+ hits: number;
236
+ misses: number;
237
+ hitRate: number;
238
+ };
239
+ getCloudURL(): string;
240
+ setTokens(accessToken: string, refreshToken?: string): void;
241
+ clearTokens(): void;
242
+ getCurrentUserId(): string | null;
243
+ hasValidToken(): boolean;
244
+ getAccessToken(): string | null;
245
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
246
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
247
+ hasAccessToken(): boolean;
248
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
249
+ maxRetries?: number;
250
+ retryDelay?: number;
251
+ authTimeoutMs?: number;
252
+ }): Promise<T>;
253
+ validate(): Promise<boolean>;
254
+ handleError(error: any): Error;
255
+ healthCheck(): Promise<{
256
+ status: string;
257
+ users?: number;
258
+ timestamp?: string;
259
+ [key: string]: any;
260
+ }>;
261
+ };
262
+ __resetTokensForTests(): void;
263
+ } & {
264
+ new (...args: any[]): {
265
+ updateLocation(latitude: number, longitude: number): Promise<any>;
266
+ getNearbyUsers(radius?: number): Promise<any[]>;
267
+ httpClient: import("./HttpClient").HttpClient;
268
+ requestManager: import("./RequestManager").RequestManager;
269
+ cloudURL: string;
270
+ config: OxyConfig;
271
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
272
+ getBaseURL(): string;
273
+ getClient(): import("./HttpClient").HttpClient;
274
+ getMetrics(): {
275
+ totalRequests: number;
276
+ successfulRequests: number;
277
+ failedRequests: number;
278
+ cacheHits: number;
279
+ cacheMisses: number;
280
+ averageResponseTime: number;
281
+ };
282
+ clearCache(): void;
283
+ clearCacheEntry(key: string): void;
284
+ getCacheStats(): {
285
+ size: number;
286
+ hits: number;
287
+ misses: number;
288
+ hitRate: number;
289
+ };
290
+ getCloudURL(): string;
291
+ setTokens(accessToken: string, refreshToken?: string): void;
292
+ clearTokens(): void;
293
+ getCurrentUserId(): string | null;
294
+ hasValidToken(): boolean;
295
+ getAccessToken(): string | null;
296
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
297
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
298
+ hasAccessToken(): boolean;
299
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
300
+ maxRetries?: number;
301
+ retryDelay?: number;
302
+ authTimeoutMs?: number;
303
+ }): Promise<T>;
304
+ validate(): Promise<boolean>;
305
+ handleError(error: any): Error;
306
+ healthCheck(): Promise<{
307
+ status: string;
308
+ users?: number;
309
+ timestamp?: string;
310
+ [key: string]: any;
311
+ }>;
312
+ };
313
+ __resetTokensForTests(): void;
314
+ } & {
315
+ new (...args: any[]): {
316
+ getDeveloperApps(): Promise<any[]>;
317
+ createDeveloperApp(data: {
318
+ name: string;
319
+ description?: string;
320
+ webhookUrl: string;
321
+ devWebhookUrl?: string;
322
+ scopes?: string[];
323
+ }): Promise<any>;
324
+ getDeveloperApp(appId: string): Promise<any>;
325
+ updateDeveloperApp(appId: string, data: {
326
+ name?: string;
327
+ description?: string;
328
+ webhookUrl?: string;
329
+ devWebhookUrl?: string;
330
+ scopes?: string[];
331
+ }): Promise<any>;
332
+ regenerateDeveloperAppSecret(appId: string): Promise<any>;
333
+ deleteDeveloperApp(appId: string): Promise<any>;
334
+ httpClient: import("./HttpClient").HttpClient;
335
+ requestManager: import("./RequestManager").RequestManager;
336
+ cloudURL: string;
337
+ config: OxyConfig;
338
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
339
+ getBaseURL(): string;
340
+ getClient(): import("./HttpClient").HttpClient;
341
+ getMetrics(): {
342
+ totalRequests: number;
343
+ successfulRequests: number;
344
+ failedRequests: number;
345
+ cacheHits: number;
346
+ cacheMisses: number;
347
+ averageResponseTime: number;
348
+ };
349
+ clearCache(): void;
350
+ clearCacheEntry(key: string): void;
351
+ getCacheStats(): {
352
+ size: number;
353
+ hits: number;
354
+ misses: number;
355
+ hitRate: number;
356
+ };
357
+ getCloudURL(): string;
358
+ setTokens(accessToken: string, refreshToken?: string): void;
359
+ clearTokens(): void;
360
+ getCurrentUserId(): string | null;
361
+ hasValidToken(): boolean;
362
+ getAccessToken(): string | null;
363
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
364
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
365
+ hasAccessToken(): boolean;
366
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
367
+ maxRetries?: number;
368
+ retryDelay?: number;
369
+ authTimeoutMs?: number;
370
+ }): Promise<T>;
371
+ validate(): Promise<boolean>;
372
+ handleError(error: any): Error;
373
+ healthCheck(): Promise<{
374
+ status: string;
375
+ users?: number;
376
+ timestamp?: string;
377
+ [key: string]: any;
378
+ }>;
379
+ };
380
+ __resetTokensForTests(): void;
381
+ } & {
382
+ new (...args: any[]): {
383
+ deleteFile(fileId: string): Promise<any>;
384
+ getFileDownloadUrl(fileId: string, variant?: string, expiresIn?: number): string;
385
+ getFileDownloadUrlAsync(fileId: string, variant?: string, expiresIn?: number): Promise<string>;
386
+ getFileStreamUrl(fileId: string): string;
387
+ listUserFiles(limit?: number, offset?: number): Promise<{
388
+ files: any[];
389
+ total: number;
390
+ hasMore: boolean;
391
+ }>;
392
+ getFileContentAsText(fileId: string, variant?: string): Promise<string>;
393
+ getFileContentAsBlob(fileId: string, variant?: string): Promise<Blob>;
394
+ uploadRawFile(file: File | Blob, visibility?: "private" | "public" | "unlisted", metadata?: Record<string, any>): Promise<any>;
395
+ calculateSHA256(file: File | Blob): Promise<string>;
396
+ assetInit(sha256: string, size: number, mime: string): Promise<import(".").AssetInitResponse>;
397
+ assetComplete(fileId: string, originalName: string, size: number, mime: string, visibility?: "private" | "public" | "unlisted", metadata?: Record<string, any>): Promise<any>;
398
+ assetUpload(file: File, visibility?: "private" | "public" | "unlisted", metadata?: Record<string, any>, onProgress?: ((progress: number) => void) | undefined): Promise<any>;
399
+ uploadToPresignedUrl(url: string, file: File, onProgress?: ((progress: number) => void) | undefined): Promise<void>;
400
+ assetLink(fileId: string, app: string, entityType: string, entityId: string, visibility?: "private" | "public" | "unlisted", webhookUrl?: string): Promise<any>;
401
+ assetUnlink(fileId: string, app: string, entityType: string, entityId: string): Promise<any>;
402
+ assetGet(fileId: string): Promise<any>;
403
+ assetGetUrl(fileId: string, variant?: string, expiresIn?: number): Promise<import(".").AssetUrlResponse>;
404
+ assetRestore(fileId: string): Promise<any>;
405
+ assetDelete(fileId: string, force?: boolean): Promise<any>;
406
+ assetGetVariants(fileId: string): Promise<import(".").AssetVariant[]>;
407
+ assetUpdateVisibility(fileId: string, visibility: "private" | "public" | "unlisted"): Promise<any>;
408
+ uploadAvatar(file: File, userId: string, app?: string): Promise<any>;
409
+ uploadProfileBanner(file: File, userId: string, app?: string): Promise<any>;
410
+ httpClient: import("./HttpClient").HttpClient;
411
+ requestManager: import("./RequestManager").RequestManager;
412
+ cloudURL: string;
413
+ config: OxyConfig;
414
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
415
+ getBaseURL(): string;
416
+ getClient(): import("./HttpClient").HttpClient;
417
+ getMetrics(): {
418
+ totalRequests: number;
419
+ successfulRequests: number;
420
+ failedRequests: number;
421
+ cacheHits: number;
422
+ cacheMisses: number;
423
+ averageResponseTime: number;
424
+ };
425
+ clearCache(): void;
426
+ clearCacheEntry(key: string): void;
427
+ getCacheStats(): {
428
+ size: number;
429
+ hits: number;
430
+ misses: number;
431
+ hitRate: number;
432
+ };
433
+ getCloudURL(): string;
434
+ setTokens(accessToken: string, refreshToken?: string): void;
435
+ clearTokens(): void;
436
+ getCurrentUserId(): string | null;
437
+ hasValidToken(): boolean;
438
+ getAccessToken(): string | null;
439
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
440
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
441
+ hasAccessToken(): boolean;
442
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
443
+ maxRetries?: number;
444
+ retryDelay?: number;
445
+ authTimeoutMs?: number;
446
+ }): Promise<T>;
447
+ validate(): Promise<boolean>;
448
+ handleError(error: any): Error;
449
+ healthCheck(): Promise<{
450
+ status: string;
451
+ users?: number;
452
+ timestamp?: string;
453
+ [key: string]: any;
454
+ }>;
455
+ };
456
+ __resetTokensForTests(): void;
457
+ } & {
458
+ new (...args: any[]): {
459
+ getUserKarma(userId: string): Promise<any>;
460
+ giveKarma(userId: string, amount: number, reason?: string): Promise<any>;
461
+ getUserKarmaTotal(userId: string): Promise<any>;
462
+ getUserKarmaHistory(userId: string, limit?: number, offset?: number): Promise<any>;
463
+ getKarmaLeaderboard(): Promise<any>;
464
+ getKarmaRules(): Promise<any>;
465
+ httpClient: import("./HttpClient").HttpClient;
466
+ requestManager: import("./RequestManager").RequestManager;
467
+ cloudURL: string;
468
+ config: OxyConfig;
469
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
470
+ getBaseURL(): string;
471
+ getClient(): import("./HttpClient").HttpClient;
472
+ getMetrics(): {
473
+ totalRequests: number;
474
+ successfulRequests: number;
475
+ failedRequests: number;
476
+ cacheHits: number;
477
+ cacheMisses: number;
478
+ averageResponseTime: number;
479
+ };
480
+ clearCache(): void;
481
+ clearCacheEntry(key: string): void;
482
+ getCacheStats(): {
483
+ size: number;
484
+ hits: number;
485
+ misses: number;
486
+ hitRate: number;
487
+ };
488
+ getCloudURL(): string;
489
+ setTokens(accessToken: string, refreshToken?: string): void;
490
+ clearTokens(): void;
491
+ getCurrentUserId(): string | null;
492
+ hasValidToken(): boolean;
493
+ getAccessToken(): string | null;
494
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
495
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
496
+ hasAccessToken(): boolean;
497
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
498
+ maxRetries?: number;
499
+ retryDelay?: number;
500
+ authTimeoutMs?: number;
501
+ }): Promise<T>;
502
+ validate(): Promise<boolean>;
503
+ handleError(error: any): Error;
504
+ healthCheck(): Promise<{
505
+ status: string;
506
+ users?: number;
507
+ timestamp?: string;
508
+ [key: string]: any;
509
+ }>;
510
+ };
511
+ __resetTokensForTests(): void;
512
+ } & {
513
+ new (...args: any[]): {
514
+ createPayment(data: any): Promise<any>;
515
+ getPayment(paymentId: string): Promise<any>;
516
+ getUserPayments(): Promise<any[]>;
517
+ httpClient: import("./HttpClient").HttpClient;
518
+ requestManager: import("./RequestManager").RequestManager;
519
+ cloudURL: string;
520
+ config: OxyConfig;
521
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
522
+ getBaseURL(): string;
523
+ getClient(): import("./HttpClient").HttpClient;
524
+ getMetrics(): {
525
+ totalRequests: number;
526
+ successfulRequests: number;
527
+ failedRequests: number;
528
+ cacheHits: number;
529
+ cacheMisses: number;
530
+ averageResponseTime: number;
531
+ };
532
+ clearCache(): void;
533
+ clearCacheEntry(key: string): void;
534
+ getCacheStats(): {
535
+ size: number;
536
+ hits: number;
537
+ misses: number;
538
+ hitRate: number;
539
+ };
540
+ getCloudURL(): string;
541
+ setTokens(accessToken: string, refreshToken?: string): void;
542
+ clearTokens(): void;
543
+ getCurrentUserId(): string | null;
544
+ hasValidToken(): boolean;
545
+ getAccessToken(): string | null;
546
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
547
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
548
+ hasAccessToken(): boolean;
549
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
550
+ maxRetries?: number;
551
+ retryDelay?: number;
552
+ authTimeoutMs?: number;
553
+ }): Promise<T>;
554
+ validate(): Promise<boolean>;
555
+ handleError(error: any): Error;
556
+ healthCheck(): Promise<{
557
+ status: string;
558
+ users?: number;
559
+ timestamp?: string;
560
+ [key: string]: any;
561
+ }>;
562
+ };
563
+ __resetTokensForTests(): void;
564
+ } & {
565
+ new (...args: any[]): {
566
+ getStorage(): Promise<{
567
+ getItem: (key: string) => Promise<string | null>;
568
+ setItem: (key: string, value: string) => Promise<void>;
569
+ removeItem: (key: string) => Promise<void>;
570
+ }>;
571
+ getCurrentLanguage(storageKeyPrefix?: string): Promise<string | null>;
572
+ getCurrentLanguageMetadata(storageKeyPrefix?: string): Promise<import(".").LanguageMetadata | null>;
573
+ getCurrentLanguageName(storageKeyPrefix?: string): Promise<string | null>;
574
+ getCurrentNativeLanguageName(storageKeyPrefix?: string): Promise<string | null>;
575
+ httpClient: import("./HttpClient").HttpClient;
576
+ requestManager: import("./RequestManager").RequestManager;
577
+ cloudURL: string;
578
+ config: OxyConfig;
579
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
580
+ getBaseURL(): string;
581
+ getClient(): import("./HttpClient").HttpClient;
582
+ getMetrics(): {
583
+ totalRequests: number;
584
+ successfulRequests: number;
585
+ failedRequests: number;
586
+ cacheHits: number;
587
+ cacheMisses: number;
588
+ averageResponseTime: number;
589
+ };
590
+ clearCache(): void;
591
+ clearCacheEntry(key: string): void;
592
+ getCacheStats(): {
593
+ size: number;
594
+ hits: number;
595
+ misses: number;
596
+ hitRate: number;
597
+ };
598
+ getCloudURL(): string;
599
+ setTokens(accessToken: string, refreshToken?: string): void;
600
+ clearTokens(): void;
601
+ getCurrentUserId(): string | null;
602
+ hasValidToken(): boolean;
603
+ getAccessToken(): string | null;
604
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
605
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
606
+ hasAccessToken(): boolean;
607
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
608
+ maxRetries?: number;
609
+ retryDelay?: number;
610
+ authTimeoutMs?: number;
611
+ }): Promise<T>;
612
+ validate(): Promise<boolean>;
613
+ handleError(error: any): Error;
614
+ healthCheck(): Promise<{
615
+ status: string;
616
+ users?: number;
617
+ timestamp?: string;
618
+ [key: string]: any;
619
+ }>;
71
620
  };
72
- /**
73
- * Clear request cache
74
- */
75
- clearCache(): void;
76
- /**
77
- * Clear specific cache entry
78
- */
79
- clearCacheEntry(key: string): void;
80
- /**
81
- * Get cache statistics
82
- */
83
- getCacheStats(): {
84
- size: number;
85
- hits: number;
86
- misses: number;
87
- hitRate: number;
621
+ __resetTokensForTests(): void;
622
+ } & {
623
+ new (...args: any[]): {
624
+ extractUserId(userIdField: string | {
625
+ _id: string;
626
+ username?: string;
627
+ avatar?: string;
628
+ }): string;
629
+ isUserInList<T extends import(".").BlockedUser | import(".").RestrictedUser>(userId: string, getUserList: () => Promise<T[]>, getIdField: (item: T) => string | {
630
+ _id: string;
631
+ username?: string;
632
+ avatar?: string;
633
+ }): Promise<boolean>;
634
+ getBlockedUsers(): Promise<import(".").BlockedUser[]>;
635
+ blockUser(userId: string): Promise<{
636
+ message: string;
637
+ }>;
638
+ unblockUser(userId: string): Promise<{
639
+ message: string;
640
+ }>;
641
+ isUserBlocked(userId: string): Promise<boolean>;
642
+ getRestrictedUsers(): Promise<import(".").RestrictedUser[]>;
643
+ restrictUser(userId: string): Promise<{
644
+ message: string;
645
+ }>;
646
+ unrestrictUser(userId: string): Promise<{
647
+ message: string;
648
+ }>;
649
+ isUserRestricted(userId: string): Promise<boolean>;
650
+ httpClient: import("./HttpClient").HttpClient;
651
+ requestManager: import("./RequestManager").RequestManager;
652
+ cloudURL: string;
653
+ config: OxyConfig;
654
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
655
+ getBaseURL(): string;
656
+ getClient(): import("./HttpClient").HttpClient;
657
+ getMetrics(): {
658
+ totalRequests: number;
659
+ successfulRequests: number;
660
+ failedRequests: number;
661
+ cacheHits: number;
662
+ cacheMisses: number;
663
+ averageResponseTime: number;
664
+ };
665
+ clearCache(): void;
666
+ clearCacheEntry(key: string): void;
667
+ getCacheStats(): {
668
+ size: number;
669
+ hits: number;
670
+ misses: number;
671
+ hitRate: number;
672
+ };
673
+ getCloudURL(): string;
674
+ setTokens(accessToken: string, refreshToken?: string): void;
675
+ clearTokens(): void;
676
+ getCurrentUserId(): string | null;
677
+ hasValidToken(): boolean;
678
+ getAccessToken(): string | null;
679
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
680
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
681
+ hasAccessToken(): boolean;
682
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
683
+ maxRetries?: number;
684
+ retryDelay?: number;
685
+ authTimeoutMs?: number;
686
+ }): Promise<T>;
687
+ validate(): Promise<boolean>;
688
+ handleError(error: any): Error;
689
+ healthCheck(): Promise<{
690
+ status: string;
691
+ users?: number;
692
+ timestamp?: string;
693
+ [key: string]: any;
694
+ }>;
88
695
  };
89
- /**
90
- * Get the configured Oxy Cloud (file storage/CDN) URL
91
- */
92
- getCloudURL(): string;
93
- /**
94
- * Set authentication tokens
95
- */
96
- setTokens(accessToken: string, refreshToken?: string): void;
97
- /**
98
- * Clear stored authentication tokens
99
- */
100
- clearTokens(): void;
101
- /**
102
- * Get the current user ID from the access token
103
- */
104
- getCurrentUserId(): string | null;
105
- /**
106
- * Check if the client has a valid access token
107
- */
108
- private hasAccessToken;
109
- /**
110
- * Check if the client has a valid access token (public method)
111
- */
112
- hasValidToken(): boolean;
113
- /**
114
- * Get the raw access token (for constructing anchor URLs when needed)
115
- */
116
- getAccessToken(): string | null;
117
- /**
118
- * Wait for authentication to be ready (public method)
119
- * Useful for apps that want to ensure authentication is complete before proceeding
120
- */
121
- waitForAuth(timeoutMs?: number): Promise<boolean>;
122
- /**
123
- * Wait for authentication to be ready with timeout
124
- */
125
- private waitForAuthentication;
126
- /**
127
- * Execute a function with automatic authentication retry logic
128
- * This handles the common case where API calls are made before authentication completes
129
- */
130
- private withAuthRetry;
131
- /**
132
- * Validate the current access token with the server
133
- */
134
- validate(): Promise<boolean>;
135
- /**
136
- * Centralized error handling
137
- */
138
- protected handleError(error: any): Error;
139
- /**
140
- * Health check endpoint
141
- */
142
- healthCheck(): Promise<{
143
- status: string;
144
- users?: number;
145
- timestamp?: string;
146
- [key: string]: any;
147
- }>;
148
- /**
149
- * Sign up a new user
150
- */
151
- signUp(username: string, email: string, password: string): Promise<{
152
- message: string;
153
- token: string;
154
- user: User;
155
- }>;
156
- /**
157
- * Request account recovery (send verification code)
158
- */
159
- requestRecovery(identifier: string): Promise<{
160
- delivery?: string;
161
- destination?: string;
162
- }>;
163
- /**
164
- * Verify recovery code
165
- */
166
- verifyRecoveryCode(identifier: string, code: string): Promise<{
167
- verified: boolean;
168
- }>;
169
- /**
170
- * Reset password using verified code
171
- */
172
- resetPassword(identifier: string, code: string, newPassword: string): Promise<{
173
- success: boolean;
174
- }>;
175
- /**
176
- * Reset password using TOTP code (recommended recovery)
177
- */
178
- resetPasswordWithTotp(identifier: string, code: string, newPassword: string): Promise<{
179
- success: boolean;
180
- }>;
181
- resetPasswordWithBackupCode(identifier: string, backupCode: string, newPassword: string): Promise<{
182
- success: boolean;
183
- }>;
184
- resetPasswordWithRecoveryKey(identifier: string, recoveryKey: string, newPassword: string): Promise<{
185
- success: boolean;
186
- nextRecoveryKey?: string;
187
- }>;
188
- /**
189
- * Sign in with device management
190
- */
191
- signIn(username: string, password: string, deviceName?: string, deviceFingerprint?: any): Promise<SessionLoginResponse | {
192
- mfaRequired: true;
193
- mfaToken: string;
194
- expiresAt: string;
195
- }>;
196
- /**
197
- * Complete login by verifying TOTP with MFA token
198
- */
199
- verifyTotpLogin(mfaToken: string, code: string): Promise<SessionLoginResponse>;
200
- /**
201
- * Get user by session ID
202
- */
203
- getUserBySession(sessionId: string): Promise<User>;
204
- /**
205
- * Batch get multiple user profiles by session IDs (optimized for account switching)
206
- * Returns array of { sessionId, user } objects
207
- */
208
- getUsersBySessions(sessionIds: string[]): Promise<Array<{
209
- sessionId: string;
210
- user: User | null;
211
- }>>;
212
- /**
213
- * Get access token by session ID and set it in the token store
214
- */
215
- getTokenBySession(sessionId: string): Promise<{
216
- accessToken: string;
217
- expiresAt: string;
218
- }>;
219
- /**
220
- * Get sessions by session ID
221
- */
222
- getSessionsBySessionId(sessionId: string): Promise<any[]>;
223
- /**
224
- * Logout from a specific session
225
- */
226
- logoutSession(sessionId: string, targetSessionId?: string): Promise<void>;
227
- /**
228
- * Logout from all sessions
229
- */
230
- logoutAllSessions(sessionId: string): Promise<void>;
231
- /**
232
- * Validate session
233
- */
234
- validateSession(sessionId: string, options?: {
235
- deviceFingerprint?: string;
236
- useHeaderValidation?: boolean;
237
- }): Promise<{
238
- valid: boolean;
239
- expiresAt: string;
240
- lastActivity: string;
241
- user: User;
242
- sessionId?: string;
243
- source?: string;
244
- }>;
245
- /**
246
- * Check username availability
247
- */
248
- checkUsernameAvailability(username: string): Promise<{
249
- available: boolean;
250
- message: string;
251
- }>;
252
- /**
253
- * Check email availability
254
- */
255
- checkEmailAvailability(email: string): Promise<{
256
- available: boolean;
257
- message: string;
258
- }>;
259
- /**
260
- * Get profile by username
261
- */
262
- getProfileByUsername(username: string): Promise<User>;
263
- startTotpEnrollment(sessionId: string): Promise<{
264
- secret: string;
265
- otpauthUrl: string;
266
- issuer: string;
267
- label: string;
268
- }>;
269
- verifyTotpEnrollment(sessionId: string, code: string): Promise<{
270
- enabled: boolean;
271
- backupCodes?: string[];
272
- recoveryKey?: string;
273
- }>;
274
- disableTotp(sessionId: string, code: string): Promise<{
275
- disabled: boolean;
276
- }>;
277
- /**
278
- * Search user profiles
279
- */
280
- searchProfiles(query: string, pagination?: PaginationParams): Promise<User[]>;
281
- /**
282
- * Get profile recommendations
283
- */
284
- getProfileRecommendations(): Promise<Array<{
285
- id: string;
286
- username: string;
287
- name?: {
288
- first?: string;
289
- last?: string;
290
- full?: string;
696
+ __resetTokensForTests(): void;
697
+ } & {
698
+ new (...args: any[]): {
699
+ startTotpEnrollment(sessionId: string): Promise<{
700
+ secret: string;
701
+ otpauthUrl: string;
702
+ issuer: string;
703
+ label: string;
704
+ }>;
705
+ verifyTotpEnrollment(sessionId: string, code: string): Promise<{
706
+ enabled: boolean;
707
+ backupCodes?: string[];
708
+ recoveryKey?: string;
709
+ }>;
710
+ disableTotp(sessionId: string, code: string): Promise<{
711
+ disabled: boolean;
712
+ }>;
713
+ httpClient: import("./HttpClient").HttpClient;
714
+ requestManager: import("./RequestManager").RequestManager;
715
+ cloudURL: string;
716
+ config: OxyConfig;
717
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
718
+ getBaseURL(): string;
719
+ getClient(): import("./HttpClient").HttpClient;
720
+ getMetrics(): {
721
+ totalRequests: number;
722
+ successfulRequests: number;
723
+ failedRequests: number;
724
+ cacheHits: number;
725
+ cacheMisses: number;
726
+ averageResponseTime: number;
291
727
  };
292
- description?: string;
293
- _count?: {
294
- followers: number;
295
- following: number;
728
+ clearCache(): void;
729
+ clearCacheEntry(key: string): void;
730
+ getCacheStats(): {
731
+ size: number;
732
+ hits: number;
733
+ misses: number;
734
+ hitRate: number;
296
735
  };
297
- [key: string]: any;
298
- }>>;
299
- /**
300
- * Get user by ID
301
- */
302
- getUserById(userId: string): Promise<User>;
303
- /**
304
- * Get current user
305
- */
306
- getCurrentUser(): Promise<User>;
307
- /**
308
- * Update user profile
309
- */
310
- updateProfile(updates: Record<string, any>): Promise<User>;
311
- /**
312
- * Get privacy settings for a user
313
- * @param userId - The user ID (defaults to current user)
314
- */
315
- getPrivacySettings(userId?: string): Promise<any>;
316
- /**
317
- * Update privacy settings
318
- * @param settings - Partial privacy settings object
319
- * @param userId - The user ID (defaults to current user)
320
- */
321
- updatePrivacySettings(settings: Record<string, any>, userId?: string): Promise<any>;
322
- /**
323
- * Get list of blocked users
324
- * @returns Array of blocked users
325
- */
326
- getBlockedUsers(): Promise<BlockedUser[]>;
327
- /**
328
- * Block a user
329
- * @param userId - The user ID to block
330
- * @returns Success message
331
- */
332
- blockUser(userId: string): Promise<{
333
- message: string;
334
- }>;
335
- /**
336
- * Unblock a user
337
- * @param userId - The user ID to unblock
338
- * @returns Success message
339
- */
340
- unblockUser(userId: string): Promise<{
341
- message: string;
342
- }>;
343
- /**
344
- * Extract user ID from blocked/restricted user object
345
- * @private
346
- */
347
- private extractUserId;
348
- /**
349
- * Check if a user is in a list (blocked or restricted)
350
- * @private
351
- */
352
- private isUserInList;
353
- /**
354
- * Check if a user is blocked
355
- * @param userId - The user ID to check
356
- * @returns True if the user is blocked, false otherwise
357
- */
358
- isUserBlocked(userId: string): Promise<boolean>;
359
- /**
360
- * Get list of restricted users
361
- * @returns Array of restricted users
362
- */
363
- getRestrictedUsers(): Promise<RestrictedUser[]>;
364
- /**
365
- * Restrict a user (limit their interactions without fully blocking)
366
- * @param userId - The user ID to restrict
367
- * @returns Success message
368
- */
369
- restrictUser(userId: string): Promise<{
370
- message: string;
371
- }>;
372
- /**
373
- * Unrestrict a user
374
- * @param userId - The user ID to unrestrict
375
- * @returns Success message
376
- */
377
- unrestrictUser(userId: string): Promise<{
378
- message: string;
379
- }>;
380
- /**
381
- * Check if a user is restricted
382
- * @param userId - The user ID to check
383
- * @returns True if the user is restricted, false otherwise
384
- */
385
- isUserRestricted(userId: string): Promise<boolean>;
386
- /**
387
- * Request account verification
388
- */
389
- requestAccountVerification(reason: string, evidence?: string): Promise<{
390
- message: string;
391
- requestId: string;
392
- }>;
393
- /**
394
- * Download account data export
395
- */
396
- downloadAccountData(format?: 'json' | 'csv'): Promise<Blob>;
397
- /**
398
- * Delete account permanently
399
- * @param password - User password for confirmation
400
- * @param confirmText - Confirmation text (usually username)
401
- */
402
- deleteAccount(password: string, confirmText: string): Promise<{
403
- message: string;
404
- }>;
405
- /**
406
- * Get the current language from storage or user profile
407
- * @param storageKeyPrefix - Optional prefix for storage key (default: 'oxy_session')
408
- * @returns The current language code (e.g., 'en-US') or null if not set
409
- */
410
- getCurrentLanguage(storageKeyPrefix?: string): Promise<string | null>;
411
- /**
412
- * Get the current language with metadata (name, nativeName, etc.)
413
- * @param storageKeyPrefix - Optional prefix for storage key (default: 'oxy_session')
414
- * @returns Language metadata object or null if not set
415
- */
416
- getCurrentLanguageMetadata(storageKeyPrefix?: string): Promise<LanguageMetadata | null>;
417
- /**
418
- * Get the current language name (e.g., 'English')
419
- * @param storageKeyPrefix - Optional prefix for storage key (default: 'oxy_session')
420
- * @returns Language name or null if not set
421
- */
422
- getCurrentLanguageName(storageKeyPrefix?: string): Promise<string | null>;
423
- /**
424
- * Get the current native language name (e.g., 'Español')
425
- * @param storageKeyPrefix - Optional prefix for storage key (default: 'oxy_session')
426
- * @returns Native language name or null if not set
427
- */
428
- getCurrentNativeLanguageName(storageKeyPrefix?: string): Promise<string | null>;
429
- /**
430
- * Get appropriate storage for the platform (similar to DeviceManager)
431
- * @private
432
- */
433
- private getStorage;
434
- /**
435
- * Update user by ID (admin function)
436
- */
437
- updateUser(userId: string, updates: Record<string, any>): Promise<User>;
438
- /**
439
- * Follow a user
440
- */
441
- followUser(userId: string): Promise<{
442
- success: boolean;
443
- message: string;
444
- }>;
445
- /**
446
- * Unfollow a user
447
- */
448
- unfollowUser(userId: string): Promise<{
449
- success: boolean;
450
- message: string;
451
- }>;
452
- /**
453
- * Get follow status
454
- */
455
- getFollowStatus(userId: string): Promise<{
456
- isFollowing: boolean;
457
- }>;
458
- /**
459
- * Get user followers
460
- */
461
- getUserFollowers(userId: string, pagination?: PaginationParams): Promise<{
462
- followers: User[];
463
- total: number;
464
- hasMore: boolean;
465
- }>;
466
- /**
467
- * Get user following
468
- */
469
- getUserFollowing(userId: string, pagination?: PaginationParams): Promise<{
470
- following: User[];
471
- total: number;
472
- hasMore: boolean;
473
- }>;
474
- /**
475
- * Get notifications
476
- */
477
- getNotifications(): Promise<Notification[]>;
478
- /**
479
- * Get unread notification count
480
- */
481
- getUnreadCount(): Promise<number>;
482
- /**
483
- * Create notification
484
- */
485
- createNotification(data: Partial<Notification>): Promise<Notification>;
486
- /**
487
- * Mark notification as read
488
- */
489
- markNotificationAsRead(notificationId: string): Promise<void>;
490
- /**
491
- * Mark all notifications as read
492
- */
493
- markAllNotificationsAsRead(): Promise<void>;
494
- /**
495
- * Delete notification
496
- */
497
- deleteNotification(notificationId: string): Promise<void>;
498
- /**
499
- * Create a payment
500
- */
501
- createPayment(data: any): Promise<any>;
502
- /**
503
- * Get payment by ID
504
- */
505
- getPayment(paymentId: string): Promise<any>;
506
- /**
507
- * Get user payments
508
- */
509
- getUserPayments(): Promise<any[]>;
510
- /**
511
- * Get user karma
512
- */
513
- getUserKarma(userId: string): Promise<any>;
514
- /**
515
- * Give karma to user
516
- */
517
- giveKarma(userId: string, amount: number, reason?: string): Promise<any>;
518
- /**
519
- * Get user karma total
520
- */
521
- getUserKarmaTotal(userId: string): Promise<any>;
522
- /**
523
- * Get user karma history
524
- */
525
- getUserKarmaHistory(userId: string, limit?: number, offset?: number): Promise<any>;
526
- /**
527
- * Get karma leaderboard
528
- */
529
- getKarmaLeaderboard(): Promise<any>;
530
- /**
531
- * Get karma rules
532
- */
533
- getKarmaRules(): Promise<any>;
534
- /**
535
- * Delete file
536
- */
537
- deleteFile(fileId: string): Promise<any>;
538
- /**
539
- * Get file download URL (API streaming proxy, attaches token for <img src>)
540
- */
541
- getFileDownloadUrl(fileId: string, variant?: string, expiresIn?: number): string;
542
- /**
543
- * Get file stream URL (direct Oxy Cloud/CDN URL, no token)
544
- */
545
- getFileStreamUrl(fileId: string): string;
546
- /**
547
- * List user files
548
- */
549
- listUserFiles(limit?: number, offset?: number): Promise<{
550
- files: any[];
551
- total: number;
552
- hasMore: boolean;
553
- }>;
554
- /**
555
- * Get file content as text
556
- */
557
- getFileContentAsText(fileId: string, variant?: string): Promise<string>;
558
- /**
559
- * Get file content as blob
560
- */
561
- getFileContentAsBlob(fileId: string, variant?: string): Promise<Blob>;
562
- /**
563
- * Upload raw file data
564
- */
565
- uploadRawFile(file: File | Blob, visibility?: 'private' | 'public' | 'unlisted', metadata?: Record<string, any>): Promise<any>;
566
- /**
567
- * Calculate SHA256 hash of file content
568
- */
569
- calculateSHA256(file: File | Blob): Promise<string>;
570
- /**
571
- * Initialize asset upload - returns pre-signed URL and file ID
572
- */
573
- assetInit(sha256: string, size: number, mime: string): Promise<AssetInitResponse>;
574
- /**
575
- * Complete asset upload - commit metadata and trigger variant generation
576
- */
577
- assetComplete(fileId: string, originalName: string, size: number, mime: string, visibility?: 'private' | 'public' | 'unlisted', metadata?: Record<string, any>): Promise<any>;
578
- /**
579
- * Upload file using Central Asset Service
580
- */
581
- assetUpload(file: File, visibility?: 'private' | 'public' | 'unlisted', metadata?: Record<string, any>, onProgress?: (progress: number) => void): Promise<any>;
582
- /**
583
- * Upload file to pre-signed URL
584
- */
585
- private uploadToPresignedUrl;
586
- /**
587
- * Link asset to an entity
588
- */
589
- assetLink(fileId: string, app: string, entityType: string, entityId: string, visibility?: 'private' | 'public' | 'unlisted', webhookUrl?: string): Promise<any>;
590
- /**
591
- * Unlink asset from an entity
592
- */
593
- assetUnlink(fileId: string, app: string, entityType: string, entityId: string): Promise<any>;
594
- /**
595
- * Get asset metadata
596
- */
597
- assetGet(fileId: string): Promise<any>;
598
- /**
599
- * Get asset URL (CDN or signed URL)
600
- */
601
- assetGetUrl(fileId: string, variant?: string, expiresIn?: number): Promise<AssetUrlResponse>;
602
- /**
603
- * Restore asset from trash
604
- */
605
- assetRestore(fileId: string): Promise<any>;
606
- /**
607
- * Delete asset with optional force
608
- */
609
- assetDelete(fileId: string, force?: boolean): Promise<any>;
610
- /**
611
- * Get list of available variants for an asset
612
- */
613
- assetGetVariants(fileId: string): Promise<AssetVariant[]>;
614
- /**
615
- * Update asset visibility
616
- * @param fileId - The file ID
617
- * @param visibility - New visibility level ('private', 'public', or 'unlisted')
618
- * @returns Updated asset information
619
- */
620
- assetUpdateVisibility(fileId: string, visibility: 'private' | 'public' | 'unlisted'): Promise<any>;
621
- /**
622
- * Helper: Upload and link avatar with automatic public visibility
623
- * @param file - The avatar file
624
- * @param userId - User ID to link to
625
- * @param app - App name (defaults to 'profiles')
626
- * @returns The uploaded and linked asset
627
- */
628
- uploadAvatar(file: File, userId: string, app?: string): Promise<any>;
629
- /**
630
- * Helper: Upload and link profile banner with automatic public visibility
631
- * @param file - The banner file
632
- * @param userId - User ID to link to
633
- * @param app - App name (defaults to 'profiles')
634
- * @returns The uploaded and linked asset
635
- */
636
- uploadProfileBanner(file: File, userId: string, app?: string): Promise<any>;
637
- /**
638
- * Get developer apps for the current user
639
- */
640
- getDeveloperApps(): Promise<any[]>;
641
- /**
642
- * Create a new developer app
643
- */
644
- createDeveloperApp(data: {
645
- name: string;
646
- description?: string;
647
- webhookUrl: string;
648
- devWebhookUrl?: string;
649
- scopes?: string[];
650
- }): Promise<any>;
651
- /**
652
- * Get a specific developer app
653
- */
654
- getDeveloperApp(appId: string): Promise<any>;
655
- /**
656
- * Update a developer app
657
- */
658
- updateDeveloperApp(appId: string, data: {
659
- name?: string;
660
- description?: string;
661
- webhookUrl?: string;
662
- devWebhookUrl?: string;
663
- scopes?: string[];
664
- }): Promise<any>;
665
- /**
666
- * Regenerate API secret for a developer app
667
- */
668
- regenerateDeveloperAppSecret(appId: string): Promise<any>;
669
- /**
670
- * Delete a developer app
671
- */
672
- deleteDeveloperApp(appId: string): Promise<any>;
673
- /**
674
- * Update user location
675
- */
676
- updateLocation(latitude: number, longitude: number): Promise<any>;
677
- /**
678
- * Get nearby users
679
- */
680
- getNearbyUsers(radius?: number): Promise<any[]>;
681
- /**
682
- * Track event
683
- */
684
- trackEvent(eventName: string, properties?: Record<string, any>): Promise<void>;
685
- /**
686
- * Get analytics data
687
- */
688
- getAnalytics(startDate?: string, endDate?: string): Promise<any>;
689
- /**
690
- * Register device
691
- */
692
- registerDevice(deviceData: any): Promise<any>;
693
- /**
694
- * Get user devices
695
- */
696
- getUserDevices(): Promise<any[]>;
697
- /**
698
- * Remove device
699
- */
700
- removeDevice(deviceId: string): Promise<void>;
701
- /**
702
- * Get device sessions
703
- * Note: Not cached by default to ensure fresh data, but can be cached via makeRequest if needed
704
- */
705
- getDeviceSessions(sessionId: string): Promise<any[]>;
706
- /**
707
- * Logout all device sessions
708
- */
709
- logoutAllDeviceSessions(sessionId: string, deviceId?: string, excludeCurrent?: boolean): Promise<any>;
710
- /**
711
- * Update device name
712
- */
713
- updateDeviceName(sessionId: string, deviceName: string): Promise<any>;
714
- /**
715
- * Fetch link metadata
716
- */
717
- fetchLinkMetadata(url: string): Promise<{
718
- url: string;
719
- title: string;
720
- description: string;
721
- image?: string;
722
- }>;
723
- /**
724
- * Simple Express.js authentication middleware
725
- *
726
- * Built-in authentication middleware that validates JWT tokens and adds user data to requests.
727
- *
728
- * @example
729
- * ```typescript
730
- * // Basic usage - just add it to your routes
731
- * app.use('/api/protected', oxyServices.auth());
732
- *
733
- * // With debug logging
734
- * app.use('/api/protected', oxyServices.auth({ debug: true }));
735
- *
736
- * // With custom error handling
737
- * app.use('/api/protected', oxyServices.auth({
738
- * onError: (error) => console.error('Auth failed:', error)
739
- * }));
740
- *
741
- * // Load full user data
742
- * app.use('/api/protected', oxyServices.auth({ loadUser: true }));
743
- * ```
744
- *
745
- * @param options Optional configuration
746
- * @param options.debug Enable debug logging (default: false)
747
- * @param options.onError Custom error handler
748
- * @param options.loadUser Load full user data (default: false for performance)
749
- * @param options.session Use session-based validation (default: false)
750
- * @returns Express middleware function
751
- */
752
- auth(options?: {
753
- debug?: boolean;
754
- onError?: (error: ApiError) => any;
755
- loadUser?: boolean;
756
- session?: boolean;
757
- }): (req: any, res: any, next: any) => any;
736
+ getCloudURL(): string;
737
+ setTokens(accessToken: string, refreshToken?: string): void;
738
+ clearTokens(): void;
739
+ getCurrentUserId(): string | null;
740
+ hasValidToken(): boolean;
741
+ getAccessToken(): string | null;
742
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
743
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
744
+ hasAccessToken(): boolean;
745
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
746
+ maxRetries?: number;
747
+ retryDelay?: number;
748
+ authTimeoutMs?: number;
749
+ }): Promise<T>;
750
+ validate(): Promise<boolean>;
751
+ handleError(error: any): Error;
752
+ healthCheck(): Promise<{
753
+ status: string;
754
+ users?: number;
755
+ timestamp?: string;
756
+ [key: string]: any;
757
+ }>;
758
+ };
759
+ __resetTokensForTests(): void;
760
+ } & {
761
+ new (...args: any[]): {
762
+ getProfileByUsername(username: string): Promise<import(".").User>;
763
+ searchProfiles(query: string, pagination?: import("..").PaginationParams): Promise<import(".").SearchProfilesResponse>;
764
+ getProfileRecommendations(): Promise<{
765
+ [key: string]: any;
766
+ id: string;
767
+ username: string;
768
+ name?: {
769
+ first?: string;
770
+ last?: string;
771
+ full?: string;
772
+ } | undefined;
773
+ description?: string;
774
+ _count?: {
775
+ followers: number;
776
+ following: number;
777
+ } | undefined;
778
+ }[]>;
779
+ getUserById(userId: string): Promise<import(".").User>;
780
+ getCurrentUser(): Promise<import(".").User>;
781
+ updateProfile(updates: Record<string, any>): Promise<import(".").User>;
782
+ getPrivacySettings(userId?: string): Promise<any>;
783
+ updatePrivacySettings(settings: Record<string, any>, userId?: string): Promise<any>;
784
+ requestAccountVerification(reason: string, evidence?: string): Promise<{
785
+ message: string;
786
+ requestId: string;
787
+ }>;
788
+ downloadAccountData(format?: "json" | "csv"): Promise<Blob>;
789
+ deleteAccount(password: string, confirmText: string): Promise<{
790
+ message: string;
791
+ }>;
792
+ updateUser(userId: string, updates: Record<string, any>): Promise<import(".").User>;
793
+ followUser(userId: string): Promise<{
794
+ success: boolean;
795
+ message: string;
796
+ }>;
797
+ unfollowUser(userId: string): Promise<{
798
+ success: boolean;
799
+ message: string;
800
+ }>;
801
+ getFollowStatus(userId: string): Promise<{
802
+ isFollowing: boolean;
803
+ }>;
804
+ getUserFollowers(userId: string, pagination?: import("..").PaginationParams): Promise<{
805
+ followers: import(".").User[];
806
+ total: number;
807
+ hasMore: boolean;
808
+ }>;
809
+ getUserFollowing(userId: string, pagination?: import("..").PaginationParams): Promise<{
810
+ following: import(".").User[];
811
+ total: number;
812
+ hasMore: boolean;
813
+ }>;
814
+ getNotifications(): Promise<import(".").Notification[]>;
815
+ getUnreadCount(): Promise<number>;
816
+ createNotification(data: Partial<import(".").Notification>): Promise<import(".").Notification>;
817
+ markNotificationAsRead(notificationId: string): Promise<void>;
818
+ markAllNotificationsAsRead(): Promise<void>;
819
+ deleteNotification(notificationId: string): Promise<void>;
820
+ httpClient: import("./HttpClient").HttpClient;
821
+ requestManager: import("./RequestManager").RequestManager;
822
+ cloudURL: string;
823
+ config: OxyConfig;
824
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
825
+ getBaseURL(): string;
826
+ getClient(): import("./HttpClient").HttpClient;
827
+ getMetrics(): {
828
+ totalRequests: number;
829
+ successfulRequests: number;
830
+ failedRequests: number;
831
+ cacheHits: number;
832
+ cacheMisses: number;
833
+ averageResponseTime: number;
834
+ };
835
+ clearCache(): void;
836
+ clearCacheEntry(key: string): void;
837
+ getCacheStats(): {
838
+ size: number;
839
+ hits: number;
840
+ misses: number;
841
+ hitRate: number;
842
+ };
843
+ getCloudURL(): string;
844
+ setTokens(accessToken: string, refreshToken?: string): void;
845
+ clearTokens(): void;
846
+ getCurrentUserId(): string | null;
847
+ hasValidToken(): boolean;
848
+ getAccessToken(): string | null;
849
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
850
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
851
+ hasAccessToken(): boolean;
852
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
853
+ maxRetries?: number;
854
+ retryDelay?: number;
855
+ authTimeoutMs?: number;
856
+ }): Promise<T>;
857
+ validate(): Promise<boolean>;
858
+ handleError(error: any): Error;
859
+ healthCheck(): Promise<{
860
+ status: string;
861
+ users?: number;
862
+ timestamp?: string;
863
+ [key: string]: any;
864
+ }>;
865
+ };
866
+ __resetTokensForTests(): void;
867
+ } & {
868
+ new (...args: any[]): {
869
+ signUp(username: string, email: string, password: string): Promise<{
870
+ message: string;
871
+ token: string;
872
+ user: import(".").User;
873
+ }>;
874
+ requestRecovery(identifier: string): Promise<{
875
+ delivery?: string;
876
+ destination?: string;
877
+ }>;
878
+ verifyRecoveryCode(identifier: string, code: string): Promise<{
879
+ verified: boolean;
880
+ }>;
881
+ resetPassword(identifier: string, code: string, newPassword: string): Promise<{
882
+ success: boolean;
883
+ }>;
884
+ resetPasswordWithTotp(identifier: string, code: string, newPassword: string): Promise<{
885
+ success: boolean;
886
+ }>;
887
+ resetPasswordWithBackupCode(identifier: string, backupCode: string, newPassword: string): Promise<{
888
+ success: boolean;
889
+ }>;
890
+ resetPasswordWithRecoveryKey(identifier: string, recoveryKey: string, newPassword: string): Promise<{
891
+ success: boolean;
892
+ nextRecoveryKey?: string;
893
+ }>;
894
+ signIn(username: string, password: string, deviceName?: string, deviceFingerprint?: any): Promise<import(".").SessionLoginResponse | {
895
+ mfaRequired: true;
896
+ mfaToken: string;
897
+ expiresAt: string;
898
+ }>;
899
+ verifyTotpLogin(mfaToken: string, code: string): Promise<import(".").SessionLoginResponse>;
900
+ getUserBySession(sessionId: string): Promise<import(".").User>;
901
+ getUsersBySessions(sessionIds: string[]): Promise<{
902
+ sessionId: string;
903
+ user: import(".").User | null;
904
+ }[]>;
905
+ getTokenBySession(sessionId: string): Promise<{
906
+ accessToken: string;
907
+ expiresAt: string;
908
+ }>;
909
+ getSessionsBySessionId(sessionId: string): Promise<any[]>;
910
+ logoutSession(sessionId: string, targetSessionId?: string): Promise<void>;
911
+ logoutAllSessions(sessionId: string): Promise<void>;
912
+ validateSession(sessionId: string, options?: {
913
+ deviceFingerprint?: string;
914
+ useHeaderValidation?: boolean;
915
+ }): Promise<{
916
+ valid: boolean;
917
+ expiresAt: string;
918
+ lastActivity: string;
919
+ user: import(".").User;
920
+ sessionId?: string;
921
+ source?: string;
922
+ }>;
923
+ checkUsernameAvailability(username: string): Promise<{
924
+ available: boolean;
925
+ message: string;
926
+ }>;
927
+ checkEmailAvailability(email: string): Promise<{
928
+ available: boolean;
929
+ message: string;
930
+ }>;
931
+ httpClient: import("./HttpClient").HttpClient;
932
+ requestManager: import("./RequestManager").RequestManager;
933
+ cloudURL: string;
934
+ config: OxyConfig;
935
+ makeRequest<T>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("./RequestManager").RequestOptions): Promise<T>;
936
+ getBaseURL(): string;
937
+ getClient(): import("./HttpClient").HttpClient;
938
+ getMetrics(): {
939
+ totalRequests: number;
940
+ successfulRequests: number;
941
+ failedRequests: number;
942
+ cacheHits: number;
943
+ cacheMisses: number;
944
+ averageResponseTime: number;
945
+ };
946
+ clearCache(): void;
947
+ clearCacheEntry(key: string): void;
948
+ getCacheStats(): {
949
+ size: number;
950
+ hits: number;
951
+ misses: number;
952
+ hitRate: number;
953
+ };
954
+ getCloudURL(): string;
955
+ setTokens(accessToken: string, refreshToken?: string): void;
956
+ clearTokens(): void;
957
+ getCurrentUserId(): string | null;
958
+ hasValidToken(): boolean;
959
+ getAccessToken(): string | null;
960
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
961
+ waitForAuthentication(timeoutMs?: number): Promise<boolean>;
962
+ hasAccessToken(): boolean;
963
+ withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
964
+ maxRetries?: number;
965
+ retryDelay?: number;
966
+ authTimeoutMs?: number;
967
+ }): Promise<T>;
968
+ validate(): Promise<boolean>;
969
+ handleError(error: any): Error;
970
+ healthCheck(): Promise<{
971
+ status: string;
972
+ users?: number;
973
+ timestamp?: string;
974
+ [key: string]: any;
975
+ }>;
976
+ };
977
+ __resetTokensForTests(): void;
978
+ } & typeof OxyServicesBase;
979
+ export declare class OxyServices extends OxyServicesComposed {
980
+ constructor(config: OxyConfig);
758
981
  }
982
+ export { OxyAuthenticationError, OxyAuthenticationTimeoutError };
759
983
  /**
760
984
  * Export the default Oxy Cloud URL (for backward compatibility)
761
985
  */