@oxyhq/services 5.13.12 → 5.13.16

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 (209) 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 -2009
  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 +406 -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 +389 -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/index.js.map +1 -1
  39. package/lib/commonjs/ui/context/OxyContext.js +26 -47
  40. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  41. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +239 -1
  42. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  43. package/lib/commonjs/utils/apiUtils.js +0 -14
  44. package/lib/commonjs/utils/apiUtils.js.map +1 -1
  45. package/lib/commonjs/utils/asyncUtils.js +0 -20
  46. package/lib/commonjs/utils/asyncUtils.js.map +1 -1
  47. package/lib/module/core/OxyServices.base.js +265 -0
  48. package/lib/module/core/OxyServices.base.js.map +1 -0
  49. package/lib/module/core/OxyServices.errors.js +20 -0
  50. package/lib/module/core/OxyServices.errors.js.map +1 -0
  51. package/lib/module/core/OxyServices.js +43 -2005
  52. package/lib/module/core/OxyServices.js.map +1 -1
  53. package/lib/module/core/mixins/OxyServices.analytics.js +56 -0
  54. package/lib/module/core/mixins/OxyServices.analytics.js.map +1 -0
  55. package/lib/module/core/mixins/OxyServices.assets.js +402 -0
  56. package/lib/module/core/mixins/OxyServices.assets.js.map +1 -0
  57. package/lib/module/core/mixins/OxyServices.auth.js +299 -0
  58. package/lib/module/core/mixins/OxyServices.auth.js.map +1 -0
  59. package/lib/module/core/mixins/OxyServices.developer.js +111 -0
  60. package/lib/module/core/mixins/OxyServices.developer.js.map +1 -0
  61. package/lib/module/core/mixins/OxyServices.devices.js +115 -0
  62. package/lib/module/core/mixins/OxyServices.devices.js.map +1 -0
  63. package/lib/module/core/mixins/OxyServices.karma.js +113 -0
  64. package/lib/module/core/mixins/OxyServices.karma.js.map +1 -0
  65. package/lib/module/core/mixins/OxyServices.language.js +120 -0
  66. package/lib/module/core/mixins/OxyServices.language.js.map +1 -0
  67. package/lib/module/core/mixins/OxyServices.location.js +51 -0
  68. package/lib/module/core/mixins/OxyServices.location.js.map +1 -0
  69. package/lib/module/core/mixins/OxyServices.payment.js +62 -0
  70. package/lib/module/core/mixins/OxyServices.payment.js.map +1 -0
  71. package/lib/module/core/mixins/OxyServices.privacy.js +170 -0
  72. package/lib/module/core/mixins/OxyServices.privacy.js.map +1 -0
  73. package/lib/module/core/mixins/OxyServices.totp.js +49 -0
  74. package/lib/module/core/mixins/OxyServices.totp.js.map +1 -0
  75. package/lib/module/core/mixins/OxyServices.user.js +385 -0
  76. package/lib/module/core/mixins/OxyServices.user.js.map +1 -0
  77. package/lib/module/core/mixins/OxyServices.utility.js +156 -0
  78. package/lib/module/core/mixins/OxyServices.utility.js.map +1 -0
  79. package/lib/module/core/mixins/index.js +36 -0
  80. package/lib/module/core/mixins/index.js.map +1 -0
  81. package/lib/module/core/mixins/mixinHelpers.js +56 -0
  82. package/lib/module/core/mixins/mixinHelpers.js.map +1 -0
  83. package/lib/module/index.js.map +1 -1
  84. package/lib/module/ui/context/OxyContext.js +26 -47
  85. package/lib/module/ui/context/OxyContext.js.map +1 -1
  86. package/lib/module/ui/navigation/types.js.map +1 -1
  87. package/lib/module/ui/screens/PrivacySettingsScreen.js +241 -3
  88. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  89. package/lib/module/utils/apiUtils.js +0 -13
  90. package/lib/module/utils/apiUtils.js.map +1 -1
  91. package/lib/module/utils/asyncUtils.js +0 -20
  92. package/lib/module/utils/asyncUtils.js.map +1 -1
  93. package/lib/typescript/core/OxyServices.base.d.ts +123 -0
  94. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -0
  95. package/lib/typescript/core/OxyServices.d.ts +969 -682
  96. package/lib/typescript/core/OxyServices.d.ts.map +1 -1
  97. package/lib/typescript/core/OxyServices.errors.d.ts +12 -0
  98. package/lib/typescript/core/OxyServices.errors.d.ts.map +1 -0
  99. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts +70 -0
  100. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -0
  101. package/lib/typescript/core/mixins/OxyServices.assets.d.ts +159 -0
  102. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -0
  103. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +168 -0
  104. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -0
  105. package/lib/typescript/core/mixins/OxyServices.developer.d.ts +103 -0
  106. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -0
  107. package/lib/typescript/core/mixins/OxyServices.devices.d.ts +93 -0
  108. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -0
  109. package/lib/typescript/core/mixins/OxyServices.karma.d.ts +89 -0
  110. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -0
  111. package/lib/typescript/core/mixins/OxyServices.language.d.ts +85 -0
  112. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -0
  113. package/lib/typescript/core/mixins/OxyServices.location.d.ts +68 -0
  114. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -0
  115. package/lib/typescript/core/mixins/OxyServices.payment.d.ts +74 -0
  116. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -0
  117. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts +126 -0
  118. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -0
  119. package/lib/typescript/core/mixins/OxyServices.totp.d.ts +69 -0
  120. package/lib/typescript/core/mixins/OxyServices.totp.d.ts.map +1 -0
  121. package/lib/typescript/core/mixins/OxyServices.user.d.ts +189 -0
  122. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -0
  123. package/lib/typescript/core/mixins/OxyServices.utility.d.ts +97 -0
  124. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -0
  125. package/lib/typescript/core/mixins/index.d.ts +898 -0
  126. package/lib/typescript/core/mixins/index.d.ts.map +1 -0
  127. package/lib/typescript/core/mixins/mixinHelpers.d.ts +32 -0
  128. package/lib/typescript/core/mixins/mixinHelpers.d.ts.map +1 -0
  129. package/lib/typescript/index.d.ts +1 -1
  130. package/lib/typescript/index.d.ts.map +1 -1
  131. package/lib/typescript/models/interfaces.d.ts +36 -0
  132. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  133. package/lib/typescript/ui/context/OxyContext.d.ts +2 -6
  134. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  135. package/lib/typescript/ui/navigation/types.d.ts +0 -1
  136. package/lib/typescript/ui/navigation/types.d.ts.map +1 -1
  137. package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  138. package/lib/typescript/utils/apiUtils.d.ts +0 -7
  139. package/lib/typescript/utils/apiUtils.d.ts.map +1 -1
  140. package/lib/typescript/utils/asyncUtils.d.ts +0 -11
  141. package/lib/typescript/utils/asyncUtils.d.ts.map +1 -1
  142. package/package.json +1 -1
  143. package/src/core/OxyServices.base.ts +311 -0
  144. package/src/core/OxyServices.errors.ts +26 -0
  145. package/src/core/OxyServices.ts +43 -2026
  146. package/src/core/mixins/OxyServices.analytics.ts +53 -0
  147. package/src/core/mixins/OxyServices.assets.ts +390 -0
  148. package/src/core/mixins/OxyServices.auth.ts +275 -0
  149. package/src/core/mixins/OxyServices.developer.ts +114 -0
  150. package/src/core/mixins/OxyServices.devices.ts +103 -0
  151. package/src/core/mixins/OxyServices.karma.ts +111 -0
  152. package/src/core/mixins/OxyServices.language.ts +127 -0
  153. package/src/core/mixins/OxyServices.location.ts +46 -0
  154. package/src/core/mixins/OxyServices.payment.ts +59 -0
  155. package/src/core/mixins/OxyServices.privacy.ts +182 -0
  156. package/src/core/mixins/OxyServices.totp.ts +36 -0
  157. package/src/core/mixins/OxyServices.user.ts +380 -0
  158. package/src/core/mixins/OxyServices.utility.ts +187 -0
  159. package/src/core/mixins/index.ts +58 -0
  160. package/src/core/mixins/mixinHelpers.ts +69 -0
  161. package/src/index.ts +4 -0
  162. package/src/models/interfaces.ts +40 -0
  163. package/src/ui/context/OxyContext.tsx +35 -53
  164. package/src/ui/navigation/types.ts +0 -1
  165. package/src/ui/screens/PrivacySettingsScreen.tsx +240 -2
  166. package/src/utils/apiUtils.ts +0 -14
  167. package/src/utils/asyncUtils.ts +0 -20
  168. package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js +0 -192
  169. package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js.map +0 -1
  170. package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js +0 -142
  171. package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js.map +0 -1
  172. package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js +0 -113
  173. package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js.map +0 -1
  174. package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js +0 -132
  175. package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js.map +0 -1
  176. package/lib/commonjs/ui/screens/internal/SignUpSummaryStep.js +0 -83
  177. package/lib/commonjs/ui/screens/internal/SignUpSummaryStep.js.map +0 -1
  178. package/lib/commonjs/ui/screens/internal/SignUpWelcomeStep.js +0 -58
  179. package/lib/commonjs/ui/screens/internal/SignUpWelcomeStep.js.map +0 -1
  180. package/lib/module/ui/screens/internal/SignInPasswordStep.js +0 -186
  181. package/lib/module/ui/screens/internal/SignInPasswordStep.js.map +0 -1
  182. package/lib/module/ui/screens/internal/SignInUsernameStep.js +0 -136
  183. package/lib/module/ui/screens/internal/SignInUsernameStep.js.map +0 -1
  184. package/lib/module/ui/screens/internal/SignUpIdentityStep.js +0 -108
  185. package/lib/module/ui/screens/internal/SignUpIdentityStep.js.map +0 -1
  186. package/lib/module/ui/screens/internal/SignUpSecurityStep.js +0 -127
  187. package/lib/module/ui/screens/internal/SignUpSecurityStep.js.map +0 -1
  188. package/lib/module/ui/screens/internal/SignUpSummaryStep.js +0 -78
  189. package/lib/module/ui/screens/internal/SignUpSummaryStep.js.map +0 -1
  190. package/lib/module/ui/screens/internal/SignUpWelcomeStep.js +0 -53
  191. package/lib/module/ui/screens/internal/SignUpWelcomeStep.js.map +0 -1
  192. package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts +0 -28
  193. package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts.map +0 -1
  194. package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts +0 -25
  195. package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts.map +0 -1
  196. package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts +0 -20
  197. package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts.map +0 -1
  198. package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts +0 -24
  199. package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts.map +0 -1
  200. package/lib/typescript/ui/screens/internal/SignUpSummaryStep.d.ts +0 -15
  201. package/lib/typescript/ui/screens/internal/SignUpSummaryStep.d.ts.map +0 -1
  202. package/lib/typescript/ui/screens/internal/SignUpWelcomeStep.d.ts +0 -13
  203. package/lib/typescript/ui/screens/internal/SignUpWelcomeStep.d.ts.map +0 -1
  204. package/src/ui/screens/internal/SignInPasswordStep.tsx +0 -184
  205. package/src/ui/screens/internal/SignInUsernameStep.tsx +0 -145
  206. package/src/ui/screens/internal/SignUpIdentityStep.tsx +0 -112
  207. package/src/ui/screens/internal/SignUpSecurityStep.tsx +0 -132
  208. package/src/ui/screens/internal/SignUpSummaryStep.tsx +0 -66
  209. package/src/ui/screens/internal/SignUpWelcomeStep.tsx +0 -52
