@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.
Files changed (114) hide show
  1. package/dist/cjs/AuthManager.js +19 -9
  2. package/dist/cjs/CrossDomainAuth.js +2 -2
  3. package/dist/cjs/HttpService.js +9 -8
  4. package/dist/cjs/OxyServices.base.js +16 -3
  5. package/dist/cjs/crypto/keyManager.js +29 -24
  6. package/dist/cjs/crypto/polyfill.js +6 -1
  7. package/dist/cjs/crypto/signatureService.js +40 -31
  8. package/dist/cjs/i18n/index.js +36 -45
  9. package/dist/cjs/i18n/locales/ar-SA.json +114 -115
  10. package/dist/cjs/i18n/locales/ca-ES.json +114 -115
  11. package/dist/cjs/i18n/locales/de-DE.json +114 -115
  12. package/dist/cjs/i18n/locales/en-US.json +936 -936
  13. package/dist/cjs/i18n/locales/es-ES.json +924 -924
  14. package/dist/cjs/i18n/locales/fr-FR.json +114 -115
  15. package/dist/cjs/i18n/locales/it-IT.json +114 -115
  16. package/dist/cjs/i18n/locales/ja-JP.json +1 -1
  17. package/dist/cjs/i18n/locales/ko-KR.json +114 -115
  18. package/dist/cjs/i18n/locales/locales/ar-SA.json +120 -0
  19. package/dist/cjs/i18n/locales/locales/ca-ES.json +120 -0
  20. package/dist/cjs/i18n/locales/locales/de-DE.json +120 -0
  21. package/dist/cjs/i18n/locales/locales/en-US.json +956 -0
  22. package/dist/cjs/i18n/locales/locales/es-ES.json +944 -0
  23. package/dist/cjs/i18n/locales/locales/fr-FR.json +120 -0
  24. package/dist/cjs/i18n/locales/locales/it-IT.json +120 -0
  25. package/dist/cjs/i18n/locales/locales/ja-JP.json +119 -0
  26. package/dist/cjs/i18n/locales/locales/ko-KR.json +120 -0
  27. package/dist/cjs/i18n/locales/locales/pt-PT.json +120 -0
  28. package/dist/cjs/i18n/locales/locales/zh-CN.json +120 -0
  29. package/dist/cjs/i18n/locales/pt-PT.json +114 -115
  30. package/dist/cjs/i18n/locales/zh-CN.json +114 -115
  31. package/dist/cjs/mixins/OxyServices.fedcm.js +13 -41
  32. package/dist/cjs/mixins/OxyServices.language.js +5 -2
  33. package/dist/cjs/mixins/OxyServices.privacy.js +2 -1
  34. package/dist/cjs/mixins/OxyServices.security.js +3 -2
  35. package/dist/cjs/shared/utils/debugUtils.js +8 -1
  36. package/dist/cjs/utils/deviceManager.js +3 -1
  37. package/dist/cjs/utils/platform.js +3 -2
  38. package/dist/esm/AuthManager.js +19 -9
  39. package/dist/esm/CrossDomainAuth.js +2 -2
  40. package/dist/esm/HttpService.js +9 -8
  41. package/dist/esm/OxyServices.base.js +16 -3
  42. package/dist/esm/crypto/keyManager.js +29 -24
  43. package/dist/esm/crypto/polyfill.js +6 -1
  44. package/dist/esm/crypto/signatureService.js +40 -31
  45. package/dist/esm/i18n/index.js +11 -23
  46. package/dist/esm/i18n/locales/ar-SA.json +114 -115
  47. package/dist/esm/i18n/locales/ca-ES.json +114 -115
  48. package/dist/esm/i18n/locales/de-DE.json +114 -115
  49. package/dist/esm/i18n/locales/en-US.json +936 -936
  50. package/dist/esm/i18n/locales/es-ES.json +924 -924
  51. package/dist/esm/i18n/locales/fr-FR.json +114 -115
  52. package/dist/esm/i18n/locales/it-IT.json +114 -115
  53. package/dist/esm/i18n/locales/ja-JP.json +1 -1
  54. package/dist/esm/i18n/locales/ko-KR.json +114 -115
  55. package/dist/esm/i18n/locales/locales/ar-SA.json +120 -0
  56. package/dist/esm/i18n/locales/locales/ca-ES.json +120 -0
  57. package/dist/esm/i18n/locales/locales/de-DE.json +120 -0
  58. package/dist/esm/i18n/locales/locales/en-US.json +956 -0
  59. package/dist/esm/i18n/locales/locales/es-ES.json +944 -0
  60. package/dist/esm/i18n/locales/locales/fr-FR.json +120 -0
  61. package/dist/esm/i18n/locales/locales/it-IT.json +120 -0
  62. package/dist/esm/i18n/locales/locales/ja-JP.json +119 -0
  63. package/dist/esm/i18n/locales/locales/ko-KR.json +120 -0
  64. package/dist/esm/i18n/locales/locales/pt-PT.json +120 -0
  65. package/dist/esm/i18n/locales/locales/zh-CN.json +120 -0
  66. package/dist/esm/i18n/locales/pt-PT.json +114 -115
  67. package/dist/esm/i18n/locales/zh-CN.json +114 -115
  68. package/dist/esm/mixins/OxyServices.fedcm.js +13 -41
  69. package/dist/esm/mixins/OxyServices.language.js +5 -2
  70. package/dist/esm/mixins/OxyServices.privacy.js +2 -1
  71. package/dist/esm/mixins/OxyServices.security.js +3 -2
  72. package/dist/esm/shared/utils/debugUtils.js +8 -1
  73. package/dist/esm/utils/deviceManager.js +3 -1
  74. package/dist/esm/utils/platform.js +3 -2
  75. package/dist/types/CrossDomainAuth.d.ts +2 -2
  76. package/dist/types/OxyServices.base.d.ts +4 -1
  77. package/dist/types/OxyServices.d.ts +13 -0
  78. package/dist/types/index.d.ts +3 -0
  79. package/dist/types/mixins/OxyServices.analytics.d.ts +2 -0
  80. package/dist/types/mixins/OxyServices.assets.d.ts +2 -0
  81. package/dist/types/mixins/OxyServices.auth.d.ts +2 -0
  82. package/dist/types/mixins/OxyServices.developer.d.ts +2 -0
  83. package/dist/types/mixins/OxyServices.devices.d.ts +2 -0
  84. package/dist/types/mixins/OxyServices.features.d.ts +2 -0
  85. package/dist/types/mixins/OxyServices.fedcm.d.ts +4 -2
  86. package/dist/types/mixins/OxyServices.karma.d.ts +2 -0
  87. package/dist/types/mixins/OxyServices.language.d.ts +2 -0
  88. package/dist/types/mixins/OxyServices.location.d.ts +2 -0
  89. package/dist/types/mixins/OxyServices.payment.d.ts +2 -0
  90. package/dist/types/mixins/OxyServices.popup.d.ts +2 -0
  91. package/dist/types/mixins/OxyServices.privacy.d.ts +2 -0
  92. package/dist/types/mixins/OxyServices.redirect.d.ts +2 -0
  93. package/dist/types/mixins/OxyServices.security.d.ts +2 -0
  94. package/dist/types/mixins/OxyServices.user.d.ts +2 -0
  95. package/dist/types/mixins/OxyServices.utility.d.ts +2 -0
  96. package/package.json +1 -2
  97. package/src/AuthManager.ts +25 -15
  98. package/src/CrossDomainAuth.ts +2 -2
  99. package/src/HttpService.ts +9 -8
  100. package/src/OxyServices.base.ts +21 -4
  101. package/src/OxyServices.ts +23 -2
  102. package/src/crypto/keyManager.ts +30 -25
  103. package/src/crypto/polyfill.ts +6 -1
  104. package/src/crypto/signatureService.ts +43 -37
  105. package/src/i18n/index.ts +33 -45
  106. package/src/index.ts +3 -0
  107. package/src/mixins/OxyServices.fedcm.ts +14 -44
  108. package/src/mixins/OxyServices.language.ts +6 -3
  109. package/src/mixins/OxyServices.privacy.ts +2 -1
  110. package/src/mixins/OxyServices.security.ts +3 -2
  111. package/src/shared/utils/__tests__/debugUtils.test.ts +55 -0
  112. package/src/shared/utils/debugUtils.ts +6 -1
  113. package/src/utils/deviceManager.ts +4 -2
  114. 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 (__DEV__) {
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 (__DEV__) {
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 (__DEV__) {
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
- return typeof __DEV__ !== 'undefined' && __DEV__;
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
- const asyncStorageModule = await import('@react-native-async-storage/async-storage');
46
- const storage = (asyncStorageModule.default as unknown) as import('@react-native-async-storage/async-storage').AsyncStorageStatic;
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),
@@ -108,8 +108,9 @@ export async function initPlatformFromReactNative(): Promise<void> {
108
108
  }
109
109
 
110
110
  try {
111
- // Dynamic import to avoid bundler issues
112
- const { Platform } = await import('react-native');
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