@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,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper utilities for mixin classes
|
|
3
|
+
* Provides common patterns to reduce code duplication
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { OxyServicesBase } from '../OxyServices.base';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wraps an async method with standard error handling
|
|
10
|
+
* Reduces boilerplate in mixin methods
|
|
11
|
+
*/
|
|
12
|
+
export async function withErrorHandling<T>(
|
|
13
|
+
operation: () => Promise<T>,
|
|
14
|
+
handleError: (error: any) => Error
|
|
15
|
+
): Promise<T> {
|
|
16
|
+
try {
|
|
17
|
+
return await operation();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw handleError(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a standard API request method with error handling
|
|
25
|
+
* Reduces duplication across mixin methods
|
|
26
|
+
*/
|
|
27
|
+
export function createApiMethod<T>(
|
|
28
|
+
makeRequest: OxyServicesBase['makeRequest'],
|
|
29
|
+
handleError: OxyServicesBase['handleError'],
|
|
30
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
|
|
31
|
+
url: string | ((...args: any[]) => string),
|
|
32
|
+
options: {
|
|
33
|
+
cache?: boolean;
|
|
34
|
+
cacheTTL?: number;
|
|
35
|
+
retry?: boolean;
|
|
36
|
+
transformData?: (data: any) => any;
|
|
37
|
+
transformResponse?: (response: any) => T;
|
|
38
|
+
} = {}
|
|
39
|
+
) {
|
|
40
|
+
return async (...args: any[]): Promise<T> => {
|
|
41
|
+
const urlString = typeof url === 'function' ? url(...args) : url;
|
|
42
|
+
const requestData = options.transformData ? options.transformData(args) : args[0];
|
|
43
|
+
|
|
44
|
+
const requestOptions = {
|
|
45
|
+
cache: options.cache ?? true,
|
|
46
|
+
cacheTTL: options.cacheTTL,
|
|
47
|
+
retry: options.retry ?? true,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const response = await makeRequest<T>(method, urlString, requestData, requestOptions);
|
|
52
|
+
return options.transformResponse ? options.transformResponse(response) : response;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw handleError(error);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Cache time constants (in milliseconds)
|
|
61
|
+
*/
|
|
62
|
+
export const CACHE_TIMES = {
|
|
63
|
+
SHORT: 1 * 60 * 1000, // 1 minute
|
|
64
|
+
MEDIUM: 2 * 60 * 1000, // 2 minutes
|
|
65
|
+
LONG: 5 * 60 * 1000, // 5 minutes
|
|
66
|
+
VERY_LONG: 10 * 60 * 1000, // 10 minutes
|
|
67
|
+
EXTRA_LONG: 30 * 60 * 1000, // 30 minutes
|
|
68
|
+
} as const;
|
|
69
|
+
|
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
export interface OxyConfig {
|
|
2
|
+
baseURL: string;
|
|
3
|
+
cloudURL?: string;
|
|
4
|
+
authWebUrl?: string;
|
|
5
|
+
authRedirectUri?: string;
|
|
6
|
+
// Performance & caching options
|
|
7
|
+
enableCache?: boolean;
|
|
8
|
+
cacheTTL?: number; // Cache TTL in milliseconds (default: 5 minutes)
|
|
9
|
+
enableRequestDeduplication?: boolean;
|
|
10
|
+
enableRetry?: boolean;
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
retryDelay?: number;
|
|
13
|
+
requestTimeout?: number; // Default timeout in milliseconds (default: 5000)
|
|
14
|
+
// Rate limiting
|
|
15
|
+
maxConcurrentRequests?: number;
|
|
16
|
+
requestQueueSize?: number;
|
|
17
|
+
// Logging
|
|
18
|
+
enableLogging?: boolean;
|
|
19
|
+
logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
20
|
+
// Performance monitoring
|
|
21
|
+
onRequestStart?: (url: string, method: string) => void;
|
|
22
|
+
onRequestEnd?: (url: string, method: string, duration: number, success: boolean) => void;
|
|
23
|
+
onRequestError?: (url: string, method: string, error: Error) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface User {
|
|
27
|
+
id: string;
|
|
28
|
+
publicKey: string;
|
|
29
|
+
username: string;
|
|
30
|
+
email?: string;
|
|
31
|
+
// Avatar file id (asset id)
|
|
32
|
+
avatar?: string;
|
|
33
|
+
// Privacy and security settings
|
|
34
|
+
privacySettings?: {
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
name?: {
|
|
38
|
+
first?: string;
|
|
39
|
+
last?: string;
|
|
40
|
+
full?: string; // virtual, not stored in DB, returned by API
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
};
|
|
43
|
+
bio?: string;
|
|
44
|
+
karma?: number;
|
|
45
|
+
location?: string;
|
|
46
|
+
website?: string;
|
|
47
|
+
createdAt?: string;
|
|
48
|
+
updatedAt?: string;
|
|
49
|
+
links?: Array<{
|
|
50
|
+
title?: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
image?: string;
|
|
53
|
+
link: string;
|
|
54
|
+
}>;
|
|
55
|
+
// Social counts
|
|
56
|
+
_count?: {
|
|
57
|
+
followers?: number;
|
|
58
|
+
following?: number;
|
|
59
|
+
};
|
|
60
|
+
accountExpiresAfterInactivityDays?: number | null; // Days of inactivity before account expires (null = never expire)
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface LoginResponse {
|
|
65
|
+
accessToken?: string;
|
|
66
|
+
refreshToken?: string;
|
|
67
|
+
token?: string; // For backwards compatibility
|
|
68
|
+
user: User;
|
|
69
|
+
message?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface Notification {
|
|
73
|
+
id: string;
|
|
74
|
+
message: string;
|
|
75
|
+
// Add other notification fields as needed
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface Wallet {
|
|
79
|
+
id: string;
|
|
80
|
+
balance: number;
|
|
81
|
+
// Add other wallet fields as needed
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface Transaction {
|
|
85
|
+
id: string;
|
|
86
|
+
amount: number;
|
|
87
|
+
type: string;
|
|
88
|
+
timestamp: string;
|
|
89
|
+
// Add other transaction fields as needed
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface BlockedUser {
|
|
93
|
+
_id?: string;
|
|
94
|
+
blockedId: string | {
|
|
95
|
+
_id: string;
|
|
96
|
+
username: string;
|
|
97
|
+
avatar?: string;
|
|
98
|
+
};
|
|
99
|
+
userId: string;
|
|
100
|
+
createdAt?: string;
|
|
101
|
+
blockedAt?: string;
|
|
102
|
+
username?: string;
|
|
103
|
+
avatar?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface RestrictedUser {
|
|
107
|
+
_id?: string;
|
|
108
|
+
restrictedId: string | {
|
|
109
|
+
_id: string;
|
|
110
|
+
username: string;
|
|
111
|
+
avatar?: string;
|
|
112
|
+
};
|
|
113
|
+
userId: string;
|
|
114
|
+
createdAt?: string;
|
|
115
|
+
restrictedAt?: string;
|
|
116
|
+
username?: string;
|
|
117
|
+
avatar?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface TransferFundsRequest {
|
|
121
|
+
fromUserId: string;
|
|
122
|
+
toUserId: string;
|
|
123
|
+
amount: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface PurchaseRequest {
|
|
127
|
+
userId: string;
|
|
128
|
+
itemId: string;
|
|
129
|
+
amount: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface WithdrawalRequest {
|
|
133
|
+
userId: string;
|
|
134
|
+
amount: number;
|
|
135
|
+
address: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface TransactionResponse {
|
|
139
|
+
success: boolean;
|
|
140
|
+
transaction: Transaction;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface PaginationInfo {
|
|
144
|
+
total: number;
|
|
145
|
+
limit: number;
|
|
146
|
+
offset: number;
|
|
147
|
+
hasMore: boolean;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface SearchProfilesResponse {
|
|
151
|
+
data: User[];
|
|
152
|
+
pagination: PaginationInfo;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface KarmaRule {
|
|
156
|
+
id: string;
|
|
157
|
+
description: string;
|
|
158
|
+
// Add other karma rule fields as needed
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface KarmaHistory {
|
|
162
|
+
id: string;
|
|
163
|
+
userId: string;
|
|
164
|
+
points: number;
|
|
165
|
+
// Add other karma history fields as needed
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface KarmaLeaderboardEntry {
|
|
169
|
+
userId: string;
|
|
170
|
+
total: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface KarmaAwardRequest {
|
|
174
|
+
userId: string;
|
|
175
|
+
points: number;
|
|
176
|
+
reason?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface ApiError {
|
|
180
|
+
message: string;
|
|
181
|
+
code: string;
|
|
182
|
+
status: number;
|
|
183
|
+
details?: Record<string, unknown>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface PaymentMethod {
|
|
187
|
+
id: string;
|
|
188
|
+
type: string;
|
|
189
|
+
// Add other payment method fields as needed
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface PaymentRequest {
|
|
193
|
+
userId: string;
|
|
194
|
+
planId: string;
|
|
195
|
+
paymentMethodId: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface PaymentResponse {
|
|
199
|
+
transactionId: string;
|
|
200
|
+
status: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface AnalyticsData {
|
|
204
|
+
userId: string;
|
|
205
|
+
// Add other analytics fields as needed
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface FollowerDetails {
|
|
209
|
+
userId: string;
|
|
210
|
+
followers: number;
|
|
211
|
+
// Add other follower details as needed
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface ContentViewer {
|
|
215
|
+
userId: string;
|
|
216
|
+
viewedAt: string;
|
|
217
|
+
// Add other content viewer fields as needed
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* File management interfaces
|
|
222
|
+
*/
|
|
223
|
+
export interface FileMetadata {
|
|
224
|
+
id: string;
|
|
225
|
+
filename: string;
|
|
226
|
+
contentType: string;
|
|
227
|
+
length: number;
|
|
228
|
+
chunkSize: number;
|
|
229
|
+
uploadDate: string;
|
|
230
|
+
metadata?: {
|
|
231
|
+
userId?: string;
|
|
232
|
+
description?: string;
|
|
233
|
+
title?: string;
|
|
234
|
+
tags?: string[];
|
|
235
|
+
[key: string]: unknown;
|
|
236
|
+
};
|
|
237
|
+
variants?: Array<{
|
|
238
|
+
type: string; // e.g. 'thumb', 'poster'
|
|
239
|
+
key: string; // storage key/path
|
|
240
|
+
width?: number;
|
|
241
|
+
height?: number;
|
|
242
|
+
readyAt?: string;
|
|
243
|
+
metadata?: Record<string, unknown>;
|
|
244
|
+
}>;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface FileUploadResponse {
|
|
248
|
+
files: FileMetadata[];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface FileListResponse {
|
|
252
|
+
files: FileMetadata[];
|
|
253
|
+
total: number;
|
|
254
|
+
hasMore: boolean;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface FileUpdateRequest {
|
|
258
|
+
filename?: string;
|
|
259
|
+
metadata?: {
|
|
260
|
+
description?: string;
|
|
261
|
+
title?: string;
|
|
262
|
+
tags?: string[];
|
|
263
|
+
[key: string]: unknown;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface FileDeleteResponse {
|
|
268
|
+
success: boolean;
|
|
269
|
+
message: string;
|
|
270
|
+
fileId: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Central Asset Service interfaces
|
|
275
|
+
*/
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* File visibility levels
|
|
279
|
+
* - private: Only accessible by owner (default)
|
|
280
|
+
* - public: Accessible by anyone without authentication (e.g., avatars, public profile content)
|
|
281
|
+
* - unlisted: Accessible with direct link but not listed publicly
|
|
282
|
+
*/
|
|
283
|
+
export type FileVisibility = 'private' | 'public' | 'unlisted';
|
|
284
|
+
|
|
285
|
+
export interface AssetLink {
|
|
286
|
+
app: string;
|
|
287
|
+
entityType: string;
|
|
288
|
+
entityId: string;
|
|
289
|
+
createdBy: string;
|
|
290
|
+
createdAt: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export type AssetMetadata = Record<string, string | number | boolean | null | undefined>;
|
|
294
|
+
|
|
295
|
+
export interface AssetVariant {
|
|
296
|
+
type: string;
|
|
297
|
+
key: string;
|
|
298
|
+
width?: number;
|
|
299
|
+
height?: number;
|
|
300
|
+
readyAt?: string;
|
|
301
|
+
size?: number;
|
|
302
|
+
metadata?: AssetMetadata;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface Asset {
|
|
306
|
+
id: string;
|
|
307
|
+
sha256: string;
|
|
308
|
+
size: number;
|
|
309
|
+
mime: string;
|
|
310
|
+
ext: string;
|
|
311
|
+
originalName?: string;
|
|
312
|
+
ownerUserId: string;
|
|
313
|
+
status: 'active' | 'trash' | 'deleted';
|
|
314
|
+
visibility: FileVisibility;
|
|
315
|
+
usageCount: number;
|
|
316
|
+
createdAt: string;
|
|
317
|
+
updatedAt: string;
|
|
318
|
+
links: AssetLink[];
|
|
319
|
+
variants: AssetVariant[];
|
|
320
|
+
metadata?: AssetMetadata;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface AssetInitRequest {
|
|
324
|
+
sha256: string;
|
|
325
|
+
size: number;
|
|
326
|
+
mime: string;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface AssetInitResponse {
|
|
330
|
+
uploadUrl: string;
|
|
331
|
+
fileId: string;
|
|
332
|
+
sha256: string;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface AssetCompleteRequest {
|
|
336
|
+
fileId: string;
|
|
337
|
+
originalName: string;
|
|
338
|
+
size: number;
|
|
339
|
+
mime: string;
|
|
340
|
+
visibility?: FileVisibility;
|
|
341
|
+
metadata?: AssetMetadata;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface AssetLinkRequest {
|
|
345
|
+
app: string;
|
|
346
|
+
entityType: string;
|
|
347
|
+
entityId: string;
|
|
348
|
+
visibility?: FileVisibility;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface AssetUnlinkRequest {
|
|
352
|
+
app: string;
|
|
353
|
+
entityType: string;
|
|
354
|
+
entityId: string;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export interface AssetUrlResponse {
|
|
358
|
+
success: boolean;
|
|
359
|
+
url: string;
|
|
360
|
+
variant?: string;
|
|
361
|
+
expiresIn: number;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface AssetDeleteSummary {
|
|
365
|
+
fileId: string;
|
|
366
|
+
wouldDelete: boolean;
|
|
367
|
+
affectedApps: string[];
|
|
368
|
+
remainingLinks: number;
|
|
369
|
+
variants: string[];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export interface AssetUpdateVisibilityRequest {
|
|
373
|
+
visibility: FileVisibility;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface AssetUpdateVisibilityResponse {
|
|
377
|
+
success: boolean;
|
|
378
|
+
file: {
|
|
379
|
+
id: string;
|
|
380
|
+
visibility: FileVisibility;
|
|
381
|
+
updatedAt: string;
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Account storage usage (server-side usage, not local AsyncStorage)
|
|
387
|
+
*/
|
|
388
|
+
export interface AccountStorageCategoryUsage {
|
|
389
|
+
bytes: number;
|
|
390
|
+
count: number;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export interface AccountStorageUsageResponse {
|
|
394
|
+
plan: 'basic' | 'pro' | 'business';
|
|
395
|
+
totalUsedBytes: number;
|
|
396
|
+
totalLimitBytes: number;
|
|
397
|
+
categories: {
|
|
398
|
+
documents: AccountStorageCategoryUsage;
|
|
399
|
+
mail: AccountStorageCategoryUsage;
|
|
400
|
+
photosVideos: AccountStorageCategoryUsage;
|
|
401
|
+
recordings: AccountStorageCategoryUsage;
|
|
402
|
+
family: AccountStorageCategoryUsage;
|
|
403
|
+
other: AccountStorageCategoryUsage;
|
|
404
|
+
};
|
|
405
|
+
updatedAt: string;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Security activity event types
|
|
410
|
+
*/
|
|
411
|
+
export type SecurityEventType =
|
|
412
|
+
| 'sign_in'
|
|
413
|
+
| 'sign_out'
|
|
414
|
+
| 'email_changed'
|
|
415
|
+
| 'profile_updated'
|
|
416
|
+
| 'device_added'
|
|
417
|
+
| 'device_removed'
|
|
418
|
+
| 'account_recovery'
|
|
419
|
+
| 'security_settings_changed'
|
|
420
|
+
| 'private_key_exported'
|
|
421
|
+
| 'backup_created'
|
|
422
|
+
| 'suspicious_activity';
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Security event severity levels
|
|
426
|
+
*/
|
|
427
|
+
export type SecurityEventSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Security event severity mapping (single source of truth)
|
|
431
|
+
* Maps each event type to its default severity level
|
|
432
|
+
*/
|
|
433
|
+
export const SECURITY_EVENT_SEVERITY_MAP: Record<SecurityEventType, SecurityEventSeverity> = {
|
|
434
|
+
'sign_in': 'low',
|
|
435
|
+
'sign_out': 'low',
|
|
436
|
+
'profile_updated': 'low',
|
|
437
|
+
'email_changed': 'medium',
|
|
438
|
+
'device_added': 'medium',
|
|
439
|
+
'device_removed': 'medium',
|
|
440
|
+
'security_settings_changed': 'medium',
|
|
441
|
+
'account_recovery': 'high',
|
|
442
|
+
'private_key_exported': 'high',
|
|
443
|
+
'backup_created': 'high',
|
|
444
|
+
'suspicious_activity': 'critical',
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Security activity event
|
|
449
|
+
*/
|
|
450
|
+
export interface SecurityActivity {
|
|
451
|
+
id: string;
|
|
452
|
+
userId: string;
|
|
453
|
+
eventType: SecurityEventType;
|
|
454
|
+
eventDescription: string;
|
|
455
|
+
metadata?: Record<string, any>;
|
|
456
|
+
ipAddress?: string;
|
|
457
|
+
userAgent?: string;
|
|
458
|
+
deviceId?: string;
|
|
459
|
+
timestamp: string;
|
|
460
|
+
severity: SecurityEventSeverity;
|
|
461
|
+
createdAt: string;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Security activity response with pagination
|
|
466
|
+
*/
|
|
467
|
+
export interface SecurityActivityResponse {
|
|
468
|
+
data: SecurityActivity[];
|
|
469
|
+
total: number;
|
|
470
|
+
limit: number;
|
|
471
|
+
offset: number;
|
|
472
|
+
hasMore: boolean;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export interface AssetUploadProgress {
|
|
476
|
+
fileId: string;
|
|
477
|
+
uploaded: number;
|
|
478
|
+
total: number;
|
|
479
|
+
percentage: number;
|
|
480
|
+
status: 'uploading' | 'processing' | 'complete' | 'error';
|
|
481
|
+
error?: string;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Device Session interfaces
|
|
485
|
+
export interface DeviceSession {
|
|
486
|
+
sessionId: string;
|
|
487
|
+
deviceId: string;
|
|
488
|
+
deviceName: string;
|
|
489
|
+
isActive: boolean;
|
|
490
|
+
lastActive: string;
|
|
491
|
+
expiresAt: string;
|
|
492
|
+
isCurrent: boolean;
|
|
493
|
+
user?: User;
|
|
494
|
+
createdAt?: string;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export interface DeviceSessionsResponse {
|
|
498
|
+
deviceId: string;
|
|
499
|
+
sessions: DeviceSession[];
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export interface DeviceSessionLogoutResponse {
|
|
503
|
+
message: string;
|
|
504
|
+
deviceId: string;
|
|
505
|
+
sessionsTerminated: number;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
export interface UpdateDeviceNameResponse {
|
|
509
|
+
message: string;
|
|
510
|
+
deviceName: string;
|
|
511
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface ClientSession {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
deviceId: string;
|
|
4
|
+
expiresAt: string;
|
|
5
|
+
lastActive: string;
|
|
6
|
+
userId?: string;
|
|
7
|
+
isCurrent?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface StorageKeys {
|
|
11
|
+
sessions: string; // Array of ClientSession objects
|
|
12
|
+
activeSessionId: string; // ID of currently active session
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MinimalUserData {
|
|
16
|
+
id: string;
|
|
17
|
+
username: string;
|
|
18
|
+
avatar?: string; // file id
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SessionLoginResponse {
|
|
22
|
+
sessionId: string;
|
|
23
|
+
deviceId: string;
|
|
24
|
+
expiresAt: string;
|
|
25
|
+
user: MinimalUserData;
|
|
26
|
+
/** JWT access token for API authentication */
|
|
27
|
+
accessToken?: string;
|
|
28
|
+
/** Refresh token for obtaining new access tokens */
|
|
29
|
+
refreshToken?: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OxyServices Shared Module
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic utilities and helpers that work everywhere:
|
|
5
|
+
* - Browser (Web, Expo Web)
|
|
6
|
+
* - React Native (iOS, Android)
|
|
7
|
+
* - Node.js (Backend)
|
|
8
|
+
*
|
|
9
|
+
* This module contains NO React Native or browser-specific dependencies.
|
|
10
|
+
*
|
|
11
|
+
* @module shared
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { darkenColor, normalizeTheme, withRetry } from '@oxyhq/services/shared';
|
|
16
|
+
*
|
|
17
|
+
* const darkBlue = darkenColor('#0066FF', 0.3);
|
|
18
|
+
* const theme = normalizeTheme(userPreference);
|
|
19
|
+
* const data = await withRetry(() => fetchData(), { maxRetries: 3 });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// Color utilities
|
|
24
|
+
export {
|
|
25
|
+
darkenColor,
|
|
26
|
+
lightenColor,
|
|
27
|
+
hexToRgb,
|
|
28
|
+
rgbToHex,
|
|
29
|
+
withOpacity,
|
|
30
|
+
isLightColor,
|
|
31
|
+
getContrastTextColor,
|
|
32
|
+
} from './utils/colorUtils';
|
|
33
|
+
|
|
34
|
+
// Theme utilities
|
|
35
|
+
export {
|
|
36
|
+
normalizeTheme,
|
|
37
|
+
normalizeColorScheme,
|
|
38
|
+
getOppositeTheme,
|
|
39
|
+
systemPrefersDarkMode,
|
|
40
|
+
getSystemColorScheme,
|
|
41
|
+
} from './utils/themeUtils';
|
|
42
|
+
export type { ThemeValue } from './utils/themeUtils';
|
|
43
|
+
|
|
44
|
+
// Error utilities
|
|
45
|
+
export {
|
|
46
|
+
HttpStatus,
|
|
47
|
+
getErrorStatus,
|
|
48
|
+
getErrorMessage,
|
|
49
|
+
isAlreadyRegisteredError,
|
|
50
|
+
isUnauthorizedError,
|
|
51
|
+
isForbiddenError,
|
|
52
|
+
isNotFoundError,
|
|
53
|
+
isRateLimitError,
|
|
54
|
+
isServerError,
|
|
55
|
+
isNetworkError,
|
|
56
|
+
isRetryableError,
|
|
57
|
+
} from './utils/errorUtils';
|
|
58
|
+
|
|
59
|
+
// Network utilities
|
|
60
|
+
export {
|
|
61
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
62
|
+
createCircuitBreakerState,
|
|
63
|
+
calculateBackoffInterval,
|
|
64
|
+
recordFailure,
|
|
65
|
+
recordSuccess,
|
|
66
|
+
shouldAllowRequest,
|
|
67
|
+
delay,
|
|
68
|
+
withRetry,
|
|
69
|
+
} from './utils/networkUtils';
|
|
70
|
+
export type {
|
|
71
|
+
CircuitBreakerState,
|
|
72
|
+
CircuitBreakerConfig,
|
|
73
|
+
} from './utils/networkUtils';
|
|
74
|
+
|
|
75
|
+
// Debug utilities
|
|
76
|
+
export {
|
|
77
|
+
isDev,
|
|
78
|
+
debugLog,
|
|
79
|
+
debugWarn,
|
|
80
|
+
debugError,
|
|
81
|
+
createDebugLogger,
|
|
82
|
+
} from './utils/debugUtils';
|