@oxyhq/services 5.16.35 → 5.16.36

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 (228) 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.map +1 -1
  23. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  24. package/lib/commonjs/ui/context/hooks/useLanguageManagement.js.map +1 -1
  25. package/lib/commonjs/ui/hooks/useLanguageManagement.js.map +1 -1
  26. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  27. package/lib/commonjs/ui/index.js +0 -2
  28. package/lib/commonjs/ui/index.js.map +1 -1
  29. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  30. package/lib/commonjs/ui/screens/OxyAuthScreen.js +11 -2
  31. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  32. package/lib/module/core/OxyServices.base.js.map +1 -1
  33. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  34. package/lib/module/core/mixins/OxyServices.utility.js.map +1 -1
  35. package/lib/module/crypto/README.md +142 -0
  36. package/lib/module/crypto/core.js +133 -0
  37. package/lib/module/crypto/core.js.map +1 -0
  38. package/lib/module/crypto/index.js +3 -9
  39. package/lib/module/crypto/index.js.map +1 -1
  40. package/lib/module/crypto/keyManager.js +19 -22
  41. package/lib/module/crypto/keyManager.js.map +1 -1
  42. package/lib/module/crypto/signatureService.js +113 -23
  43. package/lib/module/crypto/signatureService.js.map +1 -1
  44. package/lib/module/index.js +0 -2
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/models/interfaces.js +10 -11
  47. package/lib/module/models/interfaces.js.map +1 -1
  48. package/lib/module/node/index.js +3 -0
  49. package/lib/module/node/index.js.map +1 -1
  50. package/lib/module/node/signatureService.js +101 -0
  51. package/lib/module/node/signatureService.js.map +1 -0
  52. package/lib/module/ui/context/OxyContext.js.map +1 -1
  53. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  54. package/lib/module/ui/context/hooks/useLanguageManagement.js.map +1 -1
  55. package/lib/module/ui/hooks/useLanguageManagement.js.map +1 -1
  56. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  57. package/lib/module/ui/index.js +0 -1
  58. package/lib/module/ui/index.js.map +1 -1
  59. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  60. package/lib/module/ui/screens/OxyAuthScreen.js +11 -2
  61. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  62. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  63. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  64. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  65. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +1 -1
  66. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  67. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  68. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  69. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  70. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  71. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  72. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  73. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  74. package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
  75. package/lib/typescript/core/mixins/OxyServices.user.d.ts +1 -2
  76. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  77. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  78. package/lib/typescript/core/mixins/index.d.ts +13 -13
  79. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  80. package/lib/typescript/core/services/SessionService.d.ts +1 -1
  81. package/lib/typescript/core/services/SessionService.d.ts.map +1 -1
  82. package/lib/typescript/crypto/core.d.ts +56 -0
  83. package/lib/typescript/crypto/core.d.ts.map +1 -0
  84. package/lib/typescript/crypto/index.d.ts +1 -9
  85. package/lib/typescript/crypto/index.d.ts.map +1 -1
  86. package/lib/typescript/crypto/keyManager.d.ts +13 -1
  87. package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
  88. package/lib/typescript/crypto/signatureService.d.ts +15 -9
  89. package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
  90. package/lib/typescript/index.d.ts +1 -2
  91. package/lib/typescript/index.d.ts.map +1 -1
  92. package/lib/typescript/models/interfaces.d.ts +68 -15
  93. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  94. package/lib/typescript/node/index.d.ts +1 -0
  95. package/lib/typescript/node/index.d.ts.map +1 -1
  96. package/lib/typescript/node/signatureService.d.ts +55 -0
  97. package/lib/typescript/node/signatureService.d.ts.map +1 -0
  98. package/lib/typescript/ui/context/OxyContext.d.ts +1 -2
  99. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  100. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +1 -2
  101. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  102. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts +1 -2
  103. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts.map +1 -1
  104. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +1 -1
  105. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  106. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +1 -1
  107. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  108. package/lib/typescript/ui/hooks/useLanguageManagement.d.ts +1 -2
  109. package/lib/typescript/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  110. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +1 -2
  111. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
  112. package/lib/typescript/ui/index.d.ts +1 -1
  113. package/lib/typescript/ui/index.d.ts.map +1 -1
  114. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  115. package/lib/typescript/ui/stores/authStore.d.ts +1 -1
  116. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  117. package/lib/typescript/ui/utils/avatarUtils.d.ts +1 -1
  118. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  119. package/package.json +6 -1
  120. package/src/core/OxyServices.base.ts +1 -2
  121. package/src/core/mixins/OxyServices.auth.ts +1 -1
  122. package/src/core/mixins/OxyServices.user.ts +1 -2
  123. package/src/core/mixins/OxyServices.utility.ts +1 -2
  124. package/src/core/services/SessionService.ts +1 -1
  125. package/src/crypto/README.md +142 -0
  126. package/src/crypto/__tests__/core.test.ts +203 -0
  127. package/src/crypto/core.ts +142 -0
  128. package/src/crypto/index.ts +3 -10
  129. package/src/crypto/keyManager.ts +25 -21
  130. package/src/crypto/signatureService.ts +137 -36
  131. package/src/index.ts +2 -3
  132. package/src/models/interfaces.ts +73 -21
  133. package/src/node/index.ts +3 -0
  134. package/src/node/signatureService.ts +126 -0
  135. package/src/ui/context/OxyContext.tsx +1 -2
  136. package/src/ui/context/hooks/useAuthOperations.ts +1 -2
  137. package/src/ui/context/hooks/useLanguageManagement.ts +1 -2
  138. package/src/ui/hooks/auth/index.ts +2 -0
  139. package/src/ui/hooks/mutations/useAccountMutations.ts +1 -1
  140. package/src/ui/hooks/mutations/useServicesMutations.ts +1 -1
  141. package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
  142. package/src/ui/hooks/useLanguageManagement.ts +1 -2
  143. package/src/ui/hooks/useSessionManagement.ts +1 -2
  144. package/src/ui/index.ts +1 -2
  145. package/src/ui/screens/AccountSettingsScreen.tsx +6 -6
  146. package/src/ui/screens/AccountSwitcherScreen.tsx +1 -1
  147. package/src/ui/screens/OxyAuthScreen.tsx +11 -2
  148. package/src/ui/screens/ProfileScreen.tsx +1 -1
  149. package/src/ui/stores/authStore.ts +1 -1
  150. package/src/ui/types/navigation.ts +1 -1
  151. package/src/ui/utils/avatarUtils.ts +1 -1
  152. package/lib/commonjs/core/services/AuthService.js +0 -156
  153. package/lib/commonjs/core/services/AuthService.js.map +0 -1
  154. package/lib/commonjs/core/services/SessionTransportService.js +0 -64
  155. package/lib/commonjs/core/services/SessionTransportService.js.map +0 -1
  156. package/lib/commonjs/core/services/UserService.js +0 -123
  157. package/lib/commonjs/core/services/UserService.js.map +0 -1
  158. package/lib/commonjs/core/services/index.js +0 -34
  159. package/lib/commonjs/core/services/index.js.map +0 -1
  160. package/lib/commonjs/shared/crypto/messageBuilders.js +0 -79
  161. package/lib/commonjs/shared/crypto/messageBuilders.js.map +0 -1
  162. package/lib/commonjs/shared/crypto/platform.js +0 -118
  163. package/lib/commonjs/shared/crypto/platform.js.map +0 -1
  164. package/lib/commonjs/shared/crypto/signature.js +0 -191
  165. package/lib/commonjs/shared/crypto/signature.js.map +0 -1
  166. package/lib/commonjs/shared/index.js +0 -94
  167. package/lib/commonjs/shared/index.js.map +0 -1
  168. package/lib/commonjs/shared/models/index.js +0 -2
  169. package/lib/commonjs/shared/models/index.js.map +0 -1
  170. package/lib/commonjs/shared/transport/index.js +0 -260
  171. package/lib/commonjs/shared/transport/index.js.map +0 -1
  172. package/lib/commonjs/shared/utils/index.js +0 -82
  173. package/lib/commonjs/shared/utils/index.js.map +0 -1
  174. package/lib/module/core/services/AuthService.js +0 -151
  175. package/lib/module/core/services/AuthService.js.map +0 -1
  176. package/lib/module/core/services/SessionTransportService.js +0 -59
  177. package/lib/module/core/services/SessionTransportService.js.map +0 -1
  178. package/lib/module/core/services/UserService.js +0 -118
  179. package/lib/module/core/services/UserService.js.map +0 -1
  180. package/lib/module/core/services/index.js +0 -16
  181. package/lib/module/core/services/index.js.map +0 -1
  182. package/lib/module/shared/crypto/messageBuilders.js +0 -70
  183. package/lib/module/shared/crypto/messageBuilders.js.map +0 -1
  184. package/lib/module/shared/crypto/platform.js +0 -112
  185. package/lib/module/shared/crypto/platform.js.map +0 -1
  186. package/lib/module/shared/crypto/signature.js +0 -186
  187. package/lib/module/shared/crypto/signature.js.map +0 -1
  188. package/lib/module/shared/index.js +0 -30
  189. package/lib/module/shared/index.js.map +0 -1
  190. package/lib/module/shared/models/index.js +0 -2
  191. package/lib/module/shared/models/index.js.map +0 -1
  192. package/lib/module/shared/transport/index.js +0 -254
  193. package/lib/module/shared/transport/index.js.map +0 -1
  194. package/lib/module/shared/utils/index.js +0 -74
  195. package/lib/module/shared/utils/index.js.map +0 -1
  196. package/lib/typescript/core/services/AuthService.d.ts +0 -50
  197. package/lib/typescript/core/services/AuthService.d.ts.map +0 -1
  198. package/lib/typescript/core/services/SessionTransportService.d.ts +0 -31
  199. package/lib/typescript/core/services/SessionTransportService.d.ts.map +0 -1
  200. package/lib/typescript/core/services/UserService.d.ts +0 -39
  201. package/lib/typescript/core/services/UserService.d.ts.map +0 -1
  202. package/lib/typescript/core/services/index.d.ts +0 -13
  203. package/lib/typescript/core/services/index.d.ts.map +0 -1
  204. package/lib/typescript/shared/crypto/messageBuilders.d.ts +0 -38
  205. package/lib/typescript/shared/crypto/messageBuilders.d.ts.map +0 -1
  206. package/lib/typescript/shared/crypto/platform.d.ts +0 -54
  207. package/lib/typescript/shared/crypto/platform.d.ts.map +0 -1
  208. package/lib/typescript/shared/crypto/signature.d.ts +0 -72
  209. package/lib/typescript/shared/crypto/signature.d.ts.map +0 -1
  210. package/lib/typescript/shared/index.d.ts +0 -20
  211. package/lib/typescript/shared/index.d.ts.map +0 -1
  212. package/lib/typescript/shared/models/index.d.ts +0 -163
  213. package/lib/typescript/shared/models/index.d.ts.map +0 -1
  214. package/lib/typescript/shared/transport/index.d.ts +0 -73
  215. package/lib/typescript/shared/transport/index.d.ts.map +0 -1
  216. package/lib/typescript/shared/utils/index.d.ts +0 -28
  217. package/lib/typescript/shared/utils/index.d.ts.map +0 -1
  218. package/src/core/services/AuthService.ts +0 -153
  219. package/src/core/services/SessionTransportService.ts +0 -69
  220. package/src/core/services/UserService.ts +0 -125
  221. package/src/core/services/index.ts +0 -14
  222. package/src/shared/crypto/messageBuilders.ts +0 -89
  223. package/src/shared/crypto/platform.ts +0 -140
  224. package/src/shared/crypto/signature.ts +0 -235
  225. package/src/shared/index.ts +0 -28
  226. package/src/shared/models/index.ts +0 -173
  227. package/src/shared/transport/index.ts +0 -349
  228. package/src/shared/utils/index.ts +0 -73
