@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
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Authentication Methods Mixin
5
+ */
6
+
7
+ import { OxyAuthenticationError } from '../OxyServices.errors';
8
+ export function OxyServicesAuthMixin(Base) {
9
+ return class extends Base {
10
+ constructor(...args) {
11
+ super(...args);
12
+ }
13
+ /**
14
+ * Sign up a new user
15
+ */
16
+ async signUp(username, email, password) {
17
+ try {
18
+ const res = await this.makeRequest('POST', '/api/auth/signup', {
19
+ username,
20
+ email,
21
+ password
22
+ }, {
23
+ cache: false
24
+ });
25
+ if (!res || typeof res === 'object' && Object.keys(res).length === 0) {
26
+ throw new OxyAuthenticationError('Sign up failed', 'SIGNUP_FAILED', 400);
27
+ }
28
+ return res;
29
+ } catch (error) {
30
+ throw this.handleError(error);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Request account recovery (send verification code)
36
+ */
37
+ async requestRecovery(identifier) {
38
+ try {
39
+ return await this.makeRequest('POST', '/api/auth/recover/request', {
40
+ identifier
41
+ }, {
42
+ cache: false
43
+ });
44
+ } catch (error) {
45
+ throw this.handleError(error);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Verify recovery code
51
+ */
52
+ async verifyRecoveryCode(identifier, code) {
53
+ try {
54
+ return await this.makeRequest('POST', '/api/auth/recover/verify', {
55
+ identifier,
56
+ code
57
+ }, {
58
+ cache: false
59
+ });
60
+ } catch (error) {
61
+ throw this.handleError(error);
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Reset password using verified code
67
+ */
68
+ async resetPassword(identifier, code, newPassword) {
69
+ try {
70
+ return await this.makeRequest('POST', '/api/auth/recover/reset', {
71
+ identifier,
72
+ code,
73
+ newPassword
74
+ }, {
75
+ cache: false
76
+ });
77
+ } catch (error) {
78
+ throw this.handleError(error);
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Reset password using TOTP code (recommended recovery)
84
+ */
85
+ async resetPasswordWithTotp(identifier, code, newPassword) {
86
+ try {
87
+ return await this.makeRequest('POST', '/api/auth/recover/totp/reset', {
88
+ identifier,
89
+ code,
90
+ newPassword
91
+ }, {
92
+ cache: false
93
+ });
94
+ } catch (error) {
95
+ throw this.handleError(error);
96
+ }
97
+ }
98
+ async resetPasswordWithBackupCode(identifier, backupCode, newPassword) {
99
+ try {
100
+ return await this.makeRequest('POST', '/api/auth/recover/backup/reset', {
101
+ identifier,
102
+ backupCode,
103
+ newPassword
104
+ }, {
105
+ cache: false
106
+ });
107
+ } catch (error) {
108
+ throw this.handleError(error);
109
+ }
110
+ }
111
+ async resetPasswordWithRecoveryKey(identifier, recoveryKey, newPassword) {
112
+ try {
113
+ return await this.makeRequest('POST', '/api/auth/recover/recovery-key/reset', {
114
+ identifier,
115
+ recoveryKey,
116
+ newPassword
117
+ }, {
118
+ cache: false
119
+ });
120
+ } catch (error) {
121
+ throw this.handleError(error);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Sign in with device management
127
+ */
128
+ async signIn(username, password, deviceName, deviceFingerprint) {
129
+ try {
130
+ return await this.makeRequest('POST', '/api/auth/login', {
131
+ username,
132
+ password,
133
+ deviceName,
134
+ deviceFingerprint
135
+ }, {
136
+ cache: false
137
+ });
138
+ } catch (error) {
139
+ throw this.handleError(error);
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Complete login by verifying TOTP with MFA token
145
+ */
146
+ async verifyTotpLogin(mfaToken, code) {
147
+ try {
148
+ return await this.makeRequest('POST', '/api/auth/totp/verify-login', {
149
+ mfaToken,
150
+ code
151
+ }, {
152
+ cache: false
153
+ });
154
+ } catch (error) {
155
+ throw this.handleError(error);
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Get user by session ID
161
+ */
162
+ async getUserBySession(sessionId) {
163
+ try {
164
+ return await this.makeRequest('GET', `/api/session/user/${sessionId}`, undefined, {
165
+ cache: true,
166
+ cacheTTL: 2 * 60 * 1000 // 2 minutes cache for user data
167
+ });
168
+ } catch (error) {
169
+ throw this.handleError(error);
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Batch get multiple user profiles by session IDs (optimized for account switching)
175
+ * Returns array of { sessionId, user } objects
176
+ */
177
+ async getUsersBySessions(sessionIds) {
178
+ try {
179
+ if (!Array.isArray(sessionIds) || sessionIds.length === 0) {
180
+ return [];
181
+ }
182
+
183
+ // Deduplicate and sort sessionIds for consistent cache keys
184
+ const uniqueSessionIds = Array.from(new Set(sessionIds)).sort();
185
+ return await this.makeRequest('POST', '/api/session/users/batch', {
186
+ sessionIds: uniqueSessionIds
187
+ }, {
188
+ cache: true,
189
+ cacheTTL: 2 * 60 * 1000,
190
+ // 2 minutes cache
191
+ deduplicate: true // Important for batch requests
192
+ });
193
+ } catch (error) {
194
+ throw this.handleError(error);
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Get access token by session ID and set it in the token store
200
+ */
201
+ async getTokenBySession(sessionId) {
202
+ try {
203
+ const res = await this.makeRequest('GET', `/api/session/token/${sessionId}`, undefined, {
204
+ cache: false,
205
+ retry: false
206
+ });
207
+
208
+ // Set the token in the centralized token store
209
+ this.setTokens(res.accessToken);
210
+ return res;
211
+ } catch (error) {
212
+ throw this.handleError(error);
213
+ }
214
+ }
215
+
216
+ /**
217
+ * Get sessions by session ID
218
+ */
219
+ async getSessionsBySessionId(sessionId) {
220
+ try {
221
+ return await this.makeRequest('GET', `/api/session/sessions/${sessionId}`, undefined, {
222
+ cache: false
223
+ });
224
+ } catch (error) {
225
+ throw this.handleError(error);
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Logout from a specific session
231
+ */
232
+ async logoutSession(sessionId, targetSessionId) {
233
+ try {
234
+ const url = targetSessionId ? `/api/session/logout/${sessionId}/${targetSessionId}` : `/api/session/logout/${sessionId}`;
235
+ await this.makeRequest('POST', url, undefined, {
236
+ cache: false
237
+ });
238
+ } catch (error) {
239
+ throw this.handleError(error);
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Logout from all sessions
245
+ */
246
+ async logoutAllSessions(sessionId) {
247
+ try {
248
+ await this.makeRequest('POST', `/api/session/logout-all/${sessionId}`, undefined, {
249
+ cache: false
250
+ });
251
+ } catch (error) {
252
+ throw this.handleError(error);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * Validate session
258
+ */
259
+ async validateSession(sessionId, options = {}) {
260
+ try {
261
+ const urlParams = {};
262
+ if (options.deviceFingerprint) urlParams.deviceFingerprint = options.deviceFingerprint;
263
+ if (options.useHeaderValidation) urlParams.useHeaderValidation = 'true';
264
+ return await this.makeRequest('GET', `/api/session/validate/${sessionId}`, urlParams, {
265
+ cache: false
266
+ });
267
+ } catch (error) {
268
+ throw this.handleError(error);
269
+ }
270
+ }
271
+
272
+ /**
273
+ * Check username availability
274
+ */
275
+ async checkUsernameAvailability(username) {
276
+ try {
277
+ return await this.makeRequest('GET', `/api/auth/check-username/${username}`, undefined, {
278
+ cache: false
279
+ });
280
+ } catch (error) {
281
+ throw this.handleError(error);
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Check email availability
287
+ */
288
+ async checkEmailAvailability(email) {
289
+ try {
290
+ return await this.makeRequest('GET', `/api/auth/check-email/${email}`, undefined, {
291
+ cache: false
292
+ });
293
+ } catch (error) {
294
+ throw this.handleError(error);
295
+ }
296
+ }
297
+ };
298
+ }
299
+ //# sourceMappingURL=OxyServices.auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OxyAuthenticationError","OxyServicesAuthMixin","Base","constructor","args","signUp","username","email","password","res","makeRequest","cache","Object","keys","length","error","handleError","requestRecovery","identifier","verifyRecoveryCode","code","resetPassword","newPassword","resetPasswordWithTotp","resetPasswordWithBackupCode","backupCode","resetPasswordWithRecoveryKey","recoveryKey","signIn","deviceName","deviceFingerprint","verifyTotpLogin","mfaToken","getUserBySession","sessionId","undefined","cacheTTL","getUsersBySessions","sessionIds","Array","isArray","uniqueSessionIds","from","Set","sort","deduplicate","getTokenBySession","retry","setTokens","accessToken","getSessionsBySessionId","logoutSession","targetSessionId","url","logoutAllSessions","validateSession","options","urlParams","useHeaderValidation","checkUsernameAvailability","checkEmailAvailability"],"sourceRoot":"../../../../src","sources":["core/mixins/OxyServices.auth.ts"],"mappings":";;AAAA;AACA;AACA;;AAIA,SAASA,sBAAsB,QAAQ,uBAAuB;AAE9D,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,MAAMA,CAACC,QAAgB,EAAEC,KAAa,EAAEC,QAAgB,EAA2D;MACvH,IAAI;QACF,MAAMC,GAAG,GAAG,MAAM,IAAI,CAACC,WAAW,CAAiD,MAAM,EAAE,kBAAkB,EAAE;UAC7GJ,QAAQ;UACRC,KAAK;UACLC;QACF,CAAC,EAAE;UAAEG,KAAK,EAAE;QAAM,CAAC,CAAC;QACpB,IA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AACI,WAAW,CAAC,KAAK,EAAE,4BAA4BJ,QAAQ,EAAE,EAAE6B,SAAS,EAAE;UAAExB,KAAK,EAAE;QAAM,CAAC,CAAC;MAC3G,CAAC,CAAC,OAAOI,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;;IAEA;AACJ;AACA;IACI,MAAM6C,sBAAsBA,CAACrD,KAAa,EAAoD;MAC5F,IAAI;QACF,OAAO,MAAM,IAAI,CAACG,WAAW,CAAC,KAAK,EAAE,yBAAyBH,KAAK,EAAE,EAAE4B,SAAS,EAAE;UAAExB,KAAK,EAAE;QAAM,CAAC,CAAC;MACrG,CAAC,CAAC,OAAOI,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Developer API Methods Mixin
5
+ *
6
+ * Provides methods for managing developer applications and API keys
7
+ */
8
+
9
+ import { CACHE_TIMES } from './mixinHelpers';
10
+ export function OxyServicesDeveloperMixin(Base) {
11
+ return class extends Base {
12
+ constructor(...args) {
13
+ super(...args);
14
+ }
15
+
16
+ /**
17
+ * Get developer apps for the current user
18
+ * @returns Array of developer apps
19
+ */
20
+ async getDeveloperApps() {
21
+ try {
22
+ const res = await this.makeRequest('GET', '/api/developer/apps', undefined, {
23
+ cache: true,
24
+ cacheTTL: CACHE_TIMES.MEDIUM
25
+ });
26
+ return res.apps || [];
27
+ } catch (error) {
28
+ throw this.handleError(error);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Create a new developer app
34
+ * @param data - Developer app configuration
35
+ * @returns Created developer app
36
+ */
37
+ async createDeveloperApp(data) {
38
+ try {
39
+ const res = await this.makeRequest('POST', '/api/developer/apps', data, {
40
+ cache: false
41
+ });
42
+ return res.app;
43
+ } catch (error) {
44
+ throw this.handleError(error);
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Get a specific developer app
50
+ */
51
+ async getDeveloperApp(appId) {
52
+ try {
53
+ const res = await this.makeRequest('GET', `/api/developer/apps/${appId}`, undefined, {
54
+ cache: true,
55
+ cacheTTL: CACHE_TIMES.LONG
56
+ });
57
+ return res.app;
58
+ } catch (error) {
59
+ throw this.handleError(error);
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Update a developer app
65
+ * @param appId - The developer app ID
66
+ * @param data - Updated app configuration
67
+ * @returns Updated developer app
68
+ */
69
+ async updateDeveloperApp(appId, data) {
70
+ try {
71
+ const res = await this.makeRequest('PATCH', `/api/developer/apps/${appId}`, data, {
72
+ cache: false
73
+ });
74
+ return res.app;
75
+ } catch (error) {
76
+ throw this.handleError(error);
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Regenerate API secret for a developer app
82
+ * @param appId - The developer app ID
83
+ * @returns App with new secret
84
+ */
85
+ async regenerateDeveloperAppSecret(appId) {
86
+ try {
87
+ return await this.makeRequest('POST', `/api/developer/apps/${appId}/regenerate-secret`, undefined, {
88
+ cache: false
89
+ });
90
+ } catch (error) {
91
+ throw this.handleError(error);
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Delete a developer app
97
+ * @param appId - The developer app ID
98
+ * @returns Deletion result
99
+ */
100
+ async deleteDeveloperApp(appId) {
101
+ try {
102
+ return await this.makeRequest('DELETE', `/api/developer/apps/${appId}`, undefined, {
103
+ cache: false
104
+ });
105
+ } catch (error) {
106
+ throw this.handleError(error);
107
+ }
108
+ }
109
+ };
110
+ }
111
+ //# sourceMappingURL=OxyServices.developer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CACHE_TIMES","OxyServicesDeveloperMixin","Base","constructor","args","getDeveloperApps","res","makeRequest","undefined","cache","cacheTTL","MEDIUM","apps","error","handleError","createDeveloperApp","data","app","getDeveloperApp","appId","LONG","updateDeveloperApp","regenerateDeveloperAppSecret","deleteDeveloperApp"],"sourceRoot":"../../../../src","sources":["core/mixins/OxyServ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Mixin(Base) {
8
+ return class extends Base {
9
+ constructor(...args) {
10
+ super(...args);
11
+ }
12
+
13
+ /**
14
+ * Register a new device
15
+ * @param deviceData - Device information
16
+ * @returns Registered device object
17
+ */
18
+ async registerDevice(deviceData) {
19
+ try {
20
+ return await this.makeRequest('POST', '/api/devices', deviceData, {
21
+ cache: false
22
+ });
23
+ } catch (error) {
24
+ throw this.handleError(error);
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Get all devices for the current user
30
+ * @returns Array of user devices
31
+ */
32
+ async getUserDevices() {
33
+ try {
34
+ return await this.makeRequest('GET', '/api/devices', undefined, {
35
+ cache: false // Don't cache device list - always get fresh data
36
+ });
37
+ } catch (error) {
38
+ throw this.handleError(error);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Remove a device
44
+ * @param deviceId - The device ID to remove
45
+ */
46
+ async removeDevice(deviceId) {
47
+ try {
48
+ await this.makeRequest('DELETE', `/api/devices/${deviceId}`, undefined, {
49
+ cache: false
50
+ });
51
+ } catch (error) {
52
+ throw this.handleError(error);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Get device sessions for a given session ID
58
+ * Note: Not cached by default to ensure fresh data
59
+ * @param sessionId - The session ID
60
+ * @returns Array of device sessions
61
+ */
62
+ async getDeviceSessions(sessionId) {
63
+ try {
64
+ // Use makeRequest for consistent error handling and optional caching
65
+ // Cache disabled by default to ensure fresh session data
66
+ return await this.makeRequest('GET', `/api/session/device/sessions/${sessionId}`, undefined, {
67
+ cache: false,
68
+ // Don't cache sessions - always get fresh data
69
+ deduplicate: true // Deduplicate concurrent requests for same sessionId
70
+ });
71
+ } catch (error) {
72
+ throw this.handleError(error);
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Logout all device sessions
78
+ * @param sessionId - The session ID
79
+ * @param deviceId - Optional device ID to target
80
+ * @param excludeCurrent - Whether to exclude the current session
81
+ * @returns Logout result
82
+ */
83
+ async logoutAllDeviceSessions(sessionId, deviceId, excludeCurrent) {
84
+ try {
85
+ const urlParams = {};
86
+ if (deviceId) urlParams.deviceId = deviceId;
87
+ if (excludeCurrent) urlParams.excludeCurrent = 'true';
88
+ return await this.makeRequest('POST', `/api/session/device/logout-all/${sessionId}`, urlParams, {
89
+ cache: false
90
+ });
91
+ } catch (error) {
92
+ throw this.handleError(error);
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Update device name
98
+ * @param sessionId - The session ID
99
+ * @param deviceName - New device name
100
+ * @returns Updated device object
101
+ */
102
+ async updateDeviceName(sessionId, deviceName) {
103
+ try {
104
+ return await this.makeRequest('PUT', `/api/session/device/name/${sessionId}`, {
105
+ deviceName
106
+ }, {
107
+ cache: false
108
+ });
109
+ } catch (error) {
110
+ throw this.handleError(error);
111
+ }
112
+ }
113
+ };
114
+ }
115
+ //# sourceMappingURL=OxyServices.devices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OxyServicesDevicesMixin","Base","constructor","args","registerDevice","deviceData","makeRequest","cache","error","handleError","getUserDevices","undefined","removeDevice","deviceId","getDeviceSessions","sessionId","deduplicate","logoutAllDeviceSessions","excludeCurrent","urlParams","updateDeviceName","deviceName"],"sourceRoot":"../../../../src","sources":["core/mixins/OxyServices.devices.ts"],"mappings":";;AAAA;AACA;AACA;;AAGA,OAAO,SAASA,uBAAuBA,CAAmCC,IAAO,EAAE;EACjF,OAAO,cAAcA,IAAI,CAAC;IACxBC,WAAWA,CAAC,GAAGC,IAAW,EAAE;MAC1B,KAAK,CAAC,GAAIA,IAAc,CAAC;IAC3B;;IAEA;AACJ;AACA;AACA;AACA;IACI,MAAMC,cAAcA,CAACC,UAAe,EAAgB;MAClD,IAAI;QACF,OAAO,MAAM,IAAI,CAACC,WAAW,CAAC,MAAM,EAAE,cAAc,EAAED,UAAU,EAAE;UAAEE,KAAK,EAAE;QAAM,CAAC,CAAC;MACrF,CAAC,CAAC,OAAOC,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;;IAEA;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;QACrD,OAAO,MAAM,IAAI,CAACZ,WAAW,CAAC,MAAM,EAAE,kCAAkCS,SAAS,EAAE,EAAEI,SAAS,EAAE;UAAEZ,KAAK,EAAE;QAAM,CAAC,CAAC;MACnH,CAAC,CAAC,OAAOC,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;;IAEA;AACJ;AACA;AACA;AACA;AACA;IACI,MAAMY,gBAAgBA,CAACL,SAAiB,EAAEM,UAAkB,EAAgB;MAC1E,IAAI;QACF,OAAO,MAAM,IAAI,CAACf,WAAW,CAAC,KAAK,EAAE,4BAA4BS,SAAS,EAAE,EAAE;UAAEM;QAAW,CAAC,EAAE;UAAEd,KAAK,EAAE;QAAM,CAAC,CAAC;MACjH,CAAC,CAAC,OAAOC,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Karma Methods Mixin
5
+ *
6
+ * Provides methods for karma system management
7
+ */
8
+
9
+ import { CACHE_TIMES } from './mixinHelpers';
10
+ export function OxyServicesKarmaMixin(Base) {
11
+ return class extends Base {
12
+ constructor(...args) {
13
+ super(...args);
14
+ }
15
+ /**
16
+ * Get user karma
17
+ */
18
+ async getUserKarma(userId) {
19
+ try {
20
+ return await this.makeRequest('GET', `/api/karma/${userId}`, undefined, {
21
+ cache: true,
22
+ cacheTTL: 2 * 60 * 1000 // 2 minutes cache
23
+ });
24
+ } catch (error) {
25
+ throw this.handleError(error);
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Give karma to user
31
+ */
32
+ async giveKarma(userId, amount, reason) {
33
+ try {
34
+ return await this.makeRequest('POST', `/api/karma/${userId}/give`, {
35
+ amount,
36
+ reason
37
+ }, {
38
+ cache: false
39
+ });
40
+ } catch (error) {
41
+ throw this.handleError(error);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Get user karma total
47
+ * @param userId - The user ID
48
+ * @returns User karma total
49
+ */
50
+ async getUserKarmaTotal(userId) {
51
+ try {
52
+ return await this.makeRequest('GET', `/api/karma/${userId}/total`, undefined, {
53
+ cache: true,
54
+ cacheTTL: CACHE_TIMES.MEDIUM
55
+ });
56
+ } catch (error) {
57
+ throw this.handleError(error);
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Get user karma history
63
+ * @param userId - The user ID
64
+ * @param limit - Optional limit for results
65
+ * @param offset - Optional offset for pagination
66
+ * @returns User karma history
67
+ */
68
+ async getUserKarmaHistory(userId, limit, offset) {
69
+ try {
70
+ const params = {};
71
+ if (limit) params.limit = limit;
72
+ if (offset) params.offset = offset;
73
+ return await this.makeRequest('GET', `/api/karma/${userId}/history`, params, {
74
+ cache: true,
75
+ cacheTTL: CACHE_TIMES.MEDIUM
76
+ });
77
+ } catch (error) {
78
+ throw this.handleError(error);
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Get karma leaderboard
84
+ * @returns Karma leaderboard
85
+ */
86
+ async getKarmaLeaderboard() {
87
+ try {
88
+ return await this.makeRequest('GET', '/api/karma/leaderboard', undefined, {
89
+ cache: true,
90
+ cacheTTL: CACHE_TIMES.LONG
91
+ });
92
+ } catch (error) {
93
+ throw this.handleError(error);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Get karma rules
99
+ * @returns Karma rules
100
+ */
101
+ async getKarmaRules() {
102
+ try {
103
+ return await this.makeRequest('GET', '/api/karma/rules', undefined, {
104
+ cache: true,
105
+ cacheTTL: CACHE_TIMES.EXTRA_LONG // Rules don't change often
106
+ });
107
+ } catch (error) {
108
+ throw this.handleError(error);
109
+ }
110
+ }
111
+ };
112
+ }
113
+ //# sourceMappingURL=OxyServices.karma.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CACHE_TIMES","OxyServicesKarmaMixin","Base","constructor","args","getUserKarma","userId","makeRequest","undefined","cache","cacheTTL","error","handleError","giveKarma","amount","reason","getUserKarmaTotal","MEDIUM","getUserKarmaHistory","limit","offset","params","getKarmaLeaderboard","LONG","getKarmaRules","EXTRA_LONG"],"sourceRoot":"../../../../src","sources":["core/mixins/OxyServices.karma.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,gBAAgB;AAE5C,OAAO,SAASC,qBAAqBA,CAAmCC,IAAO,EAAE;EAC/E,OAAO,cAAcA,IAAI,CAAC;IACxBC,WAAWA,CAAC,GAAGC,IAAW,EAAE;MAC1B,KAAK,CAAC,GAAIA,IAAc,CAAC;IAC3B;IACA;AACJ;AACA;IACI,MAAMC,YAAYA,CAACC,MAAc,EAAgB;MAC/C,IAAI;QACF,OAAO,MAAM,IAAI,CAACC,WAAW,CAAC,KAAK,EAAE,cAAcD,MAAM,EAAE,EAAEE,SAAS,EAAE;UACtEC,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,SAASA,CAACP,MAAc,EAAEQ,MAAc,EAAEC,MAAe,EAAgB;MAC7E,IAAI;QACF,OAAO,MAAM,IAAI,CAACR,WAAW,CAAC,MAAM,EAAE,cAAcD,MAAM,OAAO,EAAE;UACjEQ,MAAM;UACNC;QACF,CAAC,EAAE;UAAEN,KAAK,EAAE;QAAM,CAAC,CAAC;MACtB,CAAC,CAAC,OAAOE,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;;IAEA;AACJ;AACA;AACA;AACA;IACI,MAAMK,iBAAiBA,CAACV,MAAc,EAAgB;MACpD,IAAI;QACF,OAAO,MAAM,IAAI,CAACC,WAAW,CAAC,KAAK,EAAE,cAAcD,MAAM,QAAQ,EAAEE,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