@oxyhq/core 1.0.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/README.md +50 -0
- package/dist/cjs/AuthManager.js +361 -0
- package/dist/cjs/CrossDomainAuth.js +258 -0
- package/dist/cjs/HttpService.js +618 -0
- package/dist/cjs/OxyServices.base.js +263 -0
- package/dist/cjs/OxyServices.errors.js +22 -0
- package/dist/cjs/OxyServices.js +63 -0
- package/dist/cjs/constants/version.js +16 -0
- package/dist/cjs/crypto/index.js +20 -0
- package/dist/cjs/crypto/keyManager.js +887 -0
- package/dist/cjs/crypto/polyfill.js +64 -0
- package/dist/cjs/crypto/recoveryPhrase.js +169 -0
- package/dist/cjs/crypto/signatureService.js +296 -0
- package/dist/cjs/i18n/index.js +73 -0
- package/dist/cjs/i18n/locales/ar-SA.json +120 -0
- package/dist/cjs/i18n/locales/ca-ES.json +120 -0
- package/dist/cjs/i18n/locales/de-DE.json +120 -0
- package/dist/cjs/i18n/locales/en-US.json +956 -0
- package/dist/cjs/i18n/locales/es-ES.json +944 -0
- package/dist/cjs/i18n/locales/fr-FR.json +120 -0
- package/dist/cjs/i18n/locales/it-IT.json +120 -0
- package/dist/cjs/i18n/locales/ja-JP.json +119 -0
- package/dist/cjs/i18n/locales/ko-KR.json +120 -0
- package/dist/cjs/i18n/locales/locales/ar-SA.json +120 -0
- package/dist/cjs/i18n/locales/locales/ca-ES.json +120 -0
- package/dist/cjs/i18n/locales/locales/de-DE.json +120 -0
- package/dist/cjs/i18n/locales/locales/en-US.json +956 -0
- package/dist/cjs/i18n/locales/locales/es-ES.json +944 -0
- package/dist/cjs/i18n/locales/locales/fr-FR.json +120 -0
- package/dist/cjs/i18n/locales/locales/it-IT.json +120 -0
- package/dist/cjs/i18n/locales/locales/ja-JP.json +119 -0
- package/dist/cjs/i18n/locales/locales/ko-KR.json +120 -0
- package/dist/cjs/i18n/locales/locales/pt-PT.json +120 -0
- package/dist/cjs/i18n/locales/locales/zh-CN.json +120 -0
- package/dist/cjs/i18n/locales/pt-PT.json +120 -0
- package/dist/cjs/i18n/locales/zh-CN.json +120 -0
- package/dist/cjs/index.js +153 -0
- package/dist/cjs/mixins/OxyServices.analytics.js +49 -0
- package/dist/cjs/mixins/OxyServices.assets.js +380 -0
- package/dist/cjs/mixins/OxyServices.auth.js +259 -0
- package/dist/cjs/mixins/OxyServices.developer.js +97 -0
- package/dist/cjs/mixins/OxyServices.devices.js +116 -0
- package/dist/cjs/mixins/OxyServices.features.js +309 -0
- package/dist/cjs/mixins/OxyServices.fedcm.js +435 -0
- package/dist/cjs/mixins/OxyServices.karma.js +108 -0
- package/dist/cjs/mixins/OxyServices.language.js +154 -0
- package/dist/cjs/mixins/OxyServices.location.js +43 -0
- package/dist/cjs/mixins/OxyServices.payment.js +158 -0
- package/dist/cjs/mixins/OxyServices.popup.js +371 -0
- package/dist/cjs/mixins/OxyServices.privacy.js +162 -0
- package/dist/cjs/mixins/OxyServices.redirect.js +345 -0
- package/dist/cjs/mixins/OxyServices.security.js +81 -0
- package/dist/cjs/mixins/OxyServices.user.js +355 -0
- package/dist/cjs/mixins/OxyServices.utility.js +156 -0
- package/dist/cjs/mixins/index.js +79 -0
- package/dist/cjs/mixins/mixinHelpers.js +53 -0
- package/dist/cjs/models/interfaces.js +20 -0
- package/dist/cjs/models/session.js +2 -0
- package/dist/cjs/shared/index.js +70 -0
- package/dist/cjs/shared/utils/colorUtils.js +153 -0
- package/dist/cjs/shared/utils/debugUtils.js +73 -0
- package/dist/cjs/shared/utils/errorUtils.js +183 -0
- package/dist/cjs/shared/utils/index.js +49 -0
- package/dist/cjs/shared/utils/networkUtils.js +183 -0
- package/dist/cjs/shared/utils/themeUtils.js +106 -0
- package/dist/cjs/utils/apiUtils.js +61 -0
- package/dist/cjs/utils/asyncUtils.js +194 -0
- package/dist/cjs/utils/cache.js +226 -0
- package/dist/cjs/utils/deviceManager.js +205 -0
- package/dist/cjs/utils/errorUtils.js +154 -0
- package/dist/cjs/utils/index.js +26 -0
- package/dist/cjs/utils/languageUtils.js +165 -0
- package/dist/cjs/utils/loggerUtils.js +126 -0
- package/dist/cjs/utils/platform.js +144 -0
- package/dist/cjs/utils/requestUtils.js +209 -0
- package/dist/cjs/utils/sessionUtils.js +181 -0
- package/dist/cjs/utils/validationUtils.js +173 -0
- package/dist/esm/AuthManager.js +356 -0
- package/dist/esm/CrossDomainAuth.js +253 -0
- package/dist/esm/HttpService.js +614 -0
- package/dist/esm/OxyServices.base.js +259 -0
- package/dist/esm/OxyServices.errors.js +17 -0
- package/dist/esm/OxyServices.js +59 -0
- package/dist/esm/constants/version.js +13 -0
- package/dist/esm/crypto/index.js +13 -0
- package/dist/esm/crypto/keyManager.js +850 -0
- package/dist/esm/crypto/polyfill.js +61 -0
- package/dist/esm/crypto/recoveryPhrase.js +132 -0
- package/dist/esm/crypto/signatureService.js +259 -0
- package/dist/esm/i18n/index.js +69 -0
- package/dist/esm/i18n/locales/ar-SA.json +120 -0
- package/dist/esm/i18n/locales/ca-ES.json +120 -0
- package/dist/esm/i18n/locales/de-DE.json +120 -0
- package/dist/esm/i18n/locales/en-US.json +956 -0
- package/dist/esm/i18n/locales/es-ES.json +944 -0
- package/dist/esm/i18n/locales/fr-FR.json +120 -0
- package/dist/esm/i18n/locales/it-IT.json +120 -0
- package/dist/esm/i18n/locales/ja-JP.json +119 -0
- package/dist/esm/i18n/locales/ko-KR.json +120 -0
- package/dist/esm/i18n/locales/locales/ar-SA.json +120 -0
- package/dist/esm/i18n/locales/locales/ca-ES.json +120 -0
- package/dist/esm/i18n/locales/locales/de-DE.json +120 -0
- package/dist/esm/i18n/locales/locales/en-US.json +956 -0
- package/dist/esm/i18n/locales/locales/es-ES.json +944 -0
- package/dist/esm/i18n/locales/locales/fr-FR.json +120 -0
- package/dist/esm/i18n/locales/locales/it-IT.json +120 -0
- package/dist/esm/i18n/locales/locales/ja-JP.json +119 -0
- package/dist/esm/i18n/locales/locales/ko-KR.json +120 -0
- package/dist/esm/i18n/locales/locales/pt-PT.json +120 -0
- package/dist/esm/i18n/locales/locales/zh-CN.json +120 -0
- package/dist/esm/i18n/locales/pt-PT.json +120 -0
- package/dist/esm/i18n/locales/zh-CN.json +120 -0
- package/dist/esm/index.js +55 -0
- package/dist/esm/mixins/OxyServices.analytics.js +46 -0
- package/dist/esm/mixins/OxyServices.assets.js +377 -0
- package/dist/esm/mixins/OxyServices.auth.js +256 -0
- package/dist/esm/mixins/OxyServices.developer.js +94 -0
- package/dist/esm/mixins/OxyServices.devices.js +113 -0
- package/dist/esm/mixins/OxyServices.features.js +306 -0
- package/dist/esm/mixins/OxyServices.fedcm.js +433 -0
- package/dist/esm/mixins/OxyServices.karma.js +105 -0
- package/dist/esm/mixins/OxyServices.language.js +118 -0
- package/dist/esm/mixins/OxyServices.location.js +40 -0
- package/dist/esm/mixins/OxyServices.payment.js +155 -0
- package/dist/esm/mixins/OxyServices.popup.js +369 -0
- package/dist/esm/mixins/OxyServices.privacy.js +159 -0
- package/dist/esm/mixins/OxyServices.redirect.js +343 -0
- package/dist/esm/mixins/OxyServices.security.js +78 -0
- package/dist/esm/mixins/OxyServices.user.js +352 -0
- package/dist/esm/mixins/OxyServices.utility.js +153 -0
- package/dist/esm/mixins/index.js +76 -0
- package/dist/esm/mixins/mixinHelpers.js +48 -0
- package/dist/esm/models/interfaces.js +17 -0
- package/dist/esm/models/session.js +1 -0
- package/dist/esm/shared/index.js +31 -0
- package/dist/esm/shared/utils/colorUtils.js +143 -0
- package/dist/esm/shared/utils/debugUtils.js +65 -0
- package/dist/esm/shared/utils/errorUtils.js +170 -0
- package/dist/esm/shared/utils/index.js +15 -0
- package/dist/esm/shared/utils/networkUtils.js +173 -0
- package/dist/esm/shared/utils/themeUtils.js +98 -0
- package/dist/esm/utils/apiUtils.js +55 -0
- package/dist/esm/utils/asyncUtils.js +179 -0
- package/dist/esm/utils/cache.js +218 -0
- package/dist/esm/utils/deviceManager.js +168 -0
- package/dist/esm/utils/errorUtils.js +146 -0
- package/dist/esm/utils/index.js +7 -0
- package/dist/esm/utils/languageUtils.js +158 -0
- package/dist/esm/utils/loggerUtils.js +115 -0
- package/dist/esm/utils/platform.js +102 -0
- package/dist/esm/utils/requestUtils.js +203 -0
- package/dist/esm/utils/sessionUtils.js +171 -0
- package/dist/esm/utils/validationUtils.js +153 -0
- package/dist/types/AuthManager.d.ts +143 -0
- package/dist/types/CrossDomainAuth.d.ts +160 -0
- package/dist/types/HttpService.d.ts +163 -0
- package/dist/types/OxyServices.base.d.ts +126 -0
- package/dist/types/OxyServices.d.ts +81 -0
- package/dist/types/OxyServices.errors.d.ts +11 -0
- package/dist/types/constants/version.d.ts +13 -0
- package/dist/types/crypto/index.d.ts +11 -0
- package/dist/types/crypto/keyManager.d.ts +189 -0
- package/dist/types/crypto/polyfill.d.ts +11 -0
- package/dist/types/crypto/recoveryPhrase.d.ts +58 -0
- package/dist/types/crypto/signatureService.d.ts +86 -0
- package/dist/types/i18n/index.d.ts +3 -0
- package/dist/types/index.d.ts +50 -0
- package/dist/types/mixins/OxyServices.analytics.d.ts +66 -0
- package/dist/types/mixins/OxyServices.assets.d.ts +135 -0
- package/dist/types/mixins/OxyServices.auth.d.ts +186 -0
- package/dist/types/mixins/OxyServices.developer.d.ts +99 -0
- package/dist/types/mixins/OxyServices.devices.d.ts +96 -0
- package/dist/types/mixins/OxyServices.features.d.ts +228 -0
- package/dist/types/mixins/OxyServices.fedcm.d.ts +200 -0
- package/dist/types/mixins/OxyServices.karma.d.ts +85 -0
- package/dist/types/mixins/OxyServices.language.d.ts +81 -0
- package/dist/types/mixins/OxyServices.location.d.ts +64 -0
- package/dist/types/mixins/OxyServices.payment.d.ts +111 -0
- package/dist/types/mixins/OxyServices.popup.d.ts +205 -0
- package/dist/types/mixins/OxyServices.privacy.d.ts +122 -0
- package/dist/types/mixins/OxyServices.redirect.d.ts +245 -0
- package/dist/types/mixins/OxyServices.security.d.ts +78 -0
- package/dist/types/mixins/OxyServices.user.d.ts +182 -0
- package/dist/types/mixins/OxyServices.utility.d.ts +93 -0
- package/dist/types/mixins/index.d.ts +30 -0
- package/dist/types/mixins/mixinHelpers.d.ts +31 -0
- package/dist/types/models/interfaces.d.ts +415 -0
- package/dist/types/models/session.d.ts +27 -0
- package/dist/types/shared/index.d.ts +28 -0
- package/dist/types/shared/utils/colorUtils.d.ts +104 -0
- package/dist/types/shared/utils/debugUtils.d.ts +48 -0
- package/dist/types/shared/utils/errorUtils.d.ts +97 -0
- package/dist/types/shared/utils/index.d.ts +13 -0
- package/dist/types/shared/utils/networkUtils.d.ts +139 -0
- package/dist/types/shared/utils/themeUtils.d.ts +90 -0
- package/dist/types/utils/apiUtils.d.ts +53 -0
- package/dist/types/utils/asyncUtils.d.ts +58 -0
- package/dist/types/utils/cache.d.ts +127 -0
- package/dist/types/utils/deviceManager.d.ts +65 -0
- package/dist/types/utils/errorUtils.d.ts +46 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/dist/types/utils/languageUtils.d.ts +37 -0
- package/dist/types/utils/loggerUtils.d.ts +48 -0
- package/dist/types/utils/platform.d.ts +40 -0
- package/dist/types/utils/requestUtils.d.ts +123 -0
- package/dist/types/utils/sessionUtils.d.ts +54 -0
- package/dist/types/utils/validationUtils.d.ts +85 -0
- package/package.json +84 -0
- package/src/AuthManager.ts +436 -0
- package/src/CrossDomainAuth.ts +307 -0
- package/src/HttpService.ts +752 -0
- package/src/OxyServices.base.ts +334 -0
- package/src/OxyServices.errors.ts +26 -0
- package/src/OxyServices.ts +129 -0
- package/src/constants/version.ts +15 -0
- package/src/crypto/index.ts +25 -0
- package/src/crypto/keyManager.ts +962 -0
- package/src/crypto/polyfill.ts +70 -0
- package/src/crypto/recoveryPhrase.ts +166 -0
- package/src/crypto/signatureService.ts +323 -0
- package/src/i18n/index.ts +75 -0
- package/src/i18n/locales/ar-SA.json +120 -0
- package/src/i18n/locales/ca-ES.json +120 -0
- package/src/i18n/locales/de-DE.json +120 -0
- package/src/i18n/locales/en-US.json +956 -0
- package/src/i18n/locales/es-ES.json +944 -0
- package/src/i18n/locales/fr-FR.json +120 -0
- package/src/i18n/locales/it-IT.json +120 -0
- package/src/i18n/locales/ja-JP.json +119 -0
- package/src/i18n/locales/ko-KR.json +120 -0
- package/src/i18n/locales/pt-PT.json +120 -0
- package/src/i18n/locales/zh-CN.json +120 -0
- package/src/index.ts +153 -0
- package/src/mixins/OxyServices.analytics.ts +53 -0
- package/src/mixins/OxyServices.assets.ts +412 -0
- package/src/mixins/OxyServices.auth.ts +358 -0
- package/src/mixins/OxyServices.developer.ts +114 -0
- package/src/mixins/OxyServices.devices.ts +119 -0
- package/src/mixins/OxyServices.features.ts +428 -0
- package/src/mixins/OxyServices.fedcm.ts +494 -0
- package/src/mixins/OxyServices.karma.ts +111 -0
- package/src/mixins/OxyServices.language.ts +127 -0
- package/src/mixins/OxyServices.location.ts +46 -0
- package/src/mixins/OxyServices.payment.ts +163 -0
- package/src/mixins/OxyServices.popup.ts +443 -0
- package/src/mixins/OxyServices.privacy.ts +182 -0
- package/src/mixins/OxyServices.redirect.ts +397 -0
- package/src/mixins/OxyServices.security.ts +103 -0
- package/src/mixins/OxyServices.user.ts +392 -0
- package/src/mixins/OxyServices.utility.ts +191 -0
- package/src/mixins/index.ts +91 -0
- package/src/mixins/mixinHelpers.ts +69 -0
- package/src/models/interfaces.ts +511 -0
- package/src/models/session.ts +30 -0
- package/src/shared/index.ts +82 -0
- package/src/shared/utils/colorUtils.ts +155 -0
- package/src/shared/utils/debugUtils.ts +73 -0
- package/src/shared/utils/errorUtils.ts +181 -0
- package/src/shared/utils/index.ts +59 -0
- package/src/shared/utils/networkUtils.ts +248 -0
- package/src/shared/utils/themeUtils.ts +115 -0
- package/src/types/bip39.d.ts +32 -0
- package/src/types/buffer.d.ts +97 -0
- package/src/types/color.d.ts +20 -0
- package/src/types/elliptic.d.ts +62 -0
- package/src/utils/apiUtils.ts +88 -0
- package/src/utils/asyncUtils.ts +252 -0
- package/src/utils/cache.ts +264 -0
- package/src/utils/deviceManager.ts +198 -0
- package/src/utils/errorUtils.ts +216 -0
- package/src/utils/index.ts +21 -0
- package/src/utils/languageUtils.ts +174 -0
- package/src/utils/loggerUtils.ts +153 -0
- package/src/utils/platform.ts +117 -0
- package/src/utils/requestUtils.ts +237 -0
- package/src/utils/sessionUtils.ts +206 -0
- package/src/utils/validationUtils.ts +174 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OxyServicesDeveloperMixin = OxyServicesDeveloperMixin;
|
|
4
|
+
const mixinHelpers_1 = require("./mixinHelpers");
|
|
5
|
+
function OxyServicesDeveloperMixin(Base) {
|
|
6
|
+
return class extends Base {
|
|
7
|
+
constructor(...args) {
|
|
8
|
+
super(...args);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get developer apps for the current user
|
|
12
|
+
* @returns Array of developer apps
|
|
13
|
+
*/
|
|
14
|
+
async getDeveloperApps() {
|
|
15
|
+
try {
|
|
16
|
+
const res = await this.makeRequest('GET', '/api/developer/apps', undefined, {
|
|
17
|
+
cache: true,
|
|
18
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.MEDIUM,
|
|
19
|
+
});
|
|
20
|
+
return res.apps || [];
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw this.handleError(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a new developer app
|
|
28
|
+
* @param data - Developer app configuration
|
|
29
|
+
* @returns Created developer app
|
|
30
|
+
*/
|
|
31
|
+
async createDeveloperApp(data) {
|
|
32
|
+
try {
|
|
33
|
+
const res = await this.makeRequest('POST', '/api/developer/apps', data, { cache: false });
|
|
34
|
+
return res.app;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw this.handleError(error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get a specific developer app
|
|
42
|
+
*/
|
|
43
|
+
async getDeveloperApp(appId) {
|
|
44
|
+
try {
|
|
45
|
+
const res = await this.makeRequest('GET', `/api/developer/apps/${appId}`, undefined, {
|
|
46
|
+
cache: true,
|
|
47
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.LONG,
|
|
48
|
+
});
|
|
49
|
+
return res.app;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw this.handleError(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Update a developer app
|
|
57
|
+
* @param appId - The developer app ID
|
|
58
|
+
* @param data - Updated app configuration
|
|
59
|
+
* @returns Updated developer app
|
|
60
|
+
*/
|
|
61
|
+
async updateDeveloperApp(appId, data) {
|
|
62
|
+
try {
|
|
63
|
+
const res = await this.makeRequest('PATCH', `/api/developer/apps/${appId}`, data, { cache: false });
|
|
64
|
+
return res.app;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw this.handleError(error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Regenerate API secret for a developer app
|
|
72
|
+
* @param appId - The developer app ID
|
|
73
|
+
* @returns App with new secret
|
|
74
|
+
*/
|
|
75
|
+
async regenerateDeveloperAppSecret(appId) {
|
|
76
|
+
try {
|
|
77
|
+
return await this.makeRequest('POST', `/api/developer/apps/${appId}/regenerate-secret`, undefined, { cache: false });
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
throw this.handleError(error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Delete a developer app
|
|
85
|
+
* @param appId - The developer app ID
|
|
86
|
+
* @returns Deletion result
|
|
87
|
+
*/
|
|
88
|
+
async deleteDeveloperApp(appId) {
|
|
89
|
+
try {
|
|
90
|
+
return await this.makeRequest('DELETE', `/api/developer/apps/${appId}`, undefined, { cache: false });
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw this.handleError(error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OxyServicesDevicesMixin = OxyServicesDevicesMixin;
|
|
4
|
+
function OxyServicesDevicesMixin(Base) {
|
|
5
|
+
return class extends Base {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Register a new device
|
|
11
|
+
* @param deviceData - Device information
|
|
12
|
+
* @returns Registered device object
|
|
13
|
+
*/
|
|
14
|
+
async registerDevice(deviceData) {
|
|
15
|
+
try {
|
|
16
|
+
return await this.makeRequest('POST', '/api/devices', deviceData, { cache: false });
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw this.handleError(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get all devices for the current user
|
|
24
|
+
* @returns Array of user devices
|
|
25
|
+
*/
|
|
26
|
+
async getUserDevices() {
|
|
27
|
+
try {
|
|
28
|
+
return await this.makeRequest('GET', '/api/devices', undefined, {
|
|
29
|
+
cache: false, // Don't cache device list - always get fresh data
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw this.handleError(error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Remove a device
|
|
38
|
+
* @param deviceId - The device ID to remove
|
|
39
|
+
*/
|
|
40
|
+
async removeDevice(deviceId) {
|
|
41
|
+
try {
|
|
42
|
+
await this.makeRequest('DELETE', `/api/devices/${deviceId}`, undefined, { cache: false });
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw this.handleError(error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get device sessions for a given session ID
|
|
50
|
+
* Note: Not cached by default to ensure fresh data
|
|
51
|
+
* @param sessionId - The session ID
|
|
52
|
+
* @returns Array of device sessions
|
|
53
|
+
*/
|
|
54
|
+
async getDeviceSessions(sessionId) {
|
|
55
|
+
try {
|
|
56
|
+
// Use makeRequest for consistent error handling and optional caching
|
|
57
|
+
// Cache disabled by default to ensure fresh session data
|
|
58
|
+
return await this.makeRequest('GET', `/api/session/device/sessions/${sessionId}`, undefined, {
|
|
59
|
+
cache: false, // Don't cache sessions - always get fresh data
|
|
60
|
+
deduplicate: true, // Deduplicate concurrent requests for same sessionId
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw this.handleError(error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Logout all device sessions
|
|
69
|
+
* @param sessionId - The session ID
|
|
70
|
+
* @param deviceId - Optional device ID to target
|
|
71
|
+
* @param excludeCurrent - Whether to exclude the current session
|
|
72
|
+
* @returns Logout result
|
|
73
|
+
*/
|
|
74
|
+
async logoutAllDeviceSessions(sessionId, deviceId, excludeCurrent) {
|
|
75
|
+
try {
|
|
76
|
+
const urlParams = {};
|
|
77
|
+
if (deviceId)
|
|
78
|
+
urlParams.deviceId = deviceId;
|
|
79
|
+
if (excludeCurrent)
|
|
80
|
+
urlParams.excludeCurrent = 'true';
|
|
81
|
+
return await this.makeRequest('POST', `/api/session/device/logout-all/${sessionId}`, urlParams, { cache: false });
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
throw this.handleError(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Update device name
|
|
89
|
+
* @param sessionId - The session ID
|
|
90
|
+
* @param deviceName - New device name
|
|
91
|
+
* @returns Updated device object
|
|
92
|
+
*/
|
|
93
|
+
async updateDeviceName(sessionId, deviceName) {
|
|
94
|
+
try {
|
|
95
|
+
return await this.makeRequest('PUT', `/api/session/device/name/${sessionId}`, { deviceName }, { cache: false });
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
throw this.handleError(error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get security information
|
|
103
|
+
* @returns Security information object
|
|
104
|
+
*/
|
|
105
|
+
async getSecurityInfo() {
|
|
106
|
+
try {
|
|
107
|
+
return await this.makeRequest('GET', '/api/devices/security', undefined, {
|
|
108
|
+
cache: false,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
throw this.handleError(error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OxyServicesFeaturesMixin = OxyServicesFeaturesMixin;
|
|
4
|
+
const mixinHelpers_1 = require("./mixinHelpers");
|
|
5
|
+
function OxyServicesFeaturesMixin(Base) {
|
|
6
|
+
return class extends Base {
|
|
7
|
+
constructor(...args) {
|
|
8
|
+
super(...args);
|
|
9
|
+
}
|
|
10
|
+
// ==================
|
|
11
|
+
// FEEDBACK METHODS
|
|
12
|
+
// ==================
|
|
13
|
+
/**
|
|
14
|
+
* Submit user feedback
|
|
15
|
+
*/
|
|
16
|
+
async submitFeedback(payload) {
|
|
17
|
+
try {
|
|
18
|
+
return await this.makeRequest('POST', '/api/feedback', payload, {
|
|
19
|
+
cache: false,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw this.handleError(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// ==================
|
|
27
|
+
// SUBSCRIPTION METHODS
|
|
28
|
+
// ==================
|
|
29
|
+
/**
|
|
30
|
+
* Get available subscription plans
|
|
31
|
+
*/
|
|
32
|
+
async getSubscriptionPlans() {
|
|
33
|
+
try {
|
|
34
|
+
return await this.makeRequest('GET', '/api/subscriptions/plans', undefined, {
|
|
35
|
+
cache: true,
|
|
36
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.LONG,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw this.handleError(error);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get individual purchasable features
|
|
45
|
+
*/
|
|
46
|
+
async getIndividualFeatures() {
|
|
47
|
+
try {
|
|
48
|
+
return await this.makeRequest('GET', '/api/subscriptions/features', undefined, {
|
|
49
|
+
cache: true,
|
|
50
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.LONG,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw this.handleError(error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Subscribe to a plan
|
|
59
|
+
*/
|
|
60
|
+
async subscribe(planId, paymentMethodId) {
|
|
61
|
+
return this.withAuthRetry(async () => {
|
|
62
|
+
return await this.makeRequest('POST', '/api/subscriptions/subscribe', {
|
|
63
|
+
planId,
|
|
64
|
+
paymentMethodId,
|
|
65
|
+
}, { cache: false });
|
|
66
|
+
}, 'subscribe');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Subscribe to an individual feature
|
|
70
|
+
*/
|
|
71
|
+
async subscribeToFeature(featureId, paymentMethodId) {
|
|
72
|
+
return this.withAuthRetry(async () => {
|
|
73
|
+
return await this.makeRequest('POST', '/api/subscriptions/features/subscribe', {
|
|
74
|
+
featureId,
|
|
75
|
+
paymentMethodId,
|
|
76
|
+
}, { cache: false });
|
|
77
|
+
}, 'subscribeToFeature');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Cancel subscription
|
|
81
|
+
*/
|
|
82
|
+
async cancelSubscription(subscriptionId) {
|
|
83
|
+
return this.withAuthRetry(async () => {
|
|
84
|
+
await this.makeRequest('POST', `/api/subscriptions/${subscriptionId}/cancel`, undefined, {
|
|
85
|
+
cache: false,
|
|
86
|
+
});
|
|
87
|
+
}, 'cancelSubscription');
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Reactivate subscription
|
|
91
|
+
*/
|
|
92
|
+
async reactivateSubscription(subscriptionId) {
|
|
93
|
+
return this.withAuthRetry(async () => {
|
|
94
|
+
await this.makeRequest('POST', `/api/subscriptions/${subscriptionId}/reactivate`, undefined, {
|
|
95
|
+
cache: false,
|
|
96
|
+
});
|
|
97
|
+
}, 'reactivateSubscription');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get current user's subscription
|
|
101
|
+
*/
|
|
102
|
+
async getCurrentSubscription() {
|
|
103
|
+
return this.withAuthRetry(async () => {
|
|
104
|
+
try {
|
|
105
|
+
return await this.makeRequest('GET', '/api/subscriptions/current', undefined, {
|
|
106
|
+
cache: true,
|
|
107
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.SHORT,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (error.status === 404)
|
|
112
|
+
return null;
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}, 'getCurrentSubscription');
|
|
116
|
+
}
|
|
117
|
+
// ==================
|
|
118
|
+
// SAVES/COLLECTIONS
|
|
119
|
+
// ==================
|
|
120
|
+
/**
|
|
121
|
+
* Get user's saved items
|
|
122
|
+
*/
|
|
123
|
+
async getSavedItems(userId) {
|
|
124
|
+
return this.withAuthRetry(async () => {
|
|
125
|
+
const endpoint = userId ? `/api/users/${userId}/saves` : '/api/saves';
|
|
126
|
+
return await this.makeRequest('GET', endpoint, undefined, {
|
|
127
|
+
cache: true,
|
|
128
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.SHORT,
|
|
129
|
+
});
|
|
130
|
+
}, 'getSavedItems');
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get user's collections
|
|
134
|
+
*/
|
|
135
|
+
async getCollections(userId) {
|
|
136
|
+
return this.withAuthRetry(async () => {
|
|
137
|
+
const endpoint = userId ? `/api/users/${userId}/collections` : '/api/collections';
|
|
138
|
+
return await this.makeRequest('GET', endpoint, undefined, {
|
|
139
|
+
cache: true,
|
|
140
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.SHORT,
|
|
141
|
+
});
|
|
142
|
+
}, 'getCollections');
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Save an item
|
|
146
|
+
*/
|
|
147
|
+
async saveItem(itemId, itemType, collectionId) {
|
|
148
|
+
return this.withAuthRetry(async () => {
|
|
149
|
+
return await this.makeRequest('POST', '/api/saves', {
|
|
150
|
+
itemId,
|
|
151
|
+
itemType,
|
|
152
|
+
collectionId,
|
|
153
|
+
}, { cache: false });
|
|
154
|
+
}, 'saveItem');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Remove an item from saves
|
|
158
|
+
*/
|
|
159
|
+
async removeSavedItem(saveId) {
|
|
160
|
+
return this.withAuthRetry(async () => {
|
|
161
|
+
await this.makeRequest('DELETE', `/api/saves/${saveId}`, undefined, { cache: false });
|
|
162
|
+
}, 'removeSavedItem');
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Create a collection
|
|
166
|
+
*/
|
|
167
|
+
async createCollection(name, description) {
|
|
168
|
+
return this.withAuthRetry(async () => {
|
|
169
|
+
return await this.makeRequest('POST', '/api/collections', {
|
|
170
|
+
name,
|
|
171
|
+
description,
|
|
172
|
+
}, { cache: false });
|
|
173
|
+
}, 'createCollection');
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Delete a collection
|
|
177
|
+
*/
|
|
178
|
+
async deleteCollection(collectionId) {
|
|
179
|
+
return this.withAuthRetry(async () => {
|
|
180
|
+
await this.makeRequest('DELETE', `/api/collections/${collectionId}`, undefined, { cache: false });
|
|
181
|
+
}, 'deleteCollection');
|
|
182
|
+
}
|
|
183
|
+
// ==================
|
|
184
|
+
// USER STATS
|
|
185
|
+
// ==================
|
|
186
|
+
/**
|
|
187
|
+
* Get user statistics
|
|
188
|
+
*/
|
|
189
|
+
async getUserStats(userId) {
|
|
190
|
+
try {
|
|
191
|
+
return await this.makeRequest('GET', `/api/users/${userId}/stats`, undefined, {
|
|
192
|
+
cache: true,
|
|
193
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.MEDIUM,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
throw this.handleError(error);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// ==================
|
|
201
|
+
// HISTORY
|
|
202
|
+
// ==================
|
|
203
|
+
/**
|
|
204
|
+
* Get user history
|
|
205
|
+
*/
|
|
206
|
+
async getUserHistory(userId, limit, offset) {
|
|
207
|
+
return this.withAuthRetry(async () => {
|
|
208
|
+
const params = {};
|
|
209
|
+
if (limit)
|
|
210
|
+
params.limit = limit;
|
|
211
|
+
if (offset)
|
|
212
|
+
params.offset = offset;
|
|
213
|
+
const endpoint = userId ? `/api/users/${userId}/history` : '/api/history';
|
|
214
|
+
return await this.makeRequest('GET', endpoint, params, {
|
|
215
|
+
cache: true,
|
|
216
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.SHORT,
|
|
217
|
+
});
|
|
218
|
+
}, 'getUserHistory');
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Clear user history
|
|
222
|
+
*/
|
|
223
|
+
async clearUserHistory() {
|
|
224
|
+
return this.withAuthRetry(async () => {
|
|
225
|
+
await this.makeRequest('DELETE', '/api/history', undefined, { cache: false });
|
|
226
|
+
}, 'clearUserHistory');
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Delete a history item
|
|
230
|
+
*/
|
|
231
|
+
async deleteHistoryItem(itemId) {
|
|
232
|
+
return this.withAuthRetry(async () => {
|
|
233
|
+
await this.makeRequest('DELETE', `/api/history/${itemId}`, undefined, { cache: false });
|
|
234
|
+
}, 'deleteHistoryItem');
|
|
235
|
+
}
|
|
236
|
+
// ==================
|
|
237
|
+
// FAQ
|
|
238
|
+
// ==================
|
|
239
|
+
/**
|
|
240
|
+
* Get FAQs
|
|
241
|
+
*/
|
|
242
|
+
async getFAQs(category) {
|
|
243
|
+
try {
|
|
244
|
+
const params = category ? { category } : undefined;
|
|
245
|
+
return await this.makeRequest('GET', '/api/faqs', params, {
|
|
246
|
+
cache: true,
|
|
247
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.LONG,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
throw this.handleError(error);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Search FAQs
|
|
256
|
+
*/
|
|
257
|
+
async searchFAQs(query) {
|
|
258
|
+
try {
|
|
259
|
+
return await this.makeRequest('GET', '/api/faqs/search', { query }, {
|
|
260
|
+
cache: true,
|
|
261
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.MEDIUM,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
throw this.handleError(error);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// ==================
|
|
269
|
+
// ACHIEVEMENTS
|
|
270
|
+
// ==================
|
|
271
|
+
/**
|
|
272
|
+
* Get user achievements
|
|
273
|
+
*/
|
|
274
|
+
async getUserAchievements(userId) {
|
|
275
|
+
return this.withAuthRetry(async () => {
|
|
276
|
+
const endpoint = userId ? `/api/users/${userId}/achievements` : '/api/achievements';
|
|
277
|
+
return await this.makeRequest('GET', endpoint, undefined, {
|
|
278
|
+
cache: true,
|
|
279
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.MEDIUM,
|
|
280
|
+
});
|
|
281
|
+
}, 'getUserAchievements');
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Get all available achievements
|
|
285
|
+
*/
|
|
286
|
+
async getAllAchievements() {
|
|
287
|
+
try {
|
|
288
|
+
return await this.makeRequest('GET', '/api/achievements/all', undefined, {
|
|
289
|
+
cache: true,
|
|
290
|
+
cacheTTL: mixinHelpers_1.CACHE_TIMES.LONG,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
throw this.handleError(error);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// ==================
|
|
298
|
+
// ACCOUNT
|
|
299
|
+
// ==================
|
|
300
|
+
/**
|
|
301
|
+
* Delete user account (requires password confirmation)
|
|
302
|
+
*/
|
|
303
|
+
async deleteAccount(password) {
|
|
304
|
+
return this.withAuthRetry(async () => {
|
|
305
|
+
await this.makeRequest('DELETE', '/api/account', { password }, { cache: false });
|
|
306
|
+
}, 'deleteAccount');
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|