@oxyhq/services 5.16.35 → 5.16.37

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 (232) hide show
  1. package/README.md +8 -26
  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/crypto/README.md +142 -0
  6. package/lib/commonjs/crypto/core.js +147 -0
  7. package/lib/commonjs/crypto/core.js.map +1 -0
  8. package/lib/commonjs/crypto/index.js +16 -0
  9. package/lib/commonjs/crypto/index.js.map +1 -1
  10. package/lib/commonjs/crypto/keyManager.js +19 -22
  11. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  12. package/lib/commonjs/crypto/signatureService.js +116 -28
  13. package/lib/commonjs/crypto/signatureService.js.map +1 -1
  14. package/lib/commonjs/index.js +0 -12
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/models/interfaces.js +10 -11
  17. package/lib/commonjs/models/interfaces.js.map +1 -1
  18. package/lib/commonjs/node/index.js +10 -1
  19. package/lib/commonjs/node/index.js.map +1 -1
  20. package/lib/commonjs/node/signatureService.js +107 -0
  21. package/lib/commonjs/node/signatureService.js.map +1 -0
  22. package/lib/commonjs/ui/context/OxyContext.js +23 -0
  23. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  24. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +29 -2
  25. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  26. package/lib/commonjs/ui/context/hooks/useLanguageManagement.js.map +1 -1
  27. package/lib/commonjs/ui/hooks/useLanguageManagement.js.map +1 -1
  28. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  29. package/lib/commonjs/ui/index.js +0 -2
  30. package/lib/commonjs/ui/index.js.map +1 -1
  31. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  32. package/lib/commonjs/ui/screens/OxyAuthScreen.js +11 -2
  33. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  34. package/lib/module/core/OxyServices.base.js.map +1 -1
  35. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  36. package/lib/module/core/mixins/OxyServices.utility.js.map +1 -1
  37. package/lib/module/crypto/README.md +142 -0
  38. package/lib/module/crypto/core.js +133 -0
  39. package/lib/module/crypto/core.js.map +1 -0
  40. package/lib/module/crypto/index.js +3 -9
  41. package/lib/module/crypto/index.js.map +1 -1
  42. package/lib/module/crypto/keyManager.js +19 -22
  43. package/lib/module/crypto/keyManager.js.map +1 -1
  44. package/lib/module/crypto/signatureService.js +113 -23
  45. package/lib/module/crypto/signatureService.js.map +1 -1
  46. package/lib/module/index.js +0 -2
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/models/interfaces.js +10 -11
  49. package/lib/module/models/interfaces.js.map +1 -1
  50. package/lib/module/node/index.js +3 -0
  51. package/lib/module/node/index.js.map +1 -1
  52. package/lib/module/node/signatureService.js +101 -0
  53. package/lib/module/node/signatureService.js.map +1 -0
  54. package/lib/module/ui/context/OxyContext.js +23 -0
  55. package/lib/module/ui/context/OxyContext.js.map +1 -1
  56. package/lib/module/ui/context/hooks/useAuthOperations.js +29 -2
  57. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  58. package/lib/module/ui/context/hooks/useLanguageManagement.js.map +1 -1
  59. package/lib/module/ui/hooks/useLanguageManagement.js.map +1 -1
  60. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  61. package/lib/module/ui/index.js +0 -1
  62. package/lib/module/ui/index.js.map +1 -1
  63. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  64. package/lib/module/ui/screens/OxyAuthScreen.js +11 -2
  65. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  66. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  67. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  68. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  69. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +1 -1
  70. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  71. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  72. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  73. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  74. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  75. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  76. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  77. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  78. package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
  79. package/lib/typescript/core/mixins/OxyServices.user.d.ts +1 -2
  80. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  81. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  82. package/lib/typescript/core/mixins/index.d.ts +13 -13
  83. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  84. package/lib/typescript/core/services/SessionService.d.ts +1 -1
  85. package/lib/typescript/core/services/SessionService.d.ts.map +1 -1
  86. package/lib/typescript/crypto/core.d.ts +56 -0
  87. package/lib/typescript/crypto/core.d.ts.map +1 -0
  88. package/lib/typescript/crypto/index.d.ts +1 -9
  89. package/lib/typescript/crypto/index.d.ts.map +1 -1
  90. package/lib/typescript/crypto/keyManager.d.ts +13 -1
  91. package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
  92. package/lib/typescript/crypto/signatureService.d.ts +15 -9
  93. package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
  94. package/lib/typescript/index.d.ts +1 -2
  95. package/lib/typescript/index.d.ts.map +1 -1
  96. package/lib/typescript/models/interfaces.d.ts +68 -15
  97. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  98. package/lib/typescript/node/index.d.ts +1 -0
  99. package/lib/typescript/node/index.d.ts.map +1 -1
  100. package/lib/typescript/node/signatureService.d.ts +55 -0
  101. package/lib/typescript/node/signatureService.d.ts.map +1 -0
  102. package/lib/typescript/ui/context/OxyContext.d.ts +1 -2
  103. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  104. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +1 -2
  105. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  106. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts +1 -2
  107. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts.map +1 -1
  108. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +1 -1
  109. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  110. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +1 -1
  111. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  112. package/lib/typescript/ui/hooks/useLanguageManagement.d.ts +1 -2
  113. package/lib/typescript/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  114. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +1 -2
  115. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
  116. package/lib/typescript/ui/index.d.ts +1 -1
  117. package/lib/typescript/ui/index.d.ts.map +1 -1
  118. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  119. package/lib/typescript/ui/stores/authStore.d.ts +1 -1
  120. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  121. package/lib/typescript/ui/utils/avatarUtils.d.ts +1 -1
  122. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  123. package/package.json +6 -1
  124. package/src/core/OxyServices.base.ts +1 -2
  125. package/src/core/mixins/OxyServices.auth.ts +1 -1
  126. package/src/core/mixins/OxyServices.user.ts +1 -2
  127. package/src/core/mixins/OxyServices.utility.ts +1 -2
  128. package/src/core/services/SessionService.ts +1 -1
  129. package/src/crypto/README.md +142 -0
  130. package/src/crypto/__tests__/core.test.ts +203 -0
  131. package/src/crypto/core.ts +142 -0
  132. package/src/crypto/index.ts +3 -10
  133. package/src/crypto/keyManager.ts +25 -21
  134. package/src/crypto/signatureService.ts +137 -36
  135. package/src/index.ts +2 -3
  136. package/src/models/interfaces.ts +73 -21
  137. package/src/node/index.ts +3 -0
  138. package/src/node/signatureService.ts +126 -0
  139. package/src/ui/context/OxyContext.tsx +26 -2
  140. package/src/ui/context/hooks/useAuthOperations.ts +33 -4
  141. package/src/ui/context/hooks/useLanguageManagement.ts +1 -2
  142. package/src/ui/hooks/auth/index.ts +2 -0
  143. package/src/ui/hooks/mutations/useAccountMutations.ts +1 -1
  144. package/src/ui/hooks/mutations/useServicesMutations.ts +1 -1
  145. package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
  146. package/src/ui/hooks/useLanguageManagement.ts +1 -2
  147. package/src/ui/hooks/useSessionManagement.ts +1 -2
  148. package/src/ui/index.ts +1 -2
  149. package/src/ui/screens/AccountSettingsScreen.tsx +6 -6
  150. package/src/ui/screens/AccountSwitcherScreen.tsx +1 -1
  151. package/src/ui/screens/OxyAuthScreen.tsx +11 -2
  152. package/src/ui/screens/ProfileScreen.tsx +1 -1
  153. package/src/ui/stores/authStore.ts +1 -1
  154. package/src/ui/types/navigation.ts +1 -1
  155. package/src/ui/utils/avatarUtils.ts +1 -1
  156. package/lib/commonjs/core/services/AuthService.js +0 -156
  157. package/lib/commonjs/core/services/AuthService.js.map +0 -1
  158. package/lib/commonjs/core/services/SessionTransportService.js +0 -64
  159. package/lib/commonjs/core/services/SessionTransportService.js.map +0 -1
  160. package/lib/commonjs/core/services/UserService.js +0 -123
  161. package/lib/commonjs/core/services/UserService.js.map +0 -1
  162. package/lib/commonjs/core/services/index.js +0 -34
  163. package/lib/commonjs/core/services/index.js.map +0 -1
  164. package/lib/commonjs/shared/crypto/messageBuilders.js +0 -79
  165. package/lib/commonjs/shared/crypto/messageBuilders.js.map +0 -1
  166. package/lib/commonjs/shared/crypto/platform.js +0 -118
  167. package/lib/commonjs/shared/crypto/platform.js.map +0 -1
  168. package/lib/commonjs/shared/crypto/signature.js +0 -191
  169. package/lib/commonjs/shared/crypto/signature.js.map +0 -1
  170. package/lib/commonjs/shared/index.js +0 -94
  171. package/lib/commonjs/shared/index.js.map +0 -1
  172. package/lib/commonjs/shared/models/index.js +0 -2
  173. package/lib/commonjs/shared/models/index.js.map +0 -1
  174. package/lib/commonjs/shared/transport/index.js +0 -260
  175. package/lib/commonjs/shared/transport/index.js.map +0 -1
  176. package/lib/commonjs/shared/utils/index.js +0 -82
  177. package/lib/commonjs/shared/utils/index.js.map +0 -1
  178. package/lib/module/core/services/AuthService.js +0 -151
  179. package/lib/module/core/services/AuthService.js.map +0 -1
  180. package/lib/module/core/services/SessionTransportService.js +0 -59
  181. package/lib/module/core/services/SessionTransportService.js.map +0 -1
  182. package/lib/module/core/services/UserService.js +0 -118
  183. package/lib/module/core/services/UserService.js.map +0 -1
  184. package/lib/module/core/services/index.js +0 -16
  185. package/lib/module/core/services/index.js.map +0 -1
  186. package/lib/module/shared/crypto/messageBuilders.js +0 -70
  187. package/lib/module/shared/crypto/messageBuilders.js.map +0 -1
  188. package/lib/module/shared/crypto/platform.js +0 -112
  189. package/lib/module/shared/crypto/platform.js.map +0 -1
  190. package/lib/module/shared/crypto/signature.js +0 -186
  191. package/lib/module/shared/crypto/signature.js.map +0 -1
  192. package/lib/module/shared/index.js +0 -30
  193. package/lib/module/shared/index.js.map +0 -1
  194. package/lib/module/shared/models/index.js +0 -2
  195. package/lib/module/shared/models/index.js.map +0 -1
  196. package/lib/module/shared/transport/index.js +0 -254
  197. package/lib/module/shared/transport/index.js.map +0 -1
  198. package/lib/module/shared/utils/index.js +0 -74
  199. package/lib/module/shared/utils/index.js.map +0 -1
  200. package/lib/typescript/core/services/AuthService.d.ts +0 -50
  201. package/lib/typescript/core/services/AuthService.d.ts.map +0 -1
  202. package/lib/typescript/core/services/SessionTransportService.d.ts +0 -31
  203. package/lib/typescript/core/services/SessionTransportService.d.ts.map +0 -1
  204. package/lib/typescript/core/services/UserService.d.ts +0 -39
  205. package/lib/typescript/core/services/UserService.d.ts.map +0 -1
  206. package/lib/typescript/core/services/index.d.ts +0 -13
  207. package/lib/typescript/core/services/index.d.ts.map +0 -1
  208. package/lib/typescript/shared/crypto/messageBuilders.d.ts +0 -38
  209. package/lib/typescript/shared/crypto/messageBuilders.d.ts.map +0 -1
  210. package/lib/typescript/shared/crypto/platform.d.ts +0 -54
  211. package/lib/typescript/shared/crypto/platform.d.ts.map +0 -1
  212. package/lib/typescript/shared/crypto/signature.d.ts +0 -72
  213. package/lib/typescript/shared/crypto/signature.d.ts.map +0 -1
  214. package/lib/typescript/shared/index.d.ts +0 -20
  215. package/lib/typescript/shared/index.d.ts.map +0 -1
  216. package/lib/typescript/shared/models/index.d.ts +0 -163
  217. package/lib/typescript/shared/models/index.d.ts.map +0 -1
  218. package/lib/typescript/shared/transport/index.d.ts +0 -73
  219. package/lib/typescript/shared/transport/index.d.ts.map +0 -1
  220. package/lib/typescript/shared/utils/index.d.ts +0 -28
  221. package/lib/typescript/shared/utils/index.d.ts.map +0 -1
  222. package/src/core/services/AuthService.ts +0 -153
  223. package/src/core/services/SessionTransportService.ts +0 -69
  224. package/src/core/services/UserService.ts +0 -125
  225. package/src/core/services/index.ts +0 -14
  226. package/src/shared/crypto/messageBuilders.ts +0 -89
  227. package/src/shared/crypto/platform.ts +0 -140
  228. package/src/shared/crypto/signature.ts +0 -235
  229. package/src/shared/index.ts +0 -28
  230. package/src/shared/models/index.ts +0 -173
  231. package/src/shared/transport/index.ts +0 -349
  232. package/src/shared/utils/index.ts +0 -73
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Session Transport Service
5
- *
6
- * Uses shared transport abstraction for WebSocket/SSE/polling
7
- * Provides unified interface for session status updates
8
- */
9
-
10
- import { TransportFactory } from '../../shared';
11
- export class SessionTransportService {
12
- transport = null;
13
- constructor(config) {
14
- this.config = config;
15
- }
16
-
17
- /**
18
- * Connect to session status updates
19
- * Automatically chooses best available transport (WebSocket > SSE > Polling)
20
- */
21
- async connect(sessionToken, callbacks) {
22
- const transportConfig = {
23
- baseURL: this.config.baseURL,
24
- namespace: 'auth-session',
25
- sessionToken,
26
- pollingInterval: 3000,
27
- // 3 seconds
28
- reconnectAttempts: 3,
29
- reconnectDelay: 1000
30
- };
31
- this.transport = await TransportFactory.create(transportConfig, callbacks);
32
- await this.transport.connect();
33
- }
34
-
35
- /**
36
- * Disconnect from session updates
37
- */
38
- disconnect() {
39
- if (this.transport) {
40
- this.transport.disconnect();
41
- this.transport = null;
42
- }
43
- }
44
-
45
- /**
46
- * Check if currently connected
47
- */
48
- isConnected() {
49
- return this.transport?.isConnected() ?? false;
50
- }
51
-
52
- /**
53
- * Get the transport type being used
54
- */
55
- getTransportType() {
56
- return this.transport?.getType() ?? 'none';
57
- }
58
- }
59
- //# sourceMappingURL=SessionTransportService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["TransportFactory","SessionTransportService","transport","constructor","config","connect","sessionToken","callbacks","transportConfig","baseURL","namespace","pollingInterval","reconnectAttempts","reconnectDelay","create","disconnect","isConnected","getTransportType","getType"],"sourceRoot":"../../../../src","sources":["core/services/SessionTransportService.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,gBAAgB,QAIX,cAAc;AAErB,OAAO,MAAMC,uBAAuB,CAAC;EAC3BC,SAAS,GAAQ,IAAI;EAG7BC,WAAWA,CAACC,MAAiB,EAAE;IAC7B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACtB;;EAEA;AACF;AACA;AACA;EACE,MAAMC,OAAOA,CACXC,YAAoB,EACpBC,SAA6B,EACd;IACf,MAAMC,eAAgC,GAAG;MACvCC,OAAO,EAAE,IAAI,CAACL,MAAM,CAACK,OAAO;MAC5BC,SAAS,EAAE,cAAc;MACzBJ,YAAY;MACZK,eAAe,EAAE,IAAI;MAAE;MACvBC,iBAAiB,EAAE,CAAC;MACpBC,cAAc,EAAE;IAClB,CAAC;IAED,IAAI,CAACX,SAAS,GAAG,MAAMF,gBAAgB,CAACc,MAAM,CAACN,eAAe,EAAED,SAAS,CAAC;IAC1E,MAAM,IAAI,CAACL,SAAS,CAACG,OAAO,CAAC,CAAC;EAChC;;EAEA;AACF;AACA;EACEU,UAAUA,CAAA,EAAS;IACjB,IAAI,IAAI,CAACb,SAAS,EAAE;MAClB,IAAI,CAACA,SAAS,CAACa,UAAU,CAAC,CAAC;MAC3B,IAAI,CAACb,SAAS,GAAG,IAAI;IACvB;EACF;;EAEA;AACF;AACA;EACEc,WAAWA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACd,SAAS,EAAEc,WAAW,CAAC,CAAC,IAAI,KAAK;EAC/C;;EAEA;AACF;AACA;EACEC,gBAAgBA,CAAA,EAAW;IACzB,OAAO,IAAI,CAACf,SAAS,EAAEgB,OAAO,CAAC,CAAC,IAAI,MAAM;EAC5C;AACF","ignoreList":[]}
@@ -1,118 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * User Service
5
- *
6
- * Handles user profile operations (no key handling):
7
- * - Profile fetch/update
8
- * - Profile search
9
- * - User recommendations
10
- */
11
-
12
- import { HttpService } from '../HttpService';
13
- export class UserService {
14
- constructor(config) {
15
- this.httpService = new HttpService(config);
16
- }
17
-
18
- /**
19
- * Get user profile by ID
20
- */
21
- async getUserById(userId) {
22
- try {
23
- return await this.httpService.request({
24
- method: 'GET',
25
- url: `/api/profiles/${userId}`,
26
- cache: true,
27
- cacheTTL: 5 * 60 * 1000
28
- });
29
- } catch (error) {
30
- throw error;
31
- }
32
- }
33
-
34
- /**
35
- * Get profile by username
36
- */
37
- async getProfileByUsername(username) {
38
- try {
39
- return await this.httpService.request({
40
- method: 'GET',
41
- url: `/api/profiles/username/${username}`,
42
- cache: true,
43
- cacheTTL: 5 * 60 * 1000
44
- });
45
- } catch (error) {
46
- throw error;
47
- }
48
- }
49
-
50
- /**
51
- * Search user profiles
52
- */
53
- async searchProfiles(query, pagination) {
54
- try {
55
- const params = new URLSearchParams();
56
- params.set('query', query);
57
- if (pagination?.limit) params.set('limit', pagination.limit.toString());
58
- if (pagination?.offset) params.set('offset', pagination.offset.toString());
59
- const response = await this.httpService.request({
60
- method: 'GET',
61
- url: `/api/profiles/search?${params.toString()}`,
62
- cache: true,
63
- cacheTTL: 2 * 60 * 1000
64
- });
65
-
66
- // Handle response format
67
- if (Array.isArray(response)) {
68
- const limit = pagination?.limit ?? response.length;
69
- const paginationInfo = {
70
- total: response.length,
71
- limit,
72
- offset: pagination?.offset ?? 0,
73
- hasMore: limit > 0 && response.length === limit
74
- };
75
- return {
76
- data: response,
77
- pagination: paginationInfo
78
- };
79
- }
80
- return response;
81
- } catch (error) {
82
- throw error;
83
- }
84
- }
85
-
86
- /**
87
- * Get profile recommendations
88
- */
89
- async getProfileRecommendations() {
90
- try {
91
- return await this.httpService.request({
92
- method: 'GET',
93
- url: '/api/profiles/recommendations',
94
- cache: true,
95
- cacheTTL: 5 * 60 * 1000
96
- });
97
- } catch (error) {
98
- throw error;
99
- }
100
- }
101
-
102
- /**
103
- * Update user profile
104
- */
105
- async updateProfile(updates) {
106
- try {
107
- return await this.httpService.request({
108
- method: 'PATCH',
109
- url: '/api/profiles/me',
110
- data: updates,
111
- cache: false
112
- });
113
- } catch (error) {
114
- throw error;
115
- }
116
- }
117
- }
118
- //# sourceMappingURL=UserService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["HttpService","UserService","constructor","config","httpService","getUserById","userId","request","method","url","cache","cacheTTL","error","getProfileByUsername","username","searchProfiles","query","pagination","params","URLSearchParams","set","limit","toString","offset","response","Array","isArray","length","paginationInfo","total","hasMore","data","getProfileRecommendations","updateProfile","updates"],"sourceRoot":"../../../../src","sources":["core/services/UserService.ts"],"mappings":";;AAAA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A,CAACC,OAAsB,EAAiB;IACzD,IAAI;MACF,OAAO,MAAM,IAAI,CAAC9B,WAAW,CAACG,OAAO,CAAO;QAC1CC,MAAM,EAAE,OAAO;QACfC,GAAG,EAAE,kBAAkB;QACvBsB,IAAI,EAAEG,OAAO;QACbxB,KAAK,EAAE;MACT,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOE,KAAK,EAAE;MACd,MAAMA,KAAK;IACb;EACF;AACF","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Focused Services
5
- *
6
- * Single-responsibility services replacing the mixin pattern:
7
- * - AuthService: Authentication, challenges, registration
8
- * - SessionService: Session management (already exists)
9
- * - UserService: User profile operations
10
- */
11
-
12
- export { AuthService } from './AuthService';
13
- export { sessionService } from './SessionService';
14
- export { UserService } from './UserService';
15
- export { tokenService } from './TokenService';
16
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["AuthService","sessionService","UserService","tokenService"],"sourceRoot":"../../../../src","sources":["core/services/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,YAAY,QAAQ,gBAAgB","ignoreList":[]}
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Canonical Message Builders
5
- *
6
- * Creates standardized, canonical message formats for signing.
7
- * These formats are used consistently across Accounts, Services SDK, and API.
8
- */
9
-
10
- /**
11
- * Build authentication message for challenge-response
12
- * Format: auth:{publicKey}:{challenge}:{timestamp}
13
- */
14
- export function buildAuthMessage(publicKey, challenge, timestamp) {
15
- return `auth:${publicKey}:${challenge}:${timestamp}`;
16
- }
17
-
18
- /**
19
- * Build registration message
20
- * Format: oxy:register:{publicKey}:{timestamp}
21
- */
22
- export function buildRegistrationMessage(publicKey, timestamp) {
23
- return `oxy:register:${publicKey}:${timestamp}`;
24
- }
25
-
26
- /**
27
- * Build request signing message
28
- * Format: request:{publicKey}:{timestamp}:{canonicalData}
29
- */
30
- export function buildRequestMessage(publicKey, timestamp, data) {
31
- // Create canonical string representation
32
- const sortedKeys = Object.keys(data).sort();
33
- const canonicalParts = sortedKeys.map(key => `${key}:${JSON.stringify(data[key])}`);
34
- const canonicalString = canonicalParts.join('|');
35
- return `request:${publicKey}:${timestamp}:${canonicalString}`;
36
- }
37
-
38
- /**
39
- * Create canonical data representation for signing
40
- * Sorts keys and creates a consistent string representation
41
- */
42
- export function canonicalizeData(data) {
43
- const sortedKeys = Object.keys(data).sort();
44
- const canonicalParts = sortedKeys.map(key => `${key}:${JSON.stringify(data[key])}`);
45
- return canonicalParts.join('|');
46
- }
47
-
48
- /**
49
- * Build auth challenge response payload
50
- * Helper to construct the signed challenge response
51
- */
52
- export function buildAuthChallengeResponse(publicKey, challenge, signature, timestamp) {
53
- return {
54
- challenge,
55
- publicKey,
56
- signature,
57
- timestamp
58
- };
59
- }
60
-
61
- /**
62
- * Validate timestamp freshness
63
- * Ensures signed messages are not too old
64
- */
65
- export function isTimestampFresh(timestamp, maxAgeMs = 5 * 60 * 1000 // 5 minutes default
66
- ) {
67
- const now = Date.now();
68
- return now - timestamp <= maxAgeMs && timestamp <= now;
69
- }
70
- //# sourceMappingURL=messageBuilders.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["buildAuthMessage","publicKey","challenge","timestamp","buildRegistrationMessage","buildRequestMessage","data","sortedKeys","Object","keys","sort","canonicalParts","map","key","JSON","stringify","canonicalString","join","canonicalizeData","buildAuthChallengeResponse","signature","isTimestampFresh","maxAgeMs","now","Date"],"sourceRoot":"../../../../src","sources":["shared/crypto/messageBuilders.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAC9BC,SAAiB,EACjBC,SAAiB,EACjBC,SAAiB,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ACA;AACA;AACA,OAAO,SAASkB,gBAAgBA,CAC9BlB,SAAiB,EACjBmB,QAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAAA,EACxB;EACT,MAAMC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAAC,CAAC;EACtB,OAAQA,GAAG,GAAGpB,SAAS,IAAKmB,QAAQ,IAAInB,SAAS,IAAIoB,GAAG;AAC1D","ignoreList":[]}
@@ -1,112 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Platform Detection and Adapters
5
- *
6
- * Provides environment detection and platform-specific crypto adapters
7
- * to support Node.js, React Native, and Web environments.
8
- */
9
-
10
- /**
11
- * Platform types
12
- */
13
-
14
- /**
15
- * Platform detection utilities
16
- */
17
- export const PlatformDetector = {
18
- /**
19
- * Detect current platform
20
- */
21
- detect() {
22
- if (typeof window === 'undefined' && typeof process !== 'undefined' && process.versions?.node) {
23
- return 'node';
24
- }
25
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
26
- return 'react-native';
27
- }
28
- return 'web';
29
- },
30
- /**
31
- * Check if running in Node.js
32
- */
33
- isNode() {
34
- return this.detect() === 'node';
35
- },
36
- /**
37
- * Check if running in React Native
38
- */
39
- isReactNative() {
40
- return this.detect() === 'react-native';
41
- },
42
- /**
43
- * Check if running in Web browser
44
- */
45
- isWeb() {
46
- return this.detect() === 'web';
47
- }
48
- };
49
-
50
- /**
51
- * Crypto adapter interface
52
- * Platform-specific implementations must implement this interface
53
- */
54
-
55
- /**
56
- * Get the appropriate crypto adapter for the current platform
57
- */
58
- export async function getCryptoAdapter() {
59
- const platform = PlatformDetector.detect();
60
- if (platform === 'node') {
61
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
62
- const getCrypto = new Function('return require("crypto")');
63
- const crypto = getCrypto();
64
- return {
65
- async randomBytes(size) {
66
- return new Uint8Array(crypto.randomBytes(size));
67
- },
68
- async sha256(message) {
69
- return crypto.createHash('sha256').update(message).digest('hex');
70
- },
71
- sha256Sync(message) {
72
- return crypto.createHash('sha256').update(message).digest('hex');
73
- }
74
- };
75
- }
76
- if (platform === 'react-native') {
77
- // Lazy load expo-crypto (peer dependency)
78
- try {
79
- // @ts-ignore - expo-crypto is an optional peer dependency
80
- const ExpoCrypto = await import('expo-crypto');
81
- return {
82
- async randomBytes(size) {
83
- const bytes = await ExpoCrypto.getRandomBytesAsync(size);
84
- return new Uint8Array(bytes);
85
- },
86
- async sha256(message) {
87
- return ExpoCrypto.digestStringAsync(ExpoCrypto.CryptoDigestAlgorithm.SHA256, message);
88
- }
89
- };
90
- } catch (error) {
91
- throw new Error(`expo-crypto is required in React Native environment: ${error instanceof Error ? error.message : String(error)}`);
92
- }
93
- }
94
-
95
- // Web platform - use Web Crypto API
96
- if (typeof window !== 'undefined' && window.crypto) {
97
- return {
98
- async randomBytes(size) {
99
- return window.crypto.getRandomValues(new Uint8Array(size));
100
- },
101
- async sha256(message) {
102
- const encoder = new TextEncoder();
103
- const data = encoder.encode(message);
104
- const hashBuffer = await window.crypto.subtle.digest('SHA-256', data);
105
- const hashArray = Array.from(new Uint8Array(hashBuffer));
106
- return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
107
- }
108
- };
109
- }
110
- throw new Error('No suitable crypto implementation found for current platform');
111
- }
112
- //# sourceMappingURL=platform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["PlatformDetector","detect","window","process","versions","node","navigator","product","isNode","isReactNative","isWeb","getCryptoAdapter","platform","getCrypto","Function","crypto","randomBytes","size","Uint8Array","sha256","message","createHash","update","digest","sha256Sync","ExpoCrypto","bytes","getRandomBytesAsync","digestStringAsync","CryptoDigestAlgorithm","SHA256","error","Error","String","getRandomValues","encoder","TextEncoder","data","encode","hashBuffer","subtle","hashArray","Array","from","map","b","toString","padStart","join"],"sourceRoot":"../../../../src","sources":["shared/crypto/platform.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA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AM,CAACyB,MAAM,CAACjB,MAAM,CAAC,SAAS,EAAEc,IAAI,CAAC;QACrE,MAAMI,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAIzB,UAAU,CAACqB,UAAU,CAAC,CAAC;QACxD,OAAOE,SAAS,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC;MACrE;IACF,CAAC;EACH;EAEA,MAAM,IAAIhB,KAAK,CAAC,8DAA8D,CAAC;AACjF","ignoreList":[]}
@@ -1,186 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Signature Verification Service
5
- *
6
- * Unified signature verification used by both backend (API) and SDK.
7
- * Uses platform adapters for crypto operations while keeping message construction shared.
8
- */
9
-
10
- import { ec as EC } from 'elliptic';
11
- import { getCryptoAdapter, PlatformDetector } from './platform';
12
- import { buildAuthMessage, buildRegistrationMessage, buildRequestMessage, isTimestampFresh } from './messageBuilders';
13
- const ec = new EC('secp256k1');
14
-
15
- /**
16
- * Maximum age for signed messages (5 minutes)
17
- */
18
- export const MAX_SIGNATURE_AGE_MS = 5 * 60 * 1000;
19
-
20
- /**
21
- * Challenge TTL (5 minutes)
22
- */
23
- export const CHALLENGE_TTL_MS = 5 * 60 * 1000;
24
-
25
- /**
26
- * Signature Service
27
- * Provides signature verification that works across all platforms
28
- */
29
- export class SignatureService {
30
- /**
31
- * Verify an ECDSA signature
32
- *
33
- * @param message - The original message that was signed
34
- * @param signature - The signature in DER format (hex encoded)
35
- * @param publicKey - The public key (hex encoded, uncompressed)
36
- * @returns true if the signature is valid
37
- */
38
- static async verify(message, signature, publicKey) {
39
- try {
40
- const key = ec.keyFromPublic(publicKey, 'hex');
41
- const adapter = await getCryptoAdapter();
42
- const messageHash = await adapter.sha256(message);
43
- return key.verify(messageHash, signature);
44
- } catch {
45
- return false;
46
- }
47
- }
48
-
49
- /**
50
- * Synchronous signature verification (Node.js only)
51
- * Uses Node.js crypto module directly for hashing
52
- */
53
- static verifySync(message, signature, publicKey) {
54
- if (!PlatformDetector.isNode()) {
55
- throw new Error('verifySync should only be used in Node.js. Use verify() in other environments.');
56
- }
57
- try {
58
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
59
- const getCrypto = new Function('return require("crypto")');
60
- const crypto = getCrypto();
61
- const key = ec.keyFromPublic(publicKey, 'hex');
62
- const messageHash = crypto.createHash('sha256').update(message).digest('hex');
63
- return key.verify(messageHash, signature);
64
- } catch {
65
- return false;
66
- }
67
- }
68
-
69
- /**
70
- * Verify an authentication challenge response
71
- *
72
- * @param publicKey - The user's public key
73
- * @param challenge - The original challenge string
74
- * @param signature - The signature of the auth message
75
- * @param timestamp - The timestamp when the signature was created
76
- * @param maxAgeMs - Maximum age of the signature in milliseconds
77
- * @returns true if the challenge response is valid
78
- */
79
- static async verifyChallengeResponse(publicKey, challenge, signature, timestamp, maxAgeMs = CHALLENGE_TTL_MS) {
80
- // Check timestamp freshness
81
- if (!isTimestampFresh(timestamp, maxAgeMs)) {
82
- return false;
83
- }
84
-
85
- // Build the canonical message
86
- const message = buildAuthMessage(publicKey, challenge, timestamp);
87
-
88
- // Verify the signature
89
- return this.verify(message, signature, publicKey);
90
- }
91
-
92
- /**
93
- * Synchronous challenge response verification (Node.js only)
94
- */
95
- static verifyChallengeResponseSync(publicKey, challenge, signature, timestamp, maxAgeMs = CHALLENGE_TTL_MS) {
96
- // Check timestamp freshness
97
- if (!isTimestampFresh(timestamp, maxAgeMs)) {
98
- return false;
99
- }
100
-
101
- // Build the canonical message
102
- const message = buildAuthMessage(publicKey, challenge, timestamp);
103
-
104
- // Verify the signature
105
- return this.verifySync(message, signature, publicKey);
106
- }
107
-
108
- /**
109
- * Verify a registration signature
110
- * Signature format: oxy:register:{publicKey}:{timestamp}
111
- */
112
- static async verifyRegistrationSignature(publicKey, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
113
- // Check timestamp freshness
114
- if (!isTimestampFresh(timestamp, maxAgeMs)) {
115
- return false;
116
- }
117
-
118
- // Build the canonical message
119
- const message = buildRegistrationMessage(publicKey, timestamp);
120
-
121
- // Verify the signature
122
- return this.verify(message, signature, publicKey);
123
- }
124
-
125
- /**
126
- * Synchronous registration signature verification (Node.js only)
127
- */
128
- static verifyRegistrationSignatureSync(publicKey, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
129
- // Check timestamp freshness
130
- if (!isTimestampFresh(timestamp, maxAgeMs)) {
131
- return false;
132
- }
133
-
134
- // Build the canonical message
135
- const message = buildRegistrationMessage(publicKey, timestamp);
136
-
137
- // Verify the signature
138
- return this.verifySync(message, signature, publicKey);
139
- }
140
-
141
- /**
142
- * Verify a signed request
143
- * Used for authenticated API operations
144
- */
145
- static async verifyRequestSignature(publicKey, data, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
146
- // Check timestamp freshness
147
- if (!isTimestampFresh(timestamp, maxAgeMs)) {
148
- return false;
149
- }
150
-
151
- // Build the canonical message
152
- const message = buildRequestMessage(publicKey, timestamp, data);
153
-
154
- // Verify the signature
155
- return this.verify(message, signature, publicKey);
156
- }
157
-
158
- /**
159
- * Synchronous request signature verification (Node.js only)
160
- */
161
- static verifyRequestSignatureSync(publicKey, data, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
162
- // Check timestamp freshness
163
- if (!isTimestampFresh(timestamp, maxAgeMs)) {
164
- return false;
165
- }
166
-
167
- // Build the canonical message
168
- const message = buildRequestMessage(publicKey, timestamp, data);
169
-
170
- // Verify the signature
171
- return this.verifySync(message, signature, publicKey);
172
- }
173
-
174
- /**
175
- * Validate that a string is a valid public key
176
- */
177
- static isValidPublicKey(publicKey) {
178
- try {
179
- ec.keyFromPublic(publicKey, 'hex');
180
- return true;
181
- } catch {
182
- return false;
183
- }
184
- }
185
- }
186
- //# sourceMappingURL=signature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ec","EC","getCryptoAdapter","PlatformDetector","buildAuthMessage","buildRegistrationMessage","buildRequestMessage","isTimestampFresh","MAX_SIGNATURE_AGE_MS","CHALLENGE_TTL_MS","SignatureService","verify","message","signature","publicKey","key","keyFromPublic","adapter","messageHash","sha256","verifySync","isNode","Error","getCrypto","Function","crypto","createHash","update","digest","verifyChallengeResponse","challenge","timestamp","maxAgeMs","verifyChallengeResponseSync","verifyRegistrationSignature","verifyRegistrationSignatureSync","verifyRequestSignature","data","verifyRequestSignatureSync","isValidPublicKey"],"sourceRoot":"../../../../src","sources":["shared/crypto/signature.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,EAAE,IAAIC,EAAE,QAAQ,UAAU;AACnC,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,YAAY;AAC/D,SACEC,gBAAgB,EAChBC,wBAAwB,EACxBC,mBAAmB,EACnBC,gBAAgB,QACX,mBAAmB;AAE1B,MAAMP,EAAE,GAAG,IAAIC,EAAE,CAAC,WAAW,CAAC;;AAE9B;AACA;AACA;AACA,OAAO,MAAMO,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI;;AAEjD;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI;;AAE7C;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC5B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,MAAMA,CACjBC,OAAe,EACfC,SAAiB,EACjBC,SAAiB,EACC;IAClB,IAAI;MACF,MAAMC,GAAG,GAAGf,EAAE,CAACgB,aAAa,CAACF,SAAS,EAAE,KAAK,CAAC;MAC9C,MAAMG,OAAO,GAAG,MAAMf,gBAAgB,CAAC,CAAC;MACxC,MAAMgB,WAAW,GAAG,MAAMD,OAAO,CAACE,MAAM,CAACP,OAAO,CAAC;MACjD,OAAOG,GAAG,CAACJ,MA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xB,oBAAoB,EACrB;IAClB;IACA,IAAI,CAACD,gBAAgB,CAACwB,SAAS,EAAEC,QAAQ,CAAC,EAAE;MAC1C,OAAO,KAAK;IACd;;IAEA;IACA,MAAMpB,OAAO,GAAGN,mBAAmB,CAACQ,SAAS,EAAEiB,SAAS,EAAEM,IAAI,CAAC;;IAE/D;IACA,OAAO,IAAI,CAAC1B,MAAM,CAACC,OAAO,EAAEC,SAAS,EAAEC,SAAS,CAAC;EACnD;;EAEA;AACF;AACA;EACE,OAAOwB,0BAA0BA,CAC/BxB,SAAiB,EACjBuB,IAA6B,EAC7BxB,SAAiB,EACjBkB,SAAiB,EACjBC,QAAgB,GAAGxB,oBAAoB,EAC9B;IACT;IACA,IAAI,CAACD,gBAAgB,CAACwB,SAAS,EAAEC,QAAQ,CAAC,EAAE;MAC1C,OAAO,KAAK;IACd;;IAEA;IACA,MAAMpB,OAAO,GAAGN,mBAAmB,CAACQ,SAAS,EAAEiB,SAAS,EAAEM,IAAI,CAAC;;IAE/D;IACA,OAAO,IAAI,CAACjB,UAAU,CAACR,OAAO,EAAEC,SAAS,EAAEC,SAAS,CAAC;EACvD;;EAEA;AACF;AACA;EACE,OAAOyB,gBAAgBA,CAACzB,SAAiB,EAAW;IAClD,IAAI;MACFd,EAAE,CAACgB,aAAa,CAACF,SAAS,EAAE,KAAK,CAAC;MAClC,OAAO,IAAI;IACb,CAAC,CAAC,MAAM;MACN,OAAO,KAAK;IACd;EACF;AACF","ignoreList":[]}
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * @oxyhq/shared
5
- *
6
- * Shared utilities, models, and crypto primitives for OxyHQ packages.
7
- *
8
- * This package provides:
9
- * - Canonical data models (User, Session, ChallengePayload, etc.)
10
- * - Unified signature verification across platforms
11
- * - Platform-agnostic crypto adapters
12
- * - Shared utility functions
13
- * - Canonical message builders for signing
14
- */
15
-
16
- // Models
17
- export * from './models/index';
18
-
19
- // Crypto
20
- export * from './crypto/signature';
21
- export * from './crypto/messageBuilders';
22
- export * from './crypto/platform';
23
- export { getCryptoAdapter, PlatformDetector } from './crypto/platform';
24
-
25
- // Utils
26
- export * from './utils/index';
27
-
28
- // Transport
29
- export * from './transport/index';
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getCryptoAdapter","PlatformDetector"],"sourceRoot":"../../../src","sources":["shared/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,gBAAgB;;AAE9B;AACA,cAAc,oBAAoB;AAClC,cAAc,0BAA0B;AACxC,cAAc,mBAAmB;AACjC,SAASA,gBAAgB,EAAEC,gBAAgB,QAAQ,mBAAmB;;AAEtE;AACA,cAAc,eAAe;;AAE7B;AACA,cAAc,mBAAmB","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["shared/models/index.ts"],"mappings":"","ignoreList":[]}