@oxyhq/services 5.13.15 → 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.
- package/README.md +10 -0
- package/lib/commonjs/core/OxyServices.base.js +271 -0
- package/lib/commonjs/core/OxyServices.base.js.map +1 -0
- package/lib/commonjs/core/OxyServices.errors.js +26 -0
- package/lib/commonjs/core/OxyServices.errors.js.map +1 -0
- package/lib/commonjs/core/OxyServices.js +58 -2168
- package/lib/commonjs/core/OxyServices.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.analytics.js +60 -0
- package/lib/commonjs/core/mixins/OxyServices.analytics.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.assets.js +406 -0
- package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.auth.js +303 -0
- package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.developer.js +115 -0
- package/lib/commonjs/core/mixins/OxyServices.developer.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.devices.js +119 -0
- package/lib/commonjs/core/mixins/OxyServices.devices.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.karma.js +117 -0
- package/lib/commonjs/core/mixins/OxyServices.karma.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.language.js +124 -0
- package/lib/commonjs/core/mixins/OxyServices.language.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.location.js +55 -0
- package/lib/commonjs/core/mixins/OxyServices.location.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.payment.js +66 -0
- package/lib/commonjs/core/mixins/OxyServices.payment.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.privacy.js +174 -0
- package/lib/commonjs/core/mixins/OxyServices.privacy.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.totp.js +53 -0
- package/lib/commonjs/core/mixins/OxyServices.totp.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.user.js +389 -0
- package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.utility.js +161 -0
- package/lib/commonjs/core/mixins/OxyServices.utility.js.map +1 -0
- package/lib/commonjs/core/mixins/index.js +39 -0
- package/lib/commonjs/core/mixins/index.js.map +1 -0
- package/lib/commonjs/core/mixins/mixinHelpers.js +62 -0
- package/lib/commonjs/core/mixins/mixinHelpers.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +27 -2
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/module/core/OxyServices.base.js +265 -0
- package/lib/module/core/OxyServices.base.js.map +1 -0
- package/lib/module/core/OxyServices.errors.js +20 -0
- package/lib/module/core/OxyServices.errors.js.map +1 -0
- package/lib/module/core/OxyServices.js +43 -2164
- package/lib/module/core/OxyServices.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.analytics.js +56 -0
- package/lib/module/core/mixins/OxyServices.analytics.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.assets.js +402 -0
- package/lib/module/core/mixins/OxyServices.assets.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.auth.js +299 -0
- package/lib/module/core/mixins/OxyServices.auth.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.developer.js +111 -0
- package/lib/module/core/mixins/OxyServices.developer.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.devices.js +115 -0
- package/lib/module/core/mixins/OxyServices.devices.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.karma.js +113 -0
- package/lib/module/core/mixins/OxyServices.karma.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.language.js +120 -0
- package/lib/module/core/mixins/OxyServices.language.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.location.js +51 -0
- package/lib/module/core/mixins/OxyServices.location.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.payment.js +62 -0
- package/lib/module/core/mixins/OxyServices.payment.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.privacy.js +170 -0
- package/lib/module/core/mixins/OxyServices.privacy.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.totp.js +49 -0
- package/lib/module/core/mixins/OxyServices.totp.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.user.js +385 -0
- package/lib/module/core/mixins/OxyServices.user.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.utility.js +156 -0
- package/lib/module/core/mixins/OxyServices.utility.js.map +1 -0
- package/lib/module/core/mixins/index.js +36 -0
- package/lib/module/core/mixins/index.js.map +1 -0
- package/lib/module/core/mixins/mixinHelpers.js +56 -0
- package/lib/module/core/mixins/mixinHelpers.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +27 -2
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/typescript/core/OxyServices.base.d.ts +123 -0
- package/lib/typescript/core/OxyServices.base.d.ts.map +1 -0
- package/lib/typescript/core/OxyServices.d.ts +969 -746
- package/lib/typescript/core/OxyServices.d.ts.map +1 -1
- package/lib/typescript/core/OxyServices.errors.d.ts +12 -0
- package/lib/typescript/core/OxyServices.errors.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.analytics.d.ts +70 -0
- package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts +159 -0
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts +168 -0
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.developer.d.ts +103 -0
- package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.devices.d.ts +93 -0
- package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.karma.d.ts +89 -0
- package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.language.d.ts +85 -0
- package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.location.d.ts +68 -0
- package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.payment.d.ts +74 -0
- package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.privacy.d.ts +126 -0
- package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.totp.d.ts +69 -0
- package/lib/typescript/core/mixins/OxyServices.totp.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.user.d.ts +189 -0
- package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.utility.d.ts +97 -0
- package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -0
- package/lib/typescript/core/mixins/index.d.ts +898 -0
- package/lib/typescript/core/mixins/index.d.ts.map +1 -0
- package/lib/typescript/core/mixins/mixinHelpers.d.ts +32 -0
- package/lib/typescript/core/mixins/mixinHelpers.d.ts.map +1 -0
- package/lib/typescript/models/interfaces.d.ts +10 -0
- package/lib/typescript/models/interfaces.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +2 -0
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/OxyServices.base.ts +311 -0
- package/src/core/OxyServices.errors.ts +26 -0
- package/src/core/OxyServices.ts +43 -2199
- package/src/core/mixins/OxyServices.analytics.ts +53 -0
- package/src/core/mixins/OxyServices.assets.ts +390 -0
- package/src/core/mixins/OxyServices.auth.ts +275 -0
- package/src/core/mixins/OxyServices.developer.ts +114 -0
- package/src/core/mixins/OxyServices.devices.ts +103 -0
- package/src/core/mixins/OxyServices.karma.ts +111 -0
- package/src/core/mixins/OxyServices.language.ts +127 -0
- package/src/core/mixins/OxyServices.location.ts +46 -0
- package/src/core/mixins/OxyServices.payment.ts +59 -0
- package/src/core/mixins/OxyServices.privacy.ts +182 -0
- package/src/core/mixins/OxyServices.totp.ts +36 -0
- package/src/core/mixins/OxyServices.user.ts +380 -0
- package/src/core/mixins/OxyServices.utility.ts +187 -0
- package/src/core/mixins/index.ts +58 -0
- package/src/core/mixins/mixinHelpers.ts +69 -0
- package/src/models/interfaces.ts +12 -0
- package/src/ui/context/OxyContext.tsx +36 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OxyServicesAuthMixin = OxyServicesAuthMixin;
|
|
7
|
+
var _OxyServices = require("../OxyServices.errors");
|
|
8
|
+
/**
|
|
9
|
+
* Authentication Methods Mixin
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function OxyServicesAuthMixin(Base) {
|
|
13
|
+
return class extends Base {
|
|
14
|
+
constructor(...args) {
|
|
15
|
+
super(...args);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Sign up a new user
|
|
19
|
+
*/
|
|
20
|
+
async signUp(username, email, password) {
|
|
21
|
+
try {
|
|
22
|
+
const res = await this.makeRequest('POST', '/api/auth/signup', {
|
|
23
|
+
username,
|
|
24
|
+
email,
|
|
25
|
+
password
|
|
26
|
+
}, {
|
|
27
|
+
cache: false
|
|
28
|
+
});
|
|
29
|
+
if (!res || typeof res === 'object' && Object.keys(res).length === 0) {
|
|
30
|
+
throw new _OxyServices.OxyAuthenticationError('Sign up failed', 'SIGNUP_FAILED', 400);
|
|
31
|
+
}
|
|
32
|
+
return res;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
throw this.handleError(error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Request account recovery (send verification code)
|
|
40
|
+
*/
|
|
41
|
+
async requestRecovery(identifier) {
|
|
42
|
+
try {
|
|
43
|
+
return await this.makeRequest('POST', '/api/auth/recover/request', {
|
|
44
|
+
identifier
|
|
45
|
+
}, {
|
|
46
|
+
cache: false
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw this.handleError(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Verify recovery code
|
|
55
|
+
*/
|
|
56
|
+
async verifyRecoveryCode(identifier, code) {
|
|
57
|
+
try {
|
|
58
|
+
return await this.makeRequest('POST', '/api/auth/recover/verify', {
|
|
59
|
+
identifier,
|
|
60
|
+
code
|
|
61
|
+
}, {
|
|
62
|
+
cache: false
|
|
63
|
+
});
|
|
64
|
+
} catch (error) {
|
|
65
|
+
throw this.handleError(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Reset password using verified code
|
|
71
|
+
*/
|
|
72
|
+
async resetPassword(identifier, code, newPassword) {
|
|
73
|
+
try {
|
|
74
|
+
return await this.makeRequest('POST', '/api/auth/recover/reset', {
|
|
75
|
+
identifier,
|
|
76
|
+
code,
|
|
77
|
+
newPassword
|
|
78
|
+
}, {
|
|
79
|
+
cache: false
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw this.handleError(error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Reset password using TOTP code (recommended recovery)
|
|
88
|
+
*/
|
|
89
|
+
async resetPasswordWithTotp(identifier, code, newPassword) {
|
|
90
|
+
try {
|
|
91
|
+
return await this.makeRequest('POST', '/api/auth/recover/totp/reset', {
|
|
92
|
+
identifier,
|
|
93
|
+
code,
|
|
94
|
+
newPassword
|
|
95
|
+
}, {
|
|
96
|
+
cache: false
|
|
97
|
+
});
|
|
98
|
+
} catch (error) {
|
|
99
|
+
throw this.handleError(error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async resetPasswordWithBackupCode(identifier, backupCode, newPassword) {
|
|
103
|
+
try {
|
|
104
|
+
return await this.makeRequest('POST', '/api/auth/recover/backup/reset', {
|
|
105
|
+
identifier,
|
|
106
|
+
backupCode,
|
|
107
|
+
newPassword
|
|
108
|
+
}, {
|
|
109
|
+
cache: false
|
|
110
|
+
});
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw this.handleError(error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async resetPasswordWithRecoveryKey(identifier, recoveryKey, newPassword) {
|
|
116
|
+
try {
|
|
117
|
+
return await this.makeRequest('POST', '/api/auth/recover/recovery-key/reset', {
|
|
118
|
+
identifier,
|
|
119
|
+
recoveryKey,
|
|
120
|
+
newPassword
|
|
121
|
+
}, {
|
|
122
|
+
cache: false
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
throw this.handleError(error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Sign in with device management
|
|
131
|
+
*/
|
|
132
|
+
async signIn(username, password, deviceName, deviceFingerprint) {
|
|
133
|
+
try {
|
|
134
|
+
return await this.makeRequest('POST', '/api/auth/login', {
|
|
135
|
+
username,
|
|
136
|
+
password,
|
|
137
|
+
deviceName,
|
|
138
|
+
deviceFingerprint
|
|
139
|
+
}, {
|
|
140
|
+
cache: false
|
|
141
|
+
});
|
|
142
|
+
} catch (error) {
|
|
143
|
+
throw this.handleError(error);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Complete login by verifying TOTP with MFA token
|
|
149
|
+
*/
|
|
150
|
+
async verifyTotpLogin(mfaToken, code) {
|
|
151
|
+
try {
|
|
152
|
+
return await this.makeRequest('POST', '/api/auth/totp/verify-login', {
|
|
153
|
+
mfaToken,
|
|
154
|
+
code
|
|
155
|
+
}, {
|
|
156
|
+
cache: false
|
|
157
|
+
});
|
|
158
|
+
} catch (error) {
|
|
159
|
+
throw this.handleError(error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get user by session ID
|
|
165
|
+
*/
|
|
166
|
+
async getUserBySession(sessionId) {
|
|
167
|
+
try {
|
|
168
|
+
return await this.makeRequest('GET', `/api/session/user/${sessionId}`, undefined, {
|
|
169
|
+
cache: true,
|
|
170
|
+
cacheTTL: 2 * 60 * 1000 // 2 minutes cache for user data
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
throw this.handleError(error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Batch get multiple user profiles by session IDs (optimized for account switching)
|
|
179
|
+
* Returns array of { sessionId, user } objects
|
|
180
|
+
*/
|
|
181
|
+
async getUsersBySessions(sessionIds) {
|
|
182
|
+
try {
|
|
183
|
+
if (!Array.isArray(sessionIds) || sessionIds.length === 0) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Deduplicate and sort sessionIds for consistent cache keys
|
|
188
|
+
const uniqueSessionIds = Array.from(new Set(sessionIds)).sort();
|
|
189
|
+
return await this.makeRequest('POST', '/api/session/users/batch', {
|
|
190
|
+
sessionIds: uniqueSessionIds
|
|
191
|
+
}, {
|
|
192
|
+
cache: true,
|
|
193
|
+
cacheTTL: 2 * 60 * 1000,
|
|
194
|
+
// 2 minutes cache
|
|
195
|
+
deduplicate: true // Important for batch requests
|
|
196
|
+
});
|
|
197
|
+
} catch (error) {
|
|
198
|
+
throw this.handleError(error);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Get access token by session ID and set it in the token store
|
|
204
|
+
*/
|
|
205
|
+
async getTokenBySession(sessionId) {
|
|
206
|
+
try {
|
|
207
|
+
const res = await this.makeRequest('GET', `/api/session/token/${sessionId}`, undefined, {
|
|
208
|
+
cache: false,
|
|
209
|
+
retry: false
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// Set the token in the centralized token store
|
|
213
|
+
this.setTokens(res.accessToken);
|
|
214
|
+
return res;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
throw this.handleError(error);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get sessions by session ID
|
|
222
|
+
*/
|
|
223
|
+
async getSessionsBySessionId(sessionId) {
|
|
224
|
+
try {
|
|
225
|
+
return await this.makeRequest('GET', `/api/session/sessions/${sessionId}`, undefined, {
|
|
226
|
+
cache: false
|
|
227
|
+
});
|
|
228
|
+
} catch (error) {
|
|
229
|
+
throw this.handleError(error);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Logout from a specific session
|
|
235
|
+
*/
|
|
236
|
+
async logoutSession(sessionId, targetSessionId) {
|
|
237
|
+
try {
|
|
238
|
+
const url = targetSessionId ? `/api/session/logout/${sessionId}/${targetSessionId}` : `/api/session/logout/${sessionId}`;
|
|
239
|
+
await this.makeRequest('POST', url, undefined, {
|
|
240
|
+
cache: false
|
|
241
|
+
});
|
|
242
|
+
} catch (error) {
|
|
243
|
+
throw this.handleError(error);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Logout from all sessions
|
|
249
|
+
*/
|
|
250
|
+
async logoutAllSessions(sessionId) {
|
|
251
|
+
try {
|
|
252
|
+
await this.makeRequest('POST', `/api/session/logout-all/${sessionId}`, undefined, {
|
|
253
|
+
cache: false
|
|
254
|
+
});
|
|
255
|
+
} catch (error) {
|
|
256
|
+
throw this.handleError(error);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Validate session
|
|
262
|
+
*/
|
|
263
|
+
async validateSession(sessionId, options = {}) {
|
|
264
|
+
try {
|
|
265
|
+
const urlParams = {};
|
|
266
|
+
if (options.deviceFingerprint) urlParams.deviceFingerprint = options.deviceFingerprint;
|
|
267
|
+
if (options.useHeaderValidation) urlParams.useHeaderValidation = 'true';
|
|
268
|
+
return await this.makeRequest('GET', `/api/session/validate/${sessionId}`, urlParams, {
|
|
269
|
+
cache: false
|
|
270
|
+
});
|
|
271
|
+
} catch (error) {
|
|
272
|
+
throw this.handleError(error);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Check username availability
|
|
278
|
+
*/
|
|
279
|
+
async checkUsernameAvailability(username) {
|
|
280
|
+
try {
|
|
281
|
+
return await this.makeRequest('GET', `/api/auth/check-username/${username}`, undefined, {
|
|
282
|
+
cache: false
|
|
283
|
+
});
|
|
284
|
+
} catch (error) {
|
|
285
|
+
throw this.handleError(error);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Check email availability
|
|
291
|
+
*/
|
|
292
|
+
async checkEmailAvailability(email) {
|
|
293
|
+
try {
|
|
294
|
+
return await this.makeRequest('GET', `/api/auth/check-email/${email}`, undefined, {
|
|
295
|
+
cache: false
|
|
296
|
+
});
|
|
297
|
+
} catch (error) {
|
|
298
|
+
throw this.handleError(error);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=OxyServices.auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_OxyServices","require","OxyServicesAuthMixin","Base","constructor","args","signUp","username","email","password","res","makeRequest","cache","Object","keys","length","OxyAuthenticationError","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":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AANA;AACA;AACA;;AAMO,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,IAAI,CAACF,GAAG,IAAK,OAAOA,GAAG,KAAK,QAAQ,IAAIG,MAAM,CAACC,IAAI,CAACJ,GAAG,CAAC,CAACK,MAAM,KAAK,CAAE,EAAE;UACtE,MAAM,IAAIC,mCAAsB,CAAC,gBAAgB,EAAE,eAAe,EAAE,GAAG,CAAC;QAC1E;QACA,OAAON,GAAG;MACZ,CAAC,CAAC,OAAOO,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;;IAEA;AACJ;AACA;IACI,MAAME,eAAeA,CAACC,UAAkB,EAAwD;MAC9F,IAAI;QACF,OAAO,MAAM,IAAI,CAACT,WAAW,CAAC,MAAM,EAAE,2BAA2B,EAAE;UAAES;QAAW,CAAC,EAAE;UAAER,KAAK,EA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B;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OxyServicesDeveloperMixin = OxyServicesDeveloperMixin;
|
|
7
|
+
var _mixinHelpers = require("./mixinHelpers");
|
|
8
|
+
/**
|
|
9
|
+
* Developer API Methods Mixin
|
|
10
|
+
*
|
|
11
|
+
* Provides methods for managing developer applications and API keys
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function OxyServicesDeveloperMixin(Base) {
|
|
15
|
+
return class extends Base {
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
super(...args);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get developer apps for the current user
|
|
22
|
+
* @returns Array of developer apps
|
|
23
|
+
*/
|
|
24
|
+
async getDeveloperApps() {
|
|
25
|
+
try {
|
|
26
|
+
const res = await this.makeRequest('GET', '/api/developer/apps', undefined, {
|
|
27
|
+
cache: true,
|
|
28
|
+
cacheTTL: _mixinHelpers.CACHE_TIMES.MEDIUM
|
|
29
|
+
});
|
|
30
|
+
return res.apps || [];
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw this.handleError(error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create a new developer app
|
|
38
|
+
* @param data - Developer app configuration
|
|
39
|
+
* @returns Created developer app
|
|
40
|
+
*/
|
|
41
|
+
async createDeveloperApp(data) {
|
|
42
|
+
try {
|
|
43
|
+
const res = await this.makeRequest('POST', '/api/developer/apps', data, {
|
|
44
|
+
cache: false
|
|
45
|
+
});
|
|
46
|
+
return res.app;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw this.handleError(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get a specific developer app
|
|
54
|
+
*/
|
|
55
|
+
async getDeveloperApp(appId) {
|
|
56
|
+
try {
|
|
57
|
+
const res = await this.makeRequest('GET', `/api/developer/apps/${appId}`, undefined, {
|
|
58
|
+
cache: true,
|
|
59
|
+
cacheTTL: _mixinHelpers.CACHE_TIMES.LONG
|
|
60
|
+
});
|
|
61
|
+
return res.app;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw this.handleError(error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Update a developer app
|
|
69
|
+
* @param appId - The developer app ID
|
|
70
|
+
* @param data - Updated app configuration
|
|
71
|
+
* @returns Updated developer app
|
|
72
|
+
*/
|
|
73
|
+
async updateDeveloperApp(appId, data) {
|
|
74
|
+
try {
|
|
75
|
+
const res = await this.makeRequest('PATCH', `/api/developer/apps/${appId}`, data, {
|
|
76
|
+
cache: false
|
|
77
|
+
});
|
|
78
|
+
return res.app;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throw this.handleError(error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Regenerate API secret for a developer app
|
|
86
|
+
* @param appId - The developer app ID
|
|
87
|
+
* @returns App with new secret
|
|
88
|
+
*/
|
|
89
|
+
async regenerateDeveloperAppSecret(appId) {
|
|
90
|
+
try {
|
|
91
|
+
return await this.makeRequest('POST', `/api/developer/apps/${appId}/regenerate-secret`, undefined, {
|
|
92
|
+
cache: false
|
|
93
|
+
});
|
|
94
|
+
} catch (error) {
|
|
95
|
+
throw this.handleError(error);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Delete a developer app
|
|
101
|
+
* @param appId - The developer app ID
|
|
102
|
+
* @returns Deletion result
|
|
103
|
+
*/
|
|
104
|
+
async deleteDeveloperApp(appId) {
|
|
105
|
+
try {
|
|
106
|
+
return await this.makeRequest('DELETE', `/api/developer/apps/${appId}`, undefined, {
|
|
107
|
+
cache: false
|
|
108
|
+
});
|
|
109
|
+
} catch (error) {
|
|
110
|
+
throw this.handleError(error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=OxyServices.developer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_mixinHelpers","require","OxyServicesDeveloperMixin","Base","constructor","args","getDeveloperApps","res","makeRequest","undefined","cache","cacheTTL","CACHE_TIMES","MEDIUM","apps","error","handleError","createDeveloperApp","data","app","getDeveloperApp","appId","LONG","updateDeveloperApp","regenerateDeveloperAppSecret","deleteDeveloperApp"],"sourceRoot":"../../../../src","sources":["core/mixins/OxyServices.developer.ts"],"mappings":";;;;;;AAMA,IAAAA,aAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;;AAIO,SAASC,yBAAyBA,CAAmCC,IAAO,EAAE;EACnF,OAAO,cAAcA,IAAI,CAAC;IACxBC,WAAWA,CAAC,GAAGC,IAAW,EAAE;MAC1B,KAAK,CAAC,GAAIA,IAAc,CAAC;IAC3B;;IAEA;AACJ;AACA;AACA;IACI,MAAMC,gBAAgBA,CAAA,EAAmB;MACvC,IAAI;QACF,MAAMC,GAAG,GAAG,MAAM,IAAI,CAACC,WAAW,CAAmB,KAAK,EAAE,qBAAqB,EAAEC,SAAS,EAAE;UAC5FC,KAAK,EAAE,IAAI;UACXC,QAAQ,EAAEC,yBAAW,CAACC;QACxB,CAAC,CAAC;QACF,OAAON,GAAG,CAACO,IAAI,IAAI,EAAE;MACvB,CAAC,CAAC,OAAOC,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;;IAEA;AACJ;AACA;AACA;AACA;IACI,MAAME,kBAAkBA,CAACC,IAMxB,EAAgB;MACf,IAAI;QACF,MAAMX,GAAG,GAAG,MAAM,IAAI,CAACC,WAAW,CAA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CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;;IAEA;AACJ;AACA;AACA;AACA;IACI,MAAMU,kBAAkBA,CAACJ,KAAa,EAAgB;MACpD,IAAI;QACF,OAAO,MAAM,IAAI,CAACb,WAAW,CAAC,QAAQ,EAAE,uBAAuBa,KAAK,EAAE,EAAEZ,SAAS,EAAE;UAAEC,KAAK,EAAE;QAAM,CAAC,CAAC;MACtG,CAAC,CAAC,OAAOK,KAAK,EAAE;QACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;MAC/B;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OxyServicesDevicesMixin = OxyServicesDevicesMixin;
|
|
7
|
+
/**
|
|
8
|
+
* Device Methods Mixin
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
function OxyServicesDevicesMixin(Base) {
|
|
12
|
+
return class extends Base {
|
|
13
|
+
constructor(...args) {
|
|
14
|
+
super(...args);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Register a new device
|
|
19
|
+
* @param deviceData - Device information
|
|
20
|
+
* @returns Registered device object
|
|
21
|
+
*/
|
|
22
|
+
async registerDevice(deviceData) {
|
|
23
|
+
try {
|
|
24
|
+
return await this.makeRequest('POST', '/api/devices', deviceData, {
|
|
25
|
+
cache: false
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw this.handleError(error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get all devices for the current user
|
|
34
|
+
* @returns Array of user devices
|
|
35
|
+
*/
|
|
36
|
+
async getUserDevices() {
|
|
37
|
+
try {
|
|
38
|
+
return await this.makeRequest('GET', '/api/devices', undefined, {
|
|
39
|
+
cache: false // Don't cache device list - always get fresh data
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw this.handleError(error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Remove a device
|
|
48
|
+
* @param deviceId - The device ID to remove
|
|
49
|
+
*/
|
|
50
|
+
async removeDevice(deviceId) {
|
|
51
|
+
try {
|
|
52
|
+
await this.makeRequest('DELETE', `/api/devices/${deviceId}`, undefined, {
|
|
53
|
+
cache: false
|
|
54
|
+
});
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw this.handleError(error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get device sessions for a given session ID
|
|
62
|
+
* Note: Not cached by default to ensure fresh data
|
|
63
|
+
* @param sessionId - The session ID
|
|
64
|
+
* @returns Array of device sessions
|
|
65
|
+
*/
|
|
66
|
+
async getDeviceSessions(sessionId) {
|
|
67
|
+
try {
|
|
68
|
+
// Use makeRequest for consistent error handling and optional caching
|
|
69
|
+
// Cache disabled by default to ensure fresh session data
|
|
70
|
+
return await this.makeRequest('GET', `/api/session/device/sessions/${sessionId}`, undefined, {
|
|
71
|
+
cache: false,
|
|
72
|
+
// Don't cache sessions - always get fresh data
|
|
73
|
+
deduplicate: true // Deduplicate concurrent requests for same sessionId
|
|
74
|
+
});
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw this.handleError(error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Logout all device sessions
|
|
82
|
+
* @param sessionId - The session ID
|
|
83
|
+
* @param deviceId - Optional device ID to target
|
|
84
|
+
* @param excludeCurrent - Whether to exclude the current session
|
|
85
|
+
* @returns Logout result
|
|
86
|
+
*/
|
|
87
|
+
async logoutAllDeviceSessions(sessionId, deviceId, excludeCurrent) {
|
|
88
|
+
try {
|
|
89
|
+
const urlParams = {};
|
|
90
|
+
if (deviceId) urlParams.deviceId = deviceId;
|
|
91
|
+
if (excludeCurrent) urlParams.excludeCurrent = 'true';
|
|
92
|
+
return await this.makeRequest('POST', `/api/session/device/logout-all/${sessionId}`, urlParams, {
|
|
93
|
+
cache: false
|
|
94
|
+
});
|
|
95
|
+
} catch (error) {
|
|
96
|
+
throw this.handleError(error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Update device name
|
|
102
|
+
* @param sessionId - The session ID
|
|
103
|
+
* @param deviceName - New device name
|
|
104
|
+
* @returns Updated device object
|
|
105
|
+
*/
|
|
106
|
+
async updateDeviceName(sessionId, deviceName) {
|
|
107
|
+
try {
|
|
108
|
+
return await this.makeRequest('PUT', `/api/session/device/name/${sessionId}`, {
|
|
109
|
+
deviceName
|
|
110
|
+
}, {
|
|
111
|
+
cache: false
|
|
112
|
+
});
|
|
113
|
+
} catch (error) {
|
|
114
|
+
throw this.handleError(error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//# 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;;AAGO,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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A,CAACF,SAAiB,EAAEF,QAAiB,EAAEK,cAAwB,EAAgB;MAC1G,IAAI;QACF,MAAMC,SAAc,GAAG,CAAC,CAAC;QACzB,IAAIN,QAAQ,EAAEM,SAAS,CAACN,QAAQ,GAAGA,QAAQ;QAC3C,IAAIK,cAAc,EAAEC,SAAS,CAACD,cAAc,GAAG,MAAM;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,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OxyServicesKarmaMixin = OxyServicesKarmaMixin;
|
|
7
|
+
var _mixinHelpers = require("./mixinHelpers");
|
|
8
|
+
/**
|
|
9
|
+
* Karma Methods Mixin
|
|
10
|
+
*
|
|
11
|
+
* Provides methods for karma system management
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function OxyServicesKarmaMixin(Base) {
|
|
15
|
+
return class extends Base {
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
super(...args);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get user karma
|
|
21
|
+
*/
|
|
22
|
+
async getUserKarma(userId) {
|
|
23
|
+
try {
|
|
24
|
+
return await this.makeRequest('GET', `/api/karma/${userId}`, undefined, {
|
|
25
|
+
cache: true,
|
|
26
|
+
cacheTTL: 2 * 60 * 1000 // 2 minutes cache
|
|
27
|
+
});
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw this.handleError(error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Give karma to user
|
|
35
|
+
*/
|
|
36
|
+
async giveKarma(userId, amount, reason) {
|
|
37
|
+
try {
|
|
38
|
+
return await this.makeRequest('POST', `/api/karma/${userId}/give`, {
|
|
39
|
+
amount,
|
|
40
|
+
reason
|
|
41
|
+
}, {
|
|
42
|
+
cache: false
|
|
43
|
+
});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw this.handleError(error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get user karma total
|
|
51
|
+
* @param userId - The user ID
|
|
52
|
+
* @returns User karma total
|
|
53
|
+
*/
|
|
54
|
+
async getUserKarmaTotal(userId) {
|
|
55
|
+
try {
|
|
56
|
+
return await this.makeRequest('GET', `/api/karma/${userId}/total`, undefined, {
|
|
57
|
+
cache: true,
|
|
58
|
+
cacheTTL: _mixinHelpers.CACHE_TIMES.MEDIUM
|
|
59
|
+
});
|
|
60
|
+
} catch (error) {
|
|
61
|
+
throw this.handleError(error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get user karma history
|
|
67
|
+
* @param userId - The user ID
|
|
68
|
+
* @param limit - Optional limit for results
|
|
69
|
+
* @param offset - Optional offset for pagination
|
|
70
|
+
* @returns User karma history
|
|
71
|
+
*/
|
|
72
|
+
async getUserKarmaHistory(userId, limit, offset) {
|
|
73
|
+
try {
|
|
74
|
+
const params = {};
|
|
75
|
+
if (limit) params.limit = limit;
|
|
76
|
+
if (offset) params.offset = offset;
|
|
77
|
+
return await this.makeRequest('GET', `/api/karma/${userId}/history`, params, {
|
|
78
|
+
cache: true,
|
|
79
|
+
cacheTTL: _mixinHelpers.CACHE_TIMES.MEDIUM
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw this.handleError(error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get karma leaderboard
|
|
88
|
+
* @returns Karma leaderboard
|
|
89
|
+
*/
|
|
90
|
+
async getKarmaLeaderboard() {
|
|
91
|
+
try {
|
|
92
|
+
return await this.makeRequest('GET', '/api/karma/leaderboard', undefined, {
|
|
93
|
+
cache: true,
|
|
94
|
+
cacheTTL: _mixinHelpers.CACHE_TIMES.LONG
|
|
95
|
+
});
|
|
96
|
+
} catch (error) {
|
|
97
|
+
throw this.handleError(error);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get karma rules
|
|
103
|
+
* @returns Karma rules
|
|
104
|
+
*/
|
|
105
|
+
async getKarmaRules() {
|
|
106
|
+
try {
|
|
107
|
+
return await this.makeRequest('GET', '/api/karma/rules', undefined, {
|
|
108
|
+
cache: true,
|
|
109
|
+
cacheTTL: _mixinHelpers.CACHE_TIMES.EXTRA_LONG // Rules don't change often
|
|
110
|
+
});
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw this.handleError(error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=OxyServices.karma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_mixinHelpers","require","OxyServicesKarmaMixin","Base","constructor","args","getUserKarma","userId","makeRequest","undefined","cache","cacheTTL","error","handleError","giveKarma","amount","reason","getUserKarmaTotal","CACHE_TIMES","MEDIUM","getUserKarmaHistory","limit","offset","params","getKarmaLeaderboard","LONG","getKarmaRules","EXTRA_LONG"],"sourceRoot":"../../../../src","sources":["core/mixins/OxyServices.karma.ts"],"mappings":";;;;;;AAMA,IAAAA,aAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;;AAIO,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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