@@ -0,0 +1,385 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * User Management Methods Mixin
5
+ */
6
+
7
+ import { buildSearchParams, buildPaginationParams } from '../../utils/apiUtils';
8
+ export function OxyServicesUserMixin(Base) {
9
+ return class extends Base {
10
+ constructor(...args) {
11
+ super(...args);
12
+ }
13
+ /**
14
+ * Get profile by username
15
+ */
16
+ async getProfileByUsername(username) {
17
+ try {
18
+ return await this.makeRequest('GET', `/api/profiles/username/${username}`, undefined, {
19
+ cache: true,
20
+ cacheTTL: 5 * 60 * 1000 // 5 minutes cache for profiles
21
+ });
22
+ } catch (error) {
23
+ throw this.handleError(error);
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Search user profiles
29
+ */
30
+ async searchProfiles(query, pagination) {
31
+ try {
32
+ const params = {
33
+ query,
34
+ ...pagination
35
+ };
36
+ const searchParams = buildSearchParams(params);
37
+ const paramsObj = {};
38
+ searchParams.forEach((value, key) => {
39
+ paramsObj[key] = value;
40
+ });
41
+ const response = await this.makeRequest('GET', '/api/profiles/search', paramsObj, {
42
+ cache: true,
43
+ cacheTTL: 2 * 60 * 1000 // 2 minutes cache
44
+ });
45
+
46
+ // New API shape: { data: User[], pagination: {...} }
47
+ if (response?.data && Array.isArray(response.data)) {
48
+ const typedResponse = response;
49
+ const paginationInfo = typedResponse.pagination ?? {
50
+ total: typedResponse.data.length,
51
+ limit: pagination?.limit ?? typedResponse.data.length,
52
+ offset: pagination?.offset ?? 0,
53
+ hasMore: false
54
+ };
55
+ return {
56
+ data: typedResponse.data,
57
+ pagination: paginationInfo
58
+ };
59
+ }
60
+
61
+ // Legacy API shape: returns raw User[]
62
+ if (Array.isArray(response)) {
63
+ const fallbackPagination = {
64
+ total: response.length,
65
+ limit: pagination?.limit ?? response.length,
66
+ offset: pagination?.offset ?? 0,
67
+ hasMore: false
68
+ };
69
+ return {
70
+ data: response,
71
+ pagination: fallbackPagination
72
+ };
73
+ }
74
+
75
+ // If response is unexpected, throw an error
76
+ throw new Error('Unexpected search response format');
77
+ } catch (error) {
78
+ throw this.handleError(error);
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Get profile recommendations
84
+ */
85
+ async getProfileRecommendations() {
86
+ return this.withAuthRetry(async () => {
87
+ return await this.makeRequest('GET', '/api/profiles/recommendations', undefined, {
88
+ cache: true
89
+ });
90
+ }, 'getProfileRecommendations');
91
+ }
92
+
93
+ /**
94
+ * Get user by ID
95
+ */
96
+ async getUserById(userId) {
97
+ try {
98
+ return await this.makeRequest('GET', `/api/users/${userId}`, undefined, {
99
+ cache: true,
100
+ cacheTTL: 5 * 60 * 1000 // 5 minutes cache
101
+ });
102
+ } catch (error) {
103
+ throw this.handleError(error);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Get current user
109
+ */
110
+ async getCurrentUser() {
111
+ return this.withAuthRetry(async () => {
112
+ return await this.makeRequest('GET', '/api/users/me', undefined, {
113
+ cache: true,
114
+ cacheTTL: 1 * 60 * 1000 // 1 minute cache for current user
115
+ });
116
+ }, 'getCurrentUser');
117
+ }
118
+
119
+ /**
120
+ * Update user profile
121
+ */
122
+ async updateProfile(updates) {
123
+ try {
124
+ return await this.makeRequest('PUT', '/api/users/me', updates, {
125
+ cache: false
126
+ });
127
+ } catch (error) {
128
+ throw this.handleError(error);
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Get privacy settings for a user
134
+ * @param userId - The user ID (defaults to current user)
135
+ */
136
+ async getPrivacySettings(userId) {
137
+ try {
138
+ const id = userId || (await this.getCurrentUser()).id;
139
+ return await this.makeRequest('GET', `/api/privacy/${id}/privacy`, undefined, {
140
+ cache: true,
141
+ cacheTTL: 2 * 60 * 1000 // 2 minutes cache
142
+ });
143
+ } catch (error) {
144
+ throw this.handleError(error);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Update privacy settings
150
+ * @param settings - Partial privacy settings object
151
+ * @param userId - The user ID (defaults to current user)
152
+ */
153
+ async updatePrivacySettings(settings, userId) {
154
+ try {
155
+ const id = userId || (await this.getCurrentUser()).id;
156
+ return await this.makeRequest('PATCH', `/api/privacy/${id}/privacy`, settings, {
157
+ cache: false
158
+ });
159
+ } catch (error) {
160
+ throw this.handleError(error);
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Request account verification
166
+ */
167
+ async requestAccountVerification(reason, evidence) {
168
+ try {
169
+ return await this.makeRequest('POST', '/api/users/verify/request', {
170
+ reason,
171
+ evidence
172
+ }, {
173
+ cache: false
174
+ });
175
+ } catch (error) {
176
+ throw this.handleError(error);
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Download account data export
182
+ */
183
+ async downloadAccountData(format = 'json') {
184
+ try {
185
+ // Use axios instance directly for blob responses since RequestManager doesn't handle blobs
186
+ const axiosInstance = this.getClient().getAxiosInstance();
187
+ const response = await axiosInstance.get(`/api/users/me/data?format=${format}`, {
188
+ responseType: 'blob'
189
+ });
190
+ return response.data;
191
+ } catch (error) {
192
+ throw this.handleError(error);
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Delete account permanently
198
+ * @param password - User password for confirmation
199
+ * @param confirmText - Confirmation text (usually username)
200
+ */
201
+ async deleteAccount(password, confirmText) {
202
+ try {
203
+ return await this.makeRequest('DELETE', '/api/users/me', {
204
+ password,
205
+ confirmText
206
+ }, {
207
+ cache: false
208
+ });
209
+ } catch (error) {
210
+ throw this.handleError(error);
211
+ }
212
+ }
213
+
214
+ /**
215
+ * Update user by ID (admin function)
216
+ */
217
+ async updateUser(userId, updates) {
218
+ try {
219
+ return await this.makeRequest('PUT', `/api/users/${userId}`, updates, {
220
+ cache: false
221
+ });
222
+ } catch (error) {
223
+ throw this.handleError(error);
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Follow a user
229
+ */
230
+ async followUser(userId) {
231
+ try {
232
+ return await this.makeRequest('POST', `/api/users/${userId}/follow`, undefined, {
233
+ cache: false
234
+ });
235
+ } catch (error) {
236
+ throw this.handleError(error);
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Unfollow a user
242
+ */
243
+ async unfollowUser(userId) {
244
+ try {
245
+ return await this.makeRequest('DELETE', `/api/users/${userId}/follow`, undefined, {
246
+ cache: false
247
+ });
248
+ } catch (error) {
249
+ throw this.handleError(error);
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Get follow status
255
+ */
256
+ async getFollowStatus(userId) {
257
+ try {
258
+ return await this.makeRequest('GET', `/api/users/${userId}/follow-status`, undefined, {
259
+ cache: true,
260
+ cacheTTL: 1 * 60 * 1000 // 1 minute cache
261
+ });
262
+ } catch (error) {
263
+ throw this.handleError(error);
264
+ }
265
+ }
266
+
267
+ /**
268
+ * Get user followers
269
+ */
270
+ async getUserFollowers(userId, pagination) {
271
+ try {
272
+ const params = buildPaginationParams(pagination || {});
273
+ const response = await this.makeRequest('GET', `/api/users/${userId}/followers`, params, {
274
+ cache: true,
275
+ cacheTTL: 2 * 60 * 1000 // 2 minutes cache
276
+ });
277
+ return {
278
+ followers: response.data || [],
279
+ total: response.pagination.total,
280
+ hasMore: response.pagination.hasMore
281
+ };
282
+ } catch (error) {
283
+ throw this.handleError(error);
284
+ }
285
+ }
286
+
287
+ /**
288
+ * Get user following
289
+ */
290
+ async getUserFollowing(userId, pagination) {
291
+ try {
292
+ const params = buildPaginationParams(pagination || {});
293
+ const response = await this.makeRequest('GET', `/api/users/${userId}/following`, params, {
294
+ cache: true,
295
+ cacheTTL: 2 * 60 * 1000 // 2 minutes cache
296
+ });
297
+ return {
298
+ following: response.data || [],
299
+ total: response.pagination.total,
300
+ hasMore: response.pagination.hasMore
301
+ };
302
+ } catch (error) {
303
+ throw this.handleError(error);
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Get notifications
309
+ */
310
+ async getNotifications() {
311
+ return this.withAuthRetry(async () => {
312
+ return await this.makeRequest('GET', '/api/notifications', undefined, {
313
+ cache: false // Don't cache notifications - always get fresh data
314
+ });
315
+ }, 'getNotifications');
316
+ }
317
+
318
+ /**
319
+ * Get unread notification count
320
+ */
321
+ async getUnreadCount() {
322
+ try {
323
+ const res = await this.makeRequest('GET', '/api/notifications/unread-count', undefined, {
324
+ cache: false // Don't cache unread count - always get fresh data
325
+ });
326
+ return res.count;
327
+ } catch (error) {
328
+ throw this.handleError(error);
329
+ }
330
+ }
331
+
332
+ /**
333
+ * Create notification
334
+ */
335
+ async createNotification(data) {
336
+ try {
337
+ return await this.makeRequest('POST', '/api/notifications', data, {
338
+ cache: false
339
+ });
340
+ } catch (error) {
341
+ throw this.handleError(error);
342
+ }
343
+ }
344
+
345
+ /**
346
+ * Mark notification as read
347
+ */
348
+ async markNotificationAsRead(notificationId) {
349
+ try {
350
+ await this.makeRequest('PUT', `/api/notifications/${notificationId}/read`, undefined, {
351
+ cache: false
352
+ });
353
+ } catch (error) {
354
+ throw this.handleError(error);
355
+ }
356
+ }
357
+
358
+ /**
359
+ * Mark all notifications as read
360
+ */
361
+ async markAllNotificationsAsRead() {
362
+ try {
363
+ await this.makeRequest('PUT', '/api/notifications/read-all', undefined, {
364
+ cache: false
365
+ });
366
+ } catch (error) {
367
+ throw this.handleError(error);
368
+ }
369
+ }
370
+
371
+ /**
372
+ * Delete notification
373
+ */
374
+ async deleteNotification(notificationId) {
375
+ try {
376
+ await this.makeRequest('DELETE', `/api/notifications/${notificationId}`, undefined, {
377
+ cache: false
378
+ });
379
+ } catch (error) {
380
+ throw this.handleError(error);
381
+ }
382
+ }
383
+ };
384
+ }
385
+ //# sourceMappingURL=OxyServices.user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["buildSearchParams","buildPaginationParams","OxyServicesUserMixin","Base","constructor","args","getProfileByUsername","username","makeRequest","undefined","cache","cacheTTL","error","handleError","searchProfiles","query","pagination","params","searchParams","paramsObj","forEach","value","key","response","data","Array","isArray","typedResponse","paginationInfo","total","length","limit","offset","hasMore","fallbackPagination","Error","getProfileRecommendations","withAuthRetry","getUserById","userId","getCurrentUser","updateProfile","updates","getPrivacySettings","id","updatePrivacySettings","settings","requestAccountVerification","reason","evidence","downloadAccountData","format","axiosInstance","getClient","getAxiosInstance","get","responseType","deleteAccount","password","confirmText","updateUser","followUser","unfollowUser","getFollowStatus","getUserFollowers","followers","getUserFollowing","following","getNotifications","getUnreadCount","res","count","createNotification","markNotificationAsRead","notificationId","markAllNotificationsAsRead","deleteNotification"],"sourceRoot":"../../../../src","sources":["core/mixins/OxyServices.user.ts"],"mappings":";;AAAA;AACA;AACA;;AAGA,SAASA,iBAAiB,EAAEC,qBAAqB,QAA+B,sBAAsB;AAEtG,OAAO,SAASC,oBAAoBA,CAAmCC,IAAO,EAAE;EAC9E,OAAO,cAAcA,IAAI,CAAC;IACxBC,WAAWA,CAAC,GAAGC,IAAW,EAAE;MAC1B,KAAK,CAAC,GAAIA,IAAc,CAAC;IAC3B;IACA;AACJ;AACA;IACI,MAAMC,oBAAoBA,CAACC,QAAgB,EAAiB;MAC1D,IAAI;QACF,OAAO,MAAM,IAAI,CAACC,WAAW,CAAO,KAAK,EAAE,0BAA0BD,QAAQ,EAAE,EAAEE,SAAS,EAAE;UAC1FC,KAAK,EAAE,IAAI;UACXC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAE;QAC3B,CAAC,CAAC;MACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;;IAEA;AACJ;AACA;IACI,MAAME,cAAcA,CAACC,KAAa,EAAEC,UAA6B,EAAmC;MAClG,IAAI;QACF,MAAMC,MAAM,GAAG;UAAEF,KAAK;UAAE,GAAGC;QAAW,CAAC;QACvC,MAAME,YAAY,GAAGlB,iBAAiB,CAACiB,MAAM,CAAC;QAC9C,MAAME,SAAiC,GAAG,CAAC,CAAC;QAC5CD,YAAY,CAACE,OAAO,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;UACnCH,SAAS,CAACG,GAAG,CAAC,GAAGD,KAAK;QACxB,CAAC,CAAC;QAEF,MAAME,QAAQ,GAAG,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AAC;MACvG,CAAC,CAAC,OAAOE,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Utility Methods Mixin
5
+ *
6
+ * Provides utility methods including link metadata fetching
7
+ * and Express.js authentication middleware
8
+ */
9
+ import { jwtDecode } from 'jwt-decode';
10
+ import { CACHE_TIMES } from './mixinHelpers';
11
+ export function OxyServicesUtilityMixin(Base) {
12
+ return class extends Base {
13
+ constructor(...args) {
14
+ super(...args);
15
+ }
16
+ /**
17
+ * Fetch link metadata
18
+ */
19
+ async fetchLinkMetadata(url) {
20
+ try {
21
+ return await this.makeRequest('GET', '/api/link-metadata', {
22
+ url
23
+ }, {
24
+ cache: true,
25
+ cacheTTL: CACHE_TIMES.EXTRA_LONG
26
+ });
27
+ } catch (error) {
28
+ throw this.handleError(error);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Simple Express.js authentication middleware
34
+ *
35
+ * Built-in authentication middleware that validates JWT tokens and adds user data to requests.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // Basic usage - just add it to your routes
40
+ * app.use('/api/protected', oxyServices.auth());
41
+ *
42
+ * // With debug logging
43
+ * app.use('/api/protected', oxyServices.auth({ debug: true }));
44
+ *
45
+ * // With custom error handling
46
+ * app.use('/api/protected', oxyServices.auth({
47
+ * onError: (error) => console.error('Auth failed:', error)
48
+ * }));
49
+ *
50
+ * // Load full user data
51
+ * app.use('/api/protected', oxyServices.auth({ loadUser: true }));
52
+ * ```
53
+ *
54
+ * @param options Optional configuration
55
+ * @param options.debug Enable debug logging (default: false)
56
+ * @param options.onError Custom error handler
57
+ * @param options.loadUser Load full user data (default: false for performance)
58
+ * @param options.session Use session-based validation (default: false)
59
+ * @returns Express middleware function
60
+ */
61
+ auth(options = {}) {
62
+ const {
63
+ debug = false,
64
+ onError,
65
+ loadUser = false,
66
+ session = false
67
+ } = options;
68
+
69
+ // Return a synchronous middleware function
70
+ return (req, res, next) => {
71
+ try {
72
+ // Extract token from Authorization header
73
+ const authHeader = req.headers['authorization'];
74
+ const token = authHeader?.startsWith('Bearer ') ? authHeader.substring(7) : null;
75
+ if (debug) {
76
+ console.log(`🔐 Auth: Processing ${req.method} ${req.path}`);
77
+ console.log(`🔐 Auth: Token present: ${!!token}`);
78
+ }
79
+ if (!token) {
80
+ const error = {
81
+ message: 'Access token required',
82
+ code: 'MISSING_TOKEN',
83
+ status: 401
84
+ };
85
+ if (debug) console.log(`❌ Auth: Missing token`);
86
+ if (onError) return onError(error);
87
+ return res.status(401).json(error);
88
+ }
89
+
90
+ // Decode and validate token
91
+ let decoded;
92
+ try {
93
+ decoded = jwtDecode(token);
94
+ if (debug) {
95
+ console.log(`🔐 Auth: Token decoded, User ID: ${decoded.userId || decoded.id}`);
96
+ }
97
+ } catch (decodeError) {
98
+ const error = {
99
+ message: 'Invalid token format',
100
+ code: 'INVALID_TOKEN_FORMAT',
101
+ status: 403
102
+ };
103
+ if (debug) console.log(`❌ Auth: Token decode failed`);
104
+ if (onError) return onError(error);
105
+ return res.status(403).json(error);
106
+ }
107
+ const userId = decoded.userId || decoded.id;
108
+ if (!userId) {
109
+ const error = {
110
+ message: 'Token missing user ID',
111
+ code: 'INVALID_TOKEN_PAYLOAD',
112
+ status: 403
113
+ };
114
+ if (debug) console.log(`❌ Auth: Token missing user ID`);
115
+ if (onError) return onError(error);
116
+ return res.status(403).json(error);
117
+ }
118
+
119
+ // Check token expiration
120
+ if (decoded.exp && decoded.exp < Math.floor(Date.now() / 1000)) {
121
+ const error = {
122
+ message: 'Token expired',
123
+ code: 'TOKEN_EXPIRED',
124
+ status: 403
125
+ };
126
+ if (debug) console.log(`❌ Auth: Token expired`);
127
+ if (onError) return onError(error);
128
+ return res.status(403).json(error);
129
+ }
130
+
131
+ // For now, skip session validation to keep it simple
132
+ // Session validation can be added later if needed
133
+
134
+ // Set request properties immediately
135
+ req.userId = userId;
136
+ req.accessToken = token;
137
+ req.user = {
138
+ id: userId
139
+ };
140
+ if (debug) {
141
+ console.log(`✅ Auth: Authentication successful for user ${userId}`);
142
+ }
143
+ next();
144
+ } catch (error) {
145
+ const apiError = this.handleError(error);
146
+ if (debug) {
147
+ console.log(`❌ Auth: Unexpected error:`, apiError);
148
+ }
149
+ if (onError) return onError(apiError);
150
+ return res.status(apiError && apiError.status || 500).json(apiError);
151
+ }
152
+ };
153
+ }
154
+ };
155
+ }
156
+ //# sourceMappingURL=OxyServices.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["jwtDecode","CACHE_TIMES","OxyServicesUtilityMixin","Base","constructor","args","fetchLinkMetadata","url","makeRequest","cache","cacheTTL","EXTRA_LONG","error","handleError","auth","options","debug","onError","loadUser","session","req","res","next","authHeader","headers","token","startsWith","substring","console","log","method","path","message","code","status","json","decoded","userId","id","decodeError","exp","Math","floor","Date","now","accessToken","user","apiError"],"sourceRoot":"../../../../src","sources":["core/mixins/OxyServices.utility.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,YAAY;AAGtC,SAASC,WAAW,QAAQ,gBAAgB;AAU5C,OAAO,SAASC,uBAAuBA,CAAmCC,IAAO,EAAE;EACjF,OAAO,cAAcA,IAAI,CAAC;IACxBC,WAAWA,CAAC,GAAGC,IAAW,EAAE;MAC1B,KAAK,CAAC,GAAIA,IAAc,CAAC;IAC3B;IACA;AACJ;AACA;IACI,MAAMC,iBAAiBA,CAACC,GAAW,EAKhC;MACD,IAAI;QACF,OAAO,MAAM,IAAI,CAACC,WAAW,CAK1B,KAAK,EAAE,oBAAoB,EAAE;UAAED;QAAI,CAAC,EAAE;UACvCE,KAAK,EAAE,IAAI;UACXC,QAAQ,EAAET,WAAW,CAACU;QACxB,CAAC,CAAC;MACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KA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AC;YAE/C,IAAIZ,OAAO,EAAE,OAAOA,OAAO,CAACL,KAAK,CAAC;YAClC,OAAOS,GAAG,CAACa,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAACvB,KAAK,CAAC;UACpC;;UAEA;UACA;;UAEA;UACAQ,GAAG,CAACiB,MAAM,GAAGA,MAAM;UACnBjB,GAAG,CAACyB,WAAW,GAAGpB,KAAK;UACvBL,GAAG,CAAC0B,IAAI,GAAG;YAAER,EAAE,EAAED;UAAO,CAAS;UAEjC,IAAIrB,KAAK,EAAE;YACTY,OAAO,CAACC,GAAG,CAAC,8CAA8CQ,MAAM,EAAE,CAAC;UACrE;UAEAf,IAAI,CAAC,CAAC;QACR,CAAC,CAAC,OAAOV,KAAK,EAAE;UACd,MAAMmC,QAAQ,GAAG,IAAI,CAAClC,WAAW,CAACD,KAAK,CAAQ;UAE/C,IAAII,KAAK,EAAE;YACTY,OAAO,CAACC,GAAG,CAAC,2BAA2B,EAAEkB,QAAQ,CAAC;UACpD;UAEA,IAAI9B,OAAO,EAAE,OAAOA,OAAO,CAAC8B,QAAQ,CAAC;UACrC,OAAO1B,GAAG,CAACa,MAAM,CAAEa,QAAQ,IAAIA,QAAQ,CAACb,MAAM,IAAK,GAAG,CAAC,CAACC,IAAI,CAACY,QAAQ,CAAC;QACxE;MACF,CAAC;IACH;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Centralized mixin exports and composition helper
5
+ *
6
+ * This module provides a clean way to compose all mixins
7
+ * and ensures consistent ordering for better maintainability
8
+ */
9
+
10
+ import { OxyServicesBase } from '../OxyServices.base';
11
+ import { OxyServicesAuthMixin } from './OxyServices.auth';
12
+ import { OxyServicesUserMixin } from './OxyServices.user';
13
+ import { OxyServicesTotpMixin } from './OxyServices.totp';
14
+ import { OxyServicesPrivacyMixin } from './OxyServices.privacy';
15
+ import { OxyServicesLanguageMixin } from './OxyServices.language';
16
+ import { OxyServicesPaymentMixin } from './OxyServices.payment';
17
+ import { OxyServicesKarmaMixin } from './OxyServices.karma';
18
+ import { OxyServicesAssetsMixin } from './OxyServices.assets';
19
+ import { OxyServicesDeveloperMixin } from './OxyServices.developer';
20
+ import { OxyServicesLocationMixin } from './OxyServices.location';
21
+ import { OxyServicesAnalyticsMixin } from './OxyServices.analytics';
22
+ import { OxyServicesDevicesMixin } from './OxyServices.devices';
23
+ import { OxyServicesUtilityMixin } from './OxyServices.utility';
24
+
25
+ /**
26
+ * Composes all OxyServices mixins in the correct order
27
+ *
28
+ * Order matters for mixins - dependencies should be applied first.
29
+ * This function ensures consistent composition across the codebase.
30
+ *
31
+ * @returns The fully composed OxyServices class with all mixins applied
32
+ */
33
+ export function composeOxyServices() {
34
+ return OxyServicesUtilityMixin(OxyServicesDevicesMixin(OxyServicesAnalyticsMixin(OxyServicesLocationMixin(OxyServicesDeveloperMixin(OxyServicesAssetsMixin(OxyServicesKarmaMixin(OxyServicesPaymentMixin(OxyServicesLanguageMixin(OxyServicesPrivacyMixin(OxyServicesTotpMixin(OxyServicesUserMixin(OxyServicesAuthMixin(OxyServicesBase)))))))))))));
35
+ }
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OxyServicesBase","OxyServicesAuthMixin","OxyServicesUserMixin","OxyServicesTotpMixin","OxyServicesPrivacyMixin","OxyServicesLanguageMixin","OxyServicesPaymentMixin","OxyServicesKarmaMixin","OxyServicesAssetsMixin","OxyServicesDeveloperMixin","OxyServicesLocationMixin","OxyServicesAnalyticsMixin","OxyServicesDevicesMixin","OxyServicesUtilityMixin","composeOxyServices"],"sourceRoot":"../../../../src","sources":["core/mixins/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,qBAAqB;AACrD,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SAASC,wBAAwB,QAAQ,wBAAwB;AACjE,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SAASC,qBAAqB,QAAQ,qBAAqB;AAC3D,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAASC,wBAAwB,QAAQ,wBAAwB;AACjE,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SAASC,uBAAuB,QAAQ,uBAAuB;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,OAAOD,uBAAuB,CAC5BD,uBAAuB,CACrBD,yBAAyB,CACvBD,wBAAwB,CACtBD,yBAAyB,CACvBD,sBAAsB,CACpBD,qBAAqB,CACnBD,uBAAuB,CACrBD,wBAAwB,CACtBD,uBAAuB,CACrBD,oBAAoB,CAClBD,oBAAoB,CAClBD,oBAAoB,CAACD,eAAe,CACtC,CACF,CACF,CACF,CACF,CACF,CACF,CACF,CACF,CACF,CACF,CACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Helper utilities for mixin classes
5
+ * Provides common patterns to reduce code duplication
6
+ */
7
+
8
+ /**
9
+ * Wraps an async method with standard error handling
10
+ * Reduces boilerplate in mixin methods
11
+ */
12
+ export async function withErrorHandling(operation, handleError) {
13
+ try {
14
+ return await operation();
15
+ } catch (error) {
16
+ throw handleError(error);
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Creates a standard API request method with error handling
22
+ * Reduces duplication across mixin methods
23
+ */
24
+ export function createApiMethod(makeRequest, handleError, method, url, options = {}) {
25
+ return async (...args) => {
26
+ const urlString = typeof url === 'function' ? url(...args) : url;
27
+ const requestData = options.transformData ? options.transformData(args) : args[0];
28
+ const requestOptions = {
29
+ cache: options.cache ?? true,
30
+ cacheTTL: options.cacheTTL,
31
+ retry: options.retry ?? true
32
+ };
33
+ try {
34
+ const response = await makeRequest(method, urlString, requestData, requestOptions);
35
+ return options.transformResponse ? options.transformResponse(response) : response;
36
+ } catch (error) {
37
+ throw handleError(error);
38
+ }
39
+ };
40
+ }
41
+
42
+ /**
43
+ * Cache time constants (in milliseconds)
44
+ */
45
+ export const CACHE_TIMES = {
46
+ SHORT: 1 * 60 * 1000,
47
+ // 1 minute
48
+ MEDIUM: 2 * 60 * 1000,
49
+ // 2 minutes
50
+ LONG: 5 * 60 * 1000,
51
+ // 5 minutes
52
+ VERY_LONG: 10 * 60 * 1000,
53
+ // 10 minutes
54
+ EXTRA_LONG: 30 * 60 * 1000 // 30 minutes
55
+ };
56
+ //# sourceMappingURL=mixinHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withErrorHandling","operation","handleError","error","createApiMethod","makeRequest","method","url","options","args","urlString","requestData","transformData","requestOptions","cache","cacheTTL","retry","response","transformResponse","CACHE_TIMES","SHORT","MEDIUM","LONG","VERY_LONG","EXTRA_LONG"],"sourceRoot":"../../../../src","sources":["core/mixins/mixinHelpers.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,OAAO,eAAeA,iBAAiBA,CACrCC,SAA2B,EAC3BC,WAAkC,EACtB;EACZ,IAAI;IACF,OAAO,MAAMD,SAAS,CAAC,CAAC;EAC1B,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,MAAMD,WAAW,CAACC,KAAK,CAAC;EAC1B;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,WAA2C,EAC3CH,WAA2C,EAC3CI,MAAmD,EACnDC,GAA0C,EAC1CC,OAMC,GAAG,CAAC,CAAC,EACN;EACA,OAAO,OAAO,GAAGC,IAAW,KAAiB;IAC3C,MAAMC,SAAS,GAAG,OAAOH,GAAG,KAAK,UAAU,GAAGA,GAAG,C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