@oxyhq/services 5.16.44 → 5.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (506) hide show
  1. package/README.md +29 -10
  2. package/lib/commonjs/core/OxyServices.js +1 -1
  3. package/lib/commonjs/core/index.js +20 -15
  4. package/lib/commonjs/core/index.js.map +1 -1
  5. package/lib/commonjs/core/mixins/OxyServices.auth.js +36 -53
  6. package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -1
  7. package/lib/commonjs/core/mixins/OxyServices.user.js +10 -17
  8. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  9. package/lib/commonjs/core/services/TokenService.js +27 -13
  10. package/lib/commonjs/core/services/TokenService.js.map +1 -1
  11. package/lib/commonjs/crypto/index.js +0 -16
  12. package/lib/commonjs/crypto/index.js.map +1 -1
  13. package/lib/commonjs/crypto/keyManager.js +21 -22
  14. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  15. package/lib/commonjs/crypto/polyfill.js +1 -10
  16. package/lib/commonjs/crypto/polyfill.js.map +1 -1
  17. package/lib/commonjs/crypto/signatureService.js +18 -32
  18. package/lib/commonjs/crypto/signatureService.js.map +1 -1
  19. package/lib/commonjs/index.js +13 -134
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/models/interfaces.js +0 -7
  22. package/lib/commonjs/models/interfaces.js.map +1 -1
  23. package/lib/commonjs/node/index.js +1 -10
  24. package/lib/commonjs/node/index.js.map +1 -1
  25. package/lib/commonjs/ui/components/BottomSheetRouter.js +1 -9
  26. package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
  27. package/lib/commonjs/ui/context/OxyContext.js +779 -450
  28. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  29. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +551 -0
  30. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -0
  31. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js +73 -0
  32. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js.map +1 -0
  33. package/lib/commonjs/ui/context/hooks/useStorage.js +79 -0
  34. package/lib/commonjs/ui/context/hooks/useStorage.js.map +1 -0
  35. package/lib/commonjs/ui/hooks/index.js +0 -20
  36. package/lib/commonjs/ui/hooks/index.js.map +1 -1
  37. package/lib/commonjs/ui/hooks/mutations/index.js +0 -12
  38. package/lib/commonjs/ui/hooks/mutations/index.js.map +1 -1
  39. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +23 -74
  40. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  41. package/lib/commonjs/ui/hooks/queries/index.js +0 -12
  42. package/lib/commonjs/ui/hooks/queries/index.js.map +1 -1
  43. package/lib/commonjs/ui/hooks/queries/queryKeys.js +1 -3
  44. package/lib/commonjs/ui/hooks/queries/queryKeys.js.map +1 -1
  45. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +28 -64
  46. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  47. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +6 -4
  48. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  49. package/lib/commonjs/ui/hooks/useDeviceManagement.js +73 -0
  50. package/lib/commonjs/ui/hooks/useDeviceManagement.js.map +1 -0
  51. package/lib/commonjs/ui/hooks/useProfileEditing.js +5 -3
  52. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  53. package/lib/commonjs/ui/hooks/useSessionManagement.js +284 -0
  54. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -0
  55. package/lib/commonjs/ui/index.js +2 -10
  56. package/lib/commonjs/ui/index.js.map +1 -1
  57. package/lib/commonjs/ui/navigation/routes.js +1 -5
  58. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  59. package/lib/commonjs/ui/screens/AccountCenterScreen.js +4 -9
  60. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  61. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +19 -37
  62. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  63. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +5 -5
  64. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  65. package/lib/commonjs/ui/screens/OxyAuthScreen.js +15 -2
  66. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  67. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +97 -76
  68. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  69. package/lib/commonjs/ui/screens/ProfileScreen.js +6 -6
  70. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  71. package/lib/commonjs/ui/stores/authStore.js +6 -54
  72. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  73. package/lib/commonjs/ui/styles/spacing.js +2 -54
  74. package/lib/commonjs/ui/styles/spacing.js.map +1 -1
  75. package/lib/commonjs/ui/utils/avatarUtils.js +12 -9
  76. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  77. package/lib/commonjs/ui/utils/sessionHelpers.js +1 -7
  78. package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
  79. package/lib/commonjs/utils/deviceManager.js +177 -0
  80. package/lib/commonjs/utils/deviceManager.js.map +1 -0
  81. package/lib/commonjs/utils/errorUtils.js +0 -13
  82. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  83. package/lib/commonjs/utils/index.js +7 -0
  84. package/lib/commonjs/utils/index.js.map +1 -1
  85. package/lib/commonjs/utils/sessionUtils.js +1 -8
  86. package/lib/commonjs/utils/sessionUtils.js.map +1 -1
  87. package/lib/commonjs/utils/validationUtils.js +1 -15
  88. package/lib/commonjs/utils/validationUtils.js.map +1 -1
  89. package/lib/module/core/OxyServices.js +1 -1
  90. package/lib/module/core/index.js +4 -6
  91. package/lib/module/core/index.js.map +1 -1
  92. package/lib/module/core/mixins/OxyServices.auth.js +36 -53
  93. package/lib/module/core/mixins/OxyServices.auth.js.map +1 -1
  94. package/lib/module/core/mixins/OxyServices.user.js +10 -17
  95. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  96. package/lib/module/core/services/TokenService.js +27 -13
  97. package/lib/module/core/services/TokenService.js.map +1 -1
  98. package/lib/module/crypto/index.js +0 -3
  99. package/lib/module/crypto/index.js.map +1 -1
  100. package/lib/module/crypto/keyManager.js +21 -22
  101. package/lib/module/crypto/keyManager.js.map +1 -1
  102. package/lib/module/crypto/polyfill.js +1 -2
  103. package/lib/module/crypto/polyfill.js.map +1 -1
  104. package/lib/module/crypto/signatureService.js +18 -32
  105. package/lib/module/crypto/signatureService.js.map +1 -1
  106. package/lib/module/index.js +7 -19
  107. package/lib/module/index.js.map +1 -1
  108. package/lib/module/models/interfaces.js +0 -7
  109. package/lib/module/models/interfaces.js.map +1 -1
  110. package/lib/module/node/index.js +0 -3
  111. package/lib/module/node/index.js.map +1 -1
  112. package/lib/module/ui/components/BottomSheetRouter.js +2 -6
  113. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  114. package/lib/module/ui/context/OxyContext.js +779 -450
  115. package/lib/module/ui/context/OxyContext.js.map +1 -1
  116. package/lib/module/ui/context/hooks/useAuthOperations.js +545 -0
  117. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -0
  118. package/lib/module/ui/context/hooks/useDeviceManagement.js +68 -0
  119. package/lib/module/ui/context/hooks/useDeviceManagement.js.map +1 -0
  120. package/lib/module/ui/context/hooks/useStorage.js +74 -0
  121. package/lib/module/ui/context/hooks/useStorage.js.map +1 -0
  122. package/lib/module/ui/hooks/index.js +0 -1
  123. package/lib/module/ui/hooks/index.js.map +1 -1
  124. package/lib/module/ui/hooks/mutations/index.js +1 -1
  125. package/lib/module/ui/hooks/mutations/index.js.map +1 -1
  126. package/lib/module/ui/hooks/mutations/useAccountMutations.js +21 -71
  127. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  128. package/lib/module/ui/hooks/queries/index.js +1 -1
  129. package/lib/module/ui/hooks/queries/index.js.map +1 -1
  130. package/lib/module/ui/hooks/queries/queryKeys.js +1 -3
  131. package/lib/module/ui/hooks/queries/queryKeys.js.map +1 -1
  132. package/lib/module/ui/hooks/queries/useAccountQueries.js +27 -61
  133. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  134. package/lib/module/ui/hooks/queries/useServicesQueries.js +6 -4
  135. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  136. package/lib/module/ui/hooks/useDeviceManagement.js +68 -0
  137. package/lib/module/ui/hooks/useDeviceManagement.js.map +1 -0
  138. package/lib/module/ui/hooks/useProfileEditing.js +5 -3
  139. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  140. package/lib/module/ui/hooks/useSessionManagement.js +279 -0
  141. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -0
  142. package/lib/module/ui/index.js +1 -2
  143. package/lib/module/ui/index.js.map +1 -1
  144. package/lib/module/ui/navigation/routes.js +1 -5
  145. package/lib/module/ui/navigation/routes.js.map +1 -1
  146. package/lib/module/ui/screens/AccountCenterScreen.js +4 -9
  147. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  148. package/lib/module/ui/screens/AccountSettingsScreen.js +19 -37
  149. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  150. package/lib/module/ui/screens/AccountSwitcherScreen.js +5 -5
  151. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  152. package/lib/module/ui/screens/OxyAuthScreen.js +15 -2
  153. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  154. package/lib/module/ui/screens/PrivacySettingsScreen.js +98 -77
  155. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  156. package/lib/module/ui/screens/ProfileScreen.js +6 -6
  157. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  158. package/lib/module/ui/stores/authStore.js +6 -54
  159. package/lib/module/ui/stores/authStore.js.map +1 -1
  160. package/lib/module/ui/styles/spacing.js +2 -6
  161. package/lib/module/ui/styles/spacing.js.map +1 -1
  162. package/lib/module/ui/utils/avatarUtils.js +12 -9
  163. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  164. package/lib/module/ui/utils/sessionHelpers.js +1 -7
  165. package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
  166. package/lib/module/utils/deviceManager.js +171 -0
  167. package/lib/module/utils/deviceManager.js.map +1 -0
  168. package/lib/module/utils/errorUtils.js +0 -7
  169. package/lib/module/utils/errorUtils.js.map +1 -1
  170. package/lib/module/utils/index.js +1 -2
  171. package/lib/module/utils/index.js.map +1 -1
  172. package/lib/module/utils/sessionUtils.js +1 -8
  173. package/lib/module/utils/sessionUtils.js.map +1 -1
  174. package/lib/module/utils/validationUtils.js +0 -13
  175. package/lib/module/utils/validationUtils.js.map +1 -1
  176. package/lib/typescript/core/OxyServices.d.ts +1 -1
  177. package/lib/typescript/core/index.d.ts +3 -3
  178. package/lib/typescript/core/index.d.ts.map +1 -1
  179. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +21 -44
  180. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  181. package/lib/typescript/core/mixins/OxyServices.user.d.ts +1 -0
  182. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  183. package/lib/typescript/core/mixins/index.d.ts +8 -15
  184. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  185. package/lib/typescript/core/services/TokenService.d.ts.map +1 -1
  186. package/lib/typescript/crypto/index.d.ts +0 -1
  187. package/lib/typescript/crypto/index.d.ts.map +1 -1
  188. package/lib/typescript/crypto/keyManager.d.ts +2 -15
  189. package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
  190. package/lib/typescript/crypto/polyfill.d.ts +1 -2
  191. package/lib/typescript/crypto/polyfill.d.ts.map +1 -1
  192. package/lib/typescript/crypto/signatureService.d.ts +0 -13
  193. package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
  194. package/lib/typescript/index.d.ts +7 -12
  195. package/lib/typescript/index.d.ts.map +1 -1
  196. package/lib/typescript/models/interfaces.d.ts +36 -5
  197. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  198. package/lib/typescript/models/session.d.ts +18 -3
  199. package/lib/typescript/models/session.d.ts.map +1 -1
  200. package/lib/typescript/node/index.d.ts +0 -1
  201. package/lib/typescript/node/index.d.ts.map +1 -1
  202. package/lib/typescript/ui/components/BottomSheetRouter.d.ts +0 -5
  203. package/lib/typescript/ui/components/BottomSheetRouter.d.ts.map +1 -1
  204. package/lib/typescript/ui/components/TextField/Addons/Outline.d.ts +2 -2
  205. package/lib/typescript/ui/components/TextField/helpers.d.ts +2 -2
  206. package/lib/typescript/ui/components/TextField/types.d.ts +0 -1
  207. package/lib/typescript/ui/components/TextField/types.d.ts.map +1 -1
  208. package/lib/typescript/ui/context/OxyContext.d.ts +28 -5
  209. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  210. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +59 -0
  211. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -0
  212. package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts +27 -0
  213. package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts.map +1 -0
  214. package/lib/typescript/ui/context/hooks/useStorage.d.ts +22 -0
  215. package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +1 -0
  216. package/lib/typescript/ui/hooks/index.d.ts +0 -1
  217. package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
  218. package/lib/typescript/ui/hooks/mutations/index.d.ts +1 -1
  219. package/lib/typescript/ui/hooks/mutations/index.d.ts.map +1 -1
  220. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +8 -19
  221. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  222. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts +1 -1
  223. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -1
  224. package/lib/typescript/ui/hooks/queries/index.d.ts +1 -1
  225. package/lib/typescript/ui/hooks/queries/index.d.ts.map +1 -1
  226. package/lib/typescript/ui/hooks/queries/queryKeys.d.ts +0 -2
  227. package/lib/typescript/ui/hooks/queries/queryKeys.d.ts.map +1 -1
  228. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +5 -17
  229. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  230. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  231. package/lib/typescript/ui/hooks/useDeviceManagement.d.ts +27 -0
  232. package/lib/typescript/ui/hooks/useDeviceManagement.d.ts.map +1 -0
  233. package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
  234. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +41 -0
  235. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -0
  236. package/lib/typescript/ui/index.d.ts +0 -1
  237. package/lib/typescript/ui/index.d.ts.map +1 -1
  238. package/lib/typescript/ui/navigation/routes.d.ts +1 -1
  239. package/lib/typescript/ui/navigation/routes.d.ts.map +1 -1
  240. package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
  241. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  242. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  243. package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  244. package/lib/typescript/ui/stores/authStore.d.ts +1 -8
  245. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  246. package/lib/typescript/ui/styles/spacing.d.ts +0 -5
  247. package/lib/typescript/ui/styles/spacing.d.ts.map +1 -1
  248. package/lib/typescript/ui/utils/avatarUtils.d.ts +4 -1
  249. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  250. package/lib/typescript/ui/utils/sessionHelpers.d.ts +0 -1
  251. package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
  252. package/lib/typescript/utils/deviceManager.d.ts +66 -0
  253. package/lib/typescript/utils/deviceManager.d.ts.map +1 -0
  254. package/lib/typescript/utils/errorUtils.d.ts +0 -6
  255. package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
  256. package/lib/typescript/utils/index.d.ts +2 -0
  257. package/lib/typescript/utils/index.d.ts.map +1 -1
  258. package/lib/typescript/utils/sessionUtils.d.ts.map +1 -1
  259. package/lib/typescript/utils/validationUtils.d.ts +0 -8
  260. package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
  261. package/package.json +1 -6
  262. package/src/core/OxyServices.ts +1 -1
  263. package/src/core/index.ts +5 -8
  264. package/src/core/mixins/OxyServices.auth.ts +44 -87
  265. package/src/core/mixins/OxyServices.user.ts +10 -18
  266. package/src/core/services/TokenService.ts +27 -16
  267. package/src/crypto/index.ts +1 -3
  268. package/src/crypto/keyManager.ts +21 -30
  269. package/src/crypto/polyfill.ts +1 -2
  270. package/src/crypto/signatureService.ts +19 -43
  271. package/src/index.ts +6 -41
  272. package/src/models/interfaces.ts +39 -12
  273. package/src/models/session.ts +19 -7
  274. package/src/node/index.ts +0 -3
  275. package/src/ui/components/BottomSheetRouter.tsx +1 -6
  276. package/src/ui/components/TextField/Addons/Outline.tsx +2 -2
  277. package/src/ui/components/TextField/helpers.tsx +2 -2
  278. package/src/ui/components/TextField/types.tsx +1 -1
  279. package/src/ui/context/OxyContext.tsx +831 -463
  280. package/src/ui/context/hooks/useAuthOperations.ts +620 -0
  281. package/src/ui/context/hooks/useDeviceManagement.ts +108 -0
  282. package/src/ui/context/hooks/useStorage.ts +104 -0
  283. package/src/ui/hooks/index.ts +1 -2
  284. package/src/ui/hooks/mutations/index.ts +0 -2
  285. package/src/ui/hooks/mutations/useAccountMutations.ts +20 -66
  286. package/src/ui/hooks/queries/index.ts +0 -2
  287. package/src/ui/hooks/queries/queryKeys.ts +0 -2
  288. package/src/ui/hooks/queries/useAccountQueries.ts +19 -53
  289. package/src/ui/hooks/queries/useServicesQueries.ts +5 -5
  290. package/src/ui/hooks/useDeviceManagement.ts +108 -0
  291. package/src/ui/hooks/useProfileEditing.ts +3 -3
  292. package/src/ui/hooks/useSessionManagement.ts +405 -0
  293. package/src/ui/index.ts +1 -2
  294. package/src/ui/navigation/routes.ts +2 -6
  295. package/src/ui/screens/AccountCenterScreen.tsx +4 -9
  296. package/src/ui/screens/AccountSettingsScreen.tsx +31 -49
  297. package/src/ui/screens/AccountSwitcherScreen.tsx +5 -5
  298. package/src/ui/screens/OxyAuthScreen.tsx +19 -4
  299. package/src/ui/screens/PrivacySettingsScreen.tsx +101 -67
  300. package/src/ui/screens/ProfileScreen.tsx +10 -10
  301. package/src/ui/stores/authStore.ts +8 -48
  302. package/src/ui/styles/spacing.ts +2 -15
  303. package/src/ui/utils/avatarUtils.ts +21 -19
  304. package/src/ui/utils/sessionHelpers.ts +0 -7
  305. package/src/utils/__tests__/validationUtils.test.ts +1 -16
  306. package/src/utils/deviceManager.ts +198 -0
  307. package/src/utils/errorUtils.ts +1 -8
  308. package/src/utils/index.ts +2 -1
  309. package/src/utils/sessionUtils.ts +0 -8
  310. package/src/utils/validationUtils.ts +0 -12
  311. package/lib/commonjs/adapters/expo/crypto.js +0 -56
  312. package/lib/commonjs/adapters/expo/crypto.js.map +0 -1
  313. package/lib/commonjs/adapters/expo/fetch.js +0 -30
  314. package/lib/commonjs/adapters/expo/fetch.js.map +0 -1
  315. package/lib/commonjs/adapters/expo/index.js +0 -48
  316. package/lib/commonjs/adapters/expo/index.js.map +0 -1
  317. package/lib/commonjs/adapters/expo/storage.js +0 -201
  318. package/lib/commonjs/adapters/expo/storage.js.map +0 -1
  319. package/lib/commonjs/adapters/index.js +0 -48
  320. package/lib/commonjs/adapters/index.js.map +0 -1
  321. package/lib/commonjs/adapters/node/crypto.js +0 -40
  322. package/lib/commonjs/adapters/node/crypto.js.map +0 -1
  323. package/lib/commonjs/adapters/node/fetch.js +0 -62
  324. package/lib/commonjs/adapters/node/fetch.js.map +0 -1
  325. package/lib/commonjs/adapters/node/index.js +0 -34
  326. package/lib/commonjs/adapters/node/index.js.map +0 -1
  327. package/lib/commonjs/adapters/node/storage.js +0 -163
  328. package/lib/commonjs/adapters/node/storage.js.map +0 -1
  329. package/lib/commonjs/core/identity-session/DeviceManager.js +0 -237
  330. package/lib/commonjs/core/identity-session/DeviceManager.js.map +0 -1
  331. package/lib/commonjs/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  332. package/lib/commonjs/core/identity-session/IdentityManager.js +0 -400
  333. package/lib/commonjs/core/identity-session/IdentityManager.js.map +0 -1
  334. package/lib/commonjs/core/identity-session/IdentitySessionCore.js +0 -394
  335. package/lib/commonjs/core/identity-session/IdentitySessionCore.js.map +0 -1
  336. package/lib/commonjs/core/identity-session/RefreshManager.js +0 -137
  337. package/lib/commonjs/core/identity-session/RefreshManager.js.map +0 -1
  338. package/lib/commonjs/core/identity-session/SessionManager.js +0 -427
  339. package/lib/commonjs/core/identity-session/SessionManager.js.map +0 -1
  340. package/lib/commonjs/core/identity-session/createIdentitySessionCore.js +0 -24
  341. package/lib/commonjs/core/identity-session/createIdentitySessionCore.js.map +0 -1
  342. package/lib/commonjs/core/identity-session/errors.js +0 -176
  343. package/lib/commonjs/core/identity-session/errors.js.map +0 -1
  344. package/lib/commonjs/core/identity-session/index.js +0 -80
  345. package/lib/commonjs/core/identity-session/index.js.map +0 -1
  346. package/lib/commonjs/core/identity-session/types.js +0 -2
  347. package/lib/commonjs/core/identity-session/types.js.map +0 -1
  348. package/lib/commonjs/crypto/README.md +0 -142
  349. package/lib/commonjs/crypto/core.js +0 -147
  350. package/lib/commonjs/crypto/core.js.map +0 -1
  351. package/lib/commonjs/node/signatureService.js +0 -107
  352. package/lib/commonjs/node/signatureService.js.map +0 -1
  353. package/lib/commonjs/ui/hooks/auth/index.js +0 -37
  354. package/lib/commonjs/ui/hooks/auth/index.js.map +0 -1
  355. package/lib/commonjs/ui/hooks/auth/useUsernameValidation.js +0 -171
  356. package/lib/commonjs/ui/hooks/auth/useUsernameValidation.js.map +0 -1
  357. package/lib/commonjs/ui/hooks/useAvatarPicker.js +0 -52
  358. package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +0 -1
  359. package/lib/commonjs/ui/hooks/useIdentityTransfer.js +0 -125
  360. package/lib/commonjs/ui/hooks/useIdentityTransfer.js.map +0 -1
  361. package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js +0 -81
  362. package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js.map +0 -1
  363. package/lib/commonjs/ui/hooks/useTransferQueries.js +0 -85
  364. package/lib/commonjs/ui/hooks/useTransferQueries.js.map +0 -1
  365. package/lib/commonjs/ui/stores/transferStore.js +0 -157
  366. package/lib/commonjs/ui/stores/transferStore.js.map +0 -1
  367. package/lib/module/adapters/expo/crypto.js +0 -51
  368. package/lib/module/adapters/expo/crypto.js.map +0 -1
  369. package/lib/module/adapters/expo/fetch.js +0 -26
  370. package/lib/module/adapters/expo/fetch.js.map +0 -1
  371. package/lib/module/adapters/expo/index.js +0 -45
  372. package/lib/module/adapters/expo/index.js.map +0 -1
  373. package/lib/module/adapters/expo/storage.js +0 -198
  374. package/lib/module/adapters/expo/storage.js.map +0 -1
  375. package/lib/module/adapters/index.js +0 -45
  376. package/lib/module/adapters/index.js.map +0 -1
  377. package/lib/module/adapters/node/crypto.js +0 -36
  378. package/lib/module/adapters/node/crypto.js.map +0 -1
  379. package/lib/module/adapters/node/fetch.js +0 -57
  380. package/lib/module/adapters/node/fetch.js.map +0 -1
  381. package/lib/module/adapters/node/index.js +0 -31
  382. package/lib/module/adapters/node/index.js.map +0 -1
  383. package/lib/module/adapters/node/storage.js +0 -159
  384. package/lib/module/adapters/node/storage.js.map +0 -1
  385. package/lib/module/core/identity-session/DeviceManager.js +0 -232
  386. package/lib/module/core/identity-session/DeviceManager.js.map +0 -1
  387. package/lib/module/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  388. package/lib/module/core/identity-session/IdentityManager.js +0 -395
  389. package/lib/module/core/identity-session/IdentityManager.js.map +0 -1
  390. package/lib/module/core/identity-session/IdentitySessionCore.js +0 -390
  391. package/lib/module/core/identity-session/IdentitySessionCore.js.map +0 -1
  392. package/lib/module/core/identity-session/RefreshManager.js +0 -132
  393. package/lib/module/core/identity-session/RefreshManager.js.map +0 -1
  394. package/lib/module/core/identity-session/SessionManager.js +0 -422
  395. package/lib/module/core/identity-session/SessionManager.js.map +0 -1
  396. package/lib/module/core/identity-session/createIdentitySessionCore.js +0 -21
  397. package/lib/module/core/identity-session/createIdentitySessionCore.js.map +0 -1
  398. package/lib/module/core/identity-session/errors.js +0 -170
  399. package/lib/module/core/identity-session/errors.js.map +0 -1
  400. package/lib/module/core/identity-session/index.js +0 -17
  401. package/lib/module/core/identity-session/index.js.map +0 -1
  402. package/lib/module/core/identity-session/types.js +0 -2
  403. package/lib/module/core/identity-session/types.js.map +0 -1
  404. package/lib/module/crypto/README.md +0 -142
  405. package/lib/module/crypto/core.js +0 -133
  406. package/lib/module/crypto/core.js.map +0 -1
  407. package/lib/module/node/signatureService.js +0 -101
  408. package/lib/module/node/signatureService.js.map +0 -1
  409. package/lib/module/ui/hooks/auth/index.js +0 -7
  410. package/lib/module/ui/hooks/auth/index.js.map +0 -1
  411. package/lib/module/ui/hooks/auth/useUsernameValidation.js +0 -167
  412. package/lib/module/ui/hooks/auth/useUsernameValidation.js.map +0 -1
  413. package/lib/module/ui/hooks/useAvatarPicker.js +0 -48
  414. package/lib/module/ui/hooks/useAvatarPicker.js.map +0 -1
  415. package/lib/module/ui/hooks/useIdentityTransfer.js +0 -121
  416. package/lib/module/ui/hooks/useIdentityTransfer.js.map +0 -1
  417. package/lib/module/ui/hooks/useTransferCodesPersistence.js +0 -77
  418. package/lib/module/ui/hooks/useTransferCodesPersistence.js.map +0 -1
  419. package/lib/module/ui/hooks/useTransferQueries.js +0 -80
  420. package/lib/module/ui/hooks/useTransferQueries.js.map +0 -1
  421. package/lib/module/ui/stores/transferStore.js +0 -152
  422. package/lib/module/ui/stores/transferStore.js.map +0 -1
  423. package/lib/typescript/adapters/expo/crypto.d.ts +0 -17
  424. package/lib/typescript/adapters/expo/crypto.d.ts.map +0 -1
  425. package/lib/typescript/adapters/expo/fetch.d.ts +0 -16
  426. package/lib/typescript/adapters/expo/fetch.d.ts.map +0 -1
  427. package/lib/typescript/adapters/expo/index.d.ts +0 -23
  428. package/lib/typescript/adapters/expo/index.d.ts.map +0 -1
  429. package/lib/typescript/adapters/expo/storage.d.ts +0 -23
  430. package/lib/typescript/adapters/expo/storage.d.ts.map +0 -1
  431. package/lib/typescript/adapters/index.d.ts +0 -17
  432. package/lib/typescript/adapters/index.d.ts.map +0 -1
  433. package/lib/typescript/adapters/node/crypto.d.ts +0 -17
  434. package/lib/typescript/adapters/node/crypto.d.ts.map +0 -1
  435. package/lib/typescript/adapters/node/fetch.d.ts +0 -16
  436. package/lib/typescript/adapters/node/fetch.d.ts.map +0 -1
  437. package/lib/typescript/adapters/node/index.d.ts +0 -23
  438. package/lib/typescript/adapters/node/index.d.ts.map +0 -1
  439. package/lib/typescript/adapters/node/storage.d.ts +0 -23
  440. package/lib/typescript/adapters/node/storage.d.ts.map +0 -1
  441. package/lib/typescript/core/identity-session/DeviceManager.d.ts +0 -64
  442. package/lib/typescript/core/identity-session/DeviceManager.d.ts.map +0 -1
  443. package/lib/typescript/core/identity-session/IdentityManager.d.ts +0 -88
  444. package/lib/typescript/core/identity-session/IdentityManager.d.ts.map +0 -1
  445. package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts +0 -141
  446. package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts.map +0 -1
  447. package/lib/typescript/core/identity-session/RefreshManager.d.ts +0 -36
  448. package/lib/typescript/core/identity-session/RefreshManager.d.ts.map +0 -1
  449. package/lib/typescript/core/identity-session/SessionManager.d.ts +0 -104
  450. package/lib/typescript/core/identity-session/SessionManager.d.ts.map +0 -1
  451. package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts +0 -11
  452. package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts.map +0 -1
  453. package/lib/typescript/core/identity-session/errors.d.ts +0 -63
  454. package/lib/typescript/core/identity-session/errors.d.ts.map +0 -1
  455. package/lib/typescript/core/identity-session/index.d.ts +0 -14
  456. package/lib/typescript/core/identity-session/index.d.ts.map +0 -1
  457. package/lib/typescript/core/identity-session/types.d.ts +0 -196
  458. package/lib/typescript/core/identity-session/types.d.ts.map +0 -1
  459. package/lib/typescript/crypto/core.d.ts +0 -56
  460. package/lib/typescript/crypto/core.d.ts.map +0 -1
  461. package/lib/typescript/node/signatureService.d.ts +0 -55
  462. package/lib/typescript/node/signatureService.d.ts.map +0 -1
  463. package/lib/typescript/ui/hooks/auth/index.d.ts +0 -6
  464. package/lib/typescript/ui/hooks/auth/index.d.ts.map +0 -1
  465. package/lib/typescript/ui/hooks/auth/useUsernameValidation.d.ts +0 -32
  466. package/lib/typescript/ui/hooks/auth/useUsernameValidation.d.ts.map +0 -1
  467. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +0 -18
  468. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +0 -1
  469. package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts +0 -24
  470. package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts.map +0 -1
  471. package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts +0 -6
  472. package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts.map +0 -1
  473. package/lib/typescript/ui/hooks/useTransferQueries.d.ts +0 -26
  474. package/lib/typescript/ui/hooks/useTransferQueries.d.ts.map +0 -1
  475. package/lib/typescript/ui/stores/transferStore.d.ts +0 -36
  476. package/lib/typescript/ui/stores/transferStore.d.ts.map +0 -1
  477. package/src/adapters/expo/crypto.ts +0 -55
  478. package/src/adapters/expo/fetch.ts +0 -28
  479. package/src/adapters/expo/index.ts +0 -51
  480. package/src/adapters/expo/storage.ts +0 -228
  481. package/src/adapters/index.ts +0 -48
  482. package/src/adapters/node/crypto.ts +0 -39
  483. package/src/adapters/node/fetch.ts +0 -59
  484. package/src/adapters/node/index.ts +0 -37
  485. package/src/adapters/node/storage.ts +0 -170
  486. package/src/core/identity-session/DeviceManager.ts +0 -273
  487. package/src/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  488. package/src/core/identity-session/IdentityManager.ts +0 -474
  489. package/src/core/identity-session/IdentitySessionCore.ts +0 -464
  490. package/src/core/identity-session/RefreshManager.ts +0 -189
  491. package/src/core/identity-session/SessionManager.ts +0 -500
  492. package/src/core/identity-session/createIdentitySessionCore.ts +0 -19
  493. package/src/core/identity-session/errors.ts +0 -197
  494. package/src/core/identity-session/index.ts +0 -15
  495. package/src/core/identity-session/types.ts +0 -188
  496. package/src/crypto/README.md +0 -142
  497. package/src/crypto/__tests__/core.test.ts +0 -203
  498. package/src/crypto/core.ts +0 -142
  499. package/src/node/signatureService.ts +0 -126
  500. package/src/ui/hooks/auth/index.ts +0 -9
  501. package/src/ui/hooks/auth/useUsernameValidation.ts +0 -177
  502. package/src/ui/hooks/useAvatarPicker.ts +0 -62
  503. package/src/ui/hooks/useIdentityTransfer.ts +0 -135
  504. package/src/ui/hooks/useTransferCodesPersistence.ts +0 -80
  505. package/src/ui/hooks/useTransferQueries.ts +0 -102
  506. package/src/ui/stores/transferStore.ts +0 -201
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["core/identity-session/types.ts"],"mappings":"","ignoreList":[]}
@@ -1,142 +0,0 @@
1
- # Oxy Crypto Module
2
-
3
- This module provides cryptographic operations for the Oxy ecosystem, supporting both React Native and Node.js environments.
4
-
5
- ## Architecture
6
-
7
- The crypto module is organized into several layers:
8
-
9
- ### Core Layer (`core.ts`)
10
- Platform-agnostic cryptographic functions that work everywhere:
11
- - Signature verification using elliptic curve cryptography
12
- - Public/private key validation
13
- - Message formatting (auth, registration, requests)
14
- - Utility functions (shortenPublicKey, derivePublicKey, etc.)
15
-
16
- ### Platform-Specific Implementations
17
-
18
- #### React Native (`signatureService.ts`, `keyManager.ts`)
19
- - **KeyManager**: Manages ECDSA key pairs with secure storage via Expo SecureStore
20
- - ⚠️ **For Oxy Accounts app only** - Not intended for third-party apps
21
- - Handles key generation, import, backup, and secure retrieval
22
- - Private keys never leave the device
23
-
24
- - **SignatureService**: Provides async signing and verification
25
- - Uses `expo-crypto` for hashing in React Native
26
- - Falls back to Node.js crypto when available
27
- - Suitable for both React Native and Node.js environments
28
-
29
- #### Node.js (`node/signatureService.ts`)
30
- - Optimized synchronous signature operations for backend
31
- - Uses Node's `crypto` module directly for better performance
32
- - Exports same API as React Native version for consistency
33
-
34
- ## Usage
35
-
36
- ### In React Native / Accounts App
37
-
38
- ```typescript
39
- import { KeyManager, SignatureService } from '@oxyhq/services/crypto';
40
-
41
- // Create identity (Accounts app only)
42
- const publicKey = await KeyManager.createIdentity();
43
-
44
- // Sign a challenge
45
- const signature = await SignatureService.sign(message);
46
-
47
- // Verify a signature
48
- const isValid = await SignatureService.verify(message, signature, publicKey);
49
- ```
50
-
51
- ### In Node.js Backend
52
-
53
- ```typescript
54
- import { SignatureService } from '@oxyhq/services/node';
55
-
56
- // Generate challenge
57
- const challenge = SignatureService.generateChallenge();
58
-
59
- // Verify signature (synchronous)
60
- const isValid = SignatureService.verifyChallengeResponse(
61
- publicKey,
62
- challenge,
63
- signature,
64
- timestamp
65
- );
66
- ```
67
-
68
- ### In Third-Party Apps (Services SDK)
69
-
70
- Third-party apps should **not** use KeyManager directly. Instead, use the authentication flows provided by the OxyServices class:
71
-
72
- ```typescript
73
- import { OxyServices } from '@oxyhq/services';
74
-
75
- const oxy = new OxyServices({ baseURL: 'https://api.oxy.so' });
76
-
77
- // Request authentication (shows QR code / deep link)
78
- // User approves in Oxy Accounts app
79
- // Returns session when approved
80
- const session = await oxy.requestAuth({ appId: 'my-app' });
81
- ```
82
-
83
- ## Security Considerations
84
-
85
- ### Message Formats
86
- All signed messages follow specific formats to prevent replay attacks:
87
-
88
- - **Authentication**: `auth:{publicKey}:{challenge}:{timestamp}`
89
- - **Registration**: `oxy:register:{publicKey}:{timestamp}`
90
- - **API Requests**: `request:{publicKey}:{timestamp}:{canonicalData}`
91
-
92
- Timestamps must be within 5 minutes to be valid.
93
-
94
- ### Key Storage
95
- - Private keys are stored in device secure storage (iOS Keychain, Android Keystore)
96
- - Never transmitted or exposed outside the device
97
- - Only the Oxy Accounts app has access to private keys
98
-
99
- ### Backup Encryption
100
- ⚠️ **Current Implementation**: The backup encryption currently uses a custom XOR scheme with key stretching. This is functional but not optimal.
101
-
102
- 📋 **Planned Improvement**: Migrate to standard AES-256-GCM encryption for better security and interoperability.
103
-
104
- ## Separation of Concerns
105
-
106
- ### Oxy Accounts App
107
- - Owns and manages the user's private key
108
- - Handles identity creation, backup, and recovery
109
- - Signs authentication challenges
110
- - Uses `KeyManager` and `SignatureService`
111
-
112
- ### Services SDK / Third-Party Apps
113
- - Does NOT generate or store private keys
114
- - Displays QR codes and deep links for authentication
115
- - Polls server for authentication status
116
- - Uses `OxyServices` class for API communication
117
-
118
- ### API Backend
119
- - Generates challenges
120
- - Verifies signatures using public keys
121
- - Manages sessions and user data
122
- - Uses `SignatureService` from `@oxyhq/services/node`
123
-
124
- ## Migration from Old Signature Service
125
-
126
- The API previously had a duplicate `signature.service.ts` file. This has been replaced with a re-export from `@oxyhq/services/node` to ensure consistency and eliminate duplication.
127
-
128
- If you're maintaining code that imports from the old location, it will continue to work as the file now re-exports from the shared module.
129
-
130
- ## Testing
131
-
132
- When making changes to crypto code:
133
- 1. Test in both React Native and Node.js environments
134
- 2. Verify signatures created in one environment can be verified in another
135
- 3. Check that timestamps are properly validated
136
- 4. Ensure message formats match exactly between client and server
137
-
138
- ## Further Reading
139
-
140
- - [Public Key Authentication Guide](../docs/PUBLIC_KEY_AUTHENTICATION.md)
141
- - [ECDSA on secp256k1](https://en.bitcoin.it/wiki/Secp256k1)
142
- - [Expo SecureStore Documentation](https://docs.expo.dev/versions/latest/sdk/securestore/)
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Core Cryptographic Functions - Platform Agnostic
5
- *
6
- * This module contains the core signature verification logic
7
- * that is shared between all platforms (React Native, Node.js, Web).
8
- * Platform-specific implementations (hashing, random generation) are injected.
9
- */
10
-
11
- import { ec as EC } from 'elliptic';
12
- const ec = new EC('secp256k1');
13
-
14
- // Constants for signature validation
15
- export const CHALLENGE_TTL_MS = 5 * 60 * 1000; // 5 minutes
16
- export const MAX_SIGNATURE_AGE_MS = 5 * 60 * 1000; // 5 minutes
17
-
18
- /**
19
- * Core signature verification using elliptic curve
20
- * This is platform-agnostic and works everywhere
21
- */
22
- export function verifySignatureCore(messageHash, signature, publicKey) {
23
- try {
24
- const key = ec.keyFromPublic(publicKey, 'hex');
25
- return key.verify(messageHash, signature);
26
- } catch {
27
- return false;
28
- }
29
- }
30
-
31
- /**
32
- * Validate that a string is a valid public key
33
- */
34
- export function isValidPublicKey(publicKey) {
35
- // Reject empty strings
36
- if (!publicKey || publicKey.trim().length === 0) {
37
- return false;
38
- }
39
- try {
40
- ec.keyFromPublic(publicKey, 'hex');
41
- return true;
42
- } catch {
43
- return false;
44
- }
45
- }
46
-
47
- /**
48
- * Validate that a string is a valid private key
49
- */
50
- export function isValidPrivateKey(privateKey) {
51
- // Reject empty strings
52
- if (!privateKey || privateKey.trim().length === 0) {
53
- return false;
54
- }
55
-
56
- // Private keys must be 64 hex characters (32 bytes)
57
- if (!/^[0-9a-fA-F]{64}$/.test(privateKey)) {
58
- return false;
59
- }
60
- try {
61
- const keyPair = ec.keyFromPrivate(privateKey);
62
- // Verify it can derive a public key and the key is valid
63
- keyPair.getPublic('hex');
64
- // Check that the private key is not zero (which would be invalid)
65
- const priv = keyPair.getPrivate();
66
- if (!priv || priv.isZero()) {
67
- return false;
68
- }
69
- return true;
70
- } catch {
71
- return false;
72
- }
73
- }
74
-
75
- /**
76
- * Get a shortened display version of a public key
77
- * Format: first 8 chars...last 8 chars
78
- */
79
- export function shortenPublicKey(publicKey) {
80
- if (publicKey.length <= 20) return publicKey;
81
- return `${publicKey.slice(0, 8)}...${publicKey.slice(-8)}`;
82
- }
83
-
84
- /**
85
- * Derive public key from a private key (without storing)
86
- */
87
- export function derivePublicKey(privateKey) {
88
- const keyPair = ec.keyFromPrivate(privateKey);
89
- return keyPair.getPublic('hex');
90
- }
91
-
92
- /**
93
- * Check timestamp freshness
94
- */
95
- export function isTimestampFresh(timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
96
- const now = Date.now();
97
- return now - timestamp <= maxAgeMs;
98
- }
99
-
100
- /**
101
- * Build authentication challenge message
102
- * Format: auth:{publicKey}:{challenge}:{timestamp}
103
- */
104
- export function buildAuthMessage(publicKey, challenge, timestamp) {
105
- return `auth:${publicKey}:${challenge}:${timestamp}`;
106
- }
107
-
108
- /**
109
- * Build registration message
110
- * Format: oxy:register:{publicKey}:{timestamp}
111
- */
112
- export function buildRegistrationMessage(publicKey, timestamp) {
113
- return `oxy:register:${publicKey}:${timestamp}`;
114
- }
115
-
116
- /**
117
- * Build request signature message
118
- * Format: request:{publicKey}:{timestamp}:{canonicalString}
119
- */
120
- export function buildRequestMessage(publicKey, timestamp, data) {
121
- const sortedKeys = Object.keys(data).sort();
122
- const canonicalParts = sortedKeys.map(key => `${key}:${JSON.stringify(data[key])}`);
123
- const canonicalString = canonicalParts.join('|');
124
- return `request:${publicKey}:${timestamp}:${canonicalString}`;
125
- }
126
-
127
- /**
128
- * Get the elliptic curve instance (for key generation)
129
- */
130
- export function getEllipticCurve() {
131
- return ec;
132
- }
133
- //# sourceMappingURL=core.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ec","EC","CHALLENGE_TTL_MS","MAX_SIGNATURE_AGE_MS","verifySignatureCore","messageHash","signature","publicKey","key","keyFromPublic","verify","isValidPublicKey","trim","length","isValidPrivateKey","privateKey","test","keyPair","keyFromPrivate","getPublic","priv","getPrivate","isZero","shortenPublicKey","slice","derivePublicKey","isTimestampFresh","timestamp","maxAgeMs","now","Date","buildAuthMessage","challenge","buildRegistrationMessage","buildRequestMessage","data","sortedKeys","Object","keys","sort","canonicalParts","map","JSON","stringify","canonicalString","join","getEllipticCurve"],"sourceRoot":"../../../src","sources":["crypto/core.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,EAAE,IAAIC,EAAE,QAAQ,UAAU;AAGnC,MAAMD,EAAE,GAAG,IAAIC,EAAE,CAAC,WAAW,CAAC;;AAE9B;AACA,OAAO,MAAMC,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AAC/C,OAAO,MAAMC,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;;AAEnD;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjCC,WAAmB,EACnBC,SAAiB,EACjBC,SAAiB,EACR;EACT,IAAI;IACF,MAAMC,GAAG,GAAGR,EAAE,CAACS,aAAa,CAACF,SAAS,EAAE,KAAK,CAAC;IAC9C,OAAOC,GAAG,CAACE,MAAM,CAACL,WAAW,EAAEC,SAAS,CAAC;EAC3C,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;;AAEA;AACA;AACA;AACA,OAAO,SAASK,gBAAgBA,CAACJ,SAAiB,EAAW;EAC3D;EACA,IAAI,CAACA,SAAS,IAAIA,SAAS,CAACK,IAAI,CAAC,CAAC,CAACC,MAAM,KAAK,CAAC,EAAE;IAC/C,OAAO,KAAK;EACd;EAEA,IAAI;IACFb,EAAE,CAACS,aAAa,CAACF,SAAS,EAAE,KAAK,CAAC;IAClC,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;;AAEA;AACA;AACA;AAC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AKC,QAAQ;AACtC;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,gBAAgBA,CAACxB,SAAiB,EAAEyB,SAAiB,EAAEL,SAAiB,EAAU;EAChG,OAAO,QAAQpB,SAAS,IAAIyB,SAAS,IAAIL,SAAS,EAAE;AACtD;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASM,wBAAwBA,CAAC1B,SAAiB,EAAEoB,SAAiB,EAAU;EACrF,OAAO,gBAAgBpB,SAAS,IAAIoB,SAAS,EAAE;AACjD;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASO,mBAAmBA,CACjC3B,SAAiB,EACjBoB,SAAiB,EACjBQ,IAA6B,EACrB;EACR,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,IAAI,CAAC,CAAC;EAC3C,MAAMC,cAAc,GAAGJ,UAAU,CAACK,GAAG,CAACjC,GAAG,IAAI,GAAGA,GAAG,IAAIkC,IAAI,CAACC,SAAS,CAACR,IAAI,CAAC3B,GAAG,CAAC,CAAC,EAAE,CAAC;EACnF,MAAMoC,eAAe,GAAGJ,cAAc,CAACK,IAAI,CAAC,GAAG,CAAC;EAChD,OAAO,WAAWtC,SAAS,IAAIoB,SAAS,IAAIiB,eAAe,EAAE;AAC/D;;AAEA;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAAA,EAAW;EACzC,OAAO9C,EAAE;AACX","ignoreList":[]}
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Node.js Signature Service
5
- *
6
- * Provides synchronous signature operations for Node.js backend.
7
- * Uses Node's crypto module for hashing and the shared core for verification.
8
- */
9
-
10
- import crypto from 'crypto';
11
- import { verifySignatureCore, isValidPublicKey, isTimestampFresh, buildAuthMessage, buildRegistrationMessage, buildRequestMessage, shortenPublicKey, CHALLENGE_TTL_MS, MAX_SIGNATURE_AGE_MS } from '../crypto/core';
12
- export class SignatureService {
13
- /**
14
- * Generate a random challenge string
15
- */
16
- static generateChallenge() {
17
- return crypto.randomBytes(32).toString('hex');
18
- }
19
-
20
- /**
21
- * Compute SHA-256 hash of a message (synchronous)
22
- */
23
- static hashMessage(message) {
24
- return crypto.createHash('sha256').update(message).digest('hex');
25
- }
26
-
27
- /**
28
- * Verify an ECDSA signature (synchronous)
29
- *
30
- * @param message - The original message that was signed
31
- * @param signature - The signature in DER format (hex encoded)
32
- * @param publicKey - The public key (hex encoded, uncompressed)
33
- * @returns true if the signature is valid
34
- */
35
- static verifySignature(message, signature, publicKey) {
36
- const messageHash = SignatureService.hashMessage(message);
37
- return verifySignatureCore(messageHash, signature, publicKey);
38
- }
39
-
40
- /**
41
- * Verify an authentication challenge response
42
- *
43
- * @param publicKey - The user's public key
44
- * @param challenge - The original challenge string
45
- * @param signature - The signature of the auth message
46
- * @param timestamp - The timestamp when the signature was created
47
- * @returns true if the challenge response is valid
48
- */
49
- static verifyChallengeResponse(publicKey, challenge, signature, timestamp) {
50
- // Check timestamp is not too old
51
- if (!isTimestampFresh(timestamp, CHALLENGE_TTL_MS)) {
52
- return false;
53
- }
54
-
55
- // Build the message and verify signature
56
- const message = buildAuthMessage(publicKey, challenge, timestamp);
57
- return SignatureService.verifySignature(message, signature, publicKey);
58
- }
59
-
60
- /**
61
- * Verify a registration signature
62
- * Signature format: oxy:register:{publicKey}:{timestamp}
63
- */
64
- static verifyRegistrationSignature(publicKey, signature, timestamp) {
65
- // Check timestamp freshness
66
- if (!isTimestampFresh(timestamp, MAX_SIGNATURE_AGE_MS)) {
67
- return false;
68
- }
69
- const message = buildRegistrationMessage(publicKey, timestamp);
70
- return SignatureService.verifySignature(message, signature, publicKey);
71
- }
72
-
73
- /**
74
- * Verify a signed request
75
- * Used for authenticated API operations
76
- */
77
- static verifyRequestSignature(publicKey, data, signature, timestamp) {
78
- // Check timestamp freshness
79
- if (!isTimestampFresh(timestamp, MAX_SIGNATURE_AGE_MS)) {
80
- return false;
81
- }
82
- const message = buildRequestMessage(publicKey, timestamp, data);
83
- return SignatureService.verifySignature(message, signature, publicKey);
84
- }
85
-
86
- /**
87
- * Validate that a string is a valid public key
88
- */
89
- static isValidPublicKey(publicKey) {
90
- return isValidPublicKey(publicKey);
91
- }
92
-
93
- /**
94
- * Get a shortened display version of a public key
95
- */
96
- static shortenPublicKey(publicKey) {
97
- return shortenPublicKey(publicKey);
98
- }
99
- }
100
- export default SignatureService;
101
- //# sourceMappingURL=signatureService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["crypto","verifySignatureCore","isValidPublicKey","isTimestampFresh","buildAuthMessage","buildRegistrationMessage","buildRequestMessage","shortenPublicKey","CHALLENGE_TTL_MS","MAX_SIGNATURE_AGE_MS","SignatureService","generateChallenge","randomBytes","toString","hashMessage","message","createHash","update","digest","verifySignature","signature","publicKey","messageHash","verifyChallengeResponse","challenge","timestamp","verifyRegistrationSignature","verifyRequestSignature","data"],"sourceRoot":"../../../src","sources":["node/signatureService.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,QAAQ;AAC3B,SACEC,mBAAmB,EACnBC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,EAChBC,wBAAwB,EACxBC,mBAAmB,EACnBC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,QACf,gBAAgB;AAEvB,OAAO,MAAMC,gBAAgB,CAAC;EAC5B;AACF;AACA;EACE,OAAOC,iBAAiBA,CAAA,EAAW;IACjC,OAAOX,MAAM,CAACY,WAAW,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,KAAK,CAAC;EAC/C;;EAEA;AACF;AACA;EACE,OAAOC,WAAWA,CAACC,OAAe,EAAU;IAC1C,OAAOf,MAAM,CAACgB,UAAU,CAAC,QAAQ,CAAC,CAACC,MAAM,CAACF,OAAO,CAAC,CAACG,MAAM,CAAC,KAAK,CAAC;EAClE;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,eAAeA,CAACJ,OA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ACS,eAAe,CAACJ,OAAO,EAAEK,SAAS,EAAEC,SAAS,CAAC;EACxE;;EAEA;AACF;AACA;EACE,OAAOnB,gBAAgBA,CAACmB,SAAiB,EAAW;IAClD,OAAOnB,gBAAgB,CAACmB,SAAS,CAAC;EACpC;;EAEA;AACF;AACA;EACE,OAAOd,gBAAgBA,CAACc,SAAiB,EAAU;IACjD,OAAOd,gBAAgB,CAACc,SAAS,CAAC;EACpC;AACF;AAEA,eAAeX,gBAAgB","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Auth-related hooks
5
- */
6
- export { useUsernameValidation, USERNAME_MIN_LENGTH, USERNAME_REGEX, USERNAME_FORMAT_ERROR, USERNAME_DEBOUNCE_MS } from './useUsernameValidation';
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useUsernameValidation","USERNAME_MIN_LENGTH","USERNAME_REGEX","USERNAME_FORMAT_ERROR","USERNAME_DEBOUNCE_MS"],"sourceRoot":"../../../../../src","sources":["ui/hooks/auth/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,qBAAqB,EAAEC,mBAAmB,EAAEC,cAAc,EAAEC,qBAAqB,EAAEC,oBAAoB,QAAQ,yBAAyB","ignoreList":[]}
@@ -1,167 +0,0 @@
1
- "use strict";
2
-
3
- import { useMemo } from 'react';
4
- import { useQuery } from '@tanstack/react-query';
5
- import { handleHttpError, ErrorCodes } from '../../../utils/errorUtils';
6
- import { useDebounce } from '../../../utils/hookUtils';
7
-
8
- /**
9
- * Username validation constants
10
- */
11
- export const USERNAME_MIN_LENGTH = 4;
12
- export const USERNAME_REGEX = /^[a-z0-9]+$/i;
13
- export const USERNAME_FORMAT_ERROR = 'You can use a-z, 0-9. Minimum length is 4 characters.';
14
- export const USERNAME_DEBOUNCE_MS = 500;
15
-
16
- /**
17
- * Username validation result interface
18
- */
19
-
20
- /**
21
- * Validate username format using services validation utilities
22
- */
23
- function validateUsernameFormat(username) {
24
- // Use stricter validation: lowercase alphanumeric only, min 4 chars
25
- return username.length >= USERNAME_MIN_LENGTH && USERNAME_REGEX.test(username);
26
- }
27
-
28
- /**
29
- * Check if an error is a network or timeout error
30
- */
31
- function isNetworkOrTimeoutError(error) {
32
- const apiError = handleHttpError(error);
33
- return apiError.code === ErrorCodes.NETWORK_ERROR || apiError.code === ErrorCodes.TIMEOUT || apiError.code === ErrorCodes.CONNECTION_FAILED;
34
- }
35
-
36
- /**
37
- * Extract error message from an unknown error shape
38
- */
39
- function extractAuthErrorMessage(error, fallbackMessage = 'An error occurred') {
40
- const apiError = handleHttpError(error);
41
- return apiError.message || fallbackMessage;
42
- }
43
-
44
- /**
45
- * Hook for username validation with debouncing and availability checking
46
- *
47
- * Uses TanStack Query for efficient API calls with:
48
- * - Automatic request cancellation when username changes
49
- * - Built-in caching (same username checked multiple times = cached result)
50
- * - Request deduplication (multiple components checking same username = single request)
51
- * - Proper error handling
52
- *
53
- * @param username - The username to validate
54
- * @param oxyServices - OxyServices instance for API calls
55
- * @returns Username validation state and result
56
- */
57
- export function useUsernameValidation(username, oxyServices) {
58
- // Debounce the username input to avoid excessive API calls
59
- const debouncedUsername = useDebounce(username.trim().toLowerCase(), USERNAME_DEBOUNCE_MS);
60
-
61
- // Validate format synchronously (no API call needed)
62
- const isValid = useMemo(() => validateUsernameFormat(username), [username]);
63
-
64
- // Determine if we should check availability
65
- const shouldCheckAvailability = useMemo(() => {
66
- if (!debouncedUsername || debouncedUsername.length < USERNAME_MIN_LENGTH) {
67
- return false;
68
- }
69
- return validateUsernameFormat(debouncedUsername);
70
- }, [debouncedUsername]);
71
-
72
- // Use TanStack Query for the API call
73
- // This provides automatic caching, request cancellation, and deduplication
74
- const {
75
- data: availabilityResult,
76
- isLoading: isChecking,
77
- error: queryError,
78
- isFetching
79
- } = useQuery({
80
- queryKey: ['username', 'availability', debouncedUsername],
81
- queryFn: async () => {
82
- if (!oxyServices) {
83
- throw new Error('OxyServices not available');
84
- }
85
- return await oxyServices.checkUsernameAvailability(debouncedUsername);
86
- },
87
- enabled: shouldCheckAvailability && !!oxyServices,
88
- staleTime: 5 * 60 * 1000,
89
- // Cache for 5 minutes (usernames don't change often)
90
- gcTime: 30 * 60 * 1000,
91
- // Keep in cache for 30 minutes
92
- retry: (failureCount, error) => {
93
- // Don't retry on network/timeout errors (user might be offline)
94
- if (isNetworkOrTimeoutError(error)) {
95
- return false;
96
- }
97
- // Retry up to 2 times for other errors
98
- return failureCount < 2;
99
- },
100
- retryDelay: attemptIndex => Math.min(1000 * 2 ** attemptIndex, 3000)
101
- });
102
-
103
- // Compute the result based on validation and query state
104
- return useMemo(() => {
105
- // If username is too short or invalid format, return early validation
106
- if (!username || username.length < USERNAME_MIN_LENGTH) {
107
- return {
108
- isValid: false,
109
- isAvailable: null,
110
- error: null,
111
- isChecking: false
112
- };
113
- }
114
- if (!isValid) {
115
- return {
116
- isValid: false,
117
- isAvailable: false,
118
- error: USERNAME_FORMAT_ERROR,
119
- isChecking: false
120
- };
121
- }
122
-
123
- // If we're not checking yet (debounce period), show checking state only if user is typing
124
- const isCurrentlyChecking = isChecking || isFetching;
125
-
126
- // Handle network/timeout errors gracefully
127
- if (queryError && isNetworkOrTimeoutError(queryError)) {
128
- // Allow proceeding if offline/network issue (optimistic)
129
- return {
130
- isValid: true,
131
- isAvailable: true,
132
- // Optimistic: allow proceeding
133
- error: null,
134
- isChecking: false
135
- };
136
- }
137
-
138
- // Handle other errors
139
- if (queryError) {
140
- return {
141
- isValid: true,
142
- isAvailable: false,
143
- error: extractAuthErrorMessage(queryError, 'Failed to check username availability'),
144
- isChecking: false
145
- };
146
- }
147
-
148
- // If we have a result, use it
149
- if (availabilityResult) {
150
- return {
151
- isValid: true,
152
- isAvailable: availabilityResult.available,
153
- error: availabilityResult.available ? null : availabilityResult.message || 'Username is already taken',
154
- isChecking: false
155
- };
156
- }
157
-
158
- // Still checking (or waiting for debounce)
159
- return {
160
- isValid: true,
161
- isAvailable: null,
162
- error: null,
163
- isChecking: isCurrentlyChecking
164
- };
165
- }, [username, isValid, availabilityResult, isChecking, isFetching, queryError]);
166
- }
167
- //# sourceMappingURL=useUsernameValidation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useMemo","useQuery","handleHttpError","ErrorCodes","useDebounce","USERNAME_MIN_LENGTH","USERNAME_REGEX","USERNAME_FORMAT_ERROR","USERNAME_DEBOUNCE_MS","validateUsernameFormat","username","length","test","isNetworkOrTimeoutError","error","apiError","code","NETWORK_ERROR","TIMEOUT","CONNECTION_FAILED","extractAuthErrorMessage","fallbackMessage","message","useUsernameValidation","oxyServices","debouncedUsername","trim","toLowerCase","isValid","shouldCheckAvailability","data","availabilityResult","isLoading","isChecking","queryError","isFetching","queryKey","queryFn","Error","checkUsernameAvailability","enabled","staleTime","gcTime","retry","failureCount","retryDelay","attemptIndex","Math","min","isAvailable","isCurrentlyChecking","available"],"sourceRoot":"../../../../../src","sources":["ui/hooks/auth/useUsernameValidation.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,QAAQ,QAAQ,uBAAuB;AAEhD,SAASC,eAAe,EAAEC,UAAU,QAAQ,2BAA2B;AACvE,SAASC,WAAW,QAAQ,0BAA0B;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAG,CAAC;AACpC,OAAO,MAAMC,cAAc,GAAG,cAAc;AAC5C,OAAO,MAAMC,qBAAqB,GAAG,uDAAuD;AAC5F,OAAO,MAAMC,oBAAoB,GAAG,GAAG;;AAEvC;AACA;AACA;;AAQA;AACA;AACA;AACA,SAASC,sBAAsBA,CAACC,QAAgB,EAAW;EACzD;EACA,OAAOA,QAAQ,CAACC,MAAM,IAAIN,mBAAmB,IAAIC,cAAc,CAACM,IAAI,CAACF,QAAQ,CAAC;AAChF;;AAEA;AACA;AACA;AACA,SAASG,uBAAuBA,CAACC,KAAc,EAAW;EACxD,MAAMC,QAAQ,GAAGb,eAAe,CAACY,KAAK,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mB,UAAU,EAAE;MACd,CAAC;IACH;;IAEA;IACA,IAAIC,UAAU,EAAE;MACd,OAAO;QACLN,OAAO,EAAE,IAAI;QACbqB,WAAW,EAAE,KAAK;QAClBnC,KAAK,EAAEM,uBAAuB,CAACc,UAAU,EAAE,uCAAuC,CAAC;QACnFD,UAAU,EAAE;MACd,CAAC;IACH;;IAEA;IACA,IAAIF,kBAAkB,EAAE;MACtB,OAAO;QACLH,OAAO,EAAE,IAAI;QACbqB,WAAW,EAAElB,kBAAkB,CAACoB,SAAS;QACzCrC,KAAK,EAAEiB,kBAAkB,CAACoB,SAAS,GAAG,IAAI,GAAIpB,kBAAkB,CAACT,OAAO,IAAI,2BAA4B;QACxGW,UAAU,EAAE;MACd,CAAC;IACH;;IAEA;IACA,OAAO;MACLL,OAAO,EAAE,IAAI;MACbqB,WAAW,EAAE,IAAI;MACjBnC,KAAK,EAAE,IAAI;MACXmB,UAAU,EAAEiB;IACd,CAAC;EACH,CAAC,EAAE,CAACxC,QAAQ,EAAEkB,OAAO,EAAEG,kBAAkB,EAAEE,UAAU,EAAEE,UAAU,EAAED,UAAU,CAAC,CAAC;AACjF","ignoreList":[]}
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- import { useCallback } from 'react';
4
- import { toast } from '../../lib/sonner';
5
- import { translate } from '../../i18n';
6
- import { showBottomSheet as globalShowBottomSheet } from '../navigation/bottomSheetManager';
7
- import { updateAvatarVisibility, updateProfileWithAvatar } from '../utils/avatarUtils';
8
- /**
9
- * Hook to handle avatar picker functionality
10
- */
11
- export function useAvatarPicker({
12
- oxyServices,
13
- currentLanguage,
14
- activeSessionId,
15
- queryClient,
16
- syncIdentity
17
- }) {
18
- const openAvatarPicker = useCallback(() => {
19
- globalShowBottomSheet({
20
- screen: 'FileManagement',
21
- props: {
22
- selectMode: true,
23
- multiSelect: false,
24
- disabledMimeTypes: ['video/', 'audio/', 'application/pdf'],
25
- afterSelect: 'none',
26
- onSelect: async file => {
27
- if (!file.contentType.startsWith('image/')) {
28
- toast.error(translate(currentLanguage, 'editProfile.toasts.selectImage') || 'Please select an image file');
29
- return;
30
- }
31
- try {
32
- await updateAvatarVisibility(file.id, oxyServices, 'useAvatarPicker');
33
- await updateProfileWithAvatar({
34
- avatar: file.id
35
- }, oxyServices, activeSessionId, queryClient, () => syncIdentity());
36
- toast.success(translate(currentLanguage, 'editProfile.toasts.avatarUpdated') || 'Avatar updated');
37
- } catch (e) {
38
- toast.error(e.message || translate(currentLanguage, 'editProfile.toasts.updateAvatarFailed') || 'Failed to update avatar');
39
- }
40
- }
41
- }
42
- });
43
- }, [oxyServices, currentLanguage, activeSessionId, queryClient, syncIdentity]);
44
- return {
45
- openAvatarPicker
46
- };
47
- }
48
- //# sourceMappingURL=useAvatarPicker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useCallback","toast","translate","showBottomSheet","globalShowBottomSheet","updateAvatarVisibility","updateProfileWithAvatar","useAvatarPicker","oxyServices","currentLanguage","activeSessionId","queryClient","syncIdentity","openAvatarPicker","screen","props","selectMode","multiSelect","disabledMimeTypes","afterSelect","onSelect","file","contentType","startsWith","error","id","avatar","success","e","message"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAvatarPicker.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AAEnC,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,eAAe,IAAIC,qBAAqB,QAAQ,kCAAkC;AAC3F,SAASC,sBAAsB,EAAEC,uBAAuB,QAAQ,sBAAsB;AAYtF;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAAC;EAC9BC,WAAW;EACXC,eAAe;EACfC,eAAe;EACfC,WAAW;EACXC;AACsB,CAAC,EAAE;EACzB,MAAMC,gBAAgB,GAAGb,WAAW,CAAC,MAAM;IACzCI,qBAAqB,CAAC;MACpBU,MAAM,EAAE,gBAA6B;MACrCC,KAAK,EAAE;QACLC,UAAU,EAAE,IAAI;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