@oxyhq/core 1.0.2 → 1.1.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 +19 -9
- package/dist/cjs/CrossDomainAuth.js +2 -2
- package/dist/cjs/HttpService.js +9 -8
- package/dist/cjs/OxyServices.base.js +16 -3
- package/dist/cjs/crypto/keyManager.js +29 -24
- package/dist/cjs/crypto/polyfill.js +6 -1
- package/dist/cjs/crypto/signatureService.js +40 -31
- package/dist/cjs/i18n/index.js +36 -45
- package/dist/cjs/i18n/locales/ar-SA.json +114 -115
- package/dist/cjs/i18n/locales/ca-ES.json +114 -115
- package/dist/cjs/i18n/locales/de-DE.json +114 -115
- package/dist/cjs/i18n/locales/en-US.json +936 -936
- package/dist/cjs/i18n/locales/es-ES.json +924 -924
- package/dist/cjs/i18n/locales/fr-FR.json +114 -115
- package/dist/cjs/i18n/locales/it-IT.json +114 -115
- package/dist/cjs/i18n/locales/ja-JP.json +1 -1
- package/dist/cjs/i18n/locales/ko-KR.json +114 -115
- 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 +114 -115
- package/dist/cjs/i18n/locales/zh-CN.json +114 -115
- package/dist/cjs/mixins/OxyServices.fedcm.js +13 -41
- package/dist/cjs/mixins/OxyServices.language.js +5 -2
- package/dist/cjs/mixins/OxyServices.privacy.js +2 -1
- package/dist/cjs/mixins/OxyServices.security.js +3 -2
- package/dist/cjs/shared/utils/debugUtils.js +8 -1
- package/dist/cjs/utils/deviceManager.js +3 -1
- package/dist/cjs/utils/platform.js +3 -2
- package/dist/esm/AuthManager.js +19 -9
- package/dist/esm/CrossDomainAuth.js +2 -2
- package/dist/esm/HttpService.js +9 -8
- package/dist/esm/OxyServices.base.js +16 -3
- package/dist/esm/crypto/keyManager.js +29 -24
- package/dist/esm/crypto/polyfill.js +6 -1
- package/dist/esm/crypto/signatureService.js +40 -31
- package/dist/esm/i18n/index.js +11 -23
- package/dist/esm/i18n/locales/ar-SA.json +114 -115
- package/dist/esm/i18n/locales/ca-ES.json +114 -115
- package/dist/esm/i18n/locales/de-DE.json +114 -115
- package/dist/esm/i18n/locales/en-US.json +936 -936
- package/dist/esm/i18n/locales/es-ES.json +924 -924
- package/dist/esm/i18n/locales/fr-FR.json +114 -115
- package/dist/esm/i18n/locales/it-IT.json +114 -115
- package/dist/esm/i18n/locales/ja-JP.json +1 -1
- package/dist/esm/i18n/locales/ko-KR.json +114 -115
- 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 +114 -115
- package/dist/esm/i18n/locales/zh-CN.json +114 -115
- package/dist/esm/mixins/OxyServices.fedcm.js +13 -41
- package/dist/esm/mixins/OxyServices.language.js +5 -2
- package/dist/esm/mixins/OxyServices.privacy.js +2 -1
- package/dist/esm/mixins/OxyServices.security.js +3 -2
- package/dist/esm/shared/utils/debugUtils.js +8 -1
- package/dist/esm/utils/deviceManager.js +3 -1
- package/dist/esm/utils/platform.js +3 -2
- package/dist/types/CrossDomainAuth.d.ts +2 -2
- package/dist/types/OxyServices.base.d.ts +4 -1
- package/dist/types/OxyServices.d.ts +13 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/mixins/OxyServices.analytics.d.ts +2 -0
- package/dist/types/mixins/OxyServices.assets.d.ts +2 -0
- package/dist/types/mixins/OxyServices.auth.d.ts +2 -0
- package/dist/types/mixins/OxyServices.developer.d.ts +2 -0
- package/dist/types/mixins/OxyServices.devices.d.ts +2 -0
- package/dist/types/mixins/OxyServices.features.d.ts +2 -0
- package/dist/types/mixins/OxyServices.fedcm.d.ts +4 -2
- package/dist/types/mixins/OxyServices.karma.d.ts +2 -0
- package/dist/types/mixins/OxyServices.language.d.ts +2 -0
- package/dist/types/mixins/OxyServices.location.d.ts +2 -0
- package/dist/types/mixins/OxyServices.payment.d.ts +2 -0
- package/dist/types/mixins/OxyServices.popup.d.ts +2 -0
- package/dist/types/mixins/OxyServices.privacy.d.ts +2 -0
- package/dist/types/mixins/OxyServices.redirect.d.ts +2 -0
- package/dist/types/mixins/OxyServices.security.d.ts +2 -0
- package/dist/types/mixins/OxyServices.user.d.ts +2 -0
- package/dist/types/mixins/OxyServices.utility.d.ts +2 -0
- package/package.json +1 -2
- package/src/AuthManager.ts +25 -15
- package/src/CrossDomainAuth.ts +2 -2
- package/src/HttpService.ts +9 -8
- package/src/OxyServices.base.ts +21 -4
- package/src/OxyServices.ts +23 -2
- package/src/crypto/keyManager.ts +30 -25
- package/src/crypto/polyfill.ts +6 -1
- package/src/crypto/signatureService.ts +43 -37
- package/src/i18n/index.ts +33 -45
- package/src/index.ts +3 -0
- package/src/mixins/OxyServices.fedcm.ts +14 -44
- package/src/mixins/OxyServices.language.ts +6 -3
- package/src/mixins/OxyServices.privacy.ts +2 -1
- package/src/mixins/OxyServices.security.ts +3 -2
- package/src/shared/utils/__tests__/debugUtils.test.ts +55 -0
- package/src/shared/utils/debugUtils.ts +6 -1
- package/src/utils/deviceManager.ts +4 -2
- package/src/utils/platform.ts +3 -2
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { BlockedUser, RestrictedUser } from '../models/interfaces';
|
|
5
5
|
import type { OxyServicesBase } from '../OxyServices.base';
|
|
6
|
+
import { isDev } from '../shared/utils/debugUtils';
|
|
6
7
|
|
|
7
8
|
export function OxyServicesPrivacyMixin<T extends typeof OxyServicesBase>(Base: T) {
|
|
8
9
|
return class extends Base {
|
|
@@ -35,7 +36,7 @@ export function OxyServicesPrivacyMixin<T extends typeof OxyServicesBase>(Base:
|
|
|
35
36
|
});
|
|
36
37
|
} catch (error) {
|
|
37
38
|
// If there's an error, assume not in list to avoid breaking functionality
|
|
38
|
-
if (
|
|
39
|
+
if (isDev()) {
|
|
39
40
|
console.warn('Error checking user list:', error);
|
|
40
41
|
}
|
|
41
42
|
return false;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { OxyServicesBase } from '../OxyServices.base';
|
|
5
5
|
import type { SecurityActivity, SecurityActivityResponse, SecurityEventType } from '../models/interfaces';
|
|
6
|
+
import { isDev } from '../shared/utils/debugUtils';
|
|
6
7
|
|
|
7
8
|
export function OxyServicesSecurityMixin<T extends typeof OxyServicesBase>(Base: T) {
|
|
8
9
|
return class extends Base {
|
|
@@ -71,7 +72,7 @@ export function OxyServicesSecurityMixin<T extends typeof OxyServicesBase>(Base:
|
|
|
71
72
|
} catch (error) {
|
|
72
73
|
// Don't throw - logging failures shouldn't break user flow
|
|
73
74
|
// But log for monitoring
|
|
74
|
-
if (
|
|
75
|
+
if (isDev()) {
|
|
75
76
|
console.warn('[OxyServices] Failed to log private key exported event:', error);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
@@ -93,7 +94,7 @@ export function OxyServicesSecurityMixin<T extends typeof OxyServicesBase>(Base:
|
|
|
93
94
|
} catch (error) {
|
|
94
95
|
// Don't throw - logging failures shouldn't break user flow
|
|
95
96
|
// But log for monitoring
|
|
96
|
-
if (
|
|
97
|
+
if (isDev()) {
|
|
97
98
|
console.warn('[OxyServices] Failed to log backup created event:', error);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for isDev() utility.
|
|
3
|
+
*
|
|
4
|
+
* These tests manipulate the global __DEV__ and process.env.NODE_ENV
|
|
5
|
+
* to verify isDev() works across RN, Node, and browser-like environments.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
describe('isDev', () => {
|
|
9
|
+
const originalDev = (globalThis as any).__DEV__;
|
|
10
|
+
const originalNodeEnv = process.env.NODE_ENV;
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
// Restore globals
|
|
14
|
+
if (originalDev === undefined) {
|
|
15
|
+
delete (globalThis as any).__DEV__;
|
|
16
|
+
} else {
|
|
17
|
+
(globalThis as any).__DEV__ = originalDev;
|
|
18
|
+
}
|
|
19
|
+
process.env.NODE_ENV = originalNodeEnv;
|
|
20
|
+
|
|
21
|
+
// Clear module cache so isDev re-evaluates
|
|
22
|
+
jest.resetModules();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
async function loadIsDev() {
|
|
26
|
+
const mod = await import('../debugUtils');
|
|
27
|
+
return mod.isDev;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
it('returns true when __DEV__ is true (React Native)', async () => {
|
|
31
|
+
(globalThis as any).__DEV__ = true;
|
|
32
|
+
const isDev = await loadIsDev();
|
|
33
|
+
expect(isDev()).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('returns false when __DEV__ is false', async () => {
|
|
37
|
+
(globalThis as any).__DEV__ = false;
|
|
38
|
+
const isDev = await loadIsDev();
|
|
39
|
+
expect(isDev()).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('falls back to NODE_ENV when __DEV__ is undefined', async () => {
|
|
43
|
+
delete (globalThis as any).__DEV__;
|
|
44
|
+
process.env.NODE_ENV = 'development';
|
|
45
|
+
const isDev = await loadIsDev();
|
|
46
|
+
expect(isDev()).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('returns false when NODE_ENV is production and __DEV__ is undefined', async () => {
|
|
50
|
+
delete (globalThis as any).__DEV__;
|
|
51
|
+
process.env.NODE_ENV = 'production';
|
|
52
|
+
const isDev = await loadIsDev();
|
|
53
|
+
expect(isDev()).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -14,7 +14,12 @@ declare const __DEV__: boolean | undefined;
|
|
|
14
14
|
* Check if running in development mode
|
|
15
15
|
*/
|
|
16
16
|
export const isDev = (): boolean => {
|
|
17
|
-
|
|
17
|
+
if (typeof __DEV__ !== 'undefined') return __DEV__;
|
|
18
|
+
try {
|
|
19
|
+
return typeof process !== 'undefined' && process.env?.NODE_ENV === 'development';
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
18
23
|
};
|
|
19
24
|
|
|
20
25
|
/**
|
|
@@ -42,8 +42,10 @@ export class DeviceManager {
|
|
|
42
42
|
}> {
|
|
43
43
|
if (this.isReactNative()) {
|
|
44
44
|
try {
|
|
45
|
-
|
|
46
|
-
const
|
|
45
|
+
// Variable indirection prevents bundlers (Vite, webpack) from statically resolving this
|
|
46
|
+
const moduleName = '@react-native-async-storage/async-storage';
|
|
47
|
+
const asyncStorageModule = await import(moduleName);
|
|
48
|
+
const storage = asyncStorageModule.default as unknown as { getItem: (key: string) => Promise<string | null>; setItem: (key: string, value: string) => Promise<void>; removeItem: (key: string) => Promise<void> };
|
|
47
49
|
return {
|
|
48
50
|
getItem: storage.getItem.bind(storage),
|
|
49
51
|
setItem: storage.setItem.bind(storage),
|
package/src/utils/platform.ts
CHANGED
|
@@ -108,8 +108,9 @@ export async function initPlatformFromReactNative(): Promise<void> {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
try {
|
|
111
|
-
//
|
|
112
|
-
const
|
|
111
|
+
// Variable indirection prevents bundlers (Vite, webpack) from statically resolving this
|
|
112
|
+
const moduleName = 'react-native';
|
|
113
|
+
const { Platform } = await import(moduleName);
|
|
113
114
|
setPlatformOS(Platform.OS as PlatformOS);
|
|
114
115
|
} catch {
|
|
115
116
|
// react-native not available, use detected platform
|