@@ -1 +0,0 @@
1
- {"version":3,"names":["shortenPublicKey","publicKey","length","slice","generateSessionToken","size","window","crypto","array","Uint8Array","getRandomValues","Array","from","byte","toString","padStart","join","process","versions","node","getCrypto","Function","randomBytes","Error","generateSessionTokenSync","bytesToHex","bytes","hexToBytes","hex","i","parseInt","substr"],"sourceRoot":"../../../../src","sources":["shared/utils/index.ts"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AAC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AM,IAAII,KAAK,CAAC,sDAAsD,CAAC;EACzE;;EAEA;EACA,MAAMH,SAAS,GAAG,IAAIC,QAAQ,CAAC,0BAA0B,CAAC;EAC1D,MAAMd,MAAM,GAAGa,SAAS,CAAC,CAAC;EAC1B,OAAOb,MAAM,CAACe,WAAW,CAACjB,IAAI,CAAC,CAACS,QAAQ,CAAC,KAAK,CAAC;AACjD;;AAEA;AACA;AACA;AACO,SAASW,UAAUA,CAACC,KAAiB,EAAU;EACpD,OAAOf,KAAK,CAACC,IAAI,CAACc,KAAK,EAAEb,IAAI,IAAIA,IAAI,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC;AAC/E;;AAEA;AACA;AACA;AACO,SAASW,UAAUA,CAACC,GAAW,EAAc;EAClD,MAAMF,KAAK,GAAG,IAAIjB,UAAU,CAACmB,GAAG,CAAC1B,MAAM,GAAG,CAAC,CAAC;EAC5C,KAAK,IAAI2B,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,GAAG,CAAC1B,MAAM,EAAE2B,CAAC,IAAI,CAAC,EAAE;IACtCH,KAAK,CAACG,CAAC,GAAG,CAAC,CAAC,GAAGC,QAAQ,CAACF,GAAG,CAACG,MAAM,CAACF,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;EAC/C;EACA,OAAOH,KAAK;AACd","ignoreList":[]}
@@ -1,151 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Auth Service
5
- *
6
- * Handles authentication operations:
7
- * - Challenge retrieval
8
- * - Signing orchestration (delegated to Accounts/KeyManager)
9
- * - Session verification
10
- * - Access token retrieval
11
- * - Registration
12
- */
13
-
14
- import { HttpService } from '../HttpService';
15
- import { SignatureService } from '../../crypto/signatureService';
16
- export class AuthService {
17
- constructor(config) {
18
- this.httpService = new HttpService(config);
19
- }
20
-
21
- /**
22
- * Check if a public key is registered on the server
23
- */
24
- async checkPublicKeyRegistered(publicKey) {
25
- try {
26
- return await this.httpService.request({
27
- method: 'GET',
28
- url: `/api/auth/check-publickey?publicKey=${encodeURIComponent(publicKey)}`,
29
- cache: true,
30
- cacheTTL: 2 * 60 * 1000
31
- });
32
- } catch (error) {
33
- throw error;
34
- }
35
- }
36
-
37
- /**
38
- * Request an authentication challenge
39
- */
40
- async requestChallenge(publicKey) {
41
- try {
42
- return await this.httpService.request({
43
- method: 'POST',
44
- url: '/api/auth/challenge',
45
- data: {
46
- publicKey
47
- },
48
- cache: false
49
- });
50
- } catch (error) {
51
- throw error;
52
- }
53
- }
54
-
55
- /**
56
- * Verify a challenge and authenticate (creates session)
57
- * This orchestrates signing via SignatureService (which uses KeyManager)
58
- */
59
- async verifyChallenge(challenge) {
60
- try {
61
- // Sign the challenge using SignatureService (requires private key)
62
- const signedChallenge = await SignatureService.signChallenge(challenge);
63
-
64
- // Verify challenge and get session
65
- return await this.httpService.request({
66
- method: 'POST',
67
- url: '/api/auth/verify',
68
- data: {
69
- publicKey: signedChallenge.publicKey,
70
- challenge: challenge,
71
- signature: signedChallenge.challenge,
72
- timestamp: signedChallenge.timestamp
73
- },
74
- cache: false
75
- });
76
- } catch (error) {
77
- throw error;
78
- }
79
- }
80
-
81
- /**
82
- * Register a new identity with the server
83
- */
84
- async register(publicKey, signature, timestamp, username, email) {
85
- try {
86
- return await this.httpService.request({
87
- method: 'POST',
88
- url: '/api/auth/register',
89
- data: {
90
- publicKey,
91
- signature,
92
- timestamp,
93
- username,
94
- email
95
- },
96
- cache: false
97
- });
98
- } catch (error) {
99
- throw error;
100
- }
101
- }
102
-
103
- /**
104
- * Register using current identity (signs automatically)
105
- */
106
- async registerCurrentIdentity(username, email) {
107
- try {
108
- const {
109
- signature,
110
- publicKey,
111
- timestamp
112
- } = await SignatureService.createRegistrationSignature();
113
- return this.register(publicKey, signature, timestamp, username, email);
114
- } catch (error) {
115
- throw error;
116
- }
117
- }
118
-
119
- /**
120
- * Get user by public key
121
- */
122
- async getUserByPublicKey(publicKey) {
123
- try {
124
- return await this.httpService.request({
125
- method: 'GET',
126
- url: `/api/auth/user/${encodeURIComponent(publicKey)}`,
127
- cache: true,
128
- cacheTTL: 2 * 60 * 1000
129
- });
130
- } catch (error) {
131
- throw error;
132
- }
133
- }
134
-
135
- /**
136
- * Get user by session ID
137
- */
138
- async getUserBySession(sessionId) {
139
- try {
140
- return await this.httpService.request({
141
- method: 'GET',
142
- url: `/api/auth/user/session/${encodeURIComponent(sessionId)}`,
143
- cache: true,
144
- cacheTTL: 2 * 60 * 1000
145
- });
146
- } catch (error) {
147
- throw error;
148
- }
149
- }
150
- }
151
- //# sourceMappingURL=AuthService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["HttpService","SignatureService","AuthService","constructor","config","httpService","checkPublicKeyRegistered","publicKey","request","method","url","encodeURIComponent","cache","cacheTTL","error","requestChallenge","data","verifyChallenge","challenge","signedChallenge","signChallenge","signature","timestamp","register","username","email","registerCurrentIdentity","createRegistrationSignature","getUserByPublicKey","getUserBySession","sessionId"],"sourceRoot":"../../../../src","sources":["core/services/AuthService.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,gBAAgB,QAAQ,+BAA+B;AAOhE,OAAO,MAAMC,WAAW,CAAC;EAGvBC,WAAWA,CAACC,MAAiB,EAAE;IAC7B,IAAI,CAACC,WAAW,GAAG,IAAIL,WAAW,CAACI,MAAM,CAAC;EAC5C;;EAEA;AACF;AACA;EACE,MAAME,wBAAwBA,CAACC,SAAiB,EAAmC;IACjF,IAAI;MACF,OAAO,MAAM,IAAI,CAACF,WAAW,CAACG,OAAO,CAAyB;QAC5DC,MAAM,EAAE,KAAK;QACbC,GAAG,EAAE,uCAAuCC,kBAAkB,CAACJ,SAAS,CAAC,EAAE;QAC3EK,KAAK,EAAE,IAAI;QACXC,QAAQ,EAAE,CAAC,G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F;AACF","ignoreList":[]}
@@ -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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,WAAW,QAAQ,gBAAgB;AAO5C,OAAO,MAAMC,WAAW,CAAC;EAGvBC,WAAWA,CAACC,MAAiB,EAAE;IAC7B,IAAI,CAACC,WAAW,GAAG,IAAIJ,WAAW,CAACG,MAAM,CAAC;EAC5C;;EAEA;AACF;AACA;EACE,MAAME,WAAWA,CAACC,MAAc,EAAiB;IAC/C,IAAI;MACF,OAAO,MAAM,IAAI,CAACF,WAAW,CAACG,OAAO,CAAO;QAC1CC,MAAM,EAAE,KAAK;QACbC,GAAG,EAAE,iBAAiBH,MAAM,EAAE;QAC9BI,KAAK,EAAE,IAAI;QACXC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG;MACrB,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,MAAMA,KAAK;IACb;EACF;;EAEA;AACF;AACA;EACE,MAAMC,oBAAoBA,CAACC,QAAgB,EAAiB;IAC1D,IAAI;MACF,OAAO,MAAM,IAAI,CAACV,WAAW,CAACG,OAAO,CAAO;QAC1CC,MAAM,EAAE,KAAK;QACbC,GAAG,EAAE,0BAA0BK,QAAQ,EAAE;QACzCJ,KAAK,EAAE,IAAI;QACXC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG;MACrB,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,MAAMA,KAAK;IACb;EACF;;EAEA;AACF;AACA;EACE,MAAMG,cAAcA,CAACC,KAAa,EAAEC,UAA6B,EAAmC;IAClG,IAAI;MACF,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAAC,CAAC;MACpCD,MAAM,CAACE,GAAG,CAAC,OAAO,EAAEJ,KAAK,CAAC;MAC1B,IAAIC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,GAAG,EAAE,GAAG;MACrB,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,MAAMA,KAAK;IACb;EACF;;EAEA;AACF;AACA;EACE,MAAMqB,aAAaA,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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,EACjBC,SAAiB,EACjBkB,SAAiB,EACjBjB,SAAiB,EACM;EACvB,OAAO;IACLD,SAAS;IACTD,SAAS;IACTmB,SAAS;IACTjB;EACF,CAAC;AACH;;AAEA;AACA;AACA;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,OAAO,MAAMA,gBAAgB,GAAG;EAC9B;AACF;AACA;EACEC,MAAMA,CAAA,EAAa;IACjB,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAI,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,QAAQ,EAAEC,IAAI,EAAE;MAC7F,OAAO,MAAM;IACf;IACA,IAAI,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,OAAO,KAAK,aAAa,EAAE;MAC3E,OAAO,cAAc;IACvB;IACA,OAAO,KAAK;EACd,CAAC;EAED;AACF;AACA;EACEC,MAAMA,CAAA,EAAY;IAChB,OAAO,IAAI,CAACP,MAAM,CAAC,CAAC,KAAK,MAAM;EACjC,CAAC;EAED;AACF;AACA;EACEQ,aAAaA,CAAA,EAAY;IACvB,OAAO,IAAI,CAACR,MAAM,CAAC,CAAC,KAAK,cAAc;EACzC,CAAC;EAED;AACF;AACA;EACES,KAAKA,CAAA,EAAY;IACf,OAAO,IAAI,CAACT,MAAM,CAAC,CAAC,KAAK,KAAK;EAChC;AACF,CAAC;;AAED;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA,OAAO,eAAeU,gBAAgBA,CAAA,EAA2B;EAC/D,MAAMC,QAAQ,GAAGZ,gBAAgB,CAACC,MAAM,CAAC,CAAC;EAE1C,IAAIW,QAAQ,KAAK,MAAM,EAAE;IACvB;IACA,MAAMC,SAAS,GAAG,IAAIC,QAAQ,CAAC,0BAA0B,CAAC;IAC1D,MAAMC,MAAM,GAAGF,SAAS,CAAC,CAAC;IAE1B,OAAO;MACL,MAAMG,WAAWA,CAACC,IAAY,EAAuB;QACnD,OAAO,IAAIC,UAAU,CAACH,MAAM,CAACC,WAAW,CAACC,IAAI,CAAC,CAAC;MACjD,CAAC;MAC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