@oxyhq/core 1.4.0 → 1.6.0
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/dist/cjs/AuthManager.js +1 -1
- package/dist/cjs/HttpService.js +87 -69
- package/dist/cjs/OxyServices.base.js +5 -4
- package/dist/cjs/crypto/keyManager.js +1 -13
- package/dist/cjs/crypto/signatureService.js +7 -20
- package/dist/cjs/mixins/OxyServices.analytics.js +2 -2
- package/dist/cjs/mixins/OxyServices.assets.js +14 -14
- package/dist/cjs/mixins/OxyServices.auth.js +20 -18
- package/dist/cjs/mixins/OxyServices.developer.js +6 -6
- package/dist/cjs/mixins/OxyServices.devices.js +7 -7
- package/dist/cjs/mixins/OxyServices.features.js +23 -23
- package/dist/cjs/mixins/OxyServices.fedcm.js +1 -1
- package/dist/cjs/mixins/OxyServices.karma.js +6 -6
- package/dist/cjs/mixins/OxyServices.location.js +2 -2
- package/dist/cjs/mixins/OxyServices.payment.js +6 -6
- package/dist/cjs/mixins/OxyServices.popup.js +1 -1
- package/dist/cjs/mixins/OxyServices.privacy.js +6 -6
- package/dist/cjs/mixins/OxyServices.security.js +3 -3
- package/dist/cjs/mixins/OxyServices.user.js +22 -22
- package/dist/cjs/mixins/OxyServices.utility.js +16 -7
- package/dist/cjs/utils/asyncUtils.js +0 -1
- package/dist/cjs/utils/platform.js +14 -0
- package/dist/esm/AuthManager.js +1 -1
- package/dist/esm/HttpService.js +87 -69
- package/dist/esm/OxyServices.base.js +5 -4
- package/dist/esm/crypto/keyManager.js +1 -13
- package/dist/esm/crypto/signatureService.js +2 -15
- package/dist/esm/mixins/OxyServices.analytics.js +2 -2
- package/dist/esm/mixins/OxyServices.assets.js +14 -14
- package/dist/esm/mixins/OxyServices.auth.js +20 -18
- package/dist/esm/mixins/OxyServices.developer.js +6 -6
- package/dist/esm/mixins/OxyServices.devices.js +7 -7
- package/dist/esm/mixins/OxyServices.features.js +23 -23
- package/dist/esm/mixins/OxyServices.fedcm.js +1 -1
- package/dist/esm/mixins/OxyServices.karma.js +6 -6
- package/dist/esm/mixins/OxyServices.location.js +2 -2
- package/dist/esm/mixins/OxyServices.payment.js +6 -6
- package/dist/esm/mixins/OxyServices.popup.js +1 -1
- package/dist/esm/mixins/OxyServices.privacy.js +6 -6
- package/dist/esm/mixins/OxyServices.security.js +3 -3
- package/dist/esm/mixins/OxyServices.user.js +22 -22
- package/dist/esm/mixins/OxyServices.utility.js +16 -7
- package/dist/esm/utils/asyncUtils.js +0 -1
- package/dist/esm/utils/platform.js +12 -0
- package/dist/types/HttpService.d.ts +4 -1
- package/dist/types/OxyServices.base.d.ts +1 -1
- package/dist/types/mixins/OxyServices.analytics.d.ts +1 -1
- package/dist/types/mixins/OxyServices.assets.d.ts +1 -1
- package/dist/types/mixins/OxyServices.auth.d.ts +1 -1
- package/dist/types/mixins/OxyServices.developer.d.ts +1 -1
- package/dist/types/mixins/OxyServices.devices.d.ts +1 -1
- package/dist/types/mixins/OxyServices.features.d.ts +1 -1
- package/dist/types/mixins/OxyServices.fedcm.d.ts +1 -1
- package/dist/types/mixins/OxyServices.karma.d.ts +1 -1
- package/dist/types/mixins/OxyServices.language.d.ts +1 -1
- package/dist/types/mixins/OxyServices.location.d.ts +1 -1
- package/dist/types/mixins/OxyServices.payment.d.ts +1 -1
- package/dist/types/mixins/OxyServices.popup.d.ts +1 -1
- package/dist/types/mixins/OxyServices.privacy.d.ts +1 -1
- package/dist/types/mixins/OxyServices.redirect.d.ts +1 -1
- package/dist/types/mixins/OxyServices.security.d.ts +1 -1
- package/dist/types/mixins/OxyServices.user.d.ts +1 -1
- package/dist/types/mixins/OxyServices.utility.d.ts +7 -6
- package/dist/types/utils/platform.d.ts +8 -0
- package/package.json +1 -1
- package/src/AuthManager.ts +1 -1
- package/src/HttpService.ts +85 -67
- package/src/OxyServices.base.ts +5 -4
- package/src/crypto/keyManager.ts +1 -15
- package/src/crypto/signatureService.ts +2 -17
- package/src/mixins/OxyServices.analytics.ts +2 -2
- package/src/mixins/OxyServices.assets.ts +14 -14
- package/src/mixins/OxyServices.auth.ts +26 -24
- package/src/mixins/OxyServices.developer.ts +6 -6
- package/src/mixins/OxyServices.devices.ts +7 -7
- package/src/mixins/OxyServices.features.ts +23 -23
- package/src/mixins/OxyServices.fedcm.ts +1 -1
- package/src/mixins/OxyServices.karma.ts +6 -6
- package/src/mixins/OxyServices.location.ts +2 -2
- package/src/mixins/OxyServices.payment.ts +6 -6
- package/src/mixins/OxyServices.popup.ts +1 -1
- package/src/mixins/OxyServices.privacy.ts +6 -6
- package/src/mixins/OxyServices.security.ts +3 -3
- package/src/mixins/OxyServices.user.ts +22 -22
- package/src/mixins/OxyServices.utility.ts +18 -8
- package/src/utils/asyncUtils.ts +1 -2
- package/src/utils/platform.ts +14 -0
|
@@ -11,7 +11,7 @@ export function OxyServicesLocationMixin(Base) {
|
|
|
11
11
|
*/
|
|
12
12
|
async updateLocation(latitude, longitude) {
|
|
13
13
|
try {
|
|
14
|
-
return await this.makeRequest('POST', '/
|
|
14
|
+
return await this.makeRequest('POST', '/location', {
|
|
15
15
|
latitude,
|
|
16
16
|
longitude
|
|
17
17
|
}, { cache: false });
|
|
@@ -28,7 +28,7 @@ export function OxyServicesLocationMixin(Base) {
|
|
|
28
28
|
async getNearbyUsers(radius) {
|
|
29
29
|
try {
|
|
30
30
|
const params = radius ? { radius } : undefined;
|
|
31
|
-
return await this.makeRequest('GET', '/
|
|
31
|
+
return await this.makeRequest('GET', '/location/nearby', params, {
|
|
32
32
|
cache: false, // Don't cache location data - always get fresh data
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -11,7 +11,7 @@ export function OxyServicesPaymentMixin(Base) {
|
|
|
11
11
|
*/
|
|
12
12
|
async createPayment(data) {
|
|
13
13
|
try {
|
|
14
|
-
return await this.makeRequest('POST', '/
|
|
14
|
+
return await this.makeRequest('POST', '/payments', data, { cache: false });
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
17
|
throw this.handleError(error);
|
|
@@ -24,7 +24,7 @@ export function OxyServicesPaymentMixin(Base) {
|
|
|
24
24
|
*/
|
|
25
25
|
async getPayment(paymentId) {
|
|
26
26
|
try {
|
|
27
|
-
return await this.makeRequest('GET', `/
|
|
27
|
+
return await this.makeRequest('GET', `/payments/${paymentId}`, undefined, {
|
|
28
28
|
cache: true,
|
|
29
29
|
cacheTTL: CACHE_TIMES.LONG,
|
|
30
30
|
});
|
|
@@ -39,7 +39,7 @@ export function OxyServicesPaymentMixin(Base) {
|
|
|
39
39
|
*/
|
|
40
40
|
async getUserPayments() {
|
|
41
41
|
try {
|
|
42
|
-
return await this.makeRequest('GET', '/
|
|
42
|
+
return await this.makeRequest('GET', '/payments/user', undefined, {
|
|
43
43
|
cache: false, // Don't cache user payments - always get fresh data
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -54,7 +54,7 @@ export function OxyServicesPaymentMixin(Base) {
|
|
|
54
54
|
*/
|
|
55
55
|
async getSubscription(userId) {
|
|
56
56
|
try {
|
|
57
|
-
return await this.makeRequest('GET', `/
|
|
57
|
+
return await this.makeRequest('GET', `/subscription/${userId}`, undefined, {
|
|
58
58
|
cache: true,
|
|
59
59
|
cacheTTL: CACHE_TIMES.MEDIUM,
|
|
60
60
|
});
|
|
@@ -86,7 +86,7 @@ export function OxyServicesPaymentMixin(Base) {
|
|
|
86
86
|
*/
|
|
87
87
|
async getWallet(userId) {
|
|
88
88
|
try {
|
|
89
|
-
return await this.makeRequest('GET', `/
|
|
89
|
+
return await this.makeRequest('GET', `/wallet/${userId}`, undefined, {
|
|
90
90
|
cache: true,
|
|
91
91
|
cacheTTL: CACHE_TIMES.SHORT, // Cache wallet for short time as balance changes frequently
|
|
92
92
|
});
|
|
@@ -125,7 +125,7 @@ export function OxyServicesPaymentMixin(Base) {
|
|
|
125
125
|
if (options?.offset)
|
|
126
126
|
params.append('offset', options.offset.toString());
|
|
127
127
|
const queryString = params.toString();
|
|
128
|
-
const url = `/
|
|
128
|
+
const url = `/wallet/transactions/${userId}${queryString ? `?${queryString}` : ''}`;
|
|
129
129
|
return await this.makeRequest('GET', url, undefined, {
|
|
130
130
|
cache: false, // Don't cache transactions - always get fresh data
|
|
131
131
|
});
|
|
@@ -87,7 +87,7 @@ export function OxyServicesPopupAuthMixin(Base) {
|
|
|
87
87
|
// The callback page only sends sessionId/accessToken, not user data
|
|
88
88
|
if (session && session.sessionId && !session.user) {
|
|
89
89
|
try {
|
|
90
|
-
const userData = await this.makeRequest('GET', `/
|
|
90
|
+
const userData = await this.makeRequest('GET', `/session/user/${session.sessionId}`, undefined, { cache: false });
|
|
91
91
|
if (userData) {
|
|
92
92
|
session.user = userData;
|
|
93
93
|
}
|
|
@@ -41,7 +41,7 @@ export function OxyServicesPrivacyMixin(Base) {
|
|
|
41
41
|
*/
|
|
42
42
|
async getBlockedUsers() {
|
|
43
43
|
try {
|
|
44
|
-
return await this.makeRequest('GET', '/
|
|
44
|
+
return await this.makeRequest('GET', '/privacy/blocked', undefined, {
|
|
45
45
|
cache: true,
|
|
46
46
|
cacheTTL: 1 * 60 * 1000, // 1 minute cache
|
|
47
47
|
});
|
|
@@ -60,7 +60,7 @@ export function OxyServicesPrivacyMixin(Base) {
|
|
|
60
60
|
if (!userId) {
|
|
61
61
|
throw new Error('User ID is required');
|
|
62
62
|
}
|
|
63
|
-
return await this.makeRequest('POST', `/
|
|
63
|
+
return await this.makeRequest('POST', `/privacy/blocked/${userId}`, undefined, {
|
|
64
64
|
cache: false,
|
|
65
65
|
});
|
|
66
66
|
}
|
|
@@ -78,7 +78,7 @@ export function OxyServicesPrivacyMixin(Base) {
|
|
|
78
78
|
if (!userId) {
|
|
79
79
|
throw new Error('User ID is required');
|
|
80
80
|
}
|
|
81
|
-
return await this.makeRequest('DELETE', `/
|
|
81
|
+
return await this.makeRequest('DELETE', `/privacy/blocked/${userId}`, undefined, {
|
|
82
82
|
cache: false,
|
|
83
83
|
});
|
|
84
84
|
}
|
|
@@ -103,7 +103,7 @@ export function OxyServicesPrivacyMixin(Base) {
|
|
|
103
103
|
*/
|
|
104
104
|
async getRestrictedUsers() {
|
|
105
105
|
try {
|
|
106
|
-
return await this.makeRequest('GET', '/
|
|
106
|
+
return await this.makeRequest('GET', '/privacy/restricted', undefined, {
|
|
107
107
|
cache: true,
|
|
108
108
|
cacheTTL: 1 * 60 * 1000, // 1 minute cache
|
|
109
109
|
});
|
|
@@ -122,7 +122,7 @@ export function OxyServicesPrivacyMixin(Base) {
|
|
|
122
122
|
if (!userId) {
|
|
123
123
|
throw new Error('User ID is required');
|
|
124
124
|
}
|
|
125
|
-
return await this.makeRequest('POST', `/
|
|
125
|
+
return await this.makeRequest('POST', `/privacy/restricted/${userId}`, undefined, {
|
|
126
126
|
cache: false,
|
|
127
127
|
});
|
|
128
128
|
}
|
|
@@ -140,7 +140,7 @@ export function OxyServicesPrivacyMixin(Base) {
|
|
|
140
140
|
if (!userId) {
|
|
141
141
|
throw new Error('User ID is required');
|
|
142
142
|
}
|
|
143
|
-
return await this.makeRequest('DELETE', `/
|
|
143
|
+
return await this.makeRequest('DELETE', `/privacy/restricted/${userId}`, undefined, {
|
|
144
144
|
cache: false,
|
|
145
145
|
});
|
|
146
146
|
}
|
|
@@ -20,7 +20,7 @@ export function OxyServicesSecurityMixin(Base) {
|
|
|
20
20
|
params.offset = offset;
|
|
21
21
|
if (eventType)
|
|
22
22
|
params.eventType = eventType;
|
|
23
|
-
const response = await this.makeRequest('GET', '/
|
|
23
|
+
const response = await this.makeRequest('GET', '/security/activity', params, { cache: false });
|
|
24
24
|
return response;
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
@@ -48,7 +48,7 @@ export function OxyServicesSecurityMixin(Base) {
|
|
|
48
48
|
*/
|
|
49
49
|
async logPrivateKeyExported(deviceId) {
|
|
50
50
|
try {
|
|
51
|
-
await this.makeRequest('POST', '/
|
|
51
|
+
await this.makeRequest('POST', '/security/activity/private-key-exported', { deviceId }, { cache: false });
|
|
52
52
|
}
|
|
53
53
|
catch (error) {
|
|
54
54
|
// Don't throw - logging failures shouldn't break user flow
|
|
@@ -65,7 +65,7 @@ export function OxyServicesSecurityMixin(Base) {
|
|
|
65
65
|
*/
|
|
66
66
|
async logBackupCreated(deviceId) {
|
|
67
67
|
try {
|
|
68
|
-
await this.makeRequest('POST', '/
|
|
68
|
+
await this.makeRequest('POST', '/security/activity/backup-created', { deviceId }, { cache: false });
|
|
69
69
|
}
|
|
70
70
|
catch (error) {
|
|
71
71
|
// Don't throw - logging failures shouldn't break user flow
|
|
@@ -9,7 +9,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
9
9
|
*/
|
|
10
10
|
async getProfileByUsername(username) {
|
|
11
11
|
try {
|
|
12
|
-
return await this.makeRequest('GET', `/
|
|
12
|
+
return await this.makeRequest('GET', `/profiles/username/${username}`, undefined, {
|
|
13
13
|
cache: true,
|
|
14
14
|
cacheTTL: 5 * 60 * 1000, // 5 minutes cache for profiles
|
|
15
15
|
});
|
|
@@ -26,7 +26,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
26
26
|
const params = { query, ...pagination };
|
|
27
27
|
const searchParams = buildSearchParams(params);
|
|
28
28
|
const paramsObj = Object.fromEntries(searchParams.entries());
|
|
29
|
-
const response = await this.makeRequest('GET', '/
|
|
29
|
+
const response = await this.makeRequest('GET', '/profiles/search', paramsObj, {
|
|
30
30
|
cache: true,
|
|
31
31
|
cacheTTL: 2 * 60 * 1000, // 2 minutes cache
|
|
32
32
|
});
|
|
@@ -71,7 +71,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
71
71
|
*/
|
|
72
72
|
async getProfileRecommendations() {
|
|
73
73
|
return this.withAuthRetry(async () => {
|
|
74
|
-
return await this.makeRequest('GET', '/
|
|
74
|
+
return await this.makeRequest('GET', '/profiles/recommendations', undefined, { cache: true });
|
|
75
75
|
}, 'getProfileRecommendations');
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
@@ -79,7 +79,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
79
79
|
*/
|
|
80
80
|
async getUserById(userId) {
|
|
81
81
|
try {
|
|
82
|
-
return await this.makeRequest('GET', `/
|
|
82
|
+
return await this.makeRequest('GET', `/users/${userId}`, undefined, {
|
|
83
83
|
cache: true,
|
|
84
84
|
cacheTTL: 5 * 60 * 1000, // 5 minutes cache
|
|
85
85
|
});
|
|
@@ -93,7 +93,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
93
93
|
*/
|
|
94
94
|
async getCurrentUser() {
|
|
95
95
|
return this.withAuthRetry(async () => {
|
|
96
|
-
return await this.makeRequest('GET', '/
|
|
96
|
+
return await this.makeRequest('GET', '/users/me', undefined, {
|
|
97
97
|
cache: true,
|
|
98
98
|
cacheTTL: 1 * 60 * 1000, // 1 minute cache for current user
|
|
99
99
|
});
|
|
@@ -105,7 +105,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
105
105
|
*/
|
|
106
106
|
async updateProfile(updates) {
|
|
107
107
|
try {
|
|
108
|
-
return await this.makeRequest('PUT', '/
|
|
108
|
+
return await this.makeRequest('PUT', '/users/me', updates, { cache: false });
|
|
109
109
|
}
|
|
110
110
|
catch (error) {
|
|
111
111
|
const errorAny = error;
|
|
@@ -131,7 +131,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
131
131
|
async getPrivacySettings(userId) {
|
|
132
132
|
try {
|
|
133
133
|
const id = userId || (await this.getCurrentUser()).id;
|
|
134
|
-
return await this.makeRequest('GET', `/
|
|
134
|
+
return await this.makeRequest('GET', `/privacy/${id}/privacy`, undefined, {
|
|
135
135
|
cache: true,
|
|
136
136
|
cacheTTL: 2 * 60 * 1000, // 2 minutes cache
|
|
137
137
|
});
|
|
@@ -148,7 +148,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
148
148
|
async updatePrivacySettings(settings, userId) {
|
|
149
149
|
try {
|
|
150
150
|
const id = userId || (await this.getCurrentUser()).id;
|
|
151
|
-
return await this.makeRequest('PATCH', `/
|
|
151
|
+
return await this.makeRequest('PATCH', `/privacy/${id}/privacy`, settings, {
|
|
152
152
|
cache: false,
|
|
153
153
|
});
|
|
154
154
|
}
|
|
@@ -161,7 +161,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
161
161
|
*/
|
|
162
162
|
async requestAccountVerification(reason, evidence) {
|
|
163
163
|
try {
|
|
164
|
-
return await this.makeRequest('POST', '/
|
|
164
|
+
return await this.makeRequest('POST', '/users/verify/request', {
|
|
165
165
|
reason,
|
|
166
166
|
evidence,
|
|
167
167
|
}, { cache: false });
|
|
@@ -178,7 +178,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
178
178
|
// Use httpService for blob responses (it handles blob responses automatically)
|
|
179
179
|
const result = await this.getClient().request({
|
|
180
180
|
method: 'GET',
|
|
181
|
-
url: `/
|
|
181
|
+
url: `/users/me/data`,
|
|
182
182
|
params: { format },
|
|
183
183
|
cache: false,
|
|
184
184
|
});
|
|
@@ -195,7 +195,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
195
195
|
*/
|
|
196
196
|
async deleteAccount(password, confirmText) {
|
|
197
197
|
try {
|
|
198
|
-
return await this.makeRequest('DELETE', '/
|
|
198
|
+
return await this.makeRequest('DELETE', '/users/me', {
|
|
199
199
|
password,
|
|
200
200
|
confirmText,
|
|
201
201
|
}, { cache: false });
|
|
@@ -209,7 +209,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
209
209
|
*/
|
|
210
210
|
async followUser(userId) {
|
|
211
211
|
try {
|
|
212
|
-
return await this.makeRequest('POST', `/
|
|
212
|
+
return await this.makeRequest('POST', `/users/${userId}/follow`, undefined, { cache: false });
|
|
213
213
|
}
|
|
214
214
|
catch (error) {
|
|
215
215
|
throw this.handleError(error);
|
|
@@ -220,7 +220,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
220
220
|
*/
|
|
221
221
|
async unfollowUser(userId) {
|
|
222
222
|
try {
|
|
223
|
-
return await this.makeRequest('DELETE', `/
|
|
223
|
+
return await this.makeRequest('DELETE', `/users/${userId}/follow`, undefined, { cache: false });
|
|
224
224
|
}
|
|
225
225
|
catch (error) {
|
|
226
226
|
throw this.handleError(error);
|
|
@@ -231,7 +231,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
231
231
|
*/
|
|
232
232
|
async getFollowStatus(userId) {
|
|
233
233
|
try {
|
|
234
|
-
return await this.makeRequest('GET', `/
|
|
234
|
+
return await this.makeRequest('GET', `/users/${userId}/follow-status`, undefined, {
|
|
235
235
|
cache: true,
|
|
236
236
|
cacheTTL: 1 * 60 * 1000, // 1 minute cache
|
|
237
237
|
});
|
|
@@ -246,7 +246,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
246
246
|
async getUserFollowers(userId, pagination) {
|
|
247
247
|
try {
|
|
248
248
|
const params = buildPaginationParams(pagination || {});
|
|
249
|
-
const response = await this.makeRequest('GET', `/
|
|
249
|
+
const response = await this.makeRequest('GET', `/users/${userId}/followers`, params, {
|
|
250
250
|
cache: true,
|
|
251
251
|
cacheTTL: 2 * 60 * 1000, // 2 minutes cache
|
|
252
252
|
});
|
|
@@ -266,7 +266,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
266
266
|
async getUserFollowing(userId, pagination) {
|
|
267
267
|
try {
|
|
268
268
|
const params = buildPaginationParams(pagination || {});
|
|
269
|
-
const response = await this.makeRequest('GET', `/
|
|
269
|
+
const response = await this.makeRequest('GET', `/users/${userId}/following`, params, {
|
|
270
270
|
cache: true,
|
|
271
271
|
cacheTTL: 2 * 60 * 1000, // 2 minutes cache
|
|
272
272
|
});
|
|
@@ -285,7 +285,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
285
285
|
*/
|
|
286
286
|
async getNotifications() {
|
|
287
287
|
return this.withAuthRetry(async () => {
|
|
288
|
-
return await this.makeRequest('GET', '/
|
|
288
|
+
return await this.makeRequest('GET', '/notifications', undefined, {
|
|
289
289
|
cache: false, // Don't cache notifications - always get fresh data
|
|
290
290
|
});
|
|
291
291
|
}, 'getNotifications');
|
|
@@ -295,7 +295,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
295
295
|
*/
|
|
296
296
|
async getUnreadCount() {
|
|
297
297
|
try {
|
|
298
|
-
const res = await this.makeRequest('GET', '/
|
|
298
|
+
const res = await this.makeRequest('GET', '/notifications/unread-count', undefined, {
|
|
299
299
|
cache: false, // Don't cache unread count - always get fresh data
|
|
300
300
|
});
|
|
301
301
|
return res.count;
|
|
@@ -309,7 +309,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
309
309
|
*/
|
|
310
310
|
async createNotification(data) {
|
|
311
311
|
try {
|
|
312
|
-
return await this.makeRequest('POST', '/
|
|
312
|
+
return await this.makeRequest('POST', '/notifications', data, { cache: false });
|
|
313
313
|
}
|
|
314
314
|
catch (error) {
|
|
315
315
|
throw this.handleError(error);
|
|
@@ -320,7 +320,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
320
320
|
*/
|
|
321
321
|
async markNotificationAsRead(notificationId) {
|
|
322
322
|
try {
|
|
323
|
-
await this.makeRequest('PUT', `/
|
|
323
|
+
await this.makeRequest('PUT', `/notifications/${notificationId}/read`, undefined, { cache: false });
|
|
324
324
|
}
|
|
325
325
|
catch (error) {
|
|
326
326
|
throw this.handleError(error);
|
|
@@ -331,7 +331,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
331
331
|
*/
|
|
332
332
|
async markAllNotificationsAsRead() {
|
|
333
333
|
try {
|
|
334
|
-
await this.makeRequest('PUT', '/
|
|
334
|
+
await this.makeRequest('PUT', '/notifications/read-all', undefined, { cache: false });
|
|
335
335
|
}
|
|
336
336
|
catch (error) {
|
|
337
337
|
throw this.handleError(error);
|
|
@@ -342,7 +342,7 @@ export function OxyServicesUserMixin(Base) {
|
|
|
342
342
|
*/
|
|
343
343
|
async deleteNotification(notificationId) {
|
|
344
344
|
try {
|
|
345
|
-
await this.makeRequest('DELETE', `/
|
|
345
|
+
await this.makeRequest('DELETE', `/notifications/${notificationId}`, undefined, { cache: false });
|
|
346
346
|
}
|
|
347
347
|
catch (error) {
|
|
348
348
|
throw this.handleError(error);
|
|
@@ -16,7 +16,7 @@ export function OxyServicesUtilityMixin(Base) {
|
|
|
16
16
|
*/
|
|
17
17
|
async fetchLinkMetadata(url) {
|
|
18
18
|
try {
|
|
19
|
-
return await this.makeRequest('GET', '/
|
|
19
|
+
return await this.makeRequest('GET', '/link-metadata', { url }, {
|
|
20
20
|
cache: true,
|
|
21
21
|
cacheTTL: CACHE_TIMES.EXTRA_LONG,
|
|
22
22
|
});
|
|
@@ -37,19 +37,19 @@ export function OxyServicesUtilityMixin(Base) {
|
|
|
37
37
|
*
|
|
38
38
|
* const oxy = new OxyServices({ baseURL: 'https://api.oxy.so' });
|
|
39
39
|
*
|
|
40
|
-
* // Protect all routes under /
|
|
41
|
-
* app.use('/
|
|
40
|
+
* // Protect all routes under /protected
|
|
41
|
+
* app.use('/protected', oxy.auth());
|
|
42
42
|
*
|
|
43
43
|
* // Access user in route handler
|
|
44
|
-
* app.get('/
|
|
44
|
+
* app.get('/protected/me', (req, res) => {
|
|
45
45
|
* res.json({ userId: req.userId, user: req.user });
|
|
46
46
|
* });
|
|
47
47
|
*
|
|
48
48
|
* // Load full user profile from API
|
|
49
|
-
* app.use('/
|
|
49
|
+
* app.use('/admin', oxy.auth({ loadUser: true }));
|
|
50
50
|
*
|
|
51
51
|
* // Optional auth - attach user if present, don't block if absent
|
|
52
|
-
* app.use('/
|
|
52
|
+
* app.use('/public', oxy.auth({ optional: true }));
|
|
53
53
|
* ```
|
|
54
54
|
*
|
|
55
55
|
* @param options Optional configuration
|
|
@@ -151,7 +151,16 @@ export function OxyServicesUtilityMixin(Base) {
|
|
|
151
151
|
throw new Error('Invalid signature');
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
catch {
|
|
154
|
+
catch (verifyError) {
|
|
155
|
+
const isSignatureError = verifyError instanceof Error &&
|
|
156
|
+
(verifyError.message === 'Invalid signature' || verifyError.message === 'Invalid token structure');
|
|
157
|
+
if (!isSignatureError) {
|
|
158
|
+
console.error('[oxy.auth] Unexpected error during service token verification:', verifyError);
|
|
159
|
+
const error = { message: 'Internal authentication error', code: 'AUTH_INTERNAL_ERROR', status: 500 };
|
|
160
|
+
if (onError)
|
|
161
|
+
return onError(error);
|
|
162
|
+
return res.status(500).json(error);
|
|
163
|
+
}
|
|
155
164
|
if (optional) {
|
|
156
165
|
req.userId = null;
|
|
157
166
|
req.user = null;
|
|
@@ -71,7 +71,6 @@ export async function retryAsync(operation, maxRetries = 3, baseDelay = 1000, sh
|
|
|
71
71
|
*/
|
|
72
72
|
export function debounceAsync(func, delay) {
|
|
73
73
|
let timeoutId;
|
|
74
|
-
const lastPromise = null;
|
|
75
74
|
return (...args) => {
|
|
76
75
|
return new Promise((resolve, reject) => {
|
|
77
76
|
clearTimeout(timeoutId);
|
|
@@ -74,6 +74,18 @@ export function isIOS() {
|
|
|
74
74
|
export function isAndroid() {
|
|
75
75
|
return getPlatformOS() === 'android';
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Check if running in React Native
|
|
79
|
+
*/
|
|
80
|
+
export function isReactNative() {
|
|
81
|
+
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if running in Node.js
|
|
85
|
+
*/
|
|
86
|
+
export function isNodeJS() {
|
|
87
|
+
return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
88
|
+
}
|
|
77
89
|
/**
|
|
78
90
|
* Set the platform OS explicitly
|
|
79
91
|
* Called by React Native entry point to register the platform
|
|
@@ -30,6 +30,8 @@ interface RequestConfig extends RequestOptions {
|
|
|
30
30
|
params?: Record<string, unknown>;
|
|
31
31
|
/** @internal Used to prevent infinite auth retry loops */
|
|
32
32
|
_isAuthRetry?: boolean;
|
|
33
|
+
/** @internal Used to prevent infinite CSRF retry loops */
|
|
34
|
+
_isCsrfRetry?: boolean;
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* Unified HTTP Service
|
|
@@ -46,6 +48,7 @@ export declare class HttpService {
|
|
|
46
48
|
private logger;
|
|
47
49
|
private config;
|
|
48
50
|
private tokenRefreshPromise;
|
|
51
|
+
private tokenRefreshCooldownUntil;
|
|
49
52
|
private _onTokenRefreshed;
|
|
50
53
|
private requestMetrics;
|
|
51
54
|
constructor(config: OxyConfig);
|
|
@@ -164,6 +167,6 @@ export declare class HttpService {
|
|
|
164
167
|
cacheMisses: number;
|
|
165
168
|
averageResponseTime: number;
|
|
166
169
|
};
|
|
167
|
-
|
|
170
|
+
__resetTokensForTests(): void;
|
|
168
171
|
}
|
|
169
172
|
export {};
|
|
@@ -11,7 +11,7 @@ export declare class OxyServicesBase {
|
|
|
11
11
|
cloudURL: string;
|
|
12
12
|
config: OxyConfig;
|
|
13
13
|
constructor(...args: any[]);
|
|
14
|
-
|
|
14
|
+
__resetTokensForTests(): void;
|
|
15
15
|
/**
|
|
16
16
|
* Make a request with all performance optimizations
|
|
17
17
|
* This is the main method for all API calls - ensures authentication and performance features
|
|
@@ -22,6 +22,7 @@ export declare function OxyServicesAnalyticsMixin<T extends typeof OxyServicesBa
|
|
|
22
22
|
httpService: import("../HttpService").HttpService;
|
|
23
23
|
cloudURL: string;
|
|
24
24
|
config: import("../OxyServices.base").OxyConfig;
|
|
25
|
+
__resetTokensForTests(): void;
|
|
25
26
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
26
27
|
getBaseURL(): string;
|
|
27
28
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -64,5 +65,4 @@ export declare function OxyServicesAnalyticsMixin<T extends typeof OxyServicesBa
|
|
|
64
65
|
[key: string]: any;
|
|
65
66
|
}>;
|
|
66
67
|
};
|
|
67
|
-
__resetTokensForTests(): void;
|
|
68
68
|
} & T;
|
|
@@ -91,6 +91,7 @@ export declare function OxyServicesAssetsMixin<T extends typeof OxyServicesBase>
|
|
|
91
91
|
httpService: import("../HttpService").HttpService;
|
|
92
92
|
cloudURL: string;
|
|
93
93
|
config: import("../OxyServices.base").OxyConfig;
|
|
94
|
+
__resetTokensForTests(): void;
|
|
94
95
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
95
96
|
getBaseURL(): string;
|
|
96
97
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -133,5 +134,4 @@ export declare function OxyServicesAssetsMixin<T extends typeof OxyServicesBase>
|
|
|
133
134
|
[key: string]: any;
|
|
134
135
|
}>;
|
|
135
136
|
};
|
|
136
|
-
__resetTokensForTests(): void;
|
|
137
137
|
} & T;
|
|
@@ -178,6 +178,7 @@ export declare function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(B
|
|
|
178
178
|
httpService: import("../HttpService").HttpService;
|
|
179
179
|
cloudURL: string;
|
|
180
180
|
config: import("../OxyServices.base").OxyConfig;
|
|
181
|
+
__resetTokensForTests(): void;
|
|
181
182
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
182
183
|
getBaseURL(): string;
|
|
183
184
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -220,5 +221,4 @@ export declare function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(B
|
|
|
220
221
|
[key: string]: any;
|
|
221
222
|
}>;
|
|
222
223
|
};
|
|
223
|
-
__resetTokensForTests(): void;
|
|
224
224
|
} & T;
|
|
@@ -55,6 +55,7 @@ export declare function OxyServicesDeveloperMixin<T extends typeof OxyServicesBa
|
|
|
55
55
|
httpService: import("../HttpService").HttpService;
|
|
56
56
|
cloudURL: string;
|
|
57
57
|
config: import("../OxyServices.base").OxyConfig;
|
|
58
|
+
__resetTokensForTests(): void;
|
|
58
59
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
59
60
|
getBaseURL(): string;
|
|
60
61
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -97,5 +98,4 @@ export declare function OxyServicesDeveloperMixin<T extends typeof OxyServicesBa
|
|
|
97
98
|
[key: string]: any;
|
|
98
99
|
}>;
|
|
99
100
|
};
|
|
100
|
-
__resetTokensForTests(): void;
|
|
101
101
|
} & T;
|
|
@@ -52,6 +52,7 @@ export declare function OxyServicesDevicesMixin<T extends typeof OxyServicesBase
|
|
|
52
52
|
httpService: import("../HttpService").HttpService;
|
|
53
53
|
cloudURL: string;
|
|
54
54
|
config: import("../OxyServices.base").OxyConfig;
|
|
55
|
+
__resetTokensForTests(): void;
|
|
55
56
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
56
57
|
getBaseURL(): string;
|
|
57
58
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -94,5 +95,4 @@ export declare function OxyServicesDevicesMixin<T extends typeof OxyServicesBase
|
|
|
94
95
|
[key: string]: any;
|
|
95
96
|
}>;
|
|
96
97
|
};
|
|
97
|
-
__resetTokensForTests(): void;
|
|
98
98
|
} & T;
|
|
@@ -184,6 +184,7 @@ export declare function OxyServicesFeaturesMixin<T extends typeof OxyServicesBas
|
|
|
184
184
|
httpService: import("../HttpService").HttpService;
|
|
185
185
|
cloudURL: string;
|
|
186
186
|
config: import("../OxyServices.base").OxyConfig;
|
|
187
|
+
__resetTokensForTests(): void;
|
|
187
188
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
188
189
|
getBaseURL(): string;
|
|
189
190
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -226,5 +227,4 @@ export declare function OxyServicesFeaturesMixin<T extends typeof OxyServicesBas
|
|
|
226
227
|
[key: string]: any;
|
|
227
228
|
}>;
|
|
228
229
|
};
|
|
229
|
-
__resetTokensForTests(): void;
|
|
230
230
|
} & T;
|
|
@@ -148,6 +148,7 @@ export declare function OxyServicesFedCMMixin<T extends typeof OxyServicesBase>(
|
|
|
148
148
|
httpService: import("../HttpService").HttpService;
|
|
149
149
|
cloudURL: string;
|
|
150
150
|
config: import("../OxyServices.base").OxyConfig;
|
|
151
|
+
__resetTokensForTests(): void;
|
|
151
152
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
152
153
|
getBaseURL(): string;
|
|
153
154
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -197,6 +198,5 @@ export declare function OxyServicesFedCMMixin<T extends typeof OxyServicesBase>(
|
|
|
197
198
|
* Check if FedCM is supported in the current browser
|
|
198
199
|
*/
|
|
199
200
|
isFedCMSupported(): boolean;
|
|
200
|
-
__resetTokensForTests(): void;
|
|
201
201
|
} & T;
|
|
202
202
|
export { OxyServicesFedCMMixin as FedCMMixin };
|
|
@@ -41,6 +41,7 @@ export declare function OxyServicesKarmaMixin<T extends typeof OxyServicesBase>(
|
|
|
41
41
|
httpService: import("../HttpService").HttpService;
|
|
42
42
|
cloudURL: string;
|
|
43
43
|
config: import("../OxyServices.base").OxyConfig;
|
|
44
|
+
__resetTokensForTests(): void;
|
|
44
45
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
45
46
|
getBaseURL(): string;
|
|
46
47
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -83,5 +84,4 @@ export declare function OxyServicesKarmaMixin<T extends typeof OxyServicesBase>(
|
|
|
83
84
|
[key: string]: any;
|
|
84
85
|
}>;
|
|
85
86
|
};
|
|
86
|
-
__resetTokensForTests(): void;
|
|
87
87
|
} & T;
|
|
@@ -37,6 +37,7 @@ export declare function OxyServicesLanguageMixin<T extends typeof OxyServicesBas
|
|
|
37
37
|
httpService: import("../HttpService").HttpService;
|
|
38
38
|
cloudURL: string;
|
|
39
39
|
config: import("../OxyServices.base").OxyConfig;
|
|
40
|
+
__resetTokensForTests(): void;
|
|
40
41
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
41
42
|
getBaseURL(): string;
|
|
42
43
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -79,5 +80,4 @@ export declare function OxyServicesLanguageMixin<T extends typeof OxyServicesBas
|
|
|
79
80
|
[key: string]: any;
|
|
80
81
|
}>;
|
|
81
82
|
};
|
|
82
|
-
__resetTokensForTests(): void;
|
|
83
83
|
} & T;
|
|
@@ -20,6 +20,7 @@ export declare function OxyServicesLocationMixin<T extends typeof OxyServicesBas
|
|
|
20
20
|
httpService: import("../HttpService").HttpService;
|
|
21
21
|
cloudURL: string;
|
|
22
22
|
config: import("../OxyServices.base").OxyConfig;
|
|
23
|
+
__resetTokensForTests(): void;
|
|
23
24
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
24
25
|
getBaseURL(): string;
|
|
25
26
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -62,5 +63,4 @@ export declare function OxyServicesLocationMixin<T extends typeof OxyServicesBas
|
|
|
62
63
|
[key: string]: any;
|
|
63
64
|
}>;
|
|
64
65
|
};
|
|
65
|
-
__resetTokensForTests(): void;
|
|
66
66
|
} & T;
|
|
@@ -67,6 +67,7 @@ export declare function OxyServicesPaymentMixin<T extends typeof OxyServicesBase
|
|
|
67
67
|
httpService: import("../HttpService").HttpService;
|
|
68
68
|
cloudURL: string;
|
|
69
69
|
config: import("../OxyServices.base").OxyConfig;
|
|
70
|
+
__resetTokensForTests(): void;
|
|
70
71
|
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
71
72
|
getBaseURL(): string;
|
|
72
73
|
getClient(): import("../HttpService").HttpService;
|
|
@@ -109,5 +110,4 @@ export declare function OxyServicesPaymentMixin<T extends typeof OxyServicesBase
|
|
|
109
110
|
[key: string]: any;
|
|
110
111
|
}>;
|
|
111
112
|
};
|
|
112
|
-
__resetTokensForTests(): void;
|
|
113
113
|
} & T;
|