@oxyhq/services 5.16.33 → 5.16.34

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 (190) hide show
  1. package/README.md +26 -8
  2. package/lib/commonjs/core/OxyServices.base.js.map +1 -1
  3. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  4. package/lib/commonjs/core/mixins/OxyServices.utility.js.map +1 -1
  5. package/lib/commonjs/core/services/AuthService.js +156 -0
  6. package/lib/commonjs/core/services/AuthService.js.map +1 -0
  7. package/lib/commonjs/core/services/SessionService.js +1 -2
  8. package/lib/commonjs/core/services/SessionService.js.map +1 -1
  9. package/lib/commonjs/core/services/SessionTransportService.js +64 -0
  10. package/lib/commonjs/core/services/SessionTransportService.js.map +1 -0
  11. package/lib/commonjs/core/services/TokenService.js +9 -17
  12. package/lib/commonjs/core/services/TokenService.js.map +1 -1
  13. package/lib/commonjs/core/services/UserService.js +123 -0
  14. package/lib/commonjs/core/services/UserService.js.map +1 -0
  15. package/lib/commonjs/core/services/index.js +34 -0
  16. package/lib/commonjs/core/services/index.js.map +1 -0
  17. package/lib/commonjs/crypto/index.js.map +1 -1
  18. package/lib/commonjs/crypto/keyManager.js +5 -2
  19. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  20. package/lib/commonjs/crypto/signatureService.js +36 -121
  21. package/lib/commonjs/crypto/signatureService.js.map +1 -1
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/models/interfaces.js +11 -11
  24. package/lib/commonjs/models/interfaces.js.map +1 -1
  25. package/lib/commonjs/ui/context/OxyContext.js +4 -40
  26. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  27. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +23 -61
  28. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  29. package/lib/commonjs/ui/context/hooks/useLanguageManagement.js.map +1 -1
  30. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +4 -12
  31. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  32. package/lib/commonjs/ui/hooks/useLanguageManagement.js.map +1 -1
  33. package/lib/commonjs/ui/hooks/useSessionManagement.js +0 -8
  34. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  35. package/lib/commonjs/ui/index.js +2 -0
  36. package/lib/commonjs/ui/index.js.map +1 -1
  37. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  38. package/lib/commonjs/ui/screens/OxyAuthScreen.js +9 -13
  39. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  40. package/lib/commonjs/ui/utils/sessionHelpers.js +11 -26
  41. package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
  42. package/lib/commonjs/utils/sessionUtils.js +1 -8
  43. package/lib/commonjs/utils/sessionUtils.js.map +1 -1
  44. package/lib/module/core/OxyServices.base.js.map +1 -1
  45. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  46. package/lib/module/core/mixins/OxyServices.utility.js.map +1 -1
  47. package/lib/module/core/services/AuthService.js +151 -0
  48. package/lib/module/core/services/AuthService.js.map +1 -0
  49. package/lib/module/core/services/SessionService.js +1 -2
  50. package/lib/module/core/services/SessionService.js.map +1 -1
  51. package/lib/module/core/services/SessionTransportService.js +59 -0
  52. package/lib/module/core/services/SessionTransportService.js.map +1 -0
  53. package/lib/module/core/services/TokenService.js +9 -17
  54. package/lib/module/core/services/TokenService.js.map +1 -1
  55. package/lib/module/core/services/UserService.js +118 -0
  56. package/lib/module/core/services/UserService.js.map +1 -0
  57. package/lib/module/core/services/index.js +16 -0
  58. package/lib/module/core/services/index.js.map +1 -0
  59. package/lib/module/crypto/index.js +9 -0
  60. package/lib/module/crypto/index.js.map +1 -1
  61. package/lib/module/crypto/keyManager.js +5 -2
  62. package/lib/module/crypto/keyManager.js.map +1 -1
  63. package/lib/module/crypto/signatureService.js +36 -122
  64. package/lib/module/crypto/signatureService.js.map +1 -1
  65. package/lib/module/index.js +1 -0
  66. package/lib/module/index.js.map +1 -1
  67. package/lib/module/models/interfaces.js +11 -11
  68. package/lib/module/models/interfaces.js.map +1 -1
  69. package/lib/module/ui/context/OxyContext.js +4 -40
  70. package/lib/module/ui/context/OxyContext.js.map +1 -1
  71. package/lib/module/ui/context/hooks/useAuthOperations.js +23 -61
  72. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  73. package/lib/module/ui/context/hooks/useLanguageManagement.js.map +1 -1
  74. package/lib/module/ui/hooks/queries/useServicesQueries.js +5 -13
  75. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  76. package/lib/module/ui/hooks/useLanguageManagement.js.map +1 -1
  77. package/lib/module/ui/hooks/useSessionManagement.js +0 -8
  78. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  79. package/lib/module/ui/index.js +1 -0
  80. package/lib/module/ui/index.js.map +1 -1
  81. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  82. package/lib/module/ui/screens/OxyAuthScreen.js +7 -9
  83. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  84. package/lib/module/ui/utils/sessionHelpers.js +11 -26
  85. package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
  86. package/lib/module/utils/sessionUtils.js +1 -8
  87. package/lib/module/utils/sessionUtils.js.map +1 -1
  88. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  89. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  90. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  91. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +1 -1
  92. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  93. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  94. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  95. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  96. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  97. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  98. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  99. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  100. package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
  101. package/lib/typescript/core/mixins/OxyServices.user.d.ts +2 -1
  102. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  103. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  104. package/lib/typescript/core/mixins/index.d.ts +13 -13
  105. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  106. package/lib/typescript/core/services/AuthService.d.ts +50 -0
  107. package/lib/typescript/core/services/AuthService.d.ts.map +1 -0
  108. package/lib/typescript/core/services/SessionService.d.ts +3 -5
  109. package/lib/typescript/core/services/SessionService.d.ts.map +1 -1
  110. package/lib/typescript/core/services/SessionTransportService.d.ts +31 -0
  111. package/lib/typescript/core/services/SessionTransportService.d.ts.map +1 -0
  112. package/lib/typescript/core/services/TokenService.d.ts +3 -8
  113. package/lib/typescript/core/services/TokenService.d.ts.map +1 -1
  114. package/lib/typescript/core/services/UserService.d.ts +39 -0
  115. package/lib/typescript/core/services/UserService.d.ts.map +1 -0
  116. package/lib/typescript/core/services/index.d.ts +13 -0
  117. package/lib/typescript/core/services/index.d.ts.map +1 -0
  118. package/lib/typescript/crypto/index.d.ts +9 -0
  119. package/lib/typescript/crypto/index.d.ts.map +1 -1
  120. package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
  121. package/lib/typescript/crypto/signatureService.d.ts +10 -13
  122. package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
  123. package/lib/typescript/index.d.ts +1 -1
  124. package/lib/typescript/index.d.ts.map +1 -1
  125. package/lib/typescript/models/interfaces.d.ts +15 -69
  126. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  127. package/lib/typescript/models/session.d.ts +2 -4
  128. package/lib/typescript/models/session.d.ts.map +1 -1
  129. package/lib/typescript/ui/context/OxyContext.d.ts +2 -1
  130. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  131. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +2 -1
  132. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  133. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts +2 -1
  134. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts.map +1 -1
  135. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +1 -1
  136. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  137. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +1 -1
  138. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  139. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  140. package/lib/typescript/ui/hooks/useLanguageManagement.d.ts +2 -1
  141. package/lib/typescript/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  142. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +2 -1
  143. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
  144. package/lib/typescript/ui/index.d.ts +1 -1
  145. package/lib/typescript/ui/index.d.ts.map +1 -1
  146. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  147. package/lib/typescript/ui/stores/authStore.d.ts +1 -1
  148. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  149. package/lib/typescript/ui/utils/avatarUtils.d.ts +1 -1
  150. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  151. package/lib/typescript/ui/utils/sessionHelpers.d.ts +2 -6
  152. package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
  153. package/lib/typescript/utils/sessionUtils.d.ts.map +1 -1
  154. package/package.json +2 -1
  155. package/src/core/OxyServices.base.ts +2 -1
  156. package/src/core/mixins/OxyServices.auth.ts +1 -1
  157. package/src/core/mixins/OxyServices.user.ts +2 -1
  158. package/src/core/mixins/OxyServices.utility.ts +2 -1
  159. package/src/core/services/AuthService.ts +153 -0
  160. package/src/core/services/SessionService.ts +3 -5
  161. package/src/core/services/SessionTransportService.ts +69 -0
  162. package/src/core/services/TokenService.ts +10 -18
  163. package/src/core/services/UserService.ts +125 -0
  164. package/src/core/services/index.ts +14 -0
  165. package/src/crypto/index.ts +9 -0
  166. package/src/crypto/keyManager.ts +3 -2
  167. package/src/crypto/signatureService.ts +44 -142
  168. package/src/index.ts +1 -2
  169. package/src/models/interfaces.ts +21 -74
  170. package/src/models/session.ts +3 -5
  171. package/src/ui/context/OxyContext.tsx +22 -57
  172. package/src/ui/context/hooks/useAuthOperations.ts +33 -65
  173. package/src/ui/context/hooks/useLanguageManagement.ts +2 -1
  174. package/src/ui/hooks/auth/index.ts +0 -2
  175. package/src/ui/hooks/mutations/useAccountMutations.ts +1 -1
  176. package/src/ui/hooks/mutations/useServicesMutations.ts +1 -1
  177. package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
  178. package/src/ui/hooks/queries/useServicesQueries.ts +3 -8
  179. package/src/ui/hooks/useLanguageManagement.ts +2 -1
  180. package/src/ui/hooks/useSessionManagement.ts +3 -9
  181. package/src/ui/index.ts +2 -1
  182. package/src/ui/screens/AccountSettingsScreen.tsx +6 -6
  183. package/src/ui/screens/AccountSwitcherScreen.tsx +1 -1
  184. package/src/ui/screens/OxyAuthScreen.tsx +5 -9
  185. package/src/ui/screens/ProfileScreen.tsx +1 -1
  186. package/src/ui/stores/authStore.ts +1 -1
  187. package/src/ui/types/navigation.ts +1 -1
  188. package/src/ui/utils/avatarUtils.ts +1 -1
  189. package/src/ui/utils/sessionHelpers.ts +15 -32
  190. package/src/utils/sessionUtils.ts +1 -8
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AASA,QAAA,IAAI,WAAW,KAAA,EAAE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EACP,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,MAAM,EACN,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAU,EACV,KAAK,EACN,CAAC;AAGF,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"OxyAuthScreen.d.ts","sourceRoot":"","sources":["../../../../src/ui/screens/OxyAuthScreen.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA6B3D,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA2W5C,CAAC;AA2GF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"OxyAuthScreen.d.ts","sourceRoot":"","sources":["../../../../src/ui/screens/OxyAuthScreen.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA6B3D,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAuW5C,CAAC;AA2GF,eAAe,aAAa,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { User } from '../../models/interfaces';
1
+ import type { User } from '@oxyhq/shared';
2
2
  export interface AuthState {
3
3
  user: User | null;
4
4
  isAuthenticated: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"authStore.d.ts","sourceRoot":"","sources":["../../../../src/ui/stores/authStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,y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AS,EAAE,OAAO,CAAC;IAEnB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,CAAC,WAAW,EAAE;QAAE,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,EAAE,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3G,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAG9B,iBAAiB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,YAAY,wEA0DtB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { OxyServices } from '../../core';
2
- import type { User } from '../../models/interfaces';
2
+ import type { User } from '@oxyhq/shared';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
4
  /**
5
5
  * Updates file visibility to public for avatar use.
@@ -1 +1 @@
1
- {"version":3,"file":"avatarUtils.d.ts","sourceRoot":"","sources":["../../../../src/ui/utils/avatarUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,MAAsB,GAClC,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EACtB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,WAAW,EAAE,WAAW,EACxB,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC,CAoEf"}
1
+ {"version":3,"file":"avatarUtils.d.ts","sourceRoot":"","sources":["../../../../src/ui/utils/avatarUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,MAAsB,GAClC,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EACtB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,WAAW,EAAE,WAAW,EACxB,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC,CAoEf"}
@@ -8,19 +8,16 @@ interface DeviceSession {
8
8
  lastActive?: string;
9
9
  user?: {
10
10
  id?: string;
11
- publicKey?: string;
12
11
  _id?: {
13
12
  toString(): string;
14
13
  };
15
14
  };
16
15
  userId?: string;
17
- publicKey?: string;
18
16
  isCurrent?: boolean;
19
17
  }
20
18
  export interface FetchSessionsWithFallbackOptions {
21
19
  fallbackDeviceId?: string;
22
20
  fallbackUserId?: string;
23
- fallbackPublicKey?: string;
24
21
  logger?: (message: string, error?: unknown) => void;
25
22
  }
26
23
  export interface ValidateSessionBatchOptions {
@@ -40,9 +37,8 @@ export interface SessionValidationResult {
40
37
  * @param sessions - Raw session array returned from the API
41
38
  * @param fallbackDeviceId - Device identifier to use when missing from payload
42
39
  * @param fallbackUserId - User identifier to use when missing from payload
43
- * @param fallbackPublicKey - Public key to use when missing from payload (canonical identity)
44
40
  */
45
- export declare const mapSessionsToClient: (sessions: DeviceSession[], fallbackDeviceId?: string, fallbackUserId?: string, fallbackPublicKey?: string) => ClientSession[];
41
+ export declare const mapSessionsToClient: (sessions: DeviceSession[], fallbackDeviceId?: string, fallbackUserId?: string) => ClientSession[];
46
42
  /**
47
43
  * Fetch device sessions with fallback to the legacy session endpoint when needed.
48
44
  *
@@ -50,7 +46,7 @@ export declare const mapSessionsToClient: (sessions: DeviceSession[], fallbackDe
50
46
  * @param sessionId - Session identifier to fetch
51
47
  * @param options - Optional fallback options
52
48
  */
53
- export declare const fetchSessionsWithFallback: (oxyServices: Pick<OxyServices, "getDeviceSessions" | "getSessionsBySessionId">, sessionId: string, { fallbackDeviceId, fallbackUserId, fallbackPublicKey, logger, }?: FetchSessionsWithFallbackOptions) => Promise<ClientSession[]>;
49
+ export declare const fetchSessionsWithFallback: (oxyServices: Pick<OxyServices, "getDeviceSessions" | "getSessionsBySessionId">, sessionId: string, { fallbackDeviceId, fallbackUserId, logger, }?: FetchSessionsWithFallbackOptions) => Promise<ClientSession[]>;
54
50
  /**
55
51
  * Validate multiple sessions concurrently with configurable concurrency.
56
52
  *
@@ -1 +1 @@
1
- {"version":3,"file":"sessionHelpers.d.ts","sourceRoot":"","sources":["../../../../src/ui/utils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E,aAAa,GAAG,OAAO,CAEzE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAWvE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAkB9E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,aAAa,EAAE,EACzB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAC9B,aAAa,EAAE,CAiCjB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,aAAa,EAAE,EACzB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,EAC/B,mBAAmB,GAAE,OAAc,GAClC,aAAa,EAAE,CAgBjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,aAAa,EAAE,EACzB,QAAQ,EAAE,aAAa,EAAE,EACzB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,EAC/B,mBAAmB,GAAE,OAAc,GAClC,aAAa,EAAE,CAgCjB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,CAAC,EAAE,aAAa,EAAE,GAAG,OAAO,CAWnF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/services",
3
- "version": "5.16.33",
3
+ "version": "5.16.34",
4
4
  "description": "Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -89,6 +89,7 @@
89
89
  "prepublishOnly": "npm run typescript && npm test && npm run build"
90
90
  },
91
91
  "dependencies": {
92
+ "@oxyhq/shared": "file:../shared",
92
93
  "@lottiefiles/dotlottie-react": "^0.13.5",
93
94
  "@react-native-async-storage/async-storage": "2.1.2",
94
95
  "@react-native-community/netinfo": "^11.4.1",
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Contains core infrastructure, HTTP client, request management, and error handling
5
5
  */
6
- import type { OxyConfig as OxyConfigBase, ApiError, User } from '../models/interfaces';
6
+ import type { OxyConfig as OxyConfigBase, ApiError } from '../models/interfaces';
7
+ import type { User } from '@oxyhq/shared';
7
8
  import { handleHttpError } from '../utils/errorUtils';
8
9
  import { HttpService, type RequestOptions } from './HttpService';
9
10
  import { OxyAuthenticationError, OxyAuthenticationTimeoutError } from './OxyServices.errors';
@@ -4,7 +4,7 @@
4
4
  * Public key authentication using ECDSA signatures.
5
5
  * No passwords required - authentication is done via challenge-response.
6
6
  */
7
- import type { User } from '../../models/interfaces';
7
+ import type { User } from '@oxyhq/shared';
8
8
  import type { SessionLoginResponse } from '../../models/session';
9
9
  import type { OxyServicesBase } from '../OxyServices.base';
10
10
  import { OxyAuthenticationError } from '../OxyServices.errors';
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * User Management Methods Mixin
3
3
  */
4
- import type { User, Notification, SearchProfilesResponse, PaginationInfo } from '../../models/interfaces';
4
+ import type { Notification } from '../../models/interfaces';
5
+ import type { User, SearchProfilesResponse, PaginationInfo } from '@oxyhq/shared';
5
6
  import type { OxyServicesBase } from '../OxyServices.base';
6
7
  import { buildSearchParams, buildPaginationParams, type PaginationParams } from '../../utils/apiUtils';
7
8
 
@@ -5,7 +5,8 @@
5
5
  * and Express.js authentication middleware
6
6
  */
7
7
  import { jwtDecode } from 'jwt-decode';
8
- import type { ApiError, User } from '../../models/interfaces';
8
+ import type { ApiError } from '../../models/interfaces';
9
+ import type { User } from '@oxyhq/shared';
9
10
  import type { OxyServicesBase } from '../OxyServices.base';
10
11
  import { CACHE_TIMES } from './mixinHelpers';
11
12
 
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Auth Service
3
+ *
4
+ * Handles authentication operations:
5
+ * - Challenge retrieval
6
+ * - Signing orchestration (delegated to Accounts/KeyManager)
7
+ * - Session verification
8
+ * - Access token retrieval
9
+ * - Registration
10
+ */
11
+
12
+ import type { OxyConfig } from '../../models/interfaces';
13
+ import type { User, LoginResponse, ChallengePayload } from '@oxyhq/shared';
14
+ import { HttpService } from '../HttpService';
15
+ import { SignatureService } from '../../crypto/signatureService';
16
+
17
+ export interface PublicKeyCheckResponse {
18
+ registered: boolean;
19
+ message: string;
20
+ }
21
+
22
+ export class AuthService {
23
+ private httpService: HttpService;
24
+
25
+ constructor(config: OxyConfig) {
26
+ this.httpService = new HttpService(config);
27
+ }
28
+
29
+ /**
30
+ * Check if a public key is registered on the server
31
+ */
32
+ async checkPublicKeyRegistered(publicKey: string): Promise<PublicKeyCheckResponse> {
33
+ try {
34
+ return await this.httpService.request<PublicKeyCheckResponse>({
35
+ method: 'GET',
36
+ url: `/api/auth/check-publickey?publicKey=${encodeURIComponent(publicKey)}`,
37
+ cache: true,
38
+ cacheTTL: 2 * 60 * 1000,
39
+ });
40
+ } catch (error) {
41
+ throw error;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Request an authentication challenge
47
+ */
48
+ async requestChallenge(publicKey: string): Promise<ChallengePayload> {
49
+ try {
50
+ return await this.httpService.request<ChallengePayload>({
51
+ method: 'POST',
52
+ url: '/api/auth/challenge',
53
+ data: { publicKey },
54
+ cache: false,
55
+ });
56
+ } catch (error) {
57
+ throw error;
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Verify a challenge and authenticate (creates session)
63
+ * This orchestrates signing via SignatureService (which uses KeyManager)
64
+ */
65
+ async verifyChallenge(challenge: string): Promise<LoginResponse> {
66
+ try {
67
+ // Sign the challenge using SignatureService (requires private key)
68
+ const signedChallenge = await SignatureService.signChallenge(challenge);
69
+
70
+ // Verify challenge and get session
71
+ return await this.httpService.request<LoginResponse>({
72
+ method: 'POST',
73
+ url: '/api/auth/verify',
74
+ data: {
75
+ publicKey: signedChallenge.publicKey,
76
+ challenge: challenge,
77
+ signature: signedChallenge.challenge,
78
+ timestamp: signedChallenge.timestamp,
79
+ },
80
+ cache: false,
81
+ });
82
+ } catch (error) {
83
+ throw error;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Register a new identity with the server
89
+ */
90
+ async register(publicKey: string, signature: string, timestamp: number, username?: string, email?: string): Promise<User> {
91
+ try {
92
+ return await this.httpService.request<User>({
93
+ method: 'POST',
94
+ url: '/api/auth/register',
95
+ data: {
96
+ publicKey,
97
+ signature,
98
+ timestamp,
99
+ username,
100
+ email,
101
+ },
102
+ cache: false,
103
+ });
104
+ } catch (error) {
105
+ throw error;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Register using current identity (signs automatically)
111
+ */
112
+ async registerCurrentIdentity(username?: string, email?: string): Promise<User> {
113
+ try {
114
+ const { signature, publicKey, timestamp } = await SignatureService.createRegistrationSignature();
115
+ return this.register(publicKey, signature, timestamp, username, email);
116
+ } catch (error) {
117
+ throw error;
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Get user by public key
123
+ */
124
+ async getUserByPublicKey(publicKey: string): Promise<User> {
125
+ try {
126
+ return await this.httpService.request<User>({
127
+ method: 'GET',
128
+ url: `/api/auth/user/${encodeURIComponent(publicKey)}`,
129
+ cache: true,
130
+ cacheTTL: 2 * 60 * 1000,
131
+ });
132
+ } catch (error) {
133
+ throw error;
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Get user by session ID
139
+ */
140
+ async getUserBySession(sessionId: string): Promise<User> {
141
+ try {
142
+ return await this.httpService.request<User>({
143
+ method: 'GET',
144
+ url: `/api/auth/user/session/${encodeURIComponent(sessionId)}`,
145
+ cache: true,
146
+ cacheTTL: 2 * 60 * 1000,
147
+ });
148
+ } catch (error) {
149
+ throw error;
150
+ }
151
+ }
152
+ }
153
+
@@ -8,20 +8,18 @@
8
8
  * - Single source of truth for session operations
9
9
  * - Handles both online and offline sessions
10
10
  * - Integrates with TokenService for token management
11
- * - publicKey is the canonical user identity (primary identifier)
12
- * - Sessions are bound to local identity stored in Accounts app
11
+ * - userId is always MongoDB ObjectId, never publicKey
13
12
  */
14
13
 
15
14
  import type { OxyServices } from '../OxyServices';
16
15
  import { tokenService } from './TokenService';
17
16
  import type { ClientSession, SessionLoginResponse } from '../../models/session';
18
- import type { User } from '../../models/interfaces';
17
+ import type { User } from '@oxyhq/shared';
19
18
 
20
19
  export interface Session {
21
20
  sessionId: string;
22
21
  deviceId: string;
23
- publicKey: string; // Canonical user identity - PRIMARY IDENTIFIER
24
- userId?: string; // MongoDB ObjectId (internal backend reference, optional)
22
+ userId: string; // MongoDB ObjectId - PRIMARY IDENTIFIER
25
23
  expiresAt: string;
26
24
  lastActive: string;
27
25
  isCurrent: boolean;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Session Transport Service
3
+ *
4
+ * Uses shared transport abstraction for WebSocket/SSE/polling
5
+ * Provides unified interface for session status updates
6
+ */
7
+
8
+ import type { OxyConfig } from '../../models/interfaces';
9
+ import {
10
+ TransportFactory,
11
+ type TransportConfig,
12
+ type TransportCallbacks,
13
+ type TransportUpdate,
14
+ } from '@oxyhq/shared';
15
+
16
+ export class SessionTransportService {
17
+ private transport: any = null;
18
+ private config: OxyConfig;
19
+
20
+ constructor(config: OxyConfig) {
21
+ this.config = config;
22
+ }
23
+
24
+ /**
25
+ * Connect to session status updates
26
+ * Automatically chooses best available transport (WebSocket > SSE > Polling)
27
+ */
28
+ async connect(
29
+ sessionToken: string,
30
+ callbacks: TransportCallbacks
31
+ ): Promise<void> {
32
+ const transportConfig: TransportConfig = {
33
+ baseURL: this.config.baseURL,
34
+ namespace: 'auth-session',
35
+ sessionToken,
36
+ pollingInterval: 3000, // 3 seconds
37
+ reconnectAttempts: 3,
38
+ reconnectDelay: 1000,
39
+ };
40
+
41
+ this.transport = await TransportFactory.create(transportConfig, callbacks);
42
+ await this.transport.connect();
43
+ }
44
+
45
+ /**
46
+ * Disconnect from session updates
47
+ */
48
+ disconnect(): void {
49
+ if (this.transport) {
50
+ this.transport.disconnect();
51
+ this.transport = null;
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Check if currently connected
57
+ */
58
+ isConnected(): boolean {
59
+ return this.transport?.isConnected() ?? false;
60
+ }
61
+
62
+ /**
63
+ * Get the transport type being used
64
+ */
65
+ getTransportType(): string {
66
+ return this.transport?.getType() ?? 'none';
67
+ }
68
+ }
69
+
@@ -8,17 +8,17 @@
8
8
  * - Single storage location (no duplication)
9
9
  * - Automatic token refresh when expiring soon
10
10
  * - Type-safe token payload handling
11
- * - publicKey is the canonical user identity
11
+ * - userId is always MongoDB ObjectId, never publicKey
12
12
  */
13
13
 
14
14
  import { jwtDecode } from 'jwt-decode';
15
15
 
16
16
  /**
17
17
  * AccessTokenPayload - Matches the token payload structure from API
18
- * publicKey is the canonical user identity (ECDSA secp256k1 public key)
18
+ * userId is always MongoDB ObjectId (24 hex characters), never publicKey
19
19
  */
20
20
  interface AccessTokenPayload {
21
- publicKey: string; // User's public key - CANONICAL USER IDENTITY
21
+ userId: string; // MongoDB ObjectId - PRIMARY IDENTIFIER
22
22
  sessionId: string; // Session UUID
23
23
  deviceId: string; // Device identifier
24
24
  type: 'access';
@@ -116,29 +116,21 @@ class TokenService {
116
116
  }
117
117
 
118
118
  /**
119
- * Get publicKey from current access token
120
- * Returns the user's public key (canonical user identity)
119
+ * Get userId from current access token
120
+ * Returns MongoDB ObjectId (never publicKey)
121
121
  */
122
- getPublicKeyFromToken(): string | null {
122
+ getUserIdFromToken(): string | null {
123
123
  const token = this.tokenStore.accessToken;
124
124
  if (!token) return null;
125
125
 
126
126
  try {
127
127
  const decoded = jwtDecode<AccessTokenPayload>(token);
128
- return decoded.publicKey || null;
128
+ return decoded.userId || null;
129
129
  } catch {
130
130
  return null;
131
131
  }
132
132
  }
133
133
 
134
- /**
135
- * @deprecated Use getPublicKeyFromToken() instead. This method is kept for backward compatibility.
136
- * Get userId from current access token (returns publicKey, not MongoDB ObjectId)
137
- */
138
- getUserIdFromToken(): string | null {
139
- return this.getPublicKeyFromToken();
140
- }
141
-
142
134
  /**
143
135
  * Refresh access token if expiring soon
144
136
  * Returns promise that resolves when token is refreshed (or already valid)
@@ -201,10 +193,10 @@ class TokenService {
201
193
  throw new Error('No access token in refresh response');
202
194
  }
203
195
 
204
- // Validate new token has publicKey (canonical user identity)
196
+ // Validate new token has correct userId format (ObjectId)
205
197
  const newDecoded = jwtDecode<AccessTokenPayload>(newToken);
206
- if (!newDecoded.publicKey) {
207
- throw new Error('Token missing publicKey after refresh');
198
+ if (newDecoded.userId && !/^[0-9a-fA-F]{24}$/.test(newDecoded.userId)) {
199
+ throw new Error(`Invalid userId format in refreshed token: ${newDecoded.userId.substring(0, 20)}...`);
208
200
  }
209
201
 
210
202
  this.setTokens(newToken);
@@ -0,0 +1,125 @@
1
+ /**
2
+ * User Service
3
+ *
4
+ * Handles user profile operations (no key handling):
5
+ * - Profile fetch/update
6
+ * - Profile search
7
+ * - User recommendations
8
+ */
9
+
10
+ import type { OxyConfig } from '../../models/interfaces';
11
+ import type { User, SearchProfilesResponse, PaginationInfo } from '@oxyhq/shared';
12
+ import { HttpService } from '../HttpService';
13
+
14
+ export interface PaginationParams {
15
+ limit?: number;
16
+ offset?: number;
17
+ }
18
+
19
+ export class UserService {
20
+ private httpService: HttpService;
21
+
22
+ constructor(config: OxyConfig) {
23
+ this.httpService = new HttpService(config);
24
+ }
25
+
26
+ /**
27
+ * Get user profile by ID
28
+ */
29
+ async getUserById(userId: string): Promise<User> {
30
+ try {
31
+ return await this.httpService.request<User>({
32
+ method: 'GET',
33
+ url: `/api/profiles/${userId}`,
34
+ cache: true,
35
+ cacheTTL: 5 * 60 * 1000,
36
+ });
37
+ } catch (error) {
38
+ throw error;
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Get profile by username
44
+ */
45
+ async getProfileByUsername(username: string): Promise<User> {
46
+ try {
47
+ return await this.httpService.request<User>({
48
+ method: 'GET',
49
+ url: `/api/profiles/username/${username}`,
50
+ cache: true,
51
+ cacheTTL: 5 * 60 * 1000,
52
+ });
53
+ } catch (error) {
54
+ throw error;
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Search user profiles
60
+ */
61
+ async searchProfiles(query: string, pagination?: PaginationParams): Promise<SearchProfilesResponse> {
62
+ try {
63
+ const params = new URLSearchParams();
64
+ params.set('query', query);
65
+ if (pagination?.limit) params.set('limit', pagination.limit.toString());
66
+ if (pagination?.offset) params.set('offset', pagination.offset.toString());
67
+
68
+ const response = await this.httpService.request<SearchProfilesResponse | User[]>({
69
+ method: 'GET',
70
+ url: `/api/profiles/search?${params.toString()}`,
71
+ cache: true,
72
+ cacheTTL: 2 * 60 * 1000,
73
+ });
74
+
75
+ // Handle response format
76
+ if (Array.isArray(response)) {
77
+ const limit = pagination?.limit ?? response.length;
78
+ const paginationInfo: PaginationInfo = {
79
+ total: response.length,
80
+ limit,
81
+ offset: pagination?.offset ?? 0,
82
+ hasMore: limit > 0 && response.length === limit,
83
+ };
84
+ return { data: response, pagination: paginationInfo };
85
+ }
86
+
87
+ return response;
88
+ } catch (error) {
89
+ throw error;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Get profile recommendations
95
+ */
96
+ async getProfileRecommendations(): Promise<User[]> {
97
+ try {
98
+ return await this.httpService.request<User[]>({
99
+ method: 'GET',
100
+ url: '/api/profiles/recommendations',
101
+ cache: true,
102
+ cacheTTL: 5 * 60 * 1000,
103
+ });
104
+ } catch (error) {
105
+ throw error;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Update user profile
111
+ */
112
+ async updateProfile(updates: Partial<User>): Promise<User> {
113
+ try {
114
+ return await this.httpService.request<User>({
115
+ method: 'PATCH',
116
+ url: '/api/profiles/me',
117
+ data: updates,
118
+ cache: false,
119
+ });
120
+ } catch (error) {
121
+ throw error;
122
+ }
123
+ }
124
+ }
125
+
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Focused Services
3
+ *
4
+ * Single-responsibility services replacing the mixin pattern:
5
+ * - AuthService: Authentication, challenges, registration
6
+ * - SessionService: Session management (already exists)
7
+ * - UserService: User profile operations
8
+ */
9
+
10
+ export { AuthService } from './AuthService';
11
+ export { sessionService } from './SessionService';
12
+ export { UserService } from './UserService';
13
+ export { tokenService } from './TokenService';
14
+
@@ -3,6 +3,15 @@
3
3
  *
4
4
  * Provides cryptographic identity management for the Oxy ecosystem.
5
5
  * Handles key generation, secure storage, and digital signatures.
6
+ *
7
+ * ⚠️ IMPORTANT: KeyManager is primarily intended for use in the Oxy Accounts app.
8
+ * While it's exported here for convenience, third-party applications should NOT
9
+ * generate or store user identities. The Accounts app is the identity wallet.
10
+ *
11
+ * For third-party apps:
12
+ * - Use SignatureService for signing operations (but keys come from Accounts app)
13
+ * - Do NOT call KeyManager.createIdentity() or KeyManager.importKeyPair()
14
+ * - The Oxy Accounts app handles all identity generation and key storage
6
15
  */
7
16
 
8
17
  // Import polyfills first - this ensures Buffer is available for crypto libraries
@@ -539,8 +539,9 @@ export class KeyManager {
539
539
  * Format: first 8 chars...last 8 chars
540
540
  */
541
541
  static shortenPublicKey(publicKey: string): string {
542
- if (publicKey.length <= 20) return publicKey;
543
- return `${publicKey.slice(0, 8)}...${publicKey.slice(-8)}`;
542
+ // Use shared utility
543
+ const { shortenPublicKey } = require('@oxyhq/shared');
544
+ return shortenPublicKey(publicKey);
544
545
  }
545
546
  }
546
547