@oxyhq/services 5.16.17 → 5.16.19

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 (268) hide show
  1. package/README.md +7 -8
  2. package/lib/commonjs/core/mixins/OxyServices.security.js +42 -0
  3. package/lib/commonjs/core/mixins/OxyServices.security.js.map +1 -1
  4. package/lib/commonjs/crypto/index.js +0 -7
  5. package/lib/commonjs/crypto/index.js.map +1 -1
  6. package/lib/commonjs/crypto/keyManager.js +2 -2
  7. package/lib/commonjs/crypto/polyfill.js +4 -4
  8. package/lib/commonjs/i18n/locales/en-US.json +1 -1
  9. package/lib/commonjs/index.js +0 -7
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/models/interfaces.js +2 -0
  12. package/lib/commonjs/models/interfaces.js.map +1 -1
  13. package/lib/commonjs/ui/components/FollowButton.js +19 -1
  14. package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
  15. package/lib/commonjs/ui/components/GroupedItem.js +1 -27
  16. package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
  17. package/lib/commonjs/ui/components/Section.js +2 -1
  18. package/lib/commonjs/ui/components/Section.js.map +1 -1
  19. package/lib/commonjs/ui/components/SectionTitle.js +1 -2
  20. package/lib/commonjs/ui/components/SectionTitle.js.map +1 -1
  21. package/lib/commonjs/ui/components/fileManagement/FileViewer.js +3 -3
  22. package/lib/commonjs/ui/components/fileManagement/FileViewer.js.map +1 -1
  23. package/lib/commonjs/ui/context/OxyContext.js +61 -9
  24. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  25. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +65 -17
  26. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  27. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js +1 -1
  28. package/lib/commonjs/ui/context/hooks/useLanguageManagement.js +1 -1
  29. package/lib/commonjs/ui/context/hooks/useSessionManagement.js +3 -3
  30. package/lib/commonjs/ui/context/hooks/useStorage.js +2 -2
  31. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +1 -1
  32. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  33. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +1 -1
  34. package/lib/commonjs/ui/hooks/useIdentityMutations.js +4 -4
  35. package/lib/commonjs/ui/hooks/useIdentityMutations.js.map +1 -1
  36. package/lib/commonjs/ui/hooks/useSessionSocket.js +22 -7
  37. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  38. package/lib/commonjs/ui/screens/AccountCenterScreen.js +13 -13
  39. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  40. package/lib/commonjs/ui/screens/AccountOverviewScreen.js +17 -17
  41. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  42. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +2 -2
  43. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  44. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +10 -9
  45. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  46. package/lib/commonjs/ui/screens/AppInfoScreen.js +15 -15
  47. package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
  48. package/lib/commonjs/ui/screens/FeedbackScreen.js +1 -1
  49. package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
  50. package/lib/commonjs/ui/screens/FileManagementScreen.js +1 -1
  51. package/lib/commonjs/ui/screens/HelpSupportScreen.js +3 -3
  52. package/lib/commonjs/ui/screens/HelpSupportScreen.js.map +1 -1
  53. package/lib/commonjs/ui/screens/HistoryViewScreen.js +2 -2
  54. package/lib/commonjs/ui/screens/HistoryViewScreen.js.map +1 -1
  55. package/lib/commonjs/ui/screens/LanguageSelectorScreen.js +3 -1
  56. package/lib/commonjs/ui/screens/LanguageSelectorScreen.js.map +1 -1
  57. package/lib/commonjs/ui/screens/LegalDocumentsScreen.js +4 -4
  58. package/lib/commonjs/ui/screens/LegalDocumentsScreen.js.map +1 -1
  59. package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +1 -1
  60. package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
  61. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +1 -2
  62. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  63. package/lib/commonjs/ui/screens/ProfileScreen.js +44 -16
  64. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  65. package/lib/commonjs/ui/screens/SavesCollectionsScreen.js.map +1 -1
  66. package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js +3 -1
  67. package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
  68. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +2 -2
  69. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  70. package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +8 -5
  71. package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
  72. package/lib/commonjs/ui/utils/errorHandlers.js +49 -2
  73. package/lib/commonjs/ui/utils/errorHandlers.js.map +1 -1
  74. package/lib/commonjs/ui/utils/sessionHelpers.js +0 -2
  75. package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
  76. package/lib/commonjs/utils/languageUtils.js +11 -11
  77. package/lib/commonjs/utils/languageUtils.js.map +1 -1
  78. package/lib/module/core/mixins/OxyServices.security.js +42 -0
  79. package/lib/module/core/mixins/OxyServices.security.js.map +1 -1
  80. package/lib/module/crypto/index.js +2 -3
  81. package/lib/module/crypto/index.js.map +1 -1
  82. package/lib/module/crypto/keyManager.js +2 -2
  83. package/lib/module/crypto/polyfill.js +4 -4
  84. package/lib/module/i18n/locales/en-US.json +1 -1
  85. package/lib/module/index.js +1 -1
  86. package/lib/module/index.js.map +1 -1
  87. package/lib/module/models/interfaces.js +2 -0
  88. package/lib/module/models/interfaces.js.map +1 -1
  89. package/lib/module/ui/components/FollowButton.js +19 -1
  90. package/lib/module/ui/components/FollowButton.js.map +1 -1
  91. package/lib/module/ui/components/GroupedItem.js +1 -29
  92. package/lib/module/ui/components/GroupedItem.js.map +1 -1
  93. package/lib/module/ui/components/Section.js +2 -1
  94. package/lib/module/ui/components/Section.js.map +1 -1
  95. package/lib/module/ui/components/SectionTitle.js +1 -2
  96. package/lib/module/ui/components/SectionTitle.js.map +1 -1
  97. package/lib/module/ui/components/fileManagement/FileViewer.js +3 -3
  98. package/lib/module/ui/components/fileManagement/FileViewer.js.map +1 -1
  99. package/lib/module/ui/context/OxyContext.js +62 -10
  100. package/lib/module/ui/context/OxyContext.js.map +1 -1
  101. package/lib/module/ui/context/hooks/useAuthOperations.js +65 -18
  102. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  103. package/lib/module/ui/context/hooks/useDeviceManagement.js +1 -1
  104. package/lib/module/ui/context/hooks/useDeviceManagement.js.map +1 -1
  105. package/lib/module/ui/context/hooks/useLanguageManagement.js +1 -1
  106. package/lib/module/ui/context/hooks/useLanguageManagement.js.map +1 -1
  107. package/lib/module/ui/context/hooks/useSessionManagement.js +3 -3
  108. package/lib/module/ui/context/hooks/useSessionManagement.js.map +1 -1
  109. package/lib/module/ui/context/hooks/useStorage.js +2 -2
  110. package/lib/module/ui/context/hooks/useStorage.js.map +1 -1
  111. package/lib/module/ui/hooks/queries/useAccountQueries.js +1 -1
  112. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  113. package/lib/module/ui/hooks/queries/useServicesQueries.js +1 -1
  114. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  115. package/lib/module/ui/hooks/useIdentityMutations.js +4 -4
  116. package/lib/module/ui/hooks/useIdentityMutations.js.map +1 -1
  117. package/lib/module/ui/hooks/useSessionSocket.js +22 -7
  118. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  119. package/lib/module/ui/screens/AccountCenterScreen.js +13 -13
  120. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  121. package/lib/module/ui/screens/AccountOverviewScreen.js +17 -17
  122. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  123. package/lib/module/ui/screens/AccountSettingsScreen.js +2 -2
  124. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  125. package/lib/module/ui/screens/AccountSwitcherScreen.js +11 -10
  126. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  127. package/lib/module/ui/screens/AppInfoScreen.js +15 -15
  128. package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
  129. package/lib/module/ui/screens/FeedbackScreen.js +1 -1
  130. package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
  131. package/lib/module/ui/screens/FileManagementScreen.js +1 -1
  132. package/lib/module/ui/screens/HelpSupportScreen.js +3 -3
  133. package/lib/module/ui/screens/HelpSupportScreen.js.map +1 -1
  134. package/lib/module/ui/screens/HistoryViewScreen.js +2 -2
  135. package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -1
  136. package/lib/module/ui/screens/LanguageSelectorScreen.js +4 -2
  137. package/lib/module/ui/screens/LanguageSelectorScreen.js.map +1 -1
  138. package/lib/module/ui/screens/LegalDocumentsScreen.js +4 -4
  139. package/lib/module/ui/screens/LegalDocumentsScreen.js.map +1 -1
  140. package/lib/module/ui/screens/PaymentGatewayScreen.js +1 -1
  141. package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
  142. package/lib/module/ui/screens/PremiumSubscriptionScreen.js +1 -2
  143. package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  144. package/lib/module/ui/screens/ProfileScreen.js +44 -16
  145. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  146. package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -1
  147. package/lib/module/ui/screens/karma/KarmaAboutScreen.js +3 -1
  148. package/lib/module/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
  149. package/lib/module/ui/screens/karma/KarmaCenterScreen.js +3 -3
  150. package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  151. package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +9 -6
  152. package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
  153. package/lib/module/ui/utils/errorHandlers.js +46 -0
  154. package/lib/module/ui/utils/errorHandlers.js.map +1 -1
  155. package/lib/module/ui/utils/sessionHelpers.js +0 -2
  156. package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
  157. package/lib/module/utils/languageUtils.js +11 -11
  158. package/lib/module/utils/languageUtils.js.map +1 -1
  159. package/lib/typescript/core/mixins/OxyServices.security.d.ts +12 -0
  160. package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
  161. package/lib/typescript/core/mixins/index.d.ts +2 -0
  162. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  163. package/lib/typescript/crypto/index.d.ts +1 -2
  164. package/lib/typescript/crypto/index.d.ts.map +1 -1
  165. package/lib/typescript/crypto/keyManager.d.ts +2 -2
  166. package/lib/typescript/crypto/polyfill.d.ts +2 -2
  167. package/lib/typescript/index.d.ts +2 -2
  168. package/lib/typescript/index.d.ts.map +1 -1
  169. package/lib/typescript/models/interfaces.d.ts +1 -1
  170. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  171. package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
  172. package/lib/typescript/ui/components/GroupedItem.d.ts.map +1 -1
  173. package/lib/typescript/ui/components/Section.d.ts.map +1 -1
  174. package/lib/typescript/ui/components/SectionTitle.d.ts.map +1 -1
  175. package/lib/typescript/ui/context/OxyContext.d.ts +6 -2
  176. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  177. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +8 -4
  178. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  179. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts +1 -1
  180. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts.map +1 -1
  181. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts +1 -1
  182. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts.map +1 -1
  183. package/lib/typescript/ui/context/hooks/useStorage.d.ts +1 -1
  184. package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +1 -1
  185. package/lib/typescript/ui/hooks/useIdentityMutations.d.ts +15 -3
  186. package/lib/typescript/ui/hooks/useIdentityMutations.d.ts.map +1 -1
  187. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
  188. package/lib/typescript/ui/screens/LanguageSelectorScreen.d.ts.map +1 -1
  189. package/lib/typescript/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
  190. package/lib/typescript/ui/screens/ProfileScreen.d.ts.map +1 -1
  191. package/lib/typescript/ui/screens/SavesCollectionsScreen.d.ts.map +1 -1
  192. package/lib/typescript/ui/screens/karma/KarmaAboutScreen.d.ts.map +1 -1
  193. package/lib/typescript/ui/screens/karma/KarmaRewardsScreen.d.ts.map +1 -1
  194. package/lib/typescript/ui/utils/errorHandlers.d.ts +5 -0
  195. package/lib/typescript/ui/utils/errorHandlers.d.ts.map +1 -1
  196. package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
  197. package/package.json +1 -2
  198. package/src/core/mixins/OxyServices.security.ts +44 -0
  199. package/src/crypto/index.ts +2 -6
  200. package/src/crypto/keyManager.ts +2 -2
  201. package/src/crypto/polyfill.ts +4 -4
  202. package/src/i18n/locales/en-US.json +1 -1
  203. package/src/index.ts +2 -4
  204. package/src/models/interfaces.ts +4 -0
  205. package/src/ui/components/FollowButton.tsx +19 -1
  206. package/src/ui/components/GroupedItem.tsx +1 -29
  207. package/src/ui/components/Section.tsx +1 -0
  208. package/src/ui/components/SectionTitle.tsx +0 -1
  209. package/src/ui/components/fileManagement/FileViewer.tsx +3 -3
  210. package/src/ui/context/OxyContext.tsx +53 -14
  211. package/src/ui/context/hooks/useAuthOperations.ts +83 -26
  212. package/src/ui/context/hooks/useDeviceManagement.ts +1 -1
  213. package/src/ui/context/hooks/useLanguageManagement.ts +2 -2
  214. package/src/ui/context/hooks/useSessionManagement.ts +3 -3
  215. package/src/ui/context/hooks/useStorage.ts +2 -2
  216. package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
  217. package/src/ui/hooks/queries/useServicesQueries.ts +1 -1
  218. package/src/ui/hooks/useIdentityMutations.ts +6 -6
  219. package/src/ui/hooks/useSessionSocket.ts +8 -7
  220. package/src/ui/screens/AccountCenterScreen.tsx +13 -13
  221. package/src/ui/screens/AccountOverviewScreen.tsx +17 -17
  222. package/src/ui/screens/AccountSettingsScreen.tsx +2 -2
  223. package/src/ui/screens/AccountSwitcherScreen.tsx +8 -8
  224. package/src/ui/screens/AppInfoScreen.tsx +15 -15
  225. package/src/ui/screens/FeedbackScreen.tsx +1 -1
  226. package/src/ui/screens/FileManagementScreen.tsx +1 -1
  227. package/src/ui/screens/HelpSupportScreen.tsx +3 -3
  228. package/src/ui/screens/HistoryViewScreen.tsx +2 -2
  229. package/src/ui/screens/LanguageSelectorScreen.tsx +4 -1
  230. package/src/ui/screens/LegalDocumentsScreen.tsx +4 -4
  231. package/src/ui/screens/PaymentGatewayScreen.tsx +1 -1
  232. package/src/ui/screens/PremiumSubscriptionScreen.tsx +0 -1
  233. package/src/ui/screens/ProfileScreen.tsx +61 -22
  234. package/src/ui/screens/SavesCollectionsScreen.tsx +10 -1
  235. package/src/ui/screens/karma/KarmaAboutScreen.tsx +8 -1
  236. package/src/ui/screens/karma/KarmaCenterScreen.tsx +2 -2
  237. package/src/ui/screens/karma/KarmaRewardsScreen.tsx +9 -6
  238. package/src/ui/utils/errorHandlers.ts +58 -0
  239. package/src/ui/utils/sessionHelpers.ts +0 -2
  240. package/src/utils/languageUtils.ts +11 -11
  241. package/lib/commonjs/crypto/recoveryPhrase.js +0 -152
  242. package/lib/commonjs/crypto/recoveryPhrase.js.map +0 -1
  243. package/lib/commonjs/ui/context/utils/errorHandlers.js +0 -100
  244. package/lib/commonjs/ui/context/utils/errorHandlers.js.map +0 -1
  245. package/lib/commonjs/ui/context/utils/sessionHelpers.js +0 -103
  246. package/lib/commonjs/ui/context/utils/sessionHelpers.js.map +0 -1
  247. package/lib/commonjs/ui/context/utils/storageHelpers.js +0 -119
  248. package/lib/commonjs/ui/context/utils/storageHelpers.js.map +0 -1
  249. package/lib/module/crypto/recoveryPhrase.js +0 -147
  250. package/lib/module/crypto/recoveryPhrase.js.map +0 -1
  251. package/lib/module/ui/context/utils/errorHandlers.js +0 -93
  252. package/lib/module/ui/context/utils/errorHandlers.js.map +0 -1
  253. package/lib/module/ui/context/utils/sessionHelpers.js +0 -96
  254. package/lib/module/ui/context/utils/sessionHelpers.js.map +0 -1
  255. package/lib/module/ui/context/utils/storageHelpers.js +0 -111
  256. package/lib/module/ui/context/utils/storageHelpers.js.map +0 -1
  257. package/lib/typescript/crypto/recoveryPhrase.d.ts +0 -59
  258. package/lib/typescript/crypto/recoveryPhrase.d.ts.map +0 -1
  259. package/lib/typescript/ui/context/utils/errorHandlers.d.ts +0 -30
  260. package/lib/typescript/ui/context/utils/errorHandlers.d.ts.map +0 -1
  261. package/lib/typescript/ui/context/utils/sessionHelpers.d.ts +0 -59
  262. package/lib/typescript/ui/context/utils/sessionHelpers.d.ts.map +0 -1
  263. package/lib/typescript/ui/context/utils/storageHelpers.d.ts +0 -31
  264. package/lib/typescript/ui/context/utils/storageHelpers.d.ts.map +0 -1
  265. package/src/crypto/recoveryPhrase.ts +0 -166
  266. package/src/ui/context/utils/errorHandlers.ts +0 -146
  267. package/src/ui/context/utils/sessionHelpers.ts +0 -146
  268. package/src/ui/context/utils/storageHelpers.ts +0 -134
