@oxyhq/services 5.16.43 → 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 -37
  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 -34
  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 -34
  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,273 +0,0 @@
1
- /**
2
- * Device Manager
3
- *
4
- * Manages device identification and device sessions (Native + Web)
5
- */
6
-
7
- import type { PlatformAdapter } from '../../adapters';
8
- import type { Device, DeviceInfo } from './types';
9
- import {
10
- createIdentitySessionError,
11
- IdentitySessionErrorCodes,
12
- } from './errors';
13
-
14
- const DEVICE_STORAGE_KEY = 'oxy_device_info';
15
-
16
- interface StoredDeviceInfo {
17
- deviceId: string;
18
- deviceName?: string;
19
- fingerprint?: string;
20
- createdAt: string;
21
- lastUsed: string;
22
- }
23
-
24
- /**
25
- * Device Manager Class
26
- */
27
- export class DeviceManager {
28
- private adapter: PlatformAdapter;
29
- private cachedDevice: Device | null = null;
30
-
31
- constructor(adapter: PlatformAdapter) {
32
- this.adapter = adapter;
33
- }
34
-
35
- /**
36
- * Invalidate cached device
37
- */
38
- invalidateCache(): void {
39
- this.cachedDevice = null;
40
- }
41
-
42
- /**
43
- * Get device fingerprint
44
- */
45
- private getDeviceFingerprint(): Record<string, unknown> {
46
- const fingerprint: Record<string, unknown> = {
47
- userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : 'unknown',
48
- platform: typeof navigator !== 'undefined' ? navigator.platform : 'unknown',
49
- language: typeof navigator !== 'undefined' ? navigator.language : undefined,
50
- timezone: typeof Intl !== 'undefined' ? Intl.DateTimeFormat().resolvedOptions().timeZone : undefined,
51
- };
52
-
53
- // Add screen info if available
54
- if (typeof screen !== 'undefined') {
55
- fingerprint.screen = {
56
- width: screen.width,
57
- height: screen.height,
58
- colorDepth: screen.colorDepth,
59
- };
60
- }
61
-
62
- return fingerprint;
63
- }
64
-
65
- /**
66
- * Generate a unique device ID
67
- */
68
- private async generateDeviceId(): Promise<string> {
69
- const randomBytes = await this.adapter.crypto.getRandomBytes(32);
70
- return Array.from(randomBytes, byte => byte.toString(16).padStart(2, '0')).join('');
71
- }
72
-
73
- /**
74
- * Get a user-friendly device name based on platform
75
- */
76
- private getDefaultDeviceName(): string {
77
- const fingerprint = this.getDeviceFingerprint();
78
- const platform = (fingerprint.platform as string || '').toLowerCase();
79
- const userAgent = (fingerprint.userAgent as string || '').toLowerCase();
80
-
81
- if (platform.includes('win')) return 'Windows Computer';
82
- if (platform.includes('mac')) return 'Mac Computer';
83
- if (platform.includes('linux')) return 'Linux Computer';
84
- if (userAgent.includes('iphone')) return 'iPhone';
85
- if (userAgent.includes('ipad')) return 'iPad';
86
- if (userAgent.includes('android')) return 'Android Device';
87
- if (this.adapter.platform === 'web') return 'Web Browser';
88
-
89
- return 'Unknown Device';
90
- }
91
-
92
- /**
93
- * Get stored device info or create new one
94
- */
95
- async getCurrentDevice(): Promise<Device | null> {
96
- if (this.cachedDevice) {
97
- return this.cachedDevice;
98
- }
99
-
100
- try {
101
- const stored = await this.adapter.storage.get(DEVICE_STORAGE_KEY);
102
-
103
- if (stored) {
104
- const deviceInfo: StoredDeviceInfo = JSON.parse(stored);
105
-
106
- // Update last used timestamp
107
- deviceInfo.lastUsed = new Date().toISOString();
108
- await this.saveDeviceInfo(deviceInfo);
109
-
110
- const device: Device = {
111
- deviceId: deviceInfo.deviceId,
112
- deviceName: deviceInfo.deviceName,
113
- deviceType: this.getDeviceType(),
114
- platform: this.adapter.platform === 'native' ? 'ios' : 'web', // Simplified
115
- fingerprint: deviceInfo.fingerprint,
116
- createdAt: deviceInfo.createdAt,
117
- updatedAt: deviceInfo.lastUsed,
118
- };
119
-
120
- this.cachedDevice = device;
121
- return device;
122
- }
123
-
124
- // Create new device info
125
- return await this.createNewDevice();
126
- } catch (error) {
127
- console.error('[DeviceManager] Error getting device info:', error);
128
- return await this.createNewDevice();
129
- }
130
- }
131
-
132
- /**
133
- * Create new device info and store it
134
- */
135
- async createNewDevice(): Promise<Device> {
136
- const deviceId = await this.generateDeviceId();
137
- const fingerprint = JSON.stringify(this.getDeviceFingerprint());
138
- const now = new Date().toISOString();
139
-
140
- const device: Device = {
141
- deviceId,
142
- deviceName: this.getDefaultDeviceName(),
143
- deviceType: this.getDeviceType(),
144
- platform: this.adapter.platform === 'native' ? 'ios' : 'web', // Simplified
145
- fingerprint,
146
- createdAt: now,
147
- updatedAt: now,
148
- };
149
-
150
- const deviceInfo: StoredDeviceInfo = {
151
- deviceId,
152
- deviceName: device.deviceName,
153
- fingerprint,
154
- createdAt: now,
155
- lastUsed: now,
156
- };
157
-
158
- await this.saveDeviceInfo(deviceInfo);
159
- this.cachedDevice = device;
160
-
161
- return device;
162
- }
163
-
164
- /**
165
- * Get device type
166
- */
167
- private getDeviceType(): string {
168
- if (this.adapter.platform === 'web') {
169
- return 'desktop'; // Simplified - could detect mobile web
170
- }
171
- // For native, would need Platform.OS detection
172
- return 'mobile';
173
- }
174
-
175
- /**
176
- * Save device info to storage
177
- */
178
- private async saveDeviceInfo(deviceInfo: StoredDeviceInfo): Promise<void> {
179
- try {
180
- await this.adapter.storage.set(DEVICE_STORAGE_KEY, JSON.stringify(deviceInfo));
181
- } catch (error) {
182
- console.error('[DeviceManager] Error saving device info:', error);
183
- throw createIdentitySessionError(
184
- IdentitySessionErrorCodes.DEVICE_CREATION_FAILED,
185
- `Failed to save device info: ${error instanceof Error ? error.message : String(error)}`
186
- );
187
- }
188
- }
189
-
190
- /**
191
- * Update device name
192
- */
193
- async updateDeviceName(deviceName: string): Promise<Device> {
194
- const device = await this.getCurrentDevice();
195
- if (!device) {
196
- throw createIdentitySessionError(
197
- IdentitySessionErrorCodes.DEVICE_NOT_FOUND,
198
- 'Device not found'
199
- );
200
- }
201
-
202
- device.deviceName = deviceName;
203
- device.updatedAt = new Date().toISOString();
204
-
205
- const deviceInfo: StoredDeviceInfo = {
206
- deviceId: device.deviceId,
207
- deviceName: device.deviceName,
208
- fingerprint: device.fingerprint,
209
- createdAt: device.createdAt || new Date().toISOString(),
210
- lastUsed: device.updatedAt,
211
- };
212
-
213
- await this.saveDeviceInfo(deviceInfo);
214
- this.cachedDevice = device;
215
-
216
- return device;
217
- }
218
-
219
- /**
220
- * Get device info for session creation
221
- */
222
- async getDeviceInfo(): Promise<DeviceInfo> {
223
- const device = await this.getCurrentDevice();
224
- if (!device) {
225
- throw createIdentitySessionError(
226
- IdentitySessionErrorCodes.DEVICE_NOT_FOUND,
227
- 'Device not found'
228
- );
229
- }
230
-
231
- const fingerprint = this.getDeviceFingerprint();
232
-
233
- return {
234
- deviceName: device.deviceName,
235
- deviceType: device.deviceType,
236
- platform: device.platform,
237
- browser: typeof navigator !== 'undefined' ? this.getBrowserName() : undefined,
238
- os: typeof navigator !== 'undefined' ? navigator.platform : undefined,
239
- lastActive: new Date().toISOString(),
240
- userAgent: fingerprint.userAgent as string,
241
- fingerprint: device.fingerprint,
242
- };
243
- }
244
-
245
- /**
246
- * Get browser name from user agent
247
- */
248
- private getBrowserName(): string | undefined {
249
- if (typeof navigator === 'undefined') return undefined;
250
-
251
- const ua = navigator.userAgent.toLowerCase();
252
- if (ua.includes('chrome')) return 'Chrome';
253
- if (ua.includes('firefox')) return 'Firefox';
254
- if (ua.includes('safari') && !ua.includes('chrome')) return 'Safari';
255
- if (ua.includes('edge')) return 'Edge';
256
- if (ua.includes('opera')) return 'Opera';
257
-
258
- return undefined;
259
- }
260
-
261
- /**
262
- * Clear stored device info
263
- */
264
- async clearDeviceInfo(): Promise<void> {
265
- try {
266
- await this.adapter.storage.remove(DEVICE_STORAGE_KEY);
267
- this.invalidateCache();
268
- } catch (error) {
269
- console.error('[DeviceManager] Error clearing device info:', error);
270
- }
271
- }
272
- }
273
-
@@ -1,287 +0,0 @@
1
- # Identity Session Core - Integration Guide
2
-
3
- ## Overview
4
-
5
- The Identity Session Core provides a unified API for identity and session management across all platforms (React Native, Web, Node). All identity and session operations go through this core - never access `KeyManager`, storage, or APIs directly.
6
-
7
- ## Architecture
8
-
9
- ```
10
- UI/Hooks Layer
11
-
12
- IdentitySessionCore (unified API)
13
-
14
- Managers (Identity, Session, Device, Refresh)
15
-
16
- Platform Adapters (Expo 54, Node)
17
- ```
18
-
19
- ## Key Principles
20
-
21
- 1. **Frontend: Use `useOxy()` hook** - This is the only API you need for React/React Native applications
22
- 2. **Backend: Use `createIdentitySessionCore()`** - Only for Node.js/backend applications
23
- 3. **Never access storage, APIs, or KeyManager directly** - Always go through the core or `useOxy()`
24
- 4. **Identity operations are NATIVE ONLY** - Web cannot create/import identities
25
- 5. **Session operations work on NATIVE + WEB** - sessions can be used on both platforms
26
- 6. **Models are aligned with backend** - same types, same error codes
27
-
28
- ## Installation
29
-
30
- ```bash
31
- npm install @oxyhq/services
32
- ```
33
-
34
- ## Basic Usage
35
-
36
- ### Using the React Hook (Recommended)
37
-
38
- ```typescript
39
- import { OxyProvider, useOxy } from '@oxyhq/services';
40
- import { Platform } from 'react-native';
41
-
42
- function App() {
43
- return (
44
- <OxyProvider baseURL="https://api.example.com">
45
- <MyComponent />
46
- </OxyProvider>
47
- );
48
- }
49
-
50
- function MyComponent() {
51
- const { createIdentity, signIn, hasIdentity, isLoading, error } = useOxy();
52
-
53
- const handleCreateIdentity = async () => {
54
- if (Platform.OS === 'web') {
55
- alert('Identity creation is only available on native platforms');
56
- return;
57
- }
58
-
59
- try {
60
- const result = await createIdentity('myusername');
61
- console.log('Identity created, synced:', result.synced);
62
- } catch (err) {
63
- console.error('Failed to create identity:', err);
64
- }
65
- };
66
-
67
- const handleSignIn = async () => {
68
- try {
69
- const user = await signIn('My Device');
70
- console.log('Signed in:', user);
71
- } catch (err) {
72
- console.error('Failed to sign in:', err);
73
- }
74
- };
75
-
76
- if (error) return <Text>Error: {error}</Text>;
77
- if (isLoading) return <Text>Loading...</Text>;
78
-
79
- return (
80
- <View>
81
- <Button onPress={handleCreateIdentity} title="Create Identity" />
82
- <Button onPress={handleSignIn} title="Sign In" />
83
- </View>
84
- );
85
- }
86
- ```
87
-
88
- ### Direct Core Usage (Backend/Node.js Only)
89
-
90
- **Note:** For frontend applications, always use `useOxy()` hook. Direct core usage is only for backend/Node.js applications.
91
-
92
- ```typescript
93
- import { createIdentitySessionCore } from '@oxyhq/services';
94
-
95
- // Backend/Node.js only
96
- const core = await createIdentitySessionCore('https://api.example.com');
97
- const identity = await core.getCurrentIdentity();
98
- const session = await core.getSession();
99
- ```
100
-
101
- ## API Reference
102
-
103
- ### Using `useOxy` Hook (Recommended)
104
-
105
- The `useOxy` hook provides all identity and session operations through a simple, reactive API:
106
-
107
- ```typescript
108
- const {
109
- // Identity (Native Only)
110
- createIdentity,
111
- importIdentity,
112
- deleteIdentityAndClearAccount,
113
- hasIdentity,
114
- getPublicKey,
115
- isIdentitySynced,
116
- syncIdentity,
117
- identity,
118
- publicKey,
119
- identitySyncState,
120
-
121
- // Session (Native + Web)
122
- signIn,
123
- logout,
124
- logoutAll,
125
- switchSession,
126
- refreshSession,
127
- session,
128
- sessions,
129
- activeSessionId,
130
- isAuthenticated,
131
-
132
- // Device (Native + Web)
133
- getDeviceSessions,
134
- logoutAllDeviceSessions,
135
- updateDeviceName,
136
- device,
137
-
138
- // State
139
- user,
140
- isLoading,
141
- isTokenReady,
142
- isStorageReady,
143
- error,
144
- } = useOxy();
145
- ```
146
-
147
- ### Identity Operations (Native Only)
148
-
149
- ```typescript
150
- // Create new identity
151
- const result = await createIdentity(username?);
152
- // result.synced indicates if identity was synced with backend
153
-
154
- // Import identity from backup
155
- const result = await importIdentity(backupData, password, username?);
156
- // result.synced indicates if identity was synced with backend
157
-
158
- // Delete identity and clear all account data
159
- await deleteIdentityAndClearAccount(skipBackup?, force?, userConfirmed?);
160
-
161
- // Check if identity exists
162
- const has = await hasIdentity();
163
-
164
- // Get public key
165
- const publicKey = await getPublicKey();
166
-
167
- // Check if identity is synced
168
- const synced = await isIdentitySynced();
169
-
170
- // Manually sync identity
171
- const user = await syncIdentity(username?);
172
- ```
173
-
174
- ### Session Operations (Native + Web)
175
-
176
- ```typescript
177
- // Sign in (create session)
178
- const user = await signIn(deviceName?);
179
-
180
- // Logout (invalidate current or specific session)
181
- await logout(sessionId?);
182
-
183
- // Logout all sessions
184
- await logoutAll();
185
-
186
- // Switch to different session
187
- await switchSession(sessionId);
188
-
189
- // Refresh current session
190
- const session = await refreshSession();
191
- ```
192
-
193
- ### Device Operations (Native + Web)
194
-
195
- ```typescript
196
- // Get all device sessions
197
- const deviceSessions = await getDeviceSessions();
198
-
199
- // Logout all sessions for current device
200
- await logoutAllDeviceSessions();
201
-
202
- // Update device name
203
- await updateDeviceName(deviceName);
204
- ```
205
-
206
- ### Direct Core Usage (Advanced)
207
-
208
- For advanced use cases, you can access the core directly:
209
-
210
- ```typescript
211
- import { createIdentitySessionCore } from '@oxyhq/services';
212
-
213
- const core = await createIdentitySessionCore('https://api.example.com');
214
- const identity = await core.getCurrentIdentity();
215
- const session = await core.getSession();
216
-
217
- // Subscribe to events
218
- const unsubscribe = core.subscribe((event) => {
219
- switch (event.type) {
220
- case 'identity:created':
221
- console.log('Identity created:', event.identity);
222
- break;
223
- case 'session:created':
224
- console.log('Session created:', event.session);
225
- break;
226
- case 'session:invalidated':
227
- console.log('Session invalidated:', event.sessionId);
228
- break;
229
- }
230
- });
231
-
232
- // Cleanup
233
- unsubscribe();
234
- ```
235
-
236
- ## Error Handling
237
-
238
- All errors use unified error codes:
239
-
240
- ```typescript
241
- import {
242
- IdentitySessionError,
243
- IdentitySessionErrorCodes
244
- } from '@oxyhq/services';
245
-
246
- try {
247
- await createIdentity();
248
- } catch (error) {
249
- if (error instanceof IdentitySessionError) {
250
- switch (error.code) {
251
- case IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB:
252
- // Handle web platform error
253
- break;
254
- case IdentitySessionErrorCodes.IDENTITY_ALREADY_EXISTS:
255
- // Handle already exists error
256
- break;
257
- default:
258
- console.error('Error:', error.message);
259
- }
260
- }
261
- }
262
- ```
263
-
264
- ## Type Exports
265
-
266
- ```typescript
267
- import type {
268
- Identity,
269
- Session,
270
- Device,
271
- DeviceInfo,
272
- BackupData,
273
- IdentitySessionEvent,
274
- } from '@oxyhq/services';
275
- ```
276
-
277
- ## Platform Detection
278
-
279
- The core automatically detects the platform and validates operations. Identity operations will throw `IDENTITY_NOT_AVAILABLE_ON_WEB` on web platforms.
280
-
281
- ## Notes
282
-
283
- - The core handles all platform-specific logic internally
284
- - Storage, crypto, and fetch are abstracted through platform adapters
285
- - All models are aligned with backend (IUser, ISession)
286
- - Error codes are unified across frontend and backend
287
- - The core is designed to be "plugged in" to any Oxy app (Mention, Homiio, Noted, etc.)