@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,394 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.IdentitySessionCore = void 0;
7
- var _IdentityManager = require("./IdentityManager");
8
- var _SessionManager = require("./SessionManager");
9
- var _DeviceManager = require("./DeviceManager");
10
- var _RefreshManager = require("./RefreshManager");
11
- var _errors = require("./errors");
12
- /**
13
- * Identity Session Core
14
- *
15
- * Main orchestrator for identity and session management.
16
- * Provides a unified API for all identity and session operations.
17
- */
18
-
19
- /**
20
- * Identity Session Core Class
21
- */
22
- class IdentitySessionCore {
23
- baseURL = null;
24
- eventListeners = new Set();
25
- initialized = false;
26
- constructor(adapter, baseURL) {
27
- this.adapter = adapter;
28
- this.baseURL = baseURL || null;
29
-
30
- // Initialize managers
31
- this.identityManager = new _IdentityManager.IdentityManager(adapter);
32
- this.deviceManager = new _DeviceManager.DeviceManager(adapter);
33
- this.refreshManager = new _RefreshManager.RefreshManager(adapter, baseURL);
34
- this.sessionManager = new _SessionManager.SessionManager(adapter, this.deviceManager, this.refreshManager, baseURL);
35
- }
36
-
37
- /**
38
- * Set base URL for API requests
39
- */
40
- setBaseURL(baseURL) {
41
- this.baseURL = baseURL;
42
- this.sessionManager.setBaseURL(baseURL);
43
- this.refreshManager.setBaseURL(baseURL);
44
- }
45
-
46
- /**
47
- * Initialize the core (load data from storage)
48
- */
49
- async initialize() {
50
- if (this.initialized) {
51
- return;
52
- }
53
- await this.sessionManager.initialize();
54
- this.initialized = true;
55
- }
56
-
57
- /**
58
- * Emit an event to all subscribers
59
- */
60
- emit(event) {
61
- this.eventListeners.forEach(listener => {
62
- try {
63
- listener(event);
64
- } catch (error) {
65
- console.error('[IdentitySessionCore] Error in event listener:', error);
66
- }
67
- });
68
- }
69
-
70
- // ==================== Identity Operations ====================
71
-
72
- /**
73
- * Get current identity (SOLO NATIVE)
74
- */
75
- async getCurrentIdentity() {
76
- if (this.adapter.platform !== 'native') {
77
- return null; // Identity only exists on native
78
- }
79
- const publicKey = await this.identityManager.getPublicKey();
80
- if (!publicKey) {
81
- return null;
82
- }
83
-
84
- // Identity object would need to be fetched from server
85
- // For now, return a minimal identity object
86
- return {
87
- id: '',
88
- // Would be fetched from server
89
- publicKey
90
- };
91
- }
92
-
93
- /**
94
- * Create a new identity (SOLO NATIVE)
95
- */
96
- async createIdentity(username) {
97
- if (this.adapter.platform !== 'native') {
98
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB, 'Identity creation is only available on native platforms');
99
- }
100
- try {
101
- const publicKey = await this.identityManager.createIdentity();
102
- const identity = {
103
- id: '',
104
- // Will be set after sync with server
105
- publicKey,
106
- username
107
- };
108
- this.emit({
109
- type: 'identity:created',
110
- identity
111
- });
112
- return identity;
113
- } catch (error) {
114
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_CREATION_FAILED, `Failed to create identity: ${error instanceof Error ? error.message : String(error)}`);
115
- }
116
- }
117
-
118
- /**
119
- * Import identity from backup (SOLO NATIVE)
120
- */
121
- async importIdentity(backupData, password) {
122
- if (this.adapter.platform !== 'native') {
123
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB, 'Identity import is only available on native platforms');
124
- }
125
- try {
126
- const publicKey = await this.identityManager.decryptAndImportBackup(backupData, password);
127
- const identity = {
128
- id: '',
129
- // Will be set after sync with server
130
- publicKey
131
- };
132
- this.emit({
133
- type: 'identity:imported',
134
- identity
135
- });
136
- return identity;
137
- } catch (error) {
138
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_IMPORT_FAILED, `Failed to import identity: ${error instanceof Error ? error.message : String(error)}`);
139
- }
140
- }
141
-
142
- /**
143
- * Delete identity (SOLO NATIVE)
144
- */
145
- async deleteIdentity(skipBackup = false, force = false, userConfirmed = false) {
146
- if (this.adapter.platform !== 'native') {
147
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB, 'Identity deletion is only available on native platforms');
148
- }
149
- try {
150
- await this.identityManager.deleteIdentity(skipBackup, force, userConfirmed);
151
- this.emit({
152
- type: 'identity:deleted'
153
- });
154
- } catch (error) {
155
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_DELETE_FAILED, `Failed to delete identity: ${error instanceof Error ? error.message : String(error)}`);
156
- }
157
- }
158
-
159
- /**
160
- * Sign a challenge (SOLO NATIVE)
161
- */
162
- async signChallenge(challenge) {
163
- if (this.adapter.platform !== 'native') {
164
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB, 'Challenge signing is only available on native platforms');
165
- }
166
- try {
167
- return await this.identityManager.signChallenge(challenge);
168
- } catch (error) {
169
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_FOUND, `Failed to sign challenge: ${error instanceof Error ? error.message : String(error)}`);
170
- }
171
- }
172
-
173
- /**
174
- * Generate a random challenge string
175
- */
176
- async generateChallenge() {
177
- const randomBytes = await this.adapter.crypto.getRandomBytes(32);
178
- return Array.from(randomBytes, byte => byte.toString(16).padStart(2, '0')).join('');
179
- }
180
-
181
- /**
182
- * Create a registration signature (SOLO NATIVE)
183
- */
184
- async createRegistrationSignature() {
185
- if (this.adapter.platform !== 'native') {
186
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB, 'Registration signature is only available on native platforms');
187
- }
188
- const publicKey = await this.identityManager.getPublicKey();
189
- if (!publicKey) {
190
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_FOUND, 'No identity found. Please create or import an identity first.');
191
- }
192
- const timestamp = Date.now();
193
- const message = `oxy:register:${publicKey}:${timestamp}`;
194
- const messageHash = await this.adapter.crypto.digestStringAsync('SHA256', message);
195
- const signature = await this.identityManager.signChallenge(messageHash);
196
- return {
197
- signature,
198
- publicKey,
199
- timestamp
200
- };
201
- }
202
-
203
- /**
204
- * Sign challenge for authentication (SOLO NATIVE)
205
- * Returns AuthChallenge object with signature, publicKey, and timestamp
206
- */
207
- async signChallengeForAuth(challenge) {
208
- if (this.adapter.platform !== 'native') {
209
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB, 'Challenge signing is only available on native platforms');
210
- }
211
- const publicKey = await this.identityManager.getPublicKey();
212
- if (!publicKey) {
213
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_FOUND, 'No identity found. Please create or import an identity first.');
214
- }
215
- const timestamp = Date.now();
216
- const message = `auth:${publicKey}:${challenge}:${timestamp}`;
217
- const messageHash = await this.adapter.crypto.digestStringAsync('SHA256', message);
218
- const signature = await this.identityManager.signChallenge(messageHash);
219
- return {
220
- challenge,
221
- signature,
222
- publicKey,
223
- timestamp
224
- };
225
- }
226
-
227
- /**
228
- * Check if identity exists
229
- */
230
- async hasIdentity() {
231
- return await this.identityManager.hasIdentity();
232
- }
233
-
234
- /**
235
- * Get public key
236
- */
237
- async getPublicKey() {
238
- return await this.identityManager.getPublicKey();
239
- }
240
-
241
- // ==================== Session Operations ====================
242
-
243
- /**
244
- * Get current session (Native + Web)
245
- */
246
- async getSession() {
247
- return await this.sessionManager.getSession();
248
- }
249
-
250
- /**
251
- * Get all sessions (Native + Web)
252
- */
253
- async getAllSessions() {
254
- return await this.sessionManager.getAllSessions();
255
- }
256
-
257
- /**
258
- * Get active session ID (Native + Web)
259
- */
260
- async getActiveSessionId() {
261
- return await this.sessionManager.getActiveSessionId();
262
- }
263
-
264
- /**
265
- * Create a new session (sign in) (Native + Web)
266
- */
267
- async createSession(deviceName) {
268
- if (this.adapter.platform !== 'native') {
269
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB, 'Session creation requires identity, which is only available on native platforms');
270
- }
271
- const publicKey = await this.identityManager.getPublicKey();
272
- if (!publicKey) {
273
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.IDENTITY_NOT_FOUND, 'No identity found. Please create or import an identity first.');
274
- }
275
-
276
- // Generate challenge and sign it
277
- const timestamp = Date.now();
278
- const challenge = `auth:${publicKey}:${timestamp}`;
279
- const signature = await this.identityManager.signChallenge(challenge);
280
- try {
281
- const session = await this.sessionManager.createSession(publicKey, signature, timestamp, deviceName);
282
- this.emit({
283
- type: 'session:created',
284
- session
285
- });
286
- return session;
287
- } catch (error) {
288
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.SESSION_CREATION_FAILED, `Failed to create session: ${error instanceof Error ? error.message : String(error)}`);
289
- }
290
- }
291
-
292
- /**
293
- * Refresh current session (Native + Web)
294
- */
295
- async refreshSession() {
296
- try {
297
- const session = await this.sessionManager.refreshSession();
298
- this.emit({
299
- type: 'session:refreshed',
300
- session
301
- });
302
- return session;
303
- } catch (error) {
304
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.SESSION_REFRESH_FAILED, `Failed to refresh session: ${error instanceof Error ? error.message : String(error)}`);
305
- }
306
- }
307
-
308
- /**
309
- * Invalidate a session (Native + Web)
310
- */
311
- async invalidateSession(sessionId) {
312
- try {
313
- await this.sessionManager.invalidateSession(sessionId);
314
- const targetSessionId = sessionId || (await this.sessionManager.getActiveSessionId());
315
- if (targetSessionId) {
316
- this.emit({
317
- type: 'session:invalidated',
318
- sessionId: targetSessionId
319
- });
320
- }
321
- } catch (error) {
322
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.SESSION_INVALID, `Failed to invalidate session: ${error instanceof Error ? error.message : String(error)}`);
323
- }
324
- }
325
-
326
- /**
327
- * Invalidate all sessions (Native + Web)
328
- */
329
- async invalidateAllSessions() {
330
- try {
331
- await this.sessionManager.invalidateAllSessions();
332
- this.emit({
333
- type: 'session:all-invalidated'
334
- });
335
- } catch (error) {
336
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.SESSION_INVALID, `Failed to invalidate all sessions: ${error instanceof Error ? error.message : String(error)}`);
337
- }
338
- }
339
-
340
- // ==================== Device Operations ====================
341
-
342
- /**
343
- * Get current device (Native + Web)
344
- */
345
- async getCurrentDevice() {
346
- return await this.deviceManager.getCurrentDevice();
347
- }
348
-
349
- // ==================== Subscriptions ====================
350
-
351
- /**
352
- * Subscribe to identity and session events
353
- */
354
- subscribe(callback) {
355
- this.eventListeners.add(callback);
356
-
357
- // Return unsubscribe function
358
- return () => {
359
- this.eventListeners.delete(callback);
360
- };
361
- }
362
-
363
- // ==================== Internal Access ====================
364
-
365
- /**
366
- * Get identity manager (for advanced operations)
367
- */
368
- getIdentityManager() {
369
- return this.identityManager;
370
- }
371
-
372
- /**
373
- * Get session manager (for advanced operations)
374
- */
375
- getSessionManager() {
376
- return this.sessionManager;
377
- }
378
-
379
- /**
380
- * Get device manager (for advanced operations)
381
- */
382
- getDeviceManager() {
383
- return this.deviceManager;
384
- }
385
-
386
- /**
387
- * Get refresh manager (for advanced operations)
388
- */
389
- getRefreshManager() {
390
- return this.refreshManager;
391
- }
392
- }
393
- exports.IdentitySessionCore = IdentitySessionCore;
394
- //# sourceMappingURL=IdentitySessionCore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_IdentityManager","require","_SessionManager","_DeviceManager","_RefreshManager","_errors","IdentitySessionCore","baseURL","eventListeners","Set","initialized","constructor","adapter","identityManager","IdentityManager","deviceManager","DeviceManager","refreshManager","RefreshManager","sessionManager","SessionManager","setBaseURL","initialize","emit","event","forEach","listener","error","console","getCurrentIdentity","platform","publicKey","getPublicKey","id","createIdentity","username","createIdentitySessionError","IdentitySessionErrorCodes","IDENTITY_NOT_AVAILABLE_ON_WEB","identity","type","IDENTITY_CREATION_FAILED","Error","message","String","importIdentity","backupData","password","decryptAndImportBackup","IDENTITY_IMPORT_FAILED","deleteIdentity","skipBackup","force","userConfirmed","IDENTITY_DELETE_FAILED","signChallenge","challenge","IDENTITY_NOT_FOUND","generateChallenge","randomBytes","crypto","getRandomBytes","Array","from","byte","toString","padStart","join","createRegistrationSignature","timestamp","Date","now","messageHash","digestStringAsync","signature","signChallengeForAuth","hasIdentity","getSession","getAllSessions","getActiveSessionId","createSession","deviceName","session","SESSION_CREATION_FAILED","refreshSession","SESSION_REFRESH_FAILED","invalidateSession","sessionId","targetSessionId","SESSION_INVALID","invalidateAllSessions","getCurrentDevice","subscribe","callback","add","delete","getIdentityManager","getSessionManager","getDeviceManager","getRefreshManager","exports"],"sourceRoot":"../../../../src","sources":["core/identity-session/IdentitySessionCore.ts"],"mappings":";;;;;;AASA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACO,MAAMK,mBAAmB,CAAC;EAMvBC,OAAO,GAAkB,IAAI;EAC7BC,cAAc,GAA+C,IAAIC,GAAG,CAAC,CAAC;EACtEC,WAAW,GAAY,KAAK;EAEpCC,WAAWA,CAACC,OAAwB,EAAEL,OAAgB,EAAE;IACtD,IAAI,CAACK,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACL,OAAO,GAAGA,OAAO,IAAI,IAAI;;IAE9B;IACA,IAAI,CAACM,eAAe,GAAG,IAAIC,gCAAe,CAACF,OAAO,CAAC;IACnD,IAAI,CAACG,aAAa,GAAG,IAAIC,4BAAa,CAACJ,OAAO,CAAC;IAC/C,IAAI,CAACK,cAAc,GAAG,IAAIC,8BAAc,CAACN,OAAO,EAAEL,OAAO,CAAC;IAC1D,IAAI,CAACY,cAAc,GAAG,IAAIC,8BAAc,CACtCR,OAAO,EACP,IAAI,CAACG,aAAa,EAClB,IAAI,CAACE,cAAc,EACnBV,OACF,CAAC;EACH;;EAEA;AACF;AACA;EACEc,UAAUA,CAACd,OAAe,EAAQ;IAChC,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACY,cAAc,CAACE,UAAU,CAACd,OAAO,CAAC;IACvC,IAAI,CAACU,cAAc,CAACI,UAAU,CAACd,OAAO,CAAC;EACzC;;EAEA;AACF;AACA;EACE,MAAMe,UA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AACsF,GAAG,CAACD,QAAQ,CAAC;;IAEjC;IACA,OAAO,MAAM;MACX,IAAI,CAACrF,cAAc,CAACuF,MAAM,CAACF,QAAQ,CAAC;IACtC,CAAC;EACH;;EAEA;;EAEA;AACF;AACA;EACEG,kBAAkBA,CAAA,EAAoB;IACpC,OAAO,IAAI,CAACnF,eAAe;EAC7B;;EAEA;AACF;AACA;EACEoF,iBAAiBA,CAAA,EAAmB;IAClC,OAAO,IAAI,CAAC9E,cAAc;EAC5B;;EAEA;AACF;AACA;EACE+E,gBAAgBA,CAAA,EAAkB;IAChC,OAAO,IAAI,CAACnF,aAAa;EAC3B;;EAEA;AACF;AACA;EACEoF,iBAAiBA,CAAA,EAAmB;IAClC,OAAO,IAAI,CAAClF,cAAc;EAC5B;AACF;AAACmF,OAAA,CAAA9F,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1,137 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.RefreshManager = void 0;
7
- var _jwtDecode = require("jwt-decode");
8
- var _errors = require("./errors");
9
- /**
10
- * Refresh Manager
11
- *
12
- * Manages token refresh operations (Native + Web)
13
- */
14
-
15
- /**
16
- * Refresh Manager Class
17
- */
18
- class RefreshManager {
19
- baseURL = null;
20
- refreshPromise = null;
21
- constructor(adapter, baseURL) {
22
- this.adapter = adapter;
23
- this.baseURL = baseURL || null;
24
- }
25
-
26
- /**
27
- * Set base URL for API requests
28
- */
29
- setBaseURL(baseURL) {
30
- this.baseURL = baseURL;
31
- }
32
-
33
- /**
34
- * Check if token is expiring soon (within 60 seconds)
35
- */
36
- isTokenExpiringSoon(accessToken) {
37
- if (!accessToken) return false;
38
- try {
39
- const decoded = (0, _jwtDecode.jwtDecode)(accessToken);
40
- if (!decoded.exp) return false;
41
- const currentTime = Math.floor(Date.now() / 1000);
42
- return decoded.exp - currentTime < 60; // Expiring within 60 seconds
43
- } catch {
44
- return false;
45
- }
46
- }
47
-
48
- /**
49
- * Get userId from access token
50
- */
51
- getUserIdFromToken(accessToken) {
52
- if (!accessToken) return null;
53
- try {
54
- const decoded = (0, _jwtDecode.jwtDecode)(accessToken);
55
- return decoded.userId || null;
56
- } catch {
57
- return null;
58
- }
59
- }
60
-
61
- /**
62
- * Refresh access token if expiring soon
63
- */
64
- async refreshTokenIfNeeded(getAccessToken, setTokens, clearTokens) {
65
- // If already refreshing, wait for that promise
66
- if (this.refreshPromise) {
67
- return this.refreshPromise;
68
- }
69
- const accessToken = getAccessToken();
70
- if (!accessToken) {
71
- return; // No token to refresh
72
- }
73
-
74
- // If token not expiring soon, no refresh needed
75
- if (!this.isTokenExpiringSoon(accessToken)) {
76
- return;
77
- }
78
-
79
- // Start refresh
80
- this.refreshPromise = this._performRefresh(accessToken, setTokens, clearTokens).finally(() => {
81
- this.refreshPromise = null;
82
- });
83
- return this.refreshPromise;
84
- }
85
-
86
- /**
87
- * Perform token refresh
88
- */
89
- async _performRefresh(accessToken, setTokens, clearTokens) {
90
- if (!this.baseURL) {
91
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.SESSION_REFRESH_FAILED, 'Base URL not set for refresh operations');
92
- }
93
- try {
94
- const decoded = (0, _jwtDecode.jwtDecode)(accessToken);
95
- if (!decoded.sessionId) {
96
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.MALFORMED_TOKEN, 'Token missing sessionId');
97
- }
98
- const refreshUrl = `${this.baseURL}/api/session/token/${decoded.sessionId}`;
99
- const response = await this.adapter.fetch.fetch(refreshUrl, {
100
- method: 'GET',
101
- headers: {
102
- 'Accept': 'application/json'
103
- },
104
- signal: AbortSignal.timeout(5000)
105
- });
106
- if (!response.ok) {
107
- if (response.status === 401 || response.status === 403) {
108
- // Token is invalid, clear it
109
- clearTokens();
110
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.TOKEN_EXPIRED, 'Token refresh failed: token is invalid');
111
- }
112
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.SESSION_REFRESH_FAILED, `Token refresh failed: ${response.status}`);
113
- }
114
- const data = await response.json();
115
- const newAccessToken = data.accessToken;
116
- if (!newAccessToken) {
117
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.SESSION_REFRESH_FAILED, 'No access token in refresh response');
118
- }
119
-
120
- // Validate new token has correct userId format (ObjectId)
121
- const newDecoded = (0, _jwtDecode.jwtDecode)(newAccessToken);
122
- if (newDecoded.userId && !/^[0-9a-fA-F]{24}$/.test(newDecoded.userId)) {
123
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.MALFORMED_TOKEN, `Invalid userId format in refreshed token: ${newDecoded.userId.substring(0, 20)}...`);
124
- }
125
- setTokens(newAccessToken, data.refreshToken);
126
- } catch (error) {
127
- // Clear tokens on refresh failure (likely expired or invalid)
128
- clearTokens();
129
- if (error instanceof Error && error.name === 'IdentitySessionError') {
130
- throw error;
131
- }
132
- throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.SESSION_REFRESH_FAILED, `Token refresh failed: ${error instanceof Error ? error.message : String(error)}`);
133
- }
134
- }
135
- }
136
- exports.RefreshManager = RefreshManager;
137
- //# sourceMappingURL=RefreshManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_jwtDecode","require","_errors","RefreshManager","baseURL","refreshPromise","constructor","adapter","setBaseURL","isTokenExpiringSoon","accessToken","decoded","jwtDecode","exp","currentTime","Math","floor","Date","now","getUserIdFromToken","userId","refreshTokenIfNeeded","getAccessToken","setTokens","clearTokens","_performRefresh","finally","createIdentitySessionError","IdentitySessionErrorCodes","SESSION_REFRESH_FAILED","sessionId","MALFORMED_TOKEN","refreshUrl","response","fetch","method","headers","signal","AbortSignal","timeout","ok","status","TOKEN_EXPIRED","data","json","newAccessToken","newDecoded","test","substring","refreshToken","error","Error","name","message","String","exports"],"sourceRoot":"../../../../src","sources":["core/identity-session/RefreshManager.ts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