@oxyhq/services 5.17.17 → 5.17.18

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 (403) hide show
  1. package/README.md +32 -38
  2. package/lib/commonjs/core/CrossDomainAuth.js +277 -0
  3. package/lib/commonjs/core/CrossDomainAuth.js.map +1 -0
  4. package/lib/commonjs/core/HttpService.js +82 -15
  5. package/lib/commonjs/core/HttpService.js.map +1 -1
  6. package/lib/commonjs/core/OxyServices.base.js +11 -3
  7. package/lib/commonjs/core/OxyServices.base.js.map +1 -1
  8. package/lib/commonjs/core/OxyServices.js +4 -1
  9. package/lib/commonjs/core/OxyServices.js.map +1 -1
  10. package/lib/commonjs/core/index.js +30 -0
  11. package/lib/commonjs/core/index.js.map +1 -1
  12. package/lib/commonjs/core/mixins/OxyServices.assets.js +16 -3
  13. package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
  14. package/lib/commonjs/core/mixins/OxyServices.auth.js +73 -32
  15. package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -1
  16. package/lib/commonjs/core/mixins/OxyServices.fedcm.js +289 -0
  17. package/lib/commonjs/core/mixins/OxyServices.fedcm.js.map +1 -0
  18. package/lib/commonjs/core/mixins/OxyServices.popup.js +352 -0
  19. package/lib/commonjs/core/mixins/OxyServices.popup.js.map +1 -0
  20. package/lib/commonjs/core/mixins/OxyServices.redirect.js +378 -0
  21. package/lib/commonjs/core/mixins/OxyServices.redirect.js.map +1 -0
  22. package/lib/commonjs/core/mixins/OxyServices.user.js +35 -24
  23. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  24. package/lib/commonjs/core/mixins/index.js +27 -15
  25. package/lib/commonjs/core/mixins/index.js.map +1 -1
  26. package/lib/commonjs/crypto/index.js +30 -0
  27. package/lib/commonjs/crypto/index.js.map +1 -1
  28. package/lib/commonjs/crypto/keyManager.js +902 -0
  29. package/lib/commonjs/crypto/keyManager.js.map +1 -0
  30. package/lib/commonjs/crypto/polyfill.js +14 -5
  31. package/lib/commonjs/crypto/polyfill.js.map +1 -1
  32. package/lib/commonjs/crypto/recoveryPhrase.js +152 -0
  33. package/lib/commonjs/crypto/recoveryPhrase.js.map +1 -0
  34. package/lib/commonjs/crypto/signatureService.js +289 -0
  35. package/lib/commonjs/crypto/signatureService.js.map +1 -0
  36. package/lib/commonjs/i18n/locales/en-US.json +1 -1
  37. package/lib/commonjs/index.js +40 -26
  38. package/lib/commonjs/index.js.map +1 -1
  39. package/lib/commonjs/models/interfaces.js +0 -15
  40. package/lib/commonjs/models/interfaces.js.map +1 -1
  41. package/lib/commonjs/ui/components/BottomSheetRouter.js +9 -1
  42. package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
  43. package/lib/commonjs/ui/components/Icon.js.map +1 -1
  44. package/lib/commonjs/ui/components/IconButton/utils.js.map +1 -1
  45. package/lib/commonjs/ui/components/OxyProvider.js +41 -11
  46. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  47. package/lib/commonjs/ui/components/TextField/Adornment/utils.js.map +1 -1
  48. package/lib/commonjs/ui/components/TextField/helpers.js.map +1 -1
  49. package/lib/commonjs/ui/components/TouchableRipple/utils.js.map +1 -1
  50. package/lib/commonjs/ui/components/Typography/AnimatedText.js.map +1 -1
  51. package/lib/commonjs/ui/context/OxyContext.js +110 -199
  52. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  53. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +150 -19
  54. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  55. package/lib/commonjs/ui/context/hooks/useSessionManagement.js +279 -0
  56. package/lib/commonjs/ui/context/hooks/useSessionManagement.js.map +1 -0
  57. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +79 -72
  58. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  59. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +38 -51
  60. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  61. package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js +3 -3
  62. package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js.map +1 -1
  63. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +18 -12
  64. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  65. package/lib/commonjs/ui/hooks/useProfileEditing.js +3 -5
  66. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  67. package/lib/commonjs/ui/hooks/useSessionManagement.js +4 -8
  68. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  69. package/lib/commonjs/ui/hooks/useSessionSocket.js +162 -315
  70. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  71. package/lib/commonjs/ui/hooks/useStorage.js +24 -58
  72. package/lib/commonjs/ui/hooks/useStorage.js.map +1 -1
  73. package/lib/commonjs/ui/index.js +50 -21
  74. package/lib/commonjs/ui/index.js.map +1 -1
  75. package/lib/commonjs/ui/navigation/routes.js +5 -1
  76. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  77. package/lib/commonjs/ui/screens/AccountCenterScreen.js +2 -2
  78. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  79. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  80. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +29 -24
  81. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  82. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +3 -3
  83. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  84. package/lib/commonjs/ui/screens/OxyAuthScreen.js +134 -66
  85. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  86. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +6 -13
  87. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  88. package/lib/commonjs/ui/stores/accountStore.js +2 -4
  89. package/lib/commonjs/ui/stores/accountStore.js.map +1 -1
  90. package/lib/commonjs/ui/stores/authStore.js +45 -32
  91. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  92. package/lib/commonjs/ui/styles/spacing.js +54 -2
  93. package/lib/commonjs/ui/styles/spacing.js.map +1 -1
  94. package/lib/commonjs/ui/utils/avatarUtils.js +37 -41
  95. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  96. package/lib/commonjs/ui/utils/storageHelpers.js.map +1 -1
  97. package/lib/commonjs/utils/errorUtils.js +13 -0
  98. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  99. package/lib/commonjs/utils/validationUtils.js +15 -1
  100. package/lib/commonjs/utils/validationUtils.js.map +1 -1
  101. package/lib/module/core/CrossDomainAuth.js +271 -0
  102. package/lib/module/core/CrossDomainAuth.js.map +1 -0
  103. package/lib/module/core/HttpService.js +82 -15
  104. package/lib/module/core/HttpService.js.map +1 -1
  105. package/lib/module/core/OxyServices.base.js +11 -4
  106. package/lib/module/core/OxyServices.base.js.map +1 -1
  107. package/lib/module/core/OxyServices.js +4 -1
  108. package/lib/module/core/OxyServices.js.map +1 -1
  109. package/lib/module/core/index.js +6 -1
  110. package/lib/module/core/index.js.map +1 -1
  111. package/lib/module/core/mixins/OxyServices.assets.js +16 -3
  112. package/lib/module/core/mixins/OxyServices.assets.js.map +1 -1
  113. package/lib/module/core/mixins/OxyServices.auth.js +73 -32
  114. package/lib/module/core/mixins/OxyServices.auth.js.map +1 -1
  115. package/lib/module/core/mixins/OxyServices.fedcm.js +286 -0
  116. package/lib/module/core/mixins/OxyServices.fedcm.js.map +1 -0
  117. package/lib/module/core/mixins/OxyServices.popup.js +349 -0
  118. package/lib/module/core/mixins/OxyServices.popup.js.map +1 -0
  119. package/lib/module/core/mixins/OxyServices.redirect.js +375 -0
  120. package/lib/module/core/mixins/OxyServices.redirect.js.map +1 -0
  121. package/lib/module/core/mixins/OxyServices.user.js +35 -24
  122. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  123. package/lib/module/core/mixins/index.js +15 -3
  124. package/lib/module/core/mixins/index.js.map +1 -1
  125. package/lib/module/crypto/index.js +8 -4
  126. package/lib/module/crypto/index.js.map +1 -1
  127. package/lib/module/crypto/keyManager.js +899 -0
  128. package/lib/module/crypto/keyManager.js.map +1 -0
  129. package/lib/module/crypto/polyfill.js +6 -5
  130. package/lib/module/crypto/polyfill.js.map +1 -1
  131. package/lib/module/crypto/recoveryPhrase.js +147 -0
  132. package/lib/module/crypto/recoveryPhrase.js.map +1 -0
  133. package/lib/module/crypto/signatureService.js +286 -0
  134. package/lib/module/crypto/signatureService.js.map +1 -0
  135. package/lib/module/i18n/locales/en-US.json +1 -1
  136. package/lib/module/index.js +6 -9
  137. package/lib/module/index.js.map +1 -1
  138. package/lib/module/models/interfaces.js +0 -15
  139. package/lib/module/models/interfaces.js.map +1 -1
  140. package/lib/module/ui/components/BottomSheetRouter.js +6 -2
  141. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  142. package/lib/module/ui/components/Icon.js.map +1 -1
  143. package/lib/module/ui/components/IconButton/utils.js.map +1 -1
  144. package/lib/module/ui/components/OxyProvider.js +41 -11
  145. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  146. package/lib/module/ui/components/TextField/Adornment/utils.js.map +1 -1
  147. package/lib/module/ui/components/TextField/helpers.js.map +1 -1
  148. package/lib/module/ui/components/TouchableRipple/utils.js.map +1 -1
  149. package/lib/module/ui/components/Typography/AnimatedText.js.map +1 -1
  150. package/lib/module/ui/context/OxyContext.js +112 -191
  151. package/lib/module/ui/context/OxyContext.js.map +1 -1
  152. package/lib/module/ui/context/hooks/useAuthOperations.js +150 -19
  153. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  154. package/lib/module/ui/context/hooks/useSessionManagement.js +274 -0
  155. package/lib/module/ui/context/hooks/useSessionManagement.js.map +1 -0
  156. package/lib/module/ui/hooks/mutations/useAccountMutations.js +80 -72
  157. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  158. package/lib/module/ui/hooks/queries/useAccountQueries.js +31 -44
  159. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  160. package/lib/module/ui/hooks/queries/useSecurityQueries.js +1 -1
  161. package/lib/module/ui/hooks/queries/useSecurityQueries.js.map +1 -1
  162. package/lib/module/ui/hooks/queries/useServicesQueries.js +13 -7
  163. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  164. package/lib/module/ui/hooks/useProfileEditing.js +3 -5
  165. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  166. package/lib/module/ui/hooks/useSessionManagement.js +4 -8
  167. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  168. package/lib/module/ui/hooks/useSessionSocket.js +162 -315
  169. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  170. package/lib/module/ui/hooks/useStorage.js +25 -59
  171. package/lib/module/ui/hooks/useStorage.js.map +1 -1
  172. package/lib/module/ui/index.js +15 -10
  173. package/lib/module/ui/index.js.map +1 -1
  174. package/lib/module/ui/navigation/routes.js +5 -1
  175. package/lib/module/ui/navigation/routes.js.map +1 -1
  176. package/lib/module/ui/screens/AccountCenterScreen.js +2 -2
  177. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  178. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  179. package/lib/module/ui/screens/AccountSettingsScreen.js +29 -24
  180. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  181. package/lib/module/ui/screens/AccountSwitcherScreen.js +3 -3
  182. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  183. package/lib/module/ui/screens/OxyAuthScreen.js +135 -68
  184. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  185. package/lib/module/ui/screens/PrivacySettingsScreen.js +6 -13
  186. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  187. package/lib/module/ui/stores/accountStore.js +2 -4
  188. package/lib/module/ui/stores/accountStore.js.map +1 -1
  189. package/lib/module/ui/stores/authStore.js +45 -32
  190. package/lib/module/ui/stores/authStore.js.map +1 -1
  191. package/lib/module/ui/styles/spacing.js +6 -2
  192. package/lib/module/ui/styles/spacing.js.map +1 -1
  193. package/lib/module/ui/utils/avatarUtils.js +37 -40
  194. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  195. package/lib/module/ui/utils/storageHelpers.js.map +1 -1
  196. package/lib/module/utils/errorUtils.js +7 -0
  197. package/lib/module/utils/errorUtils.js.map +1 -1
  198. package/lib/module/utils/validationUtils.js +13 -0
  199. package/lib/module/utils/validationUtils.js.map +1 -1
  200. package/lib/typescript/core/CrossDomainAuth.d.ts +161 -0
  201. package/lib/typescript/core/CrossDomainAuth.d.ts.map +1 -0
  202. package/lib/typescript/core/HttpService.d.ts +1 -1
  203. package/lib/typescript/core/HttpService.d.ts.map +1 -1
  204. package/lib/typescript/core/OxyServices.base.d.ts +0 -6
  205. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  206. package/lib/typescript/core/OxyServices.d.ts +5 -36
  207. package/lib/typescript/core/OxyServices.d.ts.map +1 -1
  208. package/lib/typescript/core/index.d.ts +4 -0
  209. package/lib/typescript/core/index.d.ts.map +1 -1
  210. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  211. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  212. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +40 -20
  213. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  214. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  215. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  216. package/lib/typescript/core/mixins/OxyServices.fedcm.d.ts +195 -0
  217. package/lib/typescript/core/mixins/OxyServices.fedcm.d.ts.map +1 -0
  218. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  219. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  220. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  221. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  222. package/lib/typescript/core/mixins/OxyServices.popup.d.ts +206 -0
  223. package/lib/typescript/core/mixins/OxyServices.popup.d.ts.map +1 -0
  224. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  225. package/lib/typescript/core/mixins/OxyServices.redirect.d.ts +246 -0
  226. package/lib/typescript/core/mixins/OxyServices.redirect.d.ts.map +1 -0
  227. package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
  228. package/lib/typescript/core/mixins/OxyServices.user.d.ts +6 -4
  229. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  230. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  231. package/lib/typescript/core/mixins/index.d.ts +220 -8
  232. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  233. package/lib/typescript/crypto/index.d.ts +6 -3
  234. package/lib/typescript/crypto/index.d.ts.map +1 -1
  235. package/lib/typescript/crypto/keyManager.d.ts +190 -0
  236. package/lib/typescript/crypto/keyManager.d.ts.map +1 -0
  237. package/lib/typescript/crypto/polyfill.d.ts +4 -3
  238. package/lib/typescript/crypto/polyfill.d.ts.map +1 -1
  239. package/lib/typescript/crypto/recoveryPhrase.d.ts +59 -0
  240. package/lib/typescript/crypto/recoveryPhrase.d.ts.map +1 -0
  241. package/lib/typescript/crypto/signatureService.d.ts +87 -0
  242. package/lib/typescript/crypto/signatureService.d.ts.map +1 -0
  243. package/lib/typescript/index.d.ts +5 -6
  244. package/lib/typescript/index.d.ts.map +1 -1
  245. package/lib/typescript/models/interfaces.d.ts +2 -14
  246. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  247. package/lib/typescript/models/session.d.ts +0 -9
  248. package/lib/typescript/models/session.d.ts.map +1 -1
  249. package/lib/typescript/types/bip39.d.ts +32 -0
  250. package/lib/typescript/ui/components/BottomSheetRouter.d.ts +5 -0
  251. package/lib/typescript/ui/components/BottomSheetRouter.d.ts.map +1 -1
  252. package/lib/typescript/ui/components/IconButton/utils.d.ts +1 -1
  253. package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
  254. package/lib/typescript/ui/components/TextField/Addons/Outline.d.ts +2 -2
  255. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts +1 -1
  256. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
  257. package/lib/typescript/ui/components/TextField/helpers.d.ts +8 -8
  258. package/lib/typescript/ui/components/TextField/types.d.ts +1 -0
  259. package/lib/typescript/ui/components/TextField/types.d.ts.map +1 -1
  260. package/lib/typescript/ui/components/types.d.ts +4 -0
  261. package/lib/typescript/ui/components/types.d.ts.map +1 -1
  262. package/lib/typescript/ui/context/OxyContext.d.ts +57 -3
  263. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  264. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +10 -3
  265. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  266. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts +41 -0
  267. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts.map +1 -0
  268. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  269. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  270. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  271. package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
  272. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
  273. package/lib/typescript/ui/hooks/useSessionSocket.d.ts +1 -2
  274. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
  275. package/lib/typescript/ui/hooks/useStorage.d.ts +3 -9
  276. package/lib/typescript/ui/hooks/useStorage.d.ts.map +1 -1
  277. package/lib/typescript/ui/index.d.ts +6 -2
  278. package/lib/typescript/ui/index.d.ts.map +1 -1
  279. package/lib/typescript/ui/navigation/routes.d.ts +1 -1
  280. package/lib/typescript/ui/navigation/routes.d.ts.map +1 -1
  281. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  282. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts +1 -1
  283. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  284. package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  285. package/lib/typescript/ui/stores/accountStore.d.ts.map +1 -1
  286. package/lib/typescript/ui/stores/authStore.d.ts +8 -7
  287. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  288. package/lib/typescript/ui/styles/spacing.d.ts +5 -0
  289. package/lib/typescript/ui/styles/spacing.d.ts.map +1 -1
  290. package/lib/typescript/ui/types/navigation.d.ts +2 -1
  291. package/lib/typescript/ui/types/navigation.d.ts.map +1 -1
  292. package/lib/typescript/ui/utils/avatarUtils.d.ts +2 -13
  293. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  294. package/lib/typescript/ui/utils/storageHelpers.d.ts +0 -3
  295. package/lib/typescript/ui/utils/storageHelpers.d.ts.map +1 -1
  296. package/lib/typescript/utils/errorUtils.d.ts +6 -0
  297. package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
  298. package/lib/typescript/utils/validationUtils.d.ts +8 -0
  299. package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
  300. package/package.json +8 -7
  301. package/src/core/CrossDomainAuth.ts +307 -0
  302. package/src/core/HttpService.ts +99 -16
  303. package/src/core/OxyServices.base.ts +20 -3
  304. package/src/core/OxyServices.ts +7 -3
  305. package/src/core/index.ts +9 -1
  306. package/src/core/mixins/OxyServices.assets.ts +14 -3
  307. package/src/core/mixins/OxyServices.auth.ts +105 -36
  308. package/src/core/mixins/OxyServices.fedcm.ts +315 -0
  309. package/src/core/mixins/OxyServices.popup.ts +402 -0
  310. package/src/core/mixins/OxyServices.redirect.ts +397 -0
  311. package/src/core/mixins/OxyServices.user.ts +39 -24
  312. package/src/core/mixins/index.ts +19 -3
  313. package/src/crypto/index.ts +16 -5
  314. package/src/crypto/keyManager.ts +966 -0
  315. package/src/crypto/polyfill.ts +6 -5
  316. package/src/crypto/recoveryPhrase.ts +166 -0
  317. package/src/crypto/signatureService.ts +323 -0
  318. package/src/i18n/locales/en-US.json +1 -1
  319. package/src/index.ts +19 -15
  320. package/src/models/interfaces.ts +4 -16
  321. package/src/models/session.ts +2 -11
  322. package/src/types/bip39.d.ts +32 -0
  323. package/src/ui/components/BottomSheetRouter.tsx +6 -1
  324. package/src/ui/components/Icon.tsx +1 -1
  325. package/src/ui/components/IconButton/utils.ts +1 -1
  326. package/src/ui/components/OxyProvider.tsx +44 -12
  327. package/src/ui/components/TextField/Addons/Outline.tsx +2 -2
  328. package/src/ui/components/TextField/Adornment/utils.ts +2 -2
  329. package/src/ui/components/TextField/helpers.tsx +10 -10
  330. package/src/ui/components/TextField/types.tsx +1 -1
  331. package/src/ui/components/TouchableRipple/utils.ts +2 -2
  332. package/src/ui/components/Typography/AnimatedText.tsx +2 -2
  333. package/src/ui/components/types.tsx +6 -0
  334. package/src/ui/context/OxyContext.tsx +173 -195
  335. package/src/ui/context/hooks/useAuthOperations.ts +177 -36
  336. package/src/ui/context/hooks/useSessionManagement.ts +399 -0
  337. package/src/ui/hooks/mutations/useAccountMutations.ts +83 -76
  338. package/src/ui/hooks/queries/useAccountQueries.ts +29 -35
  339. package/src/ui/hooks/queries/useSecurityQueries.ts +1 -1
  340. package/src/ui/hooks/queries/useServicesQueries.ts +14 -6
  341. package/src/ui/hooks/useProfileEditing.ts +3 -3
  342. package/src/ui/hooks/useSessionManagement.ts +5 -10
  343. package/src/ui/hooks/useSessionSocket.ts +46 -175
  344. package/src/ui/hooks/useStorage.ts +24 -76
  345. package/src/ui/index.ts +22 -13
  346. package/src/ui/navigation/routes.ts +6 -2
  347. package/src/ui/screens/AccountCenterScreen.tsx +2 -2
  348. package/src/ui/screens/AccountOverviewScreen.tsx +1 -1
  349. package/src/ui/screens/AccountSettingsScreen.tsx +34 -37
  350. package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
  351. package/src/ui/screens/OxyAuthScreen.tsx +138 -64
  352. package/src/ui/screens/PrivacySettingsScreen.tsx +6 -12
  353. package/src/ui/stores/accountStore.ts +1 -11
  354. package/src/ui/stores/authStore.ts +43 -44
  355. package/src/ui/styles/spacing.ts +15 -2
  356. package/src/ui/types/navigation.ts +2 -2
  357. package/src/ui/utils/avatarUtils.ts +39 -46
  358. package/src/ui/utils/storageHelpers.ts +0 -4
  359. package/src/utils/__tests__/validationUtils.test.ts +16 -1
  360. package/src/utils/errorUtils.ts +8 -1
  361. package/src/utils/validationUtils.ts +12 -0
  362. package/lib/commonjs/core/services/SessionService.js +0 -163
  363. package/lib/commonjs/core/services/SessionService.js.map +0 -1
  364. package/lib/commonjs/core/services/TokenService.js +0 -220
  365. package/lib/commonjs/core/services/TokenService.js.map +0 -1
  366. package/lib/commonjs/crypto/types.js +0 -2
  367. package/lib/commonjs/crypto/types.js.map +0 -1
  368. package/lib/commonjs/ui/context/OxyContextBase.js +0 -21
  369. package/lib/commonjs/ui/context/OxyContextBase.js.map +0 -1
  370. package/lib/commonjs/ui/context/hooks/useStorage.js +0 -79
  371. package/lib/commonjs/ui/context/hooks/useStorage.js.map +0 -1
  372. package/lib/commonjs/ui/hooks/useAvatarPicker.js +0 -56
  373. package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +0 -1
  374. package/lib/module/core/services/SessionService.js +0 -159
  375. package/lib/module/core/services/SessionService.js.map +0 -1
  376. package/lib/module/core/services/TokenService.js +0 -217
  377. package/lib/module/core/services/TokenService.js.map +0 -1
  378. package/lib/module/crypto/types.js +0 -2
  379. package/lib/module/crypto/types.js.map +0 -1
  380. package/lib/module/ui/context/OxyContextBase.js +0 -16
  381. package/lib/module/ui/context/OxyContextBase.js.map +0 -1
  382. package/lib/module/ui/context/hooks/useStorage.js +0 -74
  383. package/lib/module/ui/context/hooks/useStorage.js.map +0 -1
  384. package/lib/module/ui/hooks/useAvatarPicker.js +0 -50
  385. package/lib/module/ui/hooks/useAvatarPicker.js.map +0 -1
  386. package/lib/typescript/core/services/SessionService.d.ts +0 -78
  387. package/lib/typescript/core/services/SessionService.d.ts.map +0 -1
  388. package/lib/typescript/core/services/TokenService.d.ts +0 -72
  389. package/lib/typescript/core/services/TokenService.d.ts.map +0 -1
  390. package/lib/typescript/crypto/types.d.ts +0 -22
  391. package/lib/typescript/crypto/types.d.ts.map +0 -1
  392. package/lib/typescript/ui/context/OxyContextBase.d.ts +0 -63
  393. package/lib/typescript/ui/context/OxyContextBase.d.ts.map +0 -1
  394. package/lib/typescript/ui/context/hooks/useStorage.d.ts +0 -22
  395. package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +0 -1
  396. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +0 -19
  397. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +0 -1
  398. package/src/core/services/SessionService.ts +0 -173
  399. package/src/core/services/TokenService.ts +0 -237
  400. package/src/crypto/types.ts +0 -23
  401. package/src/ui/context/OxyContextBase.tsx +0 -78
  402. package/src/ui/context/hooks/useStorage.ts +0 -104
  403. package/src/ui/hooks/useAvatarPicker.ts +0 -61