@@ -1,100 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isInvalidSessionError = exports.handleAuthError = exports.extractErrorMessage = void 0;
7
- const DEFAULT_INVALID_SESSION_MESSAGES = ['Invalid or expired session', 'Session is invalid', 'Session not found', 'Session expired'];
8
- const isObject = value => typeof value === 'object' && value !== null;
9
- const getResponseStatus = error => {
10
- if (!isObject(error)) return undefined;
11
- const response = error.response;
12
- return response?.status;
13
- };
14
-
15
- /**
16
- * Determine whether the error represents an invalid session condition.
17
- * This centralizes 401 detection across different fetch clients.
18
- */
19
- const isInvalidSessionError = error => {
20
- const status = getResponseStatus(error);
21
- if (status === 401) {
22
- return true;
23
- }
24
- if (!isObject(error)) {
25
- return false;
26
- }
27
-
28
- // Check error.status directly (HttpService sets this)
29
- if (error.status === 401) {
30
- return true;
31
- }
32
- const normalizedMessage = extractErrorMessage(error)?.toLowerCase();
33
- if (!normalizedMessage) {
34
- return false;
35
- }
36
-
37
- // Check for HTTP 401 in message (HttpService creates errors with "HTTP 401:" format)
38
- if (normalizedMessage.includes('http 401') || normalizedMessage.includes('401')) {
39
- return true;
40
- }
41
- return DEFAULT_INVALID_SESSION_MESSAGES.some(msg => normalizedMessage.includes(msg.toLowerCase()));
42
- };
43
-
44
- /**
45
- * Extract a consistent error message from unknown error shapes.
46
- *
47
- * @param error - The unknown error payload
48
- * @param fallbackMessage - Message to return when no concrete message is available
49
- */
50
- exports.isInvalidSessionError = isInvalidSessionError;
51
- const extractErrorMessage = (error, fallbackMessage = 'Unexpected error') => {
52
- if (typeof error === 'string' && error.trim().length > 0) {
53
- return error;
54
- }
55
- if (!isObject(error)) {
56
- return fallbackMessage;
57
- }
58
- const withMessage = error;
59
- if (withMessage.message && withMessage.message.trim().length > 0) {
60
- return withMessage.message;
61
- }
62
- const withResponse = error;
63
- const responseMessage = withResponse.response?.data?.message ?? withResponse.response?.data?.error;
64
- if (typeof responseMessage === 'string' && responseMessage.trim().length > 0) {
65
- return responseMessage;
66
- }
67
- return fallbackMessage;
68
- };
69
-
70
- /**
71
- * Centralized error handler for auth-related operations.
72
- *
73
- * @param error - Unknown error object
74
- * @param options - Error handling configuration
75
- * @returns Resolved error message
76
- */
77
- exports.extractErrorMessage = extractErrorMessage;
78
- const handleAuthError = (error, {
79
- defaultMessage,
80
- code,
81
- status,
82
- onError,
83
- setAuthError,
84
- logger
85
- }) => {
86
- const resolvedStatus = status ?? getResponseStatus(error) ?? (isInvalidSessionError(error) ? 401 : 500);
87
- const message = extractErrorMessage(error, defaultMessage);
88
- if (logger) {
89
- logger(message, error);
90
- }
91
- setAuthError?.(message);
92
- onError?.({
93
- message,
94
- code,
95
- status: resolvedStatus
96
- });
97
- return message;
98
- };
99
- exports.handleAuthError = handleAuthError;
100
- //# sourceMappingURL=errorHandlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["DEFAULT_INVALID_SESSION_MESSAGES","isObject","value","getResponseStatus","error","undefined","response","status","isInvalidSessionError","normalizedMessage","extractErrorMessage","toLowerCase","includes","some","msg","exports","fallbackMessage","trim","length","withMessage","message","withResponse","responseMessage","data","handleAuthError","defaultMessage","code","onError","setAuthError","logger","resolvedStatus"],"sourceRoot":"../../../../../src","sources":["ui/context/utils/errorHandlers.ts"],"mappings":";;;;;;AAyBA,MAAMA,gCAAgC,GAAG,CACvC,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,CAClB;AAED,MAAMC,QAAQ,GAAIC,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI;AAE7C,MAAMC,iBAAiB,GAAIC,KAAc,IAAyB;EAChE,IAAI,CAACH,QAAQ,CAACG,KAAK,CAAC,EAAE,OAAOC,SAAS;EACtC,MAAMC,QAAQ,GAAIF,KAAK,CAAuBE,QAAQ;EACtD,OAAOA,QAAQ,EAAEC,MAAM;AACzB,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAIJ,KAAc,IAAc;EAChE,MAAMG,MAAM,GAAGJ,iBAAiB,CAACC,KAAK,CAAC;EACvC,IAAIG,MAAM,KAAK,GAAG,EAAE;IA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AY,CAACf,QAAQ,EAAEiB,IAAI,EAAEnB,KAAK;EAE5E,IAAI,OAAOkB,eAAe,KAAK,QAAQ,IAAIA,eAAe,CAACL,IAAI,CAAC,CAAC,CAACC,MAAM,GAAG,CAAC,EAAE;IAC5E,OAAOI,eAAe;EACxB;EAEA,OAAON,eAAe;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAD,OAAA,CAAAL,mBAAA,GAAAA,mBAAA;AAOO,MAAMc,eAAe,GAAGA,CAC7BpB,KAAc,EACd;EACEqB,cAAc;EACdC,IAAI;EACJnB,MAAM;EACNoB,OAAO;EACPC,YAAY;EACZC;AACsB,CAAC,KACd;EACX,MAAMC,cAAc,GAAGvB,MAAM,IAAIJ,iBAAiB,CAACC,KAAK,CAAC,KAAKI,qBAAqB,CAACJ,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;EACvG,MAAMgB,OAAO,GAAGV,mBAAmB,CAACN,KAAK,EAAEqB,cAAc,CAAC;EAE1D,IAAII,MAAM,EAAE;IACVA,MAAM,CAACT,OAAO,EAAEhB,KAAK,CAAC;EACxB;EAEAwB,YAAY,GAAGR,OAAO,CAAC;EAEvBO,OAAO,GAAG;IACRP,OAAO;IACPM,IAAI;IACJnB,MAAM,EAAEuB;EACV,CAAC,CAAC;EAEF,OAAOV,OAAO;AAChB,CAAC;AAACL,OAAA,CAAAS,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.validateSessionBatch = exports.mapSessionsToClient = exports.fetchSessionsWithFallback = void 0;
7
- /**
8
- * Normalize backend session payloads into `ClientSession` objects.
9
- *
10
- * @param sessions - Raw session array returned from the API
11
- * @param fallbackDeviceId - Device identifier to use when missing from payload
12
- * @param fallbackUserId - User identifier to use when missing from payload
13
- */
14
- const mapSessionsToClient = (sessions, fallbackDeviceId, fallbackUserId) => {
15
- const now = new Date();
16
- return sessions.map(session => ({
17
- sessionId: session.sessionId,
18
- deviceId: session.deviceId || fallbackDeviceId || '',
19
- expiresAt: session.expiresAt || new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000).toISOString(),
20
- lastActive: session.lastActive || now.toISOString(),
21
- userId: session.user?.id || session.userId || (session.user?._id ? session.user._id.toString() : undefined) || fallbackUserId || '',
22
- isCurrent: Boolean(session.isCurrent)
23
- }));
24
- };
25
-
26
- /**
27
- * Fetch device sessions with fallback to the legacy session endpoint when needed.
28
- *
29
- * @param oxyServices - Oxy service instance
30
- * @param sessionId - Session identifier to fetch
31
- * @param options - Optional fallback options
32
- */
33
- exports.mapSessionsToClient = mapSessionsToClient;
34
- const fetchSessionsWithFallback = async (oxyServices, sessionId, {
35
- fallbackDeviceId,
36
- fallbackUserId,
37
- logger
38
- } = {}) => {
39
- try {
40
- const deviceSessions = await oxyServices.getDeviceSessions(sessionId);
41
- return mapSessionsToClient(deviceSessions, fallbackDeviceId, fallbackUserId);
42
- } catch (error) {
43
- if (__DEV__ && logger) {
44
- logger('Failed to get device sessions, falling back to user sessions', error);
45
- } else if (__DEV__) {
46
- console.warn('Failed to get device sessions, falling back to user sessions:', error);
47
- }
48
- const userSessions = await oxyServices.getSessionsBySessionId(sessionId);
49
- return mapSessionsToClient(userSessions, fallbackDeviceId, fallbackUserId);
50
- }
51
- };
52
-
53
- /**
54
- * Validate multiple sessions concurrently with configurable concurrency.
55
- *
56
- * @param oxyServices - Oxy service instance
57
- * @param sessionIds - Session identifiers to validate
58
- * @param options - Validation options
59
- */
60
- exports.fetchSessionsWithFallback = fetchSessionsWithFallback;
61
- const validateSessionBatch = async (oxyServices, sessionIds, {
62
- useHeaderValidation = true,
63
- maxConcurrency = 5
64
- } = {}) => {
65
- if (!sessionIds.length) {
66
- return [];
67
- }
68
- const uniqueSessionIds = Array.from(new Set(sessionIds));
69
- const safeConcurrency = Math.max(1, Math.min(maxConcurrency, uniqueSessionIds.length));
70
- const results = [];
71
- let index = 0;
72
- const worker = async () => {
73
- while (index < uniqueSessionIds.length) {
74
- const currentIndex = index;
75
- index += 1;
76
- const sessionId = uniqueSessionIds[currentIndex];
77
- try {
78
- const validation = await oxyServices.validateSession(sessionId, {
79
- useHeaderValidation
80
- });
81
- const valid = Boolean(validation?.valid);
82
- results.push({
83
- sessionId,
84
- valid,
85
- user: validation?.user,
86
- raw: validation
87
- });
88
- } catch (error) {
89
- results.push({
90
- sessionId,
91
- valid: false,
92
- error
93
- });
94
- }
95
- }
96
- };
97
- await Promise.all(Array.from({
98
- length: safeConcurrency
99
- }, worker));
100
- return results;
101
- };
102
- exports.validateSessionBatch = validateSessionBatch;
103
- //# sourceMappingURL=sessionHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["mapSessionsToClient","sessions","fallbackDeviceId","fallbackUserId","now","Date","map","session","sessionId","deviceId","expiresAt","getTime","toISOString","lastActive","userId","user","id","_id","toString","undefined","isCurrent","Boolean","exports","fetchSessionsWithFallback","oxyServices","logger","deviceSessions","getDeviceSessions","error","__DEV__","console","warn","userSessions","getSessionsBySessionId","validateSessionBatch","sessionIds","useHeaderValidation","maxConcurrency","length","uniqueSessionIds","Array","from","Set","safeConcurrency","Math","max","min","results","index","worker","currentIndex","validation","validateSession","valid","push","raw","Promise","all"],"sourceRoot":"../../../../../src","sources":["ui/context/utils/sessionHelpers.ts"],"mappings":";;;;;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,GAAGA,CACjCC,QAAyB,EACzBC,gBAAyB,EACzBC,cAAuB,KACH;EACpB,MAAMC,GAAG,GAAG,IAAIC,IAAI,CAAC,CAAC;EAEtB,OAAOJ,QAAQ,CAACK,GAAG,CAAEC,OAAO,KAAM;IAChCC,SAAS,EAAED,OAAO,CAACC,SAAS;IAC5BC,QAAQ,EAAEF,OAAO,CAACE,QAAQ,IAAIP,gBAAgB,IAAI,EAAE;IACpDQ,SAAS,EAAEH,OAAO,CAACG,SAAS,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OAAO,CAACO,IAAI,CAAC;UACX9C,SAAS;UACT6C,KAAK,EAAE,KAAK;UACZzB;QACF,CAAC,CAAC;MACJ;IACF;EACF,CAAC;EAED,MAAM4B,OAAO,CAACC,GAAG,CAACjB,KAAK,CAACC,IAAI,CAAC;IAAEH,MAAM,EAAEK;EAAgB,CAAC,EAAEM,MAAM,CAAC,CAAC;EAElE,OAAOF,OAAO;AAChB,CAAC;AAACzB,OAAA,CAAAY,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -1,119 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isReactNative = exports.getStorageKeys = exports.createPlatformStorage = exports.STORAGE_KEY_PREFIX = void 0;
7
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
8
- /**
9
- * Create an in-memory storage implementation used as a safe fallback.
10
- */
11
- const MEMORY_STORAGE = () => {
12
- const store = new Map();
13
- return {
14
- async getItem(key) {
15
- return store.has(key) ? store.get(key) : null;
16
- },
17
- async setItem(key, value) {
18
- store.set(key, value);
19
- },
20
- async removeItem(key) {
21
- store.delete(key);
22
- },
23
- async clear() {
24
- store.clear();
25
- }
26
- };
27
- };
28
-
29
- /**
30
- * Create a web storage implementation backed by `localStorage`.
31
- * Falls back to in-memory storage when unavailable.
32
- */
33
- const createWebStorage = () => {
34
- if (typeof window === 'undefined' || typeof window.localStorage === 'undefined') {
35
- return MEMORY_STORAGE();
36
- }
37
- return {
38
- async getItem(key) {
39
- try {
40
- return window.localStorage.getItem(key);
41
- } catch {
42
- return null;
43
- }
44
- },
45
- async setItem(key, value) {
46
- try {
47
- window.localStorage.setItem(key, value);
48
- } catch {
49
- // Ignore quota or access issues for now.
50
- }
51
- },
52
- async removeItem(key) {
53
- try {
54
- window.localStorage.removeItem(key);
55
- } catch {
56
- // Ignore failures.
57
- }
58
- },
59
- async clear() {
60
- try {
61
- window.localStorage.clear();
62
- } catch {
63
- // Ignore failures.
64
- }
65
- }
66
- };
67
- };
68
- let asyncStorageInstance = null;
69
-
70
- /**
71
- * Lazily import React Native AsyncStorage implementation.
72
- */
73
- const createNativeStorage = async () => {
74
- if (asyncStorageInstance) {
75
- return asyncStorageInstance;
76
- }
77
- try {
78
- const asyncStorageModule = await Promise.resolve().then(() => _interopRequireWildcard(require('@react-native-async-storage/async-storage')));
79
- asyncStorageInstance = asyncStorageModule.default;
80
- return asyncStorageInstance;
81
- } catch (error) {
82
- if (__DEV__) {
83
- console.error('Failed to import AsyncStorage:', error);
84
- }
85
- throw new Error('AsyncStorage is required in React Native environment');
86
- }
87
- };
88
-
89
- /**
90
- * Detect whether the current runtime is React Native.
91
- */
92
- const isReactNative = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
93
-
94
- /**
95
- * Create a platform-appropriate storage implementation.
96
- * Defaults to in-memory storage when no platform storage is available.
97
- */
98
- exports.isReactNative = isReactNative;
99
- const createPlatformStorage = async () => {
100
- if (isReactNative()) {
101
- return createNativeStorage();
102
- }
103
- return createWebStorage();
104
- };
105
- exports.createPlatformStorage = createPlatformStorage;
106
- const STORAGE_KEY_PREFIX = exports.STORAGE_KEY_PREFIX = 'oxy_session';
107
-
108
- /**
109
- * Produce strongly typed storage key names for the supplied prefix.
110
- *
111
- * @param prefix - Storage key prefix
112
- */
113
- const getStorageKeys = (prefix = STORAGE_KEY_PREFIX) => ({
114
- activeSessionId: `${prefix}_active_session_id`,
115
- sessionIds: `${prefix}_session_ids`,
116
- language: `${prefix}_language`
117
- });
118
- exports.getStorageKeys = getStorageKeys;
119
- //# sourceMappingURL=storageHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["MEMORY_STORAGE","store","Map","getItem","key","has","get","setItem","value","set","removeItem","delete","clear","createWebStorage","window","localStorage","asyncStorageInstance","createNativeStorage","asyncStorageModule","Promise","resolve","then","_interopRequireWildcard","require","default","error","__DEV__","console","Error","isReactNative","navigator","product","exports","createPlatformStorage","STORAGE_KEY_PREFIX","getStorageKeys","prefix","activeSessionId","sessionIds","language"],"sourceRoot":"../../../../../src","sources":["ui/context/utils/storageHelpers.ts"],"mappings":";;;;;;;AAiBA;AACA;AACA;AACA,MAAMA,cAAc,GAAGA,CAAA,KAAwB;EAC7C,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAiB,CAAC;EAEvC,OAAO;IACL,MAAMC,OAAOA,CAACC,GAAW,EAAE;MACzB,OAAOH,KAAK,CAACI,GAAG,CAACD,GAAG,CAAC,GAAGH,KAAK,CAACK,GAAG,CAACF,GAAG,CAAC,GAAI,IAAI;IAChD,CAAC;IACD,MAAMG,OAAOA,CAACH,GAAW,EAAEI,KAAa,EAAE;MACxCP,KAAK,CAACQ,GAAG,CAACL,GAAG,EAAEI,KAAK,CAAC;IACvB,CAAC;IACD,MAAME,UAAUA,CAACN,GAAW,EAAE;MAC5BH,KAAK,CAACU,MAAM,CAACP,GAAG,CAAC;IACnB,CAAC;IACD,MAAMQ,KAAKA,CAAA,EAAG;MACZX,KAAK,CAACW,KAAK,CAAC,CAAC;IACf;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAGA,CAAA,KAAwB;EAC/C,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAI,OAAOA,MAAM,CAACC,YAAY,KAAK,WAAW,EAAE;IAC/E,OAAOf,cAAc,CAAC,CAAC;EACzB;EAEA,OAAO;IACL,MAAMG,OAAOA,CAACC,GAAW,EAAE;MACzB,IAAI;Q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OAAO,KAAK,aAAa;;AAEzE;AACA;AACA;AACA;AAHAC,OAAA,CAAAH,aAAA,GAAAA,aAAA;AAIO,MAAMI,qBAAqB,GAAG,MAAAA,CAAA,KAAuC;EAC1E,IAAIJ,aAAa,CAAC,CAAC,EAAE;IACnB,OAAOZ,mBAAmB,CAAC,CAAC;EAC9B;EAEA,OAAOJ,gBAAgB,CAAC,CAAC;AAC3B,CAAC;AAACmB,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEK,MAAMC,kBAAkB,GAAAF,OAAA,CAAAE,kBAAA,GAAG,aAAa;;AAE/C;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAGA,CAACC,MAAc,GAAGF,kBAAkB,MAA0B;EAC1FG,eAAe,EAAE,GAAGD,MAAM,oBAAoB;EAC9CE,UAAU,EAAE,GAAGF,MAAM,cAAc;EACnCG,QAAQ,EAAE,GAAGH,MAAM;AACrB,CAAC,CAAC;AAACJ,OAAA,CAAAG,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,147 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Recovery Phrase Service - BIP39 Mnemonic Generation
5
- *
6
- * Handles generation and restoration of recovery phrases (mnemonic seeds)
7
- * for backing up and restoring user identities.
8
- *
9
- * Note: This module requires the polyfill to be loaded first (done via crypto/index.ts)
10
- */
11
-
12
- import * as bip39 from 'bip39';
13
- import { KeyManager } from './keyManager';
14
-
15
- /**
16
- * Convert Uint8Array or array-like to hexadecimal string
17
- * Works in both Node.js and React Native without depending on Buffer
18
- */
19
- function toHex(data) {
20
- // Convert to array of numbers if needed
21
- const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
22
- return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
23
- }
24
- export class RecoveryPhraseService {
25
- /**
26
- * Generate a new identity with a recovery phrase
27
- * Returns the mnemonic phrase (should only be shown once to the user)
28
- */
29
- static async generateIdentityWithRecovery() {
30
- // Generate 128-bit entropy for 12-word mnemonic
31
- const mnemonic = bip39.generateMnemonic(128);
32
-
33
- // Derive private key from mnemonic
34
- // Using the seed directly as the private key (simplified approach)
35
- const seed = await bip39.mnemonicToSeed(mnemonic);
36
-
37
- // Use first 32 bytes of seed as private key
38
- const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
39
- const privateKeyHex = toHex(seedSlice);
40
-
41
- // Import the derived key pair
42
- const publicKey = await KeyManager.importKeyPair(privateKeyHex);
43
- return {
44
- phrase: mnemonic,
45
- words: mnemonic.split(' '),
46
- publicKey
47
- };
48
- }
49
-
50
- /**
51
- * Generate a 24-word recovery phrase for higher security
52
- */
53
- static async generateIdentityWithRecovery24() {
54
- // Generate 256-bit entropy for 24-word mnemonic
55
- const mnemonic = bip39.generateMnemonic(256);
56
- const seed = await bip39.mnemonicToSeed(mnemonic);
57
- const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
58
- const privateKeyHex = toHex(seedSlice);
59
- const publicKey = await KeyManager.importKeyPair(privateKeyHex);
60
- return {
61
- phrase: mnemonic,
62
- words: mnemonic.split(' '),
63
- publicKey
64
- };
65
- }
66
-
67
- /**
68
- * Restore an identity from a recovery phrase
69
- */
70
- static async restoreFromPhrase(phrase) {
71
- // Normalize and validate the phrase
72
- const normalizedPhrase = phrase.trim().toLowerCase();
73
- if (!bip39.validateMnemonic(normalizedPhrase)) {
74
- throw new Error('Invalid recovery phrase. Please check the words and try again.');
75
- }
76
-
77
- // Derive the same private key from the mnemonic
78
- const seed = await bip39.mnemonicToSeed(normalizedPhrase);
79
- const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
80
- const privateKeyHex = toHex(seedSlice);
81
-
82
- // Import and store the key pair
83
- const publicKey = await KeyManager.importKeyPair(privateKeyHex);
84
- return publicKey;
85
- }
86
-
87
- /**
88
- * Validate a recovery phrase without importing it
89
- */
90
- static validatePhrase(phrase) {
91
- const normalizedPhrase = phrase.trim().toLowerCase();
92
- return bip39.validateMnemonic(normalizedPhrase);
93
- }
94
-
95
- /**
96
- * Get the word list for autocomplete/validation
97
- */
98
- static getWordList() {
99
- return bip39.wordlists.english;
100
- }
101
-
102
- /**
103
- * Check if a word is valid in the BIP39 word list
104
- */
105
- static isValidWord(word) {
106
- return bip39.wordlists.english.includes(word.toLowerCase());
107
- }
108
-
109
- /**
110
- * Get suggestions for a partial word
111
- */
112
- static getSuggestions(partial, limit = 5) {
113
- const lowerPartial = partial.toLowerCase();
114
- return bip39.wordlists.english.filter(word => word.startsWith(lowerPartial)).slice(0, limit);
115
- }
116
-
117
- /**
118
- * Derive the public key from a phrase without storing
119
- * Useful for verification before importing
120
- */
121
- static async derivePublicKeyFromPhrase(phrase) {
122
- const normalizedPhrase = phrase.trim().toLowerCase();
123
- if (!bip39.validateMnemonic(normalizedPhrase)) {
124
- throw new Error('Invalid recovery phrase');
125
- }
126
- const seed = await bip39.mnemonicToSeed(normalizedPhrase);
127
- const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
128
- const privateKeyHex = toHex(seedSlice);
129
- return KeyManager.derivePublicKey(privateKeyHex);
130
- }
131
-
132
- /**
133
- * Convert a phrase to its word array
134
- */
135
- static phraseToWords(phrase) {
136
- return phrase.trim().toLowerCase().split(/\s+/);
137
- }
138
-
139
- /**
140
- * Convert a word array to a phrase string
141
- */
142
- static wordsToPhrase(words) {
143
- return words.map(w => w.toLowerCase().trim()).join(' ');
144
- }
145
- }
146
- export default RecoveryPhraseService;
147
- //# sourceMappingURL=recoveryPhrase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["bip39","KeyManager","toHex","data","bytes","Uint8Array","Array","from","map","b","toString","padStart","join","RecoveryPhraseService","generateIdentityWithRecovery","mnemonic","generateMnemonic","seed","mnemonicToSeed","seedSlice","subarray","slice","privateKeyHex","publicKey","importKeyPair","phrase","words","split","generateIdentityWithRecovery24","restoreFromPhrase","normalizedPhrase","trim","toLowerCase","validateMnemonic","Error","validatePhrase","getWordList","wordlists","english","isValidWord","word","includes","getSuggestions","partial","limit","lowerPartial","filter","startsWith","derivePublicKeyFromPhrase","derivePublicKey","phraseToWords","wordsToPhrase","w"],"sourceRoot":"../../../src","sources":["crypto/recoveryPhrase.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,UAAU,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA;AACA,SAASC,KAAKA,CAACC,IAAoC,EAAU;EAC3D;EACA,MAAMC,KAAK,GAAGD,IAAI,YAAYE,UAAU,GAAGF,IAAI,GAAG,IAAIE,UAAU,CAACF,IAAI,CAAC;EACtE,OAAOG,KAAK,CAACC,IAAI,CAACH,KAAK,CAAC,CACrBI,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CACzCC,IAAI,CAAC,EAAE,CAAC;AACb;AAQA,OAAO,MAAMC,qBAAqB,CAAC;EACjC;AACF;AACA;AACA;EACE,aAAaC,4BAA4BA,CAAA,EAAkC;IACzE;IACA,MAAMC,QAAQ,GAAGf,KAAK,CAACgB,gBAAgB,CAAC,GAAG,CAAC;;IAE5C;IACA;IACA,MAAMC,IAAI,GAAG,MAAMjB,KAAK,CAACkB,cAAc,CAACH,QAAQ,CAAC;;IAEjD;IACA,MAAMI,SAAS,GAAGF,IAAI,CAACG,QAAQ,GAAGH,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;IAC1E,MAAMC,aAAa,GAAGpB,KAAK,CAACiB,SAAS,CAAC;;IAEtC;IACA,MAAMI,SAAS,GAAG,MAAMtB,UAAU,CAACuB,aAAa,CAACF,aAAa,CAAC;IAE/D,OAAO;MACLG,MAAM,EAAEV,QAAQ;MAChBW,KAAK,E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,MAAMX,SAAS,GAAGF,IAAI,CAACG,QAAQ,GAAGH,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;IAC1E,MAAMC,aAAa,GAAGpB,KAAK,CAACiB,SAAS,CAAC;IAEtC,OAAOlB,UAAU,CAACgD,eAAe,CAAC3B,aAAa,CAAC;EAClD;;EAEA;AACF;AACA;EACE,OAAO4B,aAAaA,CAACzB,MAAc,EAAY;IAC7C,OAAOA,MAAM,CAACM,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACL,KAAK,CAAC,KAAK,CAAC;EACjD;;EAEA;AACF;AACA;EACE,OAAOwB,aAAaA,CAACzB,KAAe,EAAU;IAC5C,OAAOA,KAAK,CAAClB,GAAG,CAAC4C,CAAC,IAAIA,CAAC,CAACpB,WAAW,CAAC,CAAC,CAACD,IAAI,CAAC,CAAC,CAAC,CAACnB,IAAI,CAAC,GAAG,CAAC;EACzD;AACF;AAEA,eAAeC,qBAAqB","ignoreList":[]}
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- const DEFAULT_INVALID_SESSION_MESSAGES = ['Invalid or expired session', 'Session is invalid', 'Session not found', 'Session expired'];
4
- const isObject = value => typeof value === 'object' && value !== null;
5
- const getResponseStatus = error => {
6
- if (!isObject(error)) return undefined;
7
- const response = error.response;
8
- return response?.status;
9
- };
10
-
11
- /**
12
- * Determine whether the error represents an invalid session condition.
13
- * This centralizes 401 detection across different fetch clients.
14
- */
15
- export const isInvalidSessionError = error => {
16
- const status = getResponseStatus(error);
17
- if (status === 401) {
18
- return true;
19
- }
20
- if (!isObject(error)) {
21
- return false;
22
- }
23
-
24
- // Check error.status directly (HttpService sets this)
25
- if (error.status === 401) {
26
- return true;
27
- }
28
- const normalizedMessage = extractErrorMessage(error)?.toLowerCase();
29
- if (!normalizedMessage) {
30
- return false;
31
- }
32
-
33
- // Check for HTTP 401 in message (HttpService creates errors with "HTTP 401:" format)
34
- if (normalizedMessage.includes('http 401') || normalizedMessage.includes('401')) {
35
- return true;
36
- }
37
- return DEFAULT_INVALID_SESSION_MESSAGES.some(msg => normalizedMessage.includes(msg.toLowerCase()));
38
- };
39
-
40
- /**
41
- * Extract a consistent error message from unknown error shapes.
42
- *
43
- * @param error - The unknown error payload
44
- * @param fallbackMessage - Message to return when no concrete message is available
45
- */
46
- export const extractErrorMessage = (error, fallbackMessage = 'Unexpected error') => {
47
- if (typeof error === 'string' && error.trim().length > 0) {
48
- return error;
49
- }
50
- if (!isObject(error)) {
51
- return fallbackMessage;
52
- }
53
- const withMessage = error;
54
- if (withMessage.message && withMessage.message.trim().length > 0) {
55
- return withMessage.message;
56
- }
57
- const withResponse = error;
58
- const responseMessage = withResponse.response?.data?.message ?? withResponse.response?.data?.error;
59
- if (typeof responseMessage === 'string' && responseMessage.trim().length > 0) {
60
- return responseMessage;
61
- }
62
- return fallbackMessage;
63
- };
64
-
65
- /**
66
- * Centralized error handler for auth-related operations.
67
- *
68
- * @param error - Unknown error object
69
- * @param options - Error handling configuration
70
- * @returns Resolved error message
71
- */
72
- export const handleAuthError = (error, {
73
- defaultMessage,
74
- code,
75
- status,
76
- onError,
77
- setAuthError,
78
- logger
79
- }) => {
80
- const resolvedStatus = status ?? getResponseStatus(error) ?? (isInvalidSessionError(error) ? 401 : 500);
81
- const message = extractErrorMessage(error, defaultMessage);
82
- if (logger) {
83
- logger(message, error);
84
- }
85
- setAuthError?.(message);
86
- onError?.({
87
- message,
88
- code,
89
- status: resolvedStatus
90
- });
91
- return message;
92
- };
93
- //# sourceMappingURL=errorHandlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["DEFAULT_INVALID_SESSION_MESSAGES","isObject","value","getResponseStatus","error","undefined","response","status","isInvalidSessionError","normalizedMessage","extractErrorMessage","toLowerCase","includes","some","msg","fallbackMessage","trim","length","withMessage","message","withResponse","responseMessage","data","handleAuthError","defaultMessage","code","onError","setAuthError","logger","resolvedStatus"],"sourceRoot":"../../../../../src","sources":["ui/context/utils/errorHandlers.ts"],"mappings":";;AAyBA,MAAMA,gCAAgC,GAAG,CACvC,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,CAClB;AAED,MAAMC,QAAQ,GAAIC,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI;AAE7C,MAAMC,iBAAiB,GAAIC,KAAc,IAAyB;EAChE,IAAI,CAACH,QAAQ,CAACG,KAAK,CAAC,EAAE,OAAOC,SAAS;EACtC,MAAMC,QAAQ,GAAIF,KAAK,CAAuBE,QAAQ;EACtD,OAAOA,QAAQ,EAAEC,MAAM;AACzB,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAIJ,KAAc,IAAc;EAChE,MAAMG,MAAM,GAAGJ,iBAAiB,CAACC,KAAK,CAAC;EACvC,IAAIG,MAAM,KAAK,GAAG,EAAE;IAClB,OAAO,IAAI;EACb;EAEA,IAAI,CAACN,QAAQ,CAACG,KAAK,CAAC,EAAE;IACpB,OAAO,KAAK;EACd;;EAEA;EACA,IAAKA,KAAK,CAASG,MAAM,KAAK,GAAG,EAAE;IACjC,OAAO,IAAI;EACb;EAEA,MAAME,iBAAiB,GAAGC,mBAAmB,CAACN,KAAK,CAAC,EAAEO,WAAW,CAAC,CAAC;EACnE,IAAI,CAACF,iBAAiB,EAAE;IACtB,OAAO,KAAK;EACd;;EAEA;EACA,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,UAAU,CAAC,IAAIH,iBAAiB,CAACG,QAAQ,CAAC,KAAK,CAAC,EAAE;IAC/E,OAAO,IAAI;EACb;EAEA,OAAOZ,gCAAgC,CAACa,IAAI,CAAEC,GAAG,IAC/CL,iBAAiB,CAACG,QAAQ,CAACE,GAAG,CAACH,WAAW,CAAC,CAAC,CAC9C,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;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