@oxyhq/core 1.11.23 → 2.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.
Files changed (141) hide show
  1. package/README.md +5 -6
  2. package/dist/cjs/.tsbuildinfo +1 -1
  3. package/dist/cjs/AuthManager.js +678 -4
  4. package/dist/cjs/AuthManagerTypes.js +13 -0
  5. package/dist/cjs/CrossDomainAuth.js +45 -3
  6. package/dist/cjs/OxyServices.base.js +16 -0
  7. package/dist/cjs/i18n/locales/ar-SA.json +83 -0
  8. package/dist/cjs/i18n/locales/ca-ES.json +83 -0
  9. package/dist/cjs/i18n/locales/de-DE.json +83 -0
  10. package/dist/cjs/i18n/locales/en-US.json +83 -0
  11. package/dist/cjs/i18n/locales/es-ES.json +99 -4
  12. package/dist/cjs/i18n/locales/fr-FR.json +83 -0
  13. package/dist/cjs/i18n/locales/it-IT.json +83 -0
  14. package/dist/cjs/i18n/locales/ja-JP.json +83 -0
  15. package/dist/cjs/i18n/locales/ko-KR.json +83 -0
  16. package/dist/cjs/i18n/locales/locales/ar-SA.json +83 -1
  17. package/dist/cjs/i18n/locales/locales/ca-ES.json +83 -1
  18. package/dist/cjs/i18n/locales/locales/de-DE.json +83 -1
  19. package/dist/cjs/i18n/locales/locales/en-US.json +83 -0
  20. package/dist/cjs/i18n/locales/locales/es-ES.json +99 -4
  21. package/dist/cjs/i18n/locales/locales/fr-FR.json +83 -1
  22. package/dist/cjs/i18n/locales/locales/it-IT.json +83 -1
  23. package/dist/cjs/i18n/locales/locales/ja-JP.json +200 -117
  24. package/dist/cjs/i18n/locales/locales/ko-KR.json +83 -1
  25. package/dist/cjs/i18n/locales/locales/pt-PT.json +83 -1
  26. package/dist/cjs/i18n/locales/locales/zh-CN.json +83 -1
  27. package/dist/cjs/i18n/locales/pt-PT.json +83 -0
  28. package/dist/cjs/i18n/locales/zh-CN.json +83 -0
  29. package/dist/cjs/index.js +114 -57
  30. package/dist/cjs/mixins/OxyServices.auth.js +235 -0
  31. package/dist/cjs/mixins/OxyServices.fedcm.js +205 -73
  32. package/dist/cjs/mixins/OxyServices.popup.js +61 -1
  33. package/dist/cjs/mixins/OxyServices.user.js +18 -0
  34. package/dist/cjs/utils/accountUtils.js +64 -1
  35. package/dist/esm/.tsbuildinfo +1 -1
  36. package/dist/esm/AuthManager.js +678 -4
  37. package/dist/esm/AuthManagerTypes.js +12 -0
  38. package/dist/esm/CrossDomainAuth.js +45 -3
  39. package/dist/esm/OxyServices.base.js +16 -0
  40. package/dist/esm/i18n/locales/ar-SA.json +83 -0
  41. package/dist/esm/i18n/locales/ca-ES.json +83 -0
  42. package/dist/esm/i18n/locales/de-DE.json +83 -0
  43. package/dist/esm/i18n/locales/en-US.json +83 -0
  44. package/dist/esm/i18n/locales/es-ES.json +99 -4
  45. package/dist/esm/i18n/locales/fr-FR.json +83 -0
  46. package/dist/esm/i18n/locales/it-IT.json +83 -0
  47. package/dist/esm/i18n/locales/ja-JP.json +83 -0
  48. package/dist/esm/i18n/locales/ko-KR.json +83 -0
  49. package/dist/esm/i18n/locales/locales/ar-SA.json +83 -1
  50. package/dist/esm/i18n/locales/locales/ca-ES.json +83 -1
  51. package/dist/esm/i18n/locales/locales/de-DE.json +83 -1
  52. package/dist/esm/i18n/locales/locales/en-US.json +83 -0
  53. package/dist/esm/i18n/locales/locales/es-ES.json +99 -4
  54. package/dist/esm/i18n/locales/locales/fr-FR.json +83 -1
  55. package/dist/esm/i18n/locales/locales/it-IT.json +83 -1
  56. package/dist/esm/i18n/locales/locales/ja-JP.json +200 -117
  57. package/dist/esm/i18n/locales/locales/ko-KR.json +83 -1
  58. package/dist/esm/i18n/locales/locales/pt-PT.json +83 -1
  59. package/dist/esm/i18n/locales/locales/zh-CN.json +83 -1
  60. package/dist/esm/i18n/locales/pt-PT.json +83 -0
  61. package/dist/esm/i18n/locales/zh-CN.json +83 -0
  62. package/dist/esm/index.js +69 -26
  63. package/dist/esm/mixins/OxyServices.auth.js +235 -0
  64. package/dist/esm/mixins/OxyServices.fedcm.js +205 -73
  65. package/dist/esm/mixins/OxyServices.popup.js +61 -1
  66. package/dist/esm/mixins/OxyServices.user.js +18 -0
  67. package/dist/esm/utils/accountUtils.js +61 -0
  68. package/dist/types/.tsbuildinfo +1 -1
  69. package/dist/types/AuthManager.d.ts +243 -3
  70. package/dist/types/AuthManagerTypes.d.ts +68 -0
  71. package/dist/types/CrossDomainAuth.d.ts +23 -0
  72. package/dist/types/OxyServices.base.d.ts +14 -0
  73. package/dist/types/OxyServices.d.ts +16 -0
  74. package/dist/types/index.d.ts +28 -17
  75. package/dist/types/mixins/OxyServices.analytics.d.ts +1 -0
  76. package/dist/types/mixins/OxyServices.appData.d.ts +1 -0
  77. package/dist/types/mixins/OxyServices.assets.d.ts +4 -1
  78. package/dist/types/mixins/OxyServices.auth.d.ts +73 -1
  79. package/dist/types/mixins/OxyServices.contacts.d.ts +1 -0
  80. package/dist/types/mixins/OxyServices.developer.d.ts +1 -0
  81. package/dist/types/mixins/OxyServices.devices.d.ts +1 -0
  82. package/dist/types/mixins/OxyServices.features.d.ts +2 -5
  83. package/dist/types/mixins/OxyServices.fedcm.d.ts +53 -1
  84. package/dist/types/mixins/OxyServices.karma.d.ts +1 -0
  85. package/dist/types/mixins/OxyServices.language.d.ts +1 -0
  86. package/dist/types/mixins/OxyServices.location.d.ts +1 -0
  87. package/dist/types/mixins/OxyServices.managedAccounts.d.ts +1 -0
  88. package/dist/types/mixins/OxyServices.payment.d.ts +1 -0
  89. package/dist/types/mixins/OxyServices.popup.d.ts +40 -0
  90. package/dist/types/mixins/OxyServices.privacy.d.ts +1 -0
  91. package/dist/types/mixins/OxyServices.redirect.d.ts +1 -0
  92. package/dist/types/mixins/OxyServices.security.d.ts +1 -0
  93. package/dist/types/mixins/OxyServices.topics.d.ts +1 -0
  94. package/dist/types/mixins/OxyServices.user.d.ts +16 -1
  95. package/dist/types/mixins/OxyServices.utility.d.ts +1 -0
  96. package/dist/types/models/interfaces.d.ts +98 -0
  97. package/dist/types/models/session.d.ts +8 -0
  98. package/dist/types/utils/accountUtils.d.ts +33 -0
  99. package/package.json +9 -18
  100. package/src/AuthManager.ts +776 -7
  101. package/src/AuthManagerTypes.ts +72 -0
  102. package/src/CrossDomainAuth.ts +54 -3
  103. package/src/OxyServices.base.ts +17 -0
  104. package/src/OxyServices.ts +17 -0
  105. package/src/__tests__/authManager.cookiePath.test.ts +339 -0
  106. package/src/__tests__/authManager.security.test.ts +342 -0
  107. package/src/__tests__/crossDomainAuth.test.ts +191 -0
  108. package/src/i18n/locales/ar-SA.json +83 -1
  109. package/src/i18n/locales/ca-ES.json +83 -1
  110. package/src/i18n/locales/de-DE.json +83 -1
  111. package/src/i18n/locales/en-US.json +83 -0
  112. package/src/i18n/locales/es-ES.json +99 -4
  113. package/src/i18n/locales/fr-FR.json +83 -1
  114. package/src/i18n/locales/it-IT.json +83 -1
  115. package/src/i18n/locales/ja-JP.json +200 -117
  116. package/src/i18n/locales/ko-KR.json +83 -1
  117. package/src/i18n/locales/pt-PT.json +83 -1
  118. package/src/i18n/locales/zh-CN.json +83 -1
  119. package/src/index.ts +295 -112
  120. package/src/mixins/OxyServices.auth.ts +268 -1
  121. package/src/mixins/OxyServices.fedcm.ts +250 -78
  122. package/src/mixins/OxyServices.popup.ts +79 -1
  123. package/src/mixins/OxyServices.user.ts +33 -1
  124. package/src/mixins/__tests__/fedcm.test.ts +231 -0
  125. package/src/mixins/__tests__/popup.test.ts +307 -0
  126. package/src/mixins/__tests__/sessionBaseUrl.test.ts +61 -0
  127. package/src/models/interfaces.ts +116 -0
  128. package/src/models/session.ts +8 -0
  129. package/src/utils/accountUtils.ts +84 -0
  130. package/dist/cjs/crypto/index.js +0 -22
  131. package/dist/cjs/shared/index.js +0 -70
  132. package/dist/cjs/utils/index.js +0 -26
  133. package/dist/esm/crypto/index.js +0 -13
  134. package/dist/esm/shared/index.js +0 -31
  135. package/dist/esm/utils/index.js +0 -7
  136. package/dist/types/crypto/index.d.ts +0 -11
  137. package/dist/types/shared/index.d.ts +0 -28
  138. package/dist/types/utils/index.d.ts +0 -6
  139. package/src/crypto/index.ts +0 -30
  140. package/src/shared/index.ts +0 -82
  141. package/src/utils/index.ts +0 -21
@@ -1,6 +1,20 @@
1
1
  export interface OxyConfig {
2
2
  baseURL: string;
3
3
  cloudURL?: string;
4
+ /**
5
+ * Base URL the SDK's first-party session/refresh calls target.
6
+ *
7
+ * Per the 2026 session architecture (docs/SESSION-ARCHITECTURE.md), every app
8
+ * keeps its OWN first-party session on its OWN domain. For non-`oxy.so` apps
9
+ * this is the app's own same-site backend (e.g. `https://api.mention.earth`),
10
+ * whose session bridge forwards the user's refresh credential to
11
+ * `api.oxy.so`. For `*.oxy.so` apps this is omitted and falls back to
12
+ * `baseURL` (`https://api.oxy.so`), so their behavior is unchanged.
13
+ *
14
+ * Resolve via {@link OxyServices.getSessionBaseUrl}; when unset it returns
15
+ * `baseURL`. This is purely additive — no refresh/auth logic reads it yet.
16
+ */
17
+ sessionBaseUrl?: string;
4
18
  authWebUrl?: string;
5
19
  authRedirectUri?: string;
6
20
  // Performance & caching options
@@ -110,9 +124,43 @@ export interface User {
110
124
  // Managed account fields
111
125
  isManagedAccount?: boolean;
112
126
  managedBy?: string;
127
+ // User-controlled notification preferences. All channels default to on; users
128
+ // opt out per-channel. Updated via `PUT /users/me`.
129
+ notificationPreferences?: NotificationPreferences;
130
+ // General app-wide user preferences. Updated via `PUT /users/me`.
131
+ userPreferences?: UserPreferences;
113
132
  [key: string]: unknown;
114
133
  }
115
134
 
135
+ /**
136
+ * User-controlled notification channels. Persisted on the User document.
137
+ */
138
+ export interface NotificationPreferences {
139
+ /** Push notifications on registered devices. */
140
+ pushEnabled?: boolean;
141
+ /** Periodic email digest of activity. */
142
+ emailDigest?: boolean;
143
+ /** Security/account alerts (sign-ins, recovery, key changes). */
144
+ securityAlerts?: boolean;
145
+ /** Marketing / product update emails. */
146
+ marketingEmails?: boolean;
147
+ }
148
+
149
+ /**
150
+ * General per-user preferences applied across all Oxy apps for the user.
151
+ * Persisted on the User document.
152
+ */
153
+ export interface UserPreferences {
154
+ /** BCP-47 language tag, e.g. "en-US", "es-ES". Empty string = follow device. */
155
+ language?: string;
156
+ /** Theme mode preference. */
157
+ theme?: 'light' | 'dark' | 'system';
158
+ /** Mirror of OS reduce-motion preference, persisted server-side. */
159
+ reduceMotion?: boolean;
160
+ /** IANA timezone, e.g. "Europe/Madrid". Empty string = follow device. */
161
+ timezone?: string;
162
+ }
163
+
116
164
  export interface LoginResponse {
117
165
  accessToken?: string;
118
166
  refreshToken?: string;
@@ -590,3 +638,71 @@ export interface UpdateDeviceNameResponse {
590
638
  message: string;
591
639
  deviceName: string;
592
640
  }
641
+
642
+ // ---------------------------------------------------------------------------
643
+ // Multi-account "refresh-all" (Google-style)
644
+ // ---------------------------------------------------------------------------
645
+ // Wire shape of `POST /auth/refresh-all`. The server rotates every device-local
646
+ // `oxy_rt_${authuser}` cookie in parallel and returns one entry per VALID
647
+ // account, sorted by `authuser` ascending. Slot-level errors are silently
648
+ // omitted; the response is `{ accounts: [] }` in the worst case (no signed-in
649
+ // accounts, all cookies expired, or origin not allowlisted).
650
+
651
+ /**
652
+ * Minimal user shape included in a `RefreshAllAccount` entry. The server
653
+ * projects a small whitelist (`username name avatar email color`) so the
654
+ * client can render the account chooser without an extra `/users/me` round
655
+ * trip per account.
656
+ *
657
+ * `avatar` and `color` are `string | null` because they are stored as nullable
658
+ * fields in the user document.
659
+ */
660
+ export interface RefreshAllAccountUser {
661
+ id: string;
662
+ username: string;
663
+ name?: string;
664
+ avatar?: string | null;
665
+ email?: string;
666
+ color?: string | null;
667
+ }
668
+
669
+ /**
670
+ * One rotated account entry returned by `POST /auth/refresh-all`. `authuser` is
671
+ * the device-local slot index (0..N-1) the cookie was bound to. The legacy
672
+ * un-suffixed `oxy_rt` cookie yields `authuser: null` server-side, but the SDK
673
+ * normalises that to `0` before exposing it (the chooser always operates on
674
+ * numeric indices).
675
+ *
676
+ * `user` is `null` only on the SDK-side synthesised legacy fallback (when the
677
+ * server is too old to support `/auth/refresh-all` and we wrap a
678
+ * `/auth/refresh` response — that endpoint does not project a user shape).
679
+ * On the modern path every accepted entry carries a non-null user.
680
+ */
681
+ export interface RefreshAllAccount {
682
+ authuser: number;
683
+ accessToken: string;
684
+ expiresAt: string;
685
+ sessionId: string;
686
+ user: RefreshAllAccountUser | null;
687
+ }
688
+
689
+ /**
690
+ * Wire shape of `POST /auth/refresh-all`. Always 200 with a (possibly empty)
691
+ * accounts array — 401 means "no accounts signed in on this device" and is
692
+ * normalised to `{ accounts: [] }` at the SDK layer.
693
+ */
694
+ export interface RefreshAllResponse {
695
+ accounts: RefreshAllAccount[];
696
+ }
697
+
698
+ /**
699
+ * Wire shape of `POST /auth/refresh` (single-account refresh, optionally
700
+ * targeting a specific `?authuser=N` slot). The server includes `authuser` in
701
+ * the response when an indexed slot was rotated; the legacy slot yields
702
+ * `authuser: null`.
703
+ */
704
+ export interface RefreshCookieResponse {
705
+ accessToken: string;
706
+ expiresAt: string;
707
+ authuser: number | null;
708
+ }
@@ -5,6 +5,14 @@ export interface ClientSession {
5
5
  lastActive: string;
6
6
  userId?: string;
7
7
  isCurrent?: boolean;
8
+ /**
9
+ * Web-only: the device-local refresh-cookie slot index (0..N) that backs
10
+ * this session. Populated from `POST /auth/refresh-all` and from login /
11
+ * signup / fedcm-exchange responses. Required for per-session web token
12
+ * refresh via `refreshTokenViaCookie({ authuser })` without a bearer token.
13
+ * Absent on native (RN uses the bearer-protected session id directly).
14
+ */
15
+ authuser?: number;
8
16
  }
9
17
 
10
18
  export interface StorageKeys {
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { translate } from '../i18n';
7
+ import type { RefreshAllAccount } from '../models/interfaces';
7
8
 
8
9
  export interface QuickAccount {
9
10
  sessionId: string;
@@ -12,6 +13,19 @@ export interface QuickAccount {
12
13
  displayName: string;
13
14
  avatar?: string;
14
15
  avatarUrl?: string;
16
+ /**
17
+ * Device-local account slot index, 0..N-1 (Google-style multi-account).
18
+ * Mirrors the server's `oxy_rt_${authuser}` cookie slot. Optional so that
19
+ * pre-multi-account QuickAccounts (sessionId-only, non-cookie auth on RN)
20
+ * remain valid; web flows always populate it after `refreshAllSessions`.
21
+ */
22
+ authuser?: number;
23
+ /**
24
+ * Account's preferred Bloom color preset (e.g. `"blue"`, `"oxy"`). Drives
25
+ * per-account theming in the account chooser. `null` / `undefined` means
26
+ * the account has no preference and the base theme should be used.
27
+ */
28
+ color?: string | null;
15
29
  }
16
30
 
17
31
  /** Minimal user shape accepted by display-name helpers. Avoids importing the full User type. */
@@ -147,3 +161,73 @@ export const createQuickAccount = (
147
161
  avatarUrl,
148
162
  };
149
163
  };
164
+
165
+ /**
166
+ * Merge a fresh `/auth/refresh-all` snapshot into an existing QuickAccount
167
+ * list, preserving any cached fields (`avatarUrl`) for slots that didn't
168
+ * change. The fresh response is canonical: the resulting list contains EXACTLY
169
+ * the slots present in `fresh`, sorted by `authuser` ascending. Stale stored
170
+ * accounts that no longer appear in `fresh` are dropped (the server already
171
+ * authoritatively cleared the corresponding cookie).
172
+ *
173
+ * @param stored Previously persisted QuickAccount list (any order).
174
+ * @param fresh Server's authoritative refresh-all response.
175
+ * @returns Canonical merged list, sorted by `authuser` asc.
176
+ */
177
+ export const mergeAccountsFromRefreshAll = (
178
+ stored: QuickAccount[] | undefined,
179
+ fresh: RefreshAllAccount[],
180
+ ): QuickAccount[] => {
181
+ const storedByAuthuser = new Map<number, QuickAccount>();
182
+ if (stored) {
183
+ for (const account of stored) {
184
+ if (typeof account.authuser === 'number') {
185
+ storedByAuthuser.set(account.authuser, account);
186
+ }
187
+ }
188
+ }
189
+
190
+ const merged: QuickAccount[] = fresh.map((entry) => {
191
+ const previous = storedByAuthuser.get(entry.authuser);
192
+ // `entry.user` is null on the SDK legacy-fallback path; preserve any
193
+ // previously cached identity for that slot rather than overwriting
194
+ // it with blanks, and let the AuthManager's getCurrentUser() hydration
195
+ // refresh it on the next snapshot.
196
+ const wireUser = entry.user;
197
+ const username = wireUser?.username ?? previous?.username ?? '';
198
+ const displayName = getAccountDisplayName({
199
+ name: wireUser?.name,
200
+ username,
201
+ });
202
+ const avatar = wireUser?.avatar ?? previous?.avatar ?? undefined;
203
+ const avatarUrl =
204
+ previous && previous.avatar === avatar ? previous.avatarUrl : undefined;
205
+ return {
206
+ sessionId: entry.sessionId,
207
+ userId: wireUser?.id ?? previous?.userId,
208
+ username,
209
+ displayName,
210
+ avatar,
211
+ avatarUrl,
212
+ authuser: entry.authuser,
213
+ color: wireUser?.color ?? previous?.color ?? null,
214
+ };
215
+ });
216
+
217
+ merged.sort((a, b) => {
218
+ const aIdx = a.authuser ?? Number.POSITIVE_INFINITY;
219
+ const bIdx = b.authuser ?? Number.POSITIVE_INFINITY;
220
+ return aIdx - bIdx;
221
+ });
222
+
223
+ return merged;
224
+ };
225
+
226
+ /**
227
+ * Return the account's preferred Bloom color preset, or `null` if it has no
228
+ * preference. Centralises the `color ?? null` normalisation so consumers can
229
+ * drive per-account theming without duplicating the nullish-handling.
230
+ */
231
+ export const getAccountColor = (account: QuickAccount): string | null => {
232
+ return account.color ?? null;
233
+ };
@@ -1,22 +0,0 @@
1
- "use strict";
2
- /**
3
- * Oxy Crypto Module
4
- *
5
- * Provides cryptographic identity management for the Oxy ecosystem.
6
- * Handles key generation, secure storage, digital signatures, and recovery phrases.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.default = exports.RecoveryPhraseService = exports.SignatureService = exports.IdentityPersistError = exports.IdentityAlreadyExistsError = exports.KeyManager = void 0;
10
- // Import polyfills first - this ensures Buffer is available for bip39 and other libraries
11
- require("./polyfill");
12
- var keyManager_1 = require("./keyManager");
13
- Object.defineProperty(exports, "KeyManager", { enumerable: true, get: function () { return keyManager_1.KeyManager; } });
14
- Object.defineProperty(exports, "IdentityAlreadyExistsError", { enumerable: true, get: function () { return keyManager_1.IdentityAlreadyExistsError; } });
15
- Object.defineProperty(exports, "IdentityPersistError", { enumerable: true, get: function () { return keyManager_1.IdentityPersistError; } });
16
- var signatureService_1 = require("./signatureService");
17
- Object.defineProperty(exports, "SignatureService", { enumerable: true, get: function () { return signatureService_1.SignatureService; } });
18
- var recoveryPhrase_1 = require("./recoveryPhrase");
19
- Object.defineProperty(exports, "RecoveryPhraseService", { enumerable: true, get: function () { return recoveryPhrase_1.RecoveryPhraseService; } });
20
- // Re-export for convenience
21
- var keyManager_2 = require("./keyManager");
22
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return keyManager_2.KeyManager; } });
@@ -1,70 +0,0 @@
1
- "use strict";
2
- /**
3
- * OxyServices Shared Module
4
- *
5
- * Platform-agnostic utilities and helpers that work everywhere:
6
- * - Browser (Web, Expo Web)
7
- * - React Native (iOS, Android)
8
- * - Node.js (Backend)
9
- *
10
- * This module contains NO React Native or browser-specific dependencies.
11
- *
12
- * @module shared
13
- *
14
- * @example
15
- * ```ts
16
- * import { darkenColor, normalizeTheme, withRetry } from '@oxyhq/services/shared';
17
- *
18
- * const darkBlue = darkenColor('#0066FF', 0.3);
19
- * const theme = normalizeTheme(userPreference);
20
- * const data = await withRetry(() => fetchData(), { maxRetries: 3 });
21
- * ```
22
- */
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.createDebugLogger = exports.debugError = exports.debugWarn = exports.debugLog = exports.isDev = exports.withRetry = exports.delay = exports.shouldAllowRequest = exports.recordSuccess = exports.recordFailure = exports.calculateBackoffInterval = exports.createCircuitBreakerState = exports.DEFAULT_CIRCUIT_BREAKER_CONFIG = exports.isRetryableError = exports.isNetworkError = exports.isServerError = exports.isRateLimitError = exports.isNotFoundError = exports.isForbiddenError = exports.isUnauthorizedError = exports.isAlreadyRegisteredError = exports.getErrorMessage = exports.getErrorStatus = exports.HttpStatus = exports.getSystemColorScheme = exports.systemPrefersDarkMode = exports.getOppositeTheme = exports.normalizeColorScheme = exports.normalizeTheme = exports.getContrastTextColor = exports.isLightColor = exports.withOpacity = exports.rgbToHex = exports.hexToRgb = exports.lightenColor = exports.darkenColor = void 0;
25
- // Color utilities
26
- var colorUtils_1 = require("./utils/colorUtils");
27
- Object.defineProperty(exports, "darkenColor", { enumerable: true, get: function () { return colorUtils_1.darkenColor; } });
28
- Object.defineProperty(exports, "lightenColor", { enumerable: true, get: function () { return colorUtils_1.lightenColor; } });
29
- Object.defineProperty(exports, "hexToRgb", { enumerable: true, get: function () { return colorUtils_1.hexToRgb; } });
30
- Object.defineProperty(exports, "rgbToHex", { enumerable: true, get: function () { return colorUtils_1.rgbToHex; } });
31
- Object.defineProperty(exports, "withOpacity", { enumerable: true, get: function () { return colorUtils_1.withOpacity; } });
32
- Object.defineProperty(exports, "isLightColor", { enumerable: true, get: function () { return colorUtils_1.isLightColor; } });
33
- Object.defineProperty(exports, "getContrastTextColor", { enumerable: true, get: function () { return colorUtils_1.getContrastTextColor; } });
34
- // Theme utilities
35
- var themeUtils_1 = require("./utils/themeUtils");
36
- Object.defineProperty(exports, "normalizeTheme", { enumerable: true, get: function () { return themeUtils_1.normalizeTheme; } });
37
- Object.defineProperty(exports, "normalizeColorScheme", { enumerable: true, get: function () { return themeUtils_1.normalizeColorScheme; } });
38
- Object.defineProperty(exports, "getOppositeTheme", { enumerable: true, get: function () { return themeUtils_1.getOppositeTheme; } });
39
- Object.defineProperty(exports, "systemPrefersDarkMode", { enumerable: true, get: function () { return themeUtils_1.systemPrefersDarkMode; } });
40
- Object.defineProperty(exports, "getSystemColorScheme", { enumerable: true, get: function () { return themeUtils_1.getSystemColorScheme; } });
41
- // Error utilities
42
- var errorUtils_1 = require("./utils/errorUtils");
43
- Object.defineProperty(exports, "HttpStatus", { enumerable: true, get: function () { return errorUtils_1.HttpStatus; } });
44
- Object.defineProperty(exports, "getErrorStatus", { enumerable: true, get: function () { return errorUtils_1.getErrorStatus; } });
45
- Object.defineProperty(exports, "getErrorMessage", { enumerable: true, get: function () { return errorUtils_1.getErrorMessage; } });
46
- Object.defineProperty(exports, "isAlreadyRegisteredError", { enumerable: true, get: function () { return errorUtils_1.isAlreadyRegisteredError; } });
47
- Object.defineProperty(exports, "isUnauthorizedError", { enumerable: true, get: function () { return errorUtils_1.isUnauthorizedError; } });
48
- Object.defineProperty(exports, "isForbiddenError", { enumerable: true, get: function () { return errorUtils_1.isForbiddenError; } });
49
- Object.defineProperty(exports, "isNotFoundError", { enumerable: true, get: function () { return errorUtils_1.isNotFoundError; } });
50
- Object.defineProperty(exports, "isRateLimitError", { enumerable: true, get: function () { return errorUtils_1.isRateLimitError; } });
51
- Object.defineProperty(exports, "isServerError", { enumerable: true, get: function () { return errorUtils_1.isServerError; } });
52
- Object.defineProperty(exports, "isNetworkError", { enumerable: true, get: function () { return errorUtils_1.isNetworkError; } });
53
- Object.defineProperty(exports, "isRetryableError", { enumerable: true, get: function () { return errorUtils_1.isRetryableError; } });
54
- // Network utilities
55
- var networkUtils_1 = require("./utils/networkUtils");
56
- Object.defineProperty(exports, "DEFAULT_CIRCUIT_BREAKER_CONFIG", { enumerable: true, get: function () { return networkUtils_1.DEFAULT_CIRCUIT_BREAKER_CONFIG; } });
57
- Object.defineProperty(exports, "createCircuitBreakerState", { enumerable: true, get: function () { return networkUtils_1.createCircuitBreakerState; } });
58
- Object.defineProperty(exports, "calculateBackoffInterval", { enumerable: true, get: function () { return networkUtils_1.calculateBackoffInterval; } });
59
- Object.defineProperty(exports, "recordFailure", { enumerable: true, get: function () { return networkUtils_1.recordFailure; } });
60
- Object.defineProperty(exports, "recordSuccess", { enumerable: true, get: function () { return networkUtils_1.recordSuccess; } });
61
- Object.defineProperty(exports, "shouldAllowRequest", { enumerable: true, get: function () { return networkUtils_1.shouldAllowRequest; } });
62
- Object.defineProperty(exports, "delay", { enumerable: true, get: function () { return networkUtils_1.delay; } });
63
- Object.defineProperty(exports, "withRetry", { enumerable: true, get: function () { return networkUtils_1.withRetry; } });
64
- // Debug utilities
65
- var debugUtils_1 = require("./utils/debugUtils");
66
- Object.defineProperty(exports, "isDev", { enumerable: true, get: function () { return debugUtils_1.isDev; } });
67
- Object.defineProperty(exports, "debugLog", { enumerable: true, get: function () { return debugUtils_1.debugLog; } });
68
- Object.defineProperty(exports, "debugWarn", { enumerable: true, get: function () { return debugUtils_1.debugWarn; } });
69
- Object.defineProperty(exports, "debugError", { enumerable: true, get: function () { return debugUtils_1.debugError; } });
70
- Object.defineProperty(exports, "createDebugLogger", { enumerable: true, get: function () { return debugUtils_1.createDebugLogger; } });
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sessionsArraysEqual = exports.sessionsEqual = exports.mergeSessions = exports.normalizeAndSortSessions = exports.deduplicateSessionsByUserId = exports.deduplicateSessions = exports.sortSessions = exports.normalizeSession = exports.unregisterCacheFromCleanup = exports.registerCacheForCleanup = exports.createCache = exports.TTLCache = exports.SimpleLogger = exports.RequestQueue = exports.RequestDeduplicator = exports.DeviceManager = void 0;
4
- var deviceManager_1 = require("./deviceManager");
5
- Object.defineProperty(exports, "DeviceManager", { enumerable: true, get: function () { return deviceManager_1.DeviceManager; } });
6
- // Request utilities
7
- var requestUtils_1 = require("./requestUtils");
8
- Object.defineProperty(exports, "RequestDeduplicator", { enumerable: true, get: function () { return requestUtils_1.RequestDeduplicator; } });
9
- Object.defineProperty(exports, "RequestQueue", { enumerable: true, get: function () { return requestUtils_1.RequestQueue; } });
10
- Object.defineProperty(exports, "SimpleLogger", { enumerable: true, get: function () { return requestUtils_1.SimpleLogger; } });
11
- // Cache utilities
12
- var cache_1 = require("./cache");
13
- Object.defineProperty(exports, "TTLCache", { enumerable: true, get: function () { return cache_1.TTLCache; } });
14
- Object.defineProperty(exports, "createCache", { enumerable: true, get: function () { return cache_1.createCache; } });
15
- Object.defineProperty(exports, "registerCacheForCleanup", { enumerable: true, get: function () { return cache_1.registerCacheForCleanup; } });
16
- Object.defineProperty(exports, "unregisterCacheFromCleanup", { enumerable: true, get: function () { return cache_1.unregisterCacheFromCleanup; } });
17
- // Session utilities
18
- var sessionUtils_1 = require("./sessionUtils");
19
- Object.defineProperty(exports, "normalizeSession", { enumerable: true, get: function () { return sessionUtils_1.normalizeSession; } });
20
- Object.defineProperty(exports, "sortSessions", { enumerable: true, get: function () { return sessionUtils_1.sortSessions; } });
21
- Object.defineProperty(exports, "deduplicateSessions", { enumerable: true, get: function () { return sessionUtils_1.deduplicateSessions; } });
22
- Object.defineProperty(exports, "deduplicateSessionsByUserId", { enumerable: true, get: function () { return sessionUtils_1.deduplicateSessionsByUserId; } });
23
- Object.defineProperty(exports, "normalizeAndSortSessions", { enumerable: true, get: function () { return sessionUtils_1.normalizeAndSortSessions; } });
24
- Object.defineProperty(exports, "mergeSessions", { enumerable: true, get: function () { return sessionUtils_1.mergeSessions; } });
25
- Object.defineProperty(exports, "sessionsEqual", { enumerable: true, get: function () { return sessionUtils_1.sessionsEqual; } });
26
- Object.defineProperty(exports, "sessionsArraysEqual", { enumerable: true, get: function () { return sessionUtils_1.sessionsArraysEqual; } });
@@ -1,13 +0,0 @@
1
- /**
2
- * Oxy Crypto Module
3
- *
4
- * Provides cryptographic identity management for the Oxy ecosystem.
5
- * Handles key generation, secure storage, digital signatures, and recovery phrases.
6
- */
7
- // Import polyfills first - this ensures Buffer is available for bip39 and other libraries
8
- import './polyfill.js';
9
- export { KeyManager, IdentityAlreadyExistsError, IdentityPersistError, } from './keyManager.js';
10
- export { SignatureService } from './signatureService.js';
11
- export { RecoveryPhraseService } from './recoveryPhrase.js';
12
- // Re-export for convenience
13
- export { KeyManager as default } from './keyManager.js';
@@ -1,31 +0,0 @@
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
- // Color utilities
23
- export { darkenColor, lightenColor, hexToRgb, rgbToHex, withOpacity, isLightColor, getContrastTextColor, } from './utils/colorUtils.js';
24
- // Theme utilities
25
- export { normalizeTheme, normalizeColorScheme, getOppositeTheme, systemPrefersDarkMode, getSystemColorScheme, } from './utils/themeUtils.js';
26
- // Error utilities
27
- export { HttpStatus, getErrorStatus, getErrorMessage, isAlreadyRegisteredError, isUnauthorizedError, isForbiddenError, isNotFoundError, isRateLimitError, isServerError, isNetworkError, isRetryableError, } from './utils/errorUtils.js';
28
- // Network utilities
29
- export { DEFAULT_CIRCUIT_BREAKER_CONFIG, createCircuitBreakerState, calculateBackoffInterval, recordFailure, recordSuccess, shouldAllowRequest, delay, withRetry, } from './utils/networkUtils.js';
30
- // Debug utilities
31
- export { isDev, debugLog, debugWarn, debugError, createDebugLogger, } from './utils/debugUtils.js';
@@ -1,7 +0,0 @@
1
- export { DeviceManager } from './deviceManager.js';
2
- // Request utilities
3
- export { RequestDeduplicator, RequestQueue, SimpleLogger } from './requestUtils.js';
4
- // Cache utilities
5
- export { TTLCache, createCache, registerCacheForCleanup, unregisterCacheFromCleanup } from './cache.js';
6
- // Session utilities
7
- export { normalizeSession, sortSessions, deduplicateSessions, deduplicateSessionsByUserId, normalizeAndSortSessions, mergeSessions, sessionsEqual, sessionsArraysEqual } from './sessionUtils.js';
@@ -1,11 +0,0 @@
1
- /**
2
- * Oxy Crypto Module
3
- *
4
- * Provides cryptographic identity management for the Oxy ecosystem.
5
- * Handles key generation, secure storage, digital signatures, and recovery phrases.
6
- */
7
- import './polyfill';
8
- export { KeyManager, IdentityAlreadyExistsError, IdentityPersistError, type KeyPair, } from './keyManager';
9
- export { SignatureService, type SignedMessage, type AuthChallenge } from './signatureService';
10
- export { RecoveryPhraseService, type RecoveryPhraseResult } from './recoveryPhrase';
11
- export { KeyManager as default } from './keyManager';
@@ -1,28 +0,0 @@
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
- export { darkenColor, lightenColor, hexToRgb, rgbToHex, withOpacity, isLightColor, getContrastTextColor, } from './utils/colorUtils';
23
- export { normalizeTheme, normalizeColorScheme, getOppositeTheme, systemPrefersDarkMode, getSystemColorScheme, } from './utils/themeUtils';
24
- export type { ThemeValue } from './utils/themeUtils';
25
- export { HttpStatus, getErrorStatus, getErrorMessage, isAlreadyRegisteredError, isUnauthorizedError, isForbiddenError, isNotFoundError, isRateLimitError, isServerError, isNetworkError, isRetryableError, } from './utils/errorUtils';
26
- export { DEFAULT_CIRCUIT_BREAKER_CONFIG, createCircuitBreakerState, calculateBackoffInterval, recordFailure, recordSuccess, shouldAllowRequest, delay, withRetry, } from './utils/networkUtils';
27
- export type { CircuitBreakerState, CircuitBreakerConfig, } from './utils/networkUtils';
28
- export { isDev, debugLog, debugWarn, debugError, createDebugLogger, } from './utils/debugUtils';
@@ -1,6 +0,0 @@
1
- export { DeviceManager } from './deviceManager';
2
- export type { DeviceFingerprint, StoredDeviceInfo } from './deviceManager';
3
- export { RequestDeduplicator, RequestQueue, SimpleLogger } from './requestUtils';
4
- export { TTLCache, createCache, registerCacheForCleanup, unregisterCacheFromCleanup } from './cache';
5
- export type { CacheStats } from './cache';
6
- export { normalizeSession, sortSessions, deduplicateSessions, deduplicateSessionsByUserId, normalizeAndSortSessions, mergeSessions, sessionsEqual, sessionsArraysEqual } from './sessionUtils';
@@ -1,30 +0,0 @@
1
- /**
2
- * Oxy Crypto Module
3
- *
4
- * Provides cryptographic identity management for the Oxy ecosystem.
5
- * Handles key generation, secure storage, digital signatures, and recovery phrases.
6
- */
7
-
8
- // Import polyfills first - this ensures Buffer is available for bip39 and other libraries
9
- import './polyfill';
10
-
11
- export {
12
- KeyManager,
13
- IdentityAlreadyExistsError,
14
- IdentityPersistError,
15
- type KeyPair,
16
- } from './keyManager';
17
- export {
18
- SignatureService,
19
- type SignedMessage,
20
- type AuthChallenge
21
- } from './signatureService';
22
- export {
23
- RecoveryPhraseService,
24
- type RecoveryPhraseResult
25
- } from './recoveryPhrase';
26
-
27
- // Re-export for convenience
28
- export { KeyManager as default } from './keyManager';
29
-
30
-
@@ -1,82 +0,0 @@
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';
@@ -1,21 +0,0 @@
1
- export { DeviceManager } from './deviceManager';
2
- export type { DeviceFingerprint, StoredDeviceInfo } from './deviceManager';
3
-
4
- // Request utilities
5
- export { RequestDeduplicator, RequestQueue, SimpleLogger } from './requestUtils';
6
-
7
- // Cache utilities
8
- export { TTLCache, createCache, registerCacheForCleanup, unregisterCacheFromCleanup } from './cache';
9
- export type { CacheStats } from './cache';
10
-
11
- // Session utilities
12
- export {
13
- normalizeSession,
14
- sortSessions,
15
- deduplicateSessions,
16
- deduplicateSessionsByUserId,
17
- normalizeAndSortSessions,
18
- mergeSessions,
19
- sessionsEqual,
20
- sessionsArraysEqual
21
- } from './sessionUtils';