@@ -5,12 +5,12 @@
5
5
  * before any crypto operations are performed.
6
6
  *
7
7
  * Polyfills included:
8
- * - Buffer: Required by crypto libraries
9
- * - crypto.getRandomValues: Required for secure random number generation
8
+ * - Buffer: Required by bip39 and other crypto libraries
9
+ * - crypto.getRandomValues: Required by bip39 for secure random number generation
10
10
  */
11
11
 
12
12
  // Import Buffer polyfill for React Native compatibility
13
- // Some crypto libraries depend on Buffer which isn't available in React Native
13
+ // Libraries like bip39 depend on Buffer which isn't available in React Native
14
14
  import { Buffer } from 'buffer';
15
15
 
16
16
  // Get the global object in a cross-platform way
@@ -30,7 +30,7 @@ if (!globalObject.Buffer) {
30
30
  }
31
31
 
32
32
  // Polyfill crypto.getRandomValues for React Native
33
- // This is required by crypto libraries for secure random number generation
33
+ // This is required by bip39 and other crypto libraries
34
34
  type CryptoLike = {
35
35
  getRandomValues: <T extends ArrayBufferView>(array: T) => T;
36
36
  };
@@ -76,5 +76,6 @@ if (typeof globalObject.crypto === 'undefined') {
76
76
  (globalObject.crypto as CryptoLike).getRandomValues = cryptoPolyfill.getRandomValues;
77
77
  }
78
78
 
79
- // No longer re-exporting `Buffer` from this module; import from 'buffer' where needed.
79
+ // Re-export Buffer for convenience
80
+ export { Buffer };
80
81
 
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Recovery Phrase Service - BIP39 Mnemonic Generation
3
+ *
4
+ * Handles generation and restoration of recovery phrases (mnemonic seeds)
5
+ * for backing up and restoring user identities.
6
+ *
7
+ * Note: This module requires the polyfill to be loaded first (done via crypto/index.ts)
8
+ */
9
+
10
+ import * as bip39 from 'bip39';
11
+ import { KeyManager } from './keyManager';
12
+
13
+ /**
14
+ * Convert Uint8Array or array-like to hexadecimal string
15
+ * Works in both Node.js and React Native without depending on Buffer
16
+ */
17
+ function toHex(data: Uint8Array | ArrayLike<number>): string {
18
+ // Convert to array of numbers if needed
19
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
20
+ return Array.from(bytes)
21
+ .map(b => b.toString(16).padStart(2, '0'))
22
+ .join('');
23
+ }
24
+
25
+ export interface RecoveryPhraseResult {
26
+ phrase: string;
27
+ words: string[];
28
+ publicKey: string;
29
+ }
30
+
31
+ export class RecoveryPhraseService {
32
+ /**
33
+ * Generate a new identity with a recovery phrase
34
+ * Returns the mnemonic phrase (should only be shown once to the user)
35
+ */
36
+ static async generateIdentityWithRecovery(): Promise<RecoveryPhraseResult> {
37
+ // Generate 128-bit entropy for 12-word mnemonic
38
+ const mnemonic = bip39.generateMnemonic(128);
39
+
40
+ // Derive private key from mnemonic
41
+ // Using the seed directly as the private key (simplified approach)
42
+ const seed = await bip39.mnemonicToSeed(mnemonic);
43
+
44
+ // Use first 32 bytes of seed as private key
45
+ const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
46
+ const privateKeyHex = toHex(seedSlice);
47
+
48
+ // Import the derived key pair
49
+ const publicKey = await KeyManager.importKeyPair(privateKeyHex);
50
+
51
+ return {
52
+ phrase: mnemonic,
53
+ words: mnemonic.split(' '),
54
+ publicKey,
55
+ };
56
+ }
57
+
58
+ /**
59
+ * Generate a 24-word recovery phrase for higher security
60
+ */
61
+ static async generateIdentityWithRecovery24(): Promise<RecoveryPhraseResult> {
62
+ // Generate 256-bit entropy for 24-word mnemonic
63
+ const mnemonic = bip39.generateMnemonic(256);
64
+
65
+ const seed = await bip39.mnemonicToSeed(mnemonic);
66
+ const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
67
+ const privateKeyHex = toHex(seedSlice);
68
+ const publicKey = await KeyManager.importKeyPair(privateKeyHex);
69
+
70
+ return {
71
+ phrase: mnemonic,
72
+ words: mnemonic.split(' '),
73
+ publicKey,
74
+ };
75
+ }
76
+
77
+ /**
78
+ * Restore an identity from a recovery phrase
79
+ */
80
+ static async restoreFromPhrase(phrase: string): Promise<string> {
81
+ // Normalize and validate the phrase
82
+ const normalizedPhrase = phrase.trim().toLowerCase();
83
+
84
+ if (!bip39.validateMnemonic(normalizedPhrase)) {
85
+ throw new Error('Invalid recovery phrase. Please check the words and try again.');
86
+ }
87
+
88
+ // Derive the same private key from the mnemonic
89
+ const seed = await bip39.mnemonicToSeed(normalizedPhrase);
90
+ const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
91
+ const privateKeyHex = toHex(seedSlice);
92
+
93
+ // Import and store the key pair
94
+ const publicKey = await KeyManager.importKeyPair(privateKeyHex);
95
+
96
+ return publicKey;
97
+ }
98
+
99
+ /**
100
+ * Validate a recovery phrase without importing it
101
+ */
102
+ static validatePhrase(phrase: string): boolean {
103
+ const normalizedPhrase = phrase.trim().toLowerCase();
104
+ return bip39.validateMnemonic(normalizedPhrase);
105
+ }
106
+
107
+ /**
108
+ * Get the word list for autocomplete/validation
109
+ */
110
+ static getWordList(): string[] {
111
+ return bip39.wordlists.english;
112
+ }
113
+
114
+ /**
115
+ * Check if a word is valid in the BIP39 word list
116
+ */
117
+ static isValidWord(word: string): boolean {
118
+ return bip39.wordlists.english.includes(word.toLowerCase());
119
+ }
120
+
121
+ /**
122
+ * Get suggestions for a partial word
123
+ */
124
+ static getSuggestions(partial: string, limit: number = 5): string[] {
125
+ const lowerPartial = partial.toLowerCase();
126
+ return bip39.wordlists.english
127
+ .filter((word: string) => word.startsWith(lowerPartial))
128
+ .slice(0, limit);
129
+ }
130
+
131
+ /**
132
+ * Derive the public key from a phrase without storing
133
+ * Useful for verification before importing
134
+ */
135
+ static async derivePublicKeyFromPhrase(phrase: string): Promise<string> {
136
+ const normalizedPhrase = phrase.trim().toLowerCase();
137
+
138
+ if (!bip39.validateMnemonic(normalizedPhrase)) {
139
+ throw new Error('Invalid recovery phrase');
140
+ }
141
+
142
+ const seed = await bip39.mnemonicToSeed(normalizedPhrase);
143
+ const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
144
+ const privateKeyHex = toHex(seedSlice);
145
+
146
+ return KeyManager.derivePublicKey(privateKeyHex);
147
+ }
148
+
149
+ /**
150
+ * Convert a phrase to its word array
151
+ */
152
+ static phraseToWords(phrase: string): string[] {
153
+ return phrase.trim().toLowerCase().split(/\s+/);
154
+ }
155
+
156
+ /**
157
+ * Convert a word array to a phrase string
158
+ */
159
+ static wordsToPhrase(words: string[]): string {
160
+ return words.map(w => w.toLowerCase().trim()).join(' ');
161
+ }
162
+ }
163
+
164
+ export default RecoveryPhraseService;
165
+
166
+
@@ -0,0 +1,323 @@
1
+ /**
2
+ * Signature Service - ECDSA Digital Signatures
3
+ *
4
+ * Handles signing and verification of messages using ECDSA secp256k1.
5
+ * Used for authenticating requests and proving identity ownership.
6
+ */
7
+
8
+ import { ec as EC } from 'elliptic';
9
+ import { KeyManager } from './keyManager';
10
+
11
+ // Lazy import for expo-crypto
12
+ let ExpoCrypto: typeof import('expo-crypto') | null = null;
13
+
14
+ const ec = new EC('secp256k1');
15
+
16
+ /**
17
+ * Check if we're in a React Native environment
18
+ */
19
+ function isReactNative(): boolean {
20
+ return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
21
+ }
22
+
23
+ /**
24
+ * Check if we're in a Node.js environment
25
+ */
26
+ function isNodeJS(): boolean {
27
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
28
+ }
29
+
30
+ /**
31
+ * Initialize expo-crypto module
32
+ */
33
+ async function initExpoCrypto(): Promise<typeof import('expo-crypto')> {
34
+ if (!ExpoCrypto) {
35
+ ExpoCrypto = await import('expo-crypto');
36
+ }
37
+ return ExpoCrypto;
38
+ }
39
+
40
+ /**
41
+ * Compute SHA-256 hash of a string
42
+ */
43
+ async function sha256(message: string): Promise<string> {
44
+ // In React Native, always use expo-crypto
45
+ if (isReactNative() || !isNodeJS()) {
46
+ const Crypto = await initExpoCrypto();
47
+ return Crypto.digestStringAsync(
48
+ Crypto.CryptoDigestAlgorithm.SHA256,
49
+ message
50
+ );
51
+ }
52
+
53
+ // In Node.js, use Node's crypto module
54
+ // Use Function constructor to prevent Metro bundler from statically analyzing this require
55
+ // This ensures the require is only evaluated in Node.js runtime, not during Metro bundling
56
+ try {
57
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
58
+ const getCrypto = new Function('return require("crypto")');
59
+ const crypto = getCrypto();
60
+ return crypto.createHash('sha256').update(message).digest('hex');
61
+ } catch (error) {
62
+ // Fallback to expo-crypto if Node crypto fails
63
+ const Crypto = await initExpoCrypto();
64
+ return Crypto.digestStringAsync(
65
+ Crypto.CryptoDigestAlgorithm.SHA256,
66
+ message
67
+ );
68
+ }
69
+ }
70
+
71
+ export interface SignedMessage {
72
+ message: string;
73
+ signature: string;
74
+ publicKey: string;
75
+ timestamp: number;
76
+ }
77
+
78
+ export interface AuthChallenge {
79
+ challenge: string;
80
+ publicKey: string;
81
+ timestamp: number;
82
+ }
83
+
84
+ export class SignatureService {
85
+ /**
86
+ * Generate a random challenge string (for offline use)
87
+ * Uses expo-crypto in React Native, crypto.randomBytes in Node.js
88
+ */
89
+ static async generateChallenge(): Promise<string> {
90
+ if (isReactNative() || !isNodeJS()) {
91
+ // Use expo-crypto for React Native (expo-random is deprecated)
92
+ const Crypto = await initExpoCrypto();
93
+ const randomBytes = await Crypto.getRandomBytesAsync(32);
94
+ return Array.from(randomBytes)
95
+ .map((b: number) => b.toString(16).padStart(2, '0'))
96
+ .join('');
97
+ }
98
+
99
+ // Node.js fallback
100
+ try {
101
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
102
+ const getCrypto = new Function('return require("crypto")');
103
+ const crypto = getCrypto();
104
+ return crypto.randomBytes(32).toString('hex');
105
+ } catch (error) {
106
+ // Fallback to expo-crypto if Node crypto fails
107
+ const Crypto = await initExpoCrypto();
108
+ const randomBytes = await Crypto.getRandomBytesAsync(32);
109
+ return Array.from(randomBytes)
110
+ .map((b: number) => b.toString(16).padStart(2, '0'))
111
+ .join('');
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Hash a message using SHA-256
117
+ */
118
+ static async hashMessage(message: string): Promise<string> {
119
+ return sha256(message);
120
+ }
121
+
122
+ /**
123
+ * Sign a message using the stored private key
124
+ * Returns the signature in DER format (hex encoded)
125
+ */
126
+ static async sign(message: string): Promise<string> {
127
+ const keyPair = await KeyManager.getKeyPairObject();
128
+ if (!keyPair) {
129
+ throw new Error('No identity found. Please create or import an identity first.');
130
+ }
131
+
132
+ const messageHash = await sha256(message);
133
+ const signature = keyPair.sign(messageHash);
134
+ return signature.toDER('hex');
135
+ }
136
+
137
+ /**
138
+ * Sign a message with an explicit private key (without storing)
139
+ * Useful for one-time operations or testing
140
+ */
141
+ static async signWithKey(message: string, privateKey: string): Promise<string> {
142
+ const keyPair = ec.keyFromPrivate(privateKey);
143
+ const messageHash = await sha256(message);
144
+ const signature = keyPair.sign(messageHash);
145
+ return signature.toDER('hex');
146
+ }
147
+
148
+ /**
149
+ * Verify a signature against a message and public key
150
+ */
151
+ static async verify(message: string, signature: string, publicKey: string): Promise<boolean> {
152
+ try {
153
+ const key = ec.keyFromPublic(publicKey, 'hex');
154
+ const messageHash = await sha256(message);
155
+ return key.verify(messageHash, signature);
156
+ } catch {
157
+ return false;
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Synchronous verification (for Node.js backend)
163
+ * Uses crypto module directly for hashing
164
+ * Note: This method should only be used in Node.js environments
165
+ */
166
+ static verifySync(message: string, signature: string, publicKey: string): boolean {
167
+ try {
168
+ if (!isNodeJS()) {
169
+ // In React Native, use async verify instead
170
+ throw new Error('verifySync should only be used in Node.js. Use verify() in React Native.');
171
+ }
172
+ // Use Function constructor to prevent Metro bundler from statically analyzing this require
173
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
174
+ const getCrypto = new Function('return require("crypto")');
175
+ const crypto = getCrypto();
176
+ const key = ec.keyFromPublic(publicKey, 'hex');
177
+ const messageHash = crypto.createHash('sha256').update(message).digest('hex');
178
+ return key.verify(messageHash, signature);
179
+ } catch {
180
+ return false;
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Create a signed message object with metadata
186
+ */
187
+ static async createSignedMessage(message: string): Promise<SignedMessage> {
188
+ const publicKey = await KeyManager.getPublicKey();
189
+ if (!publicKey) {
190
+ throw new Error('No identity found. Please create or import an identity first.');
191
+ }
192
+
193
+ const timestamp = Date.now();
194
+ const messageWithTimestamp = `${message}:${timestamp}`;
195
+ const signature = await SignatureService.sign(messageWithTimestamp);
196
+
197
+ return {
198
+ message,
199
+ signature,
200
+ publicKey,
201
+ timestamp,
202
+ };
203
+ }
204
+
205
+ /**
206
+ * Verify a signed message object
207
+ * Checks both signature validity and timestamp freshness
208
+ */
209
+ static async verifySignedMessage(
210
+ signedMessage: SignedMessage,
211
+ maxAgeMs: number = 5 * 60 * 1000 // 5 minutes default
212
+ ): Promise<boolean> {
213
+ const { message, signature, publicKey, timestamp } = signedMessage;
214
+
215
+ // Check timestamp freshness
216
+ const now = Date.now();
217
+ if (now - timestamp > maxAgeMs) {
218
+ return false;
219
+ }
220
+
221
+ // Verify signature
222
+ const messageWithTimestamp = `${message}:${timestamp}`;
223
+ return SignatureService.verify(messageWithTimestamp, signature, publicKey);
224
+ }
225
+
226
+ /**
227
+ * Create a signed authentication challenge response
228
+ * Used for challenge-response authentication
229
+ */
230
+ static async signChallenge(challenge: string): Promise<AuthChallenge> {
231
+ const publicKey = await KeyManager.getPublicKey();
232
+ if (!publicKey) {
233
+ throw new Error('No identity found. Please create or import an identity first.');
234
+ }
235
+
236
+ const timestamp = Date.now();
237
+ const message = `auth:${publicKey}:${challenge}:${timestamp}`;
238
+ const signature = await SignatureService.sign(message);
239
+
240
+ return {
241
+ challenge: signature,
242
+ publicKey,
243
+ timestamp,
244
+ };
245
+ }
246
+
247
+ /**
248
+ * Verify a challenge response
249
+ */
250
+ static async verifyChallengeResponse(
251
+ originalChallenge: string,
252
+ response: AuthChallenge,
253
+ maxAgeMs: number = 5 * 60 * 1000
254
+ ): Promise<boolean> {
255
+ const { challenge: signature, publicKey, timestamp } = response;
256
+
257
+ // Check timestamp freshness
258
+ const now = Date.now();
259
+ if (now - timestamp > maxAgeMs) {
260
+ return false;
261
+ }
262
+
263
+ const message = `auth:${publicKey}:${originalChallenge}:${timestamp}`;
264
+ return SignatureService.verify(message, signature, publicKey);
265
+ }
266
+
267
+ /**
268
+ * Create a registration signature
269
+ * Used when registering a new identity with the server
270
+ * Format matches server expectation: oxy:register:{publicKey}:{timestamp}
271
+ */
272
+ static async createRegistrationSignature(): Promise<{ signature: string; publicKey: string; timestamp: number }> {
273
+ const publicKey = await KeyManager.getPublicKey();
274
+ if (!publicKey) {
275
+ throw new Error('No identity found. Please create or import an identity first.');
276
+ }
277
+
278
+ const timestamp = Date.now();
279
+ const message = `oxy:register:${publicKey}:${timestamp}`;
280
+ const signature = await SignatureService.sign(message);
281
+
282
+ return {
283
+ signature,
284
+ publicKey,
285
+ timestamp,
286
+ };
287
+ }
288
+
289
+ /**
290
+ * Sign arbitrary data for API requests
291
+ * Creates a canonical string representation and signs it
292
+ */
293
+ static async signRequestData(data: Record<string, unknown>): Promise<{
294
+ signature: string;
295
+ publicKey: string;
296
+ timestamp: number;
297
+ }> {
298
+ const publicKey = await KeyManager.getPublicKey();
299
+ if (!publicKey) {
300
+ throw new Error('No identity found. Please create or import an identity first.');
301
+ }
302
+
303
+ const timestamp = Date.now();
304
+
305
+ // Create canonical string representation
306
+ const sortedKeys = Object.keys(data).sort();
307
+ const canonicalParts = sortedKeys.map(key => `${key}:${JSON.stringify(data[key])}`);
308
+ const canonicalString = canonicalParts.join('|');
309
+
310
+ const message = `request:${publicKey}:${timestamp}:${canonicalString}`;
311
+ const signature = await SignatureService.sign(message);
312
+
313
+ return {
314
+ signature,
315
+ publicKey,
316
+ timestamp,
317
+ };
318
+ }
319
+ }
320
+
321
+ export default SignatureService;
322
+
323
+
@@ -237,7 +237,7 @@
237
237
  "enterCode": "Enter the 6‑digit code from your authenticator app.",
238
238
  "newPassword": "Set New Password",
239
239
  "resetSuccess": "Your password has been reset! You can now sign in.",
240
- "noEmail": "We no longer send recovery emails. Please use your backup file to restore your identity. Contact support if you need assistance.",
240
+ "noEmail": "We no longer send recovery emails. Please use your recovery phrase to restore your identity. Contact support if you need assistance.",
241
241
  "password": {
242
242
  "minLength": "Password must be at least 8 characters long",
243
243
  "mismatch": "Passwords do not match",
package/src/index.ts CHANGED
@@ -4,21 +4,32 @@
4
4
  * This exports everything but uses environment detection to avoid crashes.
5
5
  * - Frontend: Full UI + Core functionality
6
6
  * - Backend: Core functionality only (UI components are no-ops)
7
- *
8
- * NOTE: Identity management (KeyManager, SignatureService) belongs ONLY in the Accounts app.
9
- * Services SDK handles tokens/sessions, NOT identity.
10
7
  */
11
8
 
12
9
  // IMPORTANT: Import crypto module first to ensure polyfills are loaded
13
10
  // before any other code that might use Buffer or other polyfilled APIs
14
11
  import './crypto/polyfill';
15
12
 
13
+ // Crypto/Identity exports (must be before core to ensure polyfills are available)
14
+ export {
15
+ KeyManager,
16
+ SignatureService,
17
+ RecoveryPhraseService
18
+ } from './crypto';
19
+
16
20
  // Core exports
17
21
  export { OxyServices, OxyAuthenticationError, OxyAuthenticationTimeoutError } from './core';
18
22
  export { OXY_CLOUD_URL, oxyClient } from './core';
19
23
 
20
- // Type exports from crypto (types only - no identity implementation)
21
- export type { BackupData } from './crypto';
24
+ // Cross-domain authentication (Web SSO via FedCM/popup/redirect)
25
+ export { CrossDomainAuth, createCrossDomainAuth } from './core';
26
+ export type { CrossDomainAuthOptions } from './core';
27
+ export type {
28
+ KeyPair,
29
+ SignedMessage,
30
+ AuthChallenge,
31
+ RecoveryPhraseResult
32
+ } from './crypto';
22
33
 
23
34
  // React context
24
35
  export { useOxy } from './ui/context/OxyContext';
@@ -177,7 +188,8 @@ export {
177
188
  ErrorCodes,
178
189
  createApiError,
179
190
  handleHttpError,
180
- validateRequiredFields
191
+ validateRequiredFields,
192
+ retryWithBackoff
181
193
  } from './utils/errorUtils';
182
194
  export * from './utils/validationUtils';
183
195
  export {
@@ -193,12 +205,4 @@ export {
193
205
  logPerformance
194
206
  } from './utils/loggerUtils';
195
207
  export * from './utils/asyncUtils';
196
- export * from './utils/hookUtils';
197
-
198
- // Avatar and account utilities
199
- export {
200
- refreshAvatarInStore,
201
- refreshAccountInStore,
202
- updateAvatarVisibility,
203
- updateProfileWithAvatar
204
- } from './ui/utils/avatarUtils';
208
+ export * from './utils/hookUtils';
@@ -1,6 +1,8 @@
1
1
  export interface OxyConfig {
2
2
  baseURL: string;
3
3
  cloudURL?: string;
4
+ authWebUrl?: string;
5
+ authRedirectUri?: string;
4
6
  // Performance & caching options
5
7
  enableCache?: boolean;
6
8
  cacheTTL?: number; // Cache TTL in milliseconds (default: 5 minutes)
@@ -21,23 +23,9 @@ export interface OxyConfig {
21
23
  onRequestError?: (url: string, method: string, error: Error) => void;
22
24
  }
23
25
 
24
- /**
25
- * User Model
26
- *
27
- * IMPORTANT:
28
- * - id: MongoDB ObjectId (24 hex characters) - PRIMARY IDENTIFIER for all internal operations
29
- * - publicKey: Cryptographic public key (130 hex characters) - LOOKUP KEY for authentication and identity operations
30
- *
31
- * Never use publicKey as an ID. Always use id (ObjectId) for:
32
- * - Database queries
33
- * - Session userId
34
- * - Token userId
35
- * - Socket room names
36
- * - API route parameters (unless explicitly doing publicKey lookup)
37
- */
38
26
  export interface User {
39
- id: string; // MongoDB ObjectId - PRIMARY IDENTIFIER (always 24 hex chars)
40
- publicKey: string; // Cryptographic public key - LOOKUP KEY (130 hex chars for secp256k1)
27
+ id: string;
28
+ publicKey: string;
41
29
  username: string;
42
30
  email?: string;
43
31
  // Avatar file id (asset id)
@@ -1,16 +1,9 @@
1
- /**
2
- * Client Session Model
3
- *
4
- * IMPORTANT:
5
- * - userId: MongoDB ObjectId (24 hex characters), never publicKey
6
- * - Used for session management and user identification
7
- */
8
1
  export interface ClientSession {
9
2
  sessionId: string;
10
3
  deviceId: string;
11
4
  expiresAt: string;
12
5
  lastActive: string;
13
- userId?: string; // MongoDB ObjectId - PRIMARY IDENTIFIER (never publicKey)
6
+ userId?: string;
14
7
  isCurrent?: boolean;
15
8
  }
16
9
 
@@ -29,7 +22,5 @@ export interface SessionLoginResponse {
29
22
  sessionId: string;
30
23
  deviceId: string;
31
24
  expiresAt: string;
32
- accessToken: string;
33
- refreshToken: string;
34
25
  user: MinimalUserData;
35
- }
26
+ }
@@ -0,0 +1,32 @@
1
+ declare module 'bip39' {
2
+ export interface Wordlist {
3
+ [index: number]: string;
4
+ length: number;
5
+ getWord(index: number): string;
6
+ getWordIndex(word: string): number;
7
+ }
8
+
9
+ export const wordlists: {
10
+ english: string[];
11
+ chinese_simplified: string[];
12
+ chinese_traditional: string[];
13
+ french: string[];
14
+ italian: string[];
15
+ japanese: string[];
16
+ korean: string[];
17
+ spanish: string[];
18
+ };
19
+
20
+ // Use Uint8Array instead of Buffer for React Native compatibility
21
+ // In Node.js, Buffer extends Uint8Array so this is compatible
22
+ export function generateMnemonic(strength?: number, rng?: (size: number) => Uint8Array, wordlist?: string[]): string;
23
+ export function mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Uint8Array>;
24
+ export function mnemonicToSeedSync(mnemonic: string, passphrase?: string): Uint8Array;
25
+ export function mnemonicToEntropy(mnemonic: string, wordlist?: string[]): string;
26
+ export function entropyToMnemonic(entropy: string, wordlist?: string[]): string;
27
+ export function validateMnemonic(mnemonic: string, wordlist?: string[]): boolean;
28
+ export function mnemonicToSeedHex(mnemonic: string, passphrase?: string): Promise<string>;
29
+ export function mnemonicToSeedHexSync(mnemonic: string, passphrase?: string): string;
30
+ }
31
+
32
+