@oxyhq/services 5.7.4 → 5.8.1

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 (252) hide show
  1. package/README.md +125 -268
  2. package/lib/commonjs/core/index.js +172 -0
  3. package/lib/commonjs/core/index.js.map +1 -1
  4. package/lib/commonjs/index.js +88 -29
  5. package/lib/commonjs/index.js.map +1 -1
  6. package/lib/commonjs/node/createAuth.js +585 -7
  7. package/lib/commonjs/node/createAuth.js.map +1 -1
  8. package/lib/commonjs/node/index.js +31 -41
  9. package/lib/commonjs/node/index.js.map +1 -1
  10. package/lib/commonjs/ui/components/Avatar.js +15 -6
  11. package/lib/commonjs/ui/components/Avatar.js.map +1 -1
  12. package/lib/commonjs/ui/components/GroupedItem.js +58 -13
  13. package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
  14. package/lib/commonjs/ui/components/GroupedSection.js +7 -1
  15. package/lib/commonjs/ui/components/GroupedSection.js.map +1 -1
  16. package/lib/commonjs/ui/components/Header.js +322 -0
  17. package/lib/commonjs/ui/components/Header.js.map +1 -0
  18. package/lib/commonjs/ui/components/OxyProvider.js +23 -7
  19. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  20. package/lib/commonjs/ui/components/index.js +7 -0
  21. package/lib/commonjs/ui/components/index.js.map +1 -1
  22. package/lib/commonjs/ui/components/internal/GroupedPillButtons.js +1 -1
  23. package/lib/commonjs/ui/components/internal/GroupedPillButtons.js.map +1 -1
  24. package/lib/commonjs/ui/components/internal/TextField.js +606 -546
  25. package/lib/commonjs/ui/components/internal/TextField.js.map +1 -1
  26. package/lib/commonjs/ui/components/internal/TextField.md +436 -0
  27. package/lib/commonjs/ui/context/OxyContext.js +122 -78
  28. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  29. package/lib/commonjs/ui/hooks/useSessionSocket.js +5 -2
  30. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  31. package/lib/commonjs/ui/index.js +1 -16
  32. package/lib/commonjs/ui/index.js.map +1 -1
  33. package/lib/commonjs/ui/navigation/OxyRouter.js +1 -1
  34. package/lib/commonjs/ui/navigation/OxyRouter.js.map +1 -1
  35. package/lib/commonjs/ui/screens/AccountCenterScreen.js +6 -6
  36. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  37. package/lib/commonjs/ui/screens/AccountManagementDemo.js +3 -3
  38. package/lib/commonjs/ui/screens/AccountManagementDemo.js.map +1 -1
  39. package/lib/commonjs/ui/screens/AccountOverviewScreen.js +241 -598
  40. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  41. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +1151 -406
  42. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  43. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +135 -237
  44. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  45. package/lib/commonjs/ui/screens/AppInfoScreen.js +246 -463
  46. package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
  47. package/lib/commonjs/ui/screens/FeedbackScreen.js +3 -3
  48. package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
  49. package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +808 -650
  50. package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
  51. package/lib/commonjs/ui/screens/RecoverAccountScreen.js +51 -72
  52. package/lib/commonjs/ui/screens/RecoverAccountScreen.js.map +1 -1
  53. package/lib/commonjs/ui/screens/SessionManagementScreen.js +11 -29
  54. package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
  55. package/lib/commonjs/ui/screens/SignInScreen.js +30 -303
  56. package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
  57. package/lib/commonjs/ui/screens/SignUpScreen.js +4 -4
  58. package/lib/commonjs/ui/screens/SignUpScreen.js.map +1 -1
  59. package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js +19 -31
  60. package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js.map +1 -1
  61. package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js +7 -10
  62. package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js.map +1 -1
  63. package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js +11 -5
  64. package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js.map +1 -1
  65. package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js +11 -4
  66. package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js.map +1 -1
  67. package/lib/commonjs/ui/stores/authStore.js +12 -0
  68. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  69. package/lib/commonjs/ui/styles/authStyles.js +337 -0
  70. package/lib/commonjs/ui/styles/authStyles.js.map +1 -0
  71. package/lib/commonjs/ui/styles/index.js +11 -0
  72. package/lib/commonjs/ui/styles/index.js.map +1 -1
  73. package/lib/module/core/index.js +172 -0
  74. package/lib/module/core/index.js.map +1 -1
  75. package/lib/module/index.js +26 -4
  76. package/lib/module/index.js.map +1 -1
  77. package/lib/module/node/createAuth.js +584 -7
  78. package/lib/module/node/createAuth.js.map +1 -1
  79. package/lib/module/node/index.js +8 -12
  80. package/lib/module/node/index.js.map +1 -1
  81. package/lib/module/ui/components/Avatar.js +15 -6
  82. package/lib/module/ui/components/Avatar.js.map +1 -1
  83. package/lib/module/ui/components/GroupedItem.js +59 -14
  84. package/lib/module/ui/components/GroupedItem.js.map +1 -1
  85. package/lib/module/ui/components/GroupedSection.js +7 -1
  86. package/lib/module/ui/components/GroupedSection.js.map +1 -1
  87. package/lib/module/ui/components/Header.js +317 -0
  88. package/lib/module/ui/components/Header.js.map +1 -0
  89. package/lib/module/ui/components/OxyProvider.js +25 -9
  90. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  91. package/lib/module/ui/components/index.js +1 -0
  92. package/lib/module/ui/components/index.js.map +1 -1
  93. package/lib/module/ui/components/internal/GroupedPillButtons.js +1 -1
  94. package/lib/module/ui/components/internal/GroupedPillButtons.js.map +1 -1
  95. package/lib/module/ui/components/internal/TextField.js +607 -547
  96. package/lib/module/ui/components/internal/TextField.js.map +1 -1
  97. package/lib/module/ui/components/internal/TextField.md +436 -0
  98. package/lib/module/ui/context/OxyContext.js +121 -77
  99. package/lib/module/ui/context/OxyContext.js.map +1 -1
  100. package/lib/module/ui/hooks/useSessionSocket.js +5 -2
  101. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  102. package/lib/module/ui/index.js +1 -16
  103. package/lib/module/ui/index.js.map +1 -1
  104. package/lib/module/ui/navigation/OxyRouter.js +1 -1
  105. package/lib/module/ui/navigation/OxyRouter.js.map +1 -1
  106. package/lib/module/ui/screens/AccountCenterScreen.js +6 -6
  107. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  108. package/lib/module/ui/screens/AccountManagementDemo.js +3 -3
  109. package/lib/module/ui/screens/AccountManagementDemo.js.map +1 -1
  110. package/lib/module/ui/screens/AccountOverviewScreen.js +242 -597
  111. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  112. package/lib/module/ui/screens/AccountSettingsScreen.js +1152 -407
  113. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  114. package/lib/module/ui/screens/AccountSwitcherScreen.js +135 -237
  115. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  116. package/lib/module/ui/screens/AppInfoScreen.js +248 -465
  117. package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
  118. package/lib/module/ui/screens/FeedbackScreen.js +3 -3
  119. package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
  120. package/lib/module/ui/screens/PaymentGatewayScreen.js +809 -651
  121. package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
  122. package/lib/module/ui/screens/RecoverAccountScreen.js +53 -74
  123. package/lib/module/ui/screens/RecoverAccountScreen.js.map +1 -1
  124. package/lib/module/ui/screens/SessionManagementScreen.js +11 -29
  125. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  126. package/lib/module/ui/screens/SignInScreen.js +32 -305
  127. package/lib/module/ui/screens/SignInScreen.js.map +1 -1
  128. package/lib/module/ui/screens/SignUpScreen.js +5 -5
  129. package/lib/module/ui/screens/SignUpScreen.js.map +1 -1
  130. package/lib/module/ui/screens/internal/SignInPasswordStep.js +19 -31
  131. package/lib/module/ui/screens/internal/SignInPasswordStep.js.map +1 -1
  132. package/lib/module/ui/screens/internal/SignInUsernameStep.js +7 -10
  133. package/lib/module/ui/screens/internal/SignInUsernameStep.js.map +1 -1
  134. package/lib/module/ui/screens/internal/SignUpIdentityStep.js +11 -5
  135. package/lib/module/ui/screens/internal/SignUpIdentityStep.js.map +1 -1
  136. package/lib/module/ui/screens/internal/SignUpSecurityStep.js +11 -4
  137. package/lib/module/ui/screens/internal/SignUpSecurityStep.js.map +1 -1
  138. package/lib/module/ui/stores/authStore.js +12 -0
  139. package/lib/module/ui/stores/authStore.js.map +1 -1
  140. package/lib/module/ui/styles/authStyles.js +332 -0
  141. package/lib/module/ui/styles/authStyles.js.map +1 -0
  142. package/lib/module/ui/styles/index.js +1 -0
  143. package/lib/module/ui/styles/index.js.map +1 -1
  144. package/lib/typescript/core/index.d.ts +67 -0
  145. package/lib/typescript/core/index.d.ts.map +1 -1
  146. package/lib/typescript/index.d.ts +13 -3
  147. package/lib/typescript/index.d.ts.map +1 -1
  148. package/lib/typescript/node/createAuth.d.ts +112 -0
  149. package/lib/typescript/node/createAuth.d.ts.map +1 -1
  150. package/lib/typescript/node/index.d.ts +3 -7
  151. package/lib/typescript/node/index.d.ts.map +1 -1
  152. package/lib/typescript/ui/components/Avatar.d.ts.map +1 -1
  153. package/lib/typescript/ui/components/GroupedItem.d.ts +6 -0
  154. package/lib/typescript/ui/components/GroupedItem.d.ts.map +1 -1
  155. package/lib/typescript/ui/components/GroupedSection.d.ts +6 -0
  156. package/lib/typescript/ui/components/GroupedSection.d.ts.map +1 -1
  157. package/lib/typescript/ui/components/Header.d.ts +22 -0
  158. package/lib/typescript/ui/components/Header.d.ts.map +1 -0
  159. package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
  160. package/lib/typescript/ui/components/index.d.ts +1 -0
  161. package/lib/typescript/ui/components/index.d.ts.map +1 -1
  162. package/lib/typescript/ui/components/internal/TextField.d.ts +31 -16
  163. package/lib/typescript/ui/components/internal/TextField.d.ts.map +1 -1
  164. package/lib/typescript/ui/context/OxyContext.d.ts +5 -2
  165. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  166. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
  167. package/lib/typescript/ui/index.d.ts +1 -2
  168. package/lib/typescript/ui/index.d.ts.map +1 -1
  169. package/lib/typescript/ui/navigation/types.d.ts +9 -2
  170. package/lib/typescript/ui/navigation/types.d.ts.map +1 -1
  171. package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
  172. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  173. package/lib/typescript/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
  174. package/lib/typescript/ui/screens/AppInfoScreen.d.ts.map +1 -1
  175. package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts.map +1 -1
  176. package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts +5 -1
  177. package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts.map +1 -1
  178. package/lib/typescript/ui/screens/SessionManagementScreen.d.ts.map +1 -1
  179. package/lib/typescript/ui/screens/SignInScreen.d.ts.map +1 -1
  180. package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts +1 -1
  181. package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts.map +1 -1
  182. package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts +0 -1
  183. package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts.map +1 -1
  184. package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts.map +1 -1
  185. package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts.map +1 -1
  186. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  187. package/lib/typescript/ui/styles/authStyles.d.ts +326 -0
  188. package/lib/typescript/ui/styles/authStyles.d.ts.map +1 -0
  189. package/lib/typescript/ui/styles/index.d.ts +1 -0
  190. package/lib/typescript/ui/styles/index.d.ts.map +1 -1
  191. package/package.json +1 -6
  192. package/src/core/index.ts +189 -0
  193. package/src/index.ts +72 -4
  194. package/src/node/createAuth.ts +623 -7
  195. package/src/node/index.ts +20 -18
  196. package/src/ui/components/Avatar.tsx +11 -5
  197. package/src/ui/components/GroupedItem.tsx +57 -9
  198. package/src/ui/components/GroupedSection.tsx +12 -0
  199. package/src/ui/components/Header.tsx +364 -0
  200. package/src/ui/components/OxyProvider.tsx +31 -15
  201. package/src/ui/components/index.ts +1 -0
  202. package/src/ui/components/internal/GroupedPillButtons.tsx +1 -1
  203. package/src/ui/components/internal/TextField.md +436 -0
  204. package/src/ui/components/internal/TextField.tsx +720 -620
  205. package/src/ui/context/OxyContext.tsx +150 -63
  206. package/src/ui/hooks/useSessionSocket.ts +5 -2
  207. package/src/ui/index.ts +1 -19
  208. package/src/ui/navigation/OxyRouter.tsx +1 -1
  209. package/src/ui/navigation/types.ts +10 -2
  210. package/src/ui/screens/AccountCenterScreen.tsx +5 -5
  211. package/src/ui/screens/AccountManagementDemo.tsx +9 -9
  212. package/src/ui/screens/AccountOverviewScreen.tsx +265 -414
  213. package/src/ui/screens/AccountSettingsScreen.tsx +1165 -403
  214. package/src/ui/screens/AccountSwitcherScreen.tsx +158 -202
  215. package/src/ui/screens/AppInfoScreen.tsx +270 -497
  216. package/src/ui/screens/FeedbackScreen.tsx +3 -3
  217. package/src/ui/screens/PaymentGatewayScreen.tsx +668 -365
  218. package/src/ui/screens/ProfileScreen.tsx +5 -5
  219. package/src/ui/screens/RecoverAccountScreen.tsx +46 -74
  220. package/src/ui/screens/SessionManagementScreen.tsx +14 -22
  221. package/src/ui/screens/SignInScreen.tsx +27 -294
  222. package/src/ui/screens/SignUpScreen.tsx +5 -5
  223. package/src/ui/screens/internal/SignInPasswordStep.tsx +11 -22
  224. package/src/ui/screens/internal/SignInUsernameStep.tsx +3 -10
  225. package/src/ui/screens/internal/SignUpIdentityStep.tsx +2 -5
  226. package/src/ui/screens/internal/SignUpSecurityStep.tsx +3 -4
  227. package/src/ui/stores/authStore.ts +12 -0
  228. package/src/ui/styles/authStyles.ts +352 -0
  229. package/src/ui/styles/index.ts +1 -0
  230. package/lib/commonjs/node/middleware.js +0 -227
  231. package/lib/commonjs/node/middleware.js.map +0 -1
  232. package/lib/commonjs/ui/zero-config/index.js +0 -25
  233. package/lib/commonjs/ui/zero-config/index.js.map +0 -1
  234. package/lib/commonjs/ui/zero-config/provider.js +0 -278
  235. package/lib/commonjs/ui/zero-config/provider.js.map +0 -1
  236. package/lib/module/node/middleware.js +0 -199
  237. package/lib/module/node/middleware.js.map +0 -1
  238. package/lib/module/ui/zero-config/index.js +0 -8
  239. package/lib/module/ui/zero-config/index.js.map +0 -1
  240. package/lib/module/ui/zero-config/provider.js +0 -270
  241. package/lib/module/ui/zero-config/provider.js.map +0 -1
  242. package/lib/typescript/node/middleware.d.ts +0 -92
  243. package/lib/typescript/node/middleware.d.ts.map +0 -1
  244. package/lib/typescript/ui/zero-config/index.d.ts +0 -5
  245. package/lib/typescript/ui/zero-config/index.d.ts.map +0 -1
  246. package/lib/typescript/ui/zero-config/provider.d.ts +0 -84
  247. package/lib/typescript/ui/zero-config/provider.d.ts.map +0 -1
  248. package/src/__tests__/middleware.test.ts +0 -105
  249. package/src/__tests__/setup.ts +0 -10
  250. package/src/node/middleware.ts +0 -234
  251. package/src/ui/zero-config/index.ts +0 -11
  252. package/src/ui/zero-config/provider.tsx +0 -310
package/README.md CHANGED
@@ -1,347 +1,201 @@
1
1
  # OxyHQServices
2
2
 
3
- A TypeScript client library for the Oxy API providing **zero-config** authentication, user management, and UI components for React and React Native applications.
4
-
5
- ## ✨ Zero-Config Quick Start
6
-
7
- ### Frontend (React/Next.js) - 2 lines of code:
8
-
9
- ```jsx
10
- import { OxyZeroConfigProvider, useOxyZeroConfig } from '@oxyhq/services/ui';
11
-
12
- // 1. Wrap your app
13
- function App() {
14
- return (
15
- <OxyZeroConfigProvider>
16
- <YourApp />
17
- </OxyZeroConfigProvider>
18
- );
19
- }
20
-
21
- // 2. Use authentication anywhere
22
- function Dashboard() {
23
- const { user, login, logout, isAuthenticated } = useOxyZeroConfig();
24
-
25
- if (isAuthenticated) {
26
- return <div>Welcome {user.username}! <button onClick={logout}>Logout</button></div>;
27
- }
28
-
29
- return <button onClick={() => login('user', 'password')}>Login</button>;
30
- }
31
- ```
32
-
33
- ### Backend (Express.js) - 1 line of code:
34
-
35
- ```js
36
- import express from 'express';
37
- import { createOxyAuth } from '@oxyhq/services/node';
38
-
39
- const app = express();
40
-
41
- // Zero-config auth - req.user automatically available
42
- app.use('/api', createOxyAuth());
43
-
44
- app.get('/api/profile', (req, res) => {
45
- res.json({ user: req.user }); // req.user populated automatically!
46
- });
47
- ```
48
-
49
- **That's it!** No complex configuration, no manual token management, no middleware setup.
3
+ A TypeScript client library for the Oxy API providing authentication, user management, and UI components for React and React Native applications.
50
4
 
51
5
  ## Table of Contents
52
6
 
53
- - [Zero-Config Guide](#-zero-config-quick-start)
54
7
  - [Features](#features)
55
- - [Installation](#installation)
56
- - [Complete Examples](#complete-examples)
57
- - [Advanced Usage](#advanced-usage)
8
+ - [Quick Start](#quick-start)
58
9
  - [Documentation](#documentation)
59
- - [Migration Guide](#migration-guide)
10
+ - [UI Components](#ui-components)
11
+ - [Package Exports](#package-exports)
12
+ - [Requirements](#requirements)
13
+ - [Development](#development)
14
+ - [Integration](#integration)
15
+ - [License](#license)
60
16
 
61
17
  ## Features
62
18
 
63
- - 🚀 **Zero-Config**: Get authentication working in 2-3 lines of code
64
- - 🔐 **Automatic Token Management**: Tokens saved, restored, and refreshed automatically
19
+ - 🔐 **Streamlined Authentication**: Zero-config authentication with automatic token management
20
+ - 🔄 **Auto Token Refresh**: Seamless token lifecycle management behind the scenes
65
21
  - 👥 **User Management**: Profile operations and social features
66
- - 🎨 **UI Components**: Pre-built React components for common functionality
22
+ - 🎨 **UI Components**: Pre-built React components for common functionality
67
23
  - 📱 **Cross-Platform**: Works in React Native and web applications
68
24
  - 🔧 **TypeScript**: Full type safety and IntelliSense support
69
- - 🔄 **Auto Backend Integration**: Frontend automatically sends tokens to backend
70
- - 📦 **Express Middleware**: One-line backend authentication with `req.user` support
25
+ - 🚀 **Performance**: Optimized with automatic caching and state management
71
26
 
72
- ## Installation
27
+ ## Quick Start
73
28
 
74
29
  ```bash
75
30
  npm install @oxyhq/services
76
31
  ```
77
32
 
78
- ## Complete Examples
33
+ ### Streamlined Authentication (Recommended)
79
34
 
80
- ### React Application
81
-
82
- **App.js**
83
- ```jsx
84
- import React from 'react';
85
- import { OxyZeroConfigProvider } from '@oxyhq/services/ui';
86
- import Dashboard from './Dashboard';
35
+ ```typescript
36
+ import { OxyProvider, useOxy } from '@oxyhq/services';
87
37
 
88
- export default function App() {
38
+ function App() {
89
39
  return (
90
- <OxyZeroConfigProvider>
91
- <Dashboard />
92
- </OxyZeroConfigProvider>
40
+ <OxyProvider baseURL="https://api.example.com">
41
+ <YourApp />
42
+ </OxyProvider>
93
43
  );
94
44
  }
45
+
46
+ function UserProfile() {
47
+ const { oxyServices } = useOxy();
48
+
49
+ const fetchData = async () => {
50
+ // No manual authentication needed - everything is automatic!
51
+ const user = await oxyServices.getCurrentUser();
52
+ const notifications = await oxyServices.getNotifications();
53
+ };
54
+ }
95
55
  ```
96
56
 
97
- **Dashboard.js**
98
- ```jsx
99
- import React from 'react';
100
- import { useOxyZeroConfig } from '@oxyhq/services/ui';
57
+ ### With Built-in Bottom Sheet
101
58
 
102
- export default function Dashboard() {
103
- const { user, login, logout, isAuthenticated, isLoading } = useOxyZeroConfig();
59
+ The OxyProvider now includes a built-in gorhom bottom sheet - no manual setup required!
104
60
 
105
- if (isLoading) return <div>Loading...</div>;
61
+ ```typescript
62
+ import { OxyProvider, useOxy, OxySignInButton } from '@oxyhq/services';
106
63
 
107
- if (!isAuthenticated) {
108
- return (
109
- <div>
110
- <h1>Please log in</h1>
111
- <button onClick={() => login('demo', 'password')}>Login</button>
112
- </div>
113
- );
114
- }
64
+ function App() {
65
+ return (
66
+ <OxyProvider
67
+ baseURL="https://api.example.com"
68
+ initialScreen="SignIn"
69
+ theme="light"
70
+ >
71
+ <YourApp />
72
+ </OxyProvider>
73
+ );
74
+ }
115
75
 
76
+ function Component() {
77
+ const { showBottomSheet } = useOxy();
78
+
79
+ const openSignIn = () => {
80
+ showBottomSheet('SignIn'); // Works automatically!
81
+ };
82
+
116
83
  return (
117
84
  <div>
118
- <h1>Welcome, {user.username}!</h1>
119
- <button onClick={logout}>Logout</button>
85
+ <button onClick={openSignIn}>Sign In</button>
86
+ <OxySignInButton /> {/* Also works automatically! */}
120
87
  </div>
121
88
  );
122
89
  }
123
90
  ```
124
91
 
125
- ### Express.js Backend
92
+ ### Traditional Usage
126
93
 
127
- **server.js**
128
- ```js
129
- import express from 'express';
130
- import { createOxyAuth } from '@oxyhq/services/node';
131
-
132
- const app = express();
133
- app.use(express.json());
94
+ ```typescript
95
+ import { OxyServices } from '@oxyhq/services';
134
96
 
135
- // Public routes
136
- app.get('/', (req, res) => {
137
- res.json({ message: 'Public endpoint' });
97
+ const oxy = new OxyServices({
98
+ baseURL: 'http://localhost:3000'
138
99
  });
139
100
 
140
- // Protected routes - zero config!
141
- app.use('/api', createOxyAuth());
142
-
143
- // req.user is automatically available
144
- app.get('/api/profile', (req, res) => {
145
- res.json({
146
- message: `Hello ${req.user.username}!`,
147
- user: req.user
148
- });
101
+ // Authenticate
102
+ const response = await oxy.auth.login({
103
+ email: 'user@example.com',
104
+ password: 'password'
149
105
  });
150
106
 
151
- app.listen(3000, () => console.log('Server running on port 3000'));
152
- ```
153
-
154
- ### Next.js Full-Stack
155
-
156
- **pages/_app.js**
157
- ```jsx
158
- import { OxyZeroConfigProvider } from '@oxyhq/services/ui';
159
-
160
- export default function App({ Component, pageProps }) {
161
- return (
162
- <OxyZeroConfigProvider>
163
- <Component {...pageProps} />
164
- </OxyZeroConfigProvider>
165
- );
166
- }
167
- ```
168
-
169
- **pages/api/user.js**
170
- ```js
171
- import { createOxyAuth } from '@oxyhq/services/node';
172
-
173
- const auth = createOxyAuth();
174
-
175
- export default async function handler(req, res) {
176
- // Apply authentication
177
- await new Promise((resolve, reject) => {
178
- auth(req, res, (err) => {
179
- if (err) reject(err);
180
- else resolve();
181
- });
182
- });
183
-
184
- // req.user is now available
185
- res.json({ user: req.user });
186
- }
107
+ // Get current user
108
+ const user = await oxy.users.getCurrentUser();
187
109
  ```
188
110
 
189
- ## Advanced Usage
190
-
191
- ### Configuration Options
192
-
193
- **Frontend**
194
- ```jsx
195
- <OxyZeroConfigProvider
196
- apiUrl="https://your-api.com"
197
- onAuthChange={(user) => console.log('Auth changed:', user)}
198
- >
199
- <App />
200
- </OxyZeroConfigProvider>
201
- ```
202
-
203
- **Backend**
204
- ```js
205
- app.use('/api', createOxyAuth({
206
- baseURL: 'https://your-oxy-api.com',
207
- loadUser: true,
208
- publicPaths: ['/api/health'],
209
- onError: (error, req, res) => {
210
- res.status(error.status).json({ error: error.message });
211
- }
212
- }));
213
- ```
214
-
215
- ### Direct API Access
216
-
217
- ```jsx
218
- import { useOxyApi } from '@oxyhq/services/ui';
219
-
220
- function ProfileForm() {
221
- const api = useOxyApi();
222
-
223
- const updateProfile = async (data) => {
224
- const user = await api.updateProfile(data);
225
- // Token automatically included in request
226
- };
111
+ ## Documentation
227
112
 
228
- return <button onClick={() => updateProfile({ name: 'New Name' })}>Update</button>;
229
- }
230
- ```
113
+ For comprehensive documentation, API reference, and examples:
231
114
 
232
- ### Optional Authentication
115
+ - [📚 Full Documentation](./docs/README.md)
116
+ - [🚀 Quick Start Guide](./docs/quick-start.md)
117
+ - [🔐 Core API Reference](./docs/core-api.md)
118
+ - [⚡ Streamlined Authentication](./docs/core-api.md#streamlined-authentication) - **NEW!**
119
+ - [💼 Integration Examples](./docs/examples/)
233
120
 
234
- ```js
235
- import { createOptionalOxyAuth } from '@oxyhq/services/node';
121
+ ## UI Components
236
122
 
237
- // Works with or without authentication
238
- app.use('/api/content', createOptionalOxyAuth());
123
+ Import and use pre-built React components:
239
124
 
240
- app.get('/api/content', (req, res) => {
241
- if (req.user) {
242
- res.json({ content: 'personalized', user: req.user });
243
- } else {
244
- res.json({ content: 'public' });
245
- }
246
- });
125
+ ```typescript
126
+ import { OxyProvider, Avatar, FollowButton } from '@oxyhq/services/ui';
247
127
  ```
248
128
 
249
- ## Documentation
250
-
251
- ### Zero-Config Guide
252
- - **[🚀 Zero-Config Setup Guide](./docs/zero-config.md)** - Complete guide with examples
253
-
254
- ### Advanced Documentation
255
- - **[📚 Full Documentation](./docs/README.md)** - Complete system documentation
256
- - **[🚀 Quick Start Guide](./docs/quick-start.md)** - Traditional setup guide
257
- - **[🔐 Core API Reference](./docs/core-api.md)** - Detailed API documentation
258
- - **[💼 Integration Examples](./docs/examples/)** - More integration examples
259
-
260
- ### UI Components
261
- - **[🎨 UI Components Guide](./docs/ui-components.md)** - React/RN component usage
129
+ ## Package Exports
262
130
 
263
- ## Migration Guide
131
+ The library provides multiple entry points:
264
132
 
265
- ### From Complex Setup
266
-
267
- **Before (complex setup):**
268
- ```jsx
269
- import { OxyProvider, useOxy } from '@oxyhq/services/ui';
133
+ ```typescript
134
+ // Core services only (Node.js/Express)
270
135
  import { OxyServices } from '@oxyhq/services';
271
136
 
272
- const oxy = new OxyServices({ baseURL: 'http://localhost:3001' });
137
+ // UI components only (React/React Native)
138
+ import { OxyProvider, Avatar } from '@oxyhq/services/ui';
273
139
 
274
- function App() {
275
- return (
276
- <OxyProvider oxyServices={oxy}>
277
- <Dashboard />
278
- </OxyProvider>
279
- );
280
- }
140
+ // Full package (Core + UI)
141
+ import { OxyServices, OxyProvider } from '@oxyhq/services/full';
281
142
  ```
282
143
 
283
- **After (zero-config):**
284
- ```jsx
285
- import { OxyZeroConfigProvider, useOxyZeroConfig } from '@oxyhq/services/ui';
144
+ ## Zero-Config Express Router
286
145
 
287
- function App() {
288
- return (
289
- <OxyZeroConfigProvider>
290
- <Dashboard />
291
- </OxyZeroConfigProvider>
292
- );
293
- }
294
- ```
295
-
296
- Just change the provider and hook names - the API is nearly identical!
297
-
298
- ### Package Exports
299
-
300
- The library provides multiple entry points for different use cases:
146
+ Quickly mount authentication routes in any Express app:
301
147
 
302
148
  ```typescript
303
- // Zero-config frontend
304
- import { OxyZeroConfigProvider, useOxyZeroConfig } from '@oxyhq/services/ui';
305
-
306
- // Zero-config backend
307
- import { createOxyAuth } from '@oxyhq/services/node';
308
-
309
- // Core services only (traditional)
310
- import { OxyServices } from '@oxyhq/services';
149
+ import express from 'express';
150
+ import { createAuth } from '@oxyhq/services/core';
311
151
 
312
- // Full package (Core + UI + Node)
313
- import { OxyServices, OxyProvider, createOxyAuth } from '@oxyhq/services/full';
152
+ const app = express();
153
+ app.use('/auth', createAuth({ baseURL: 'http://localhost:3000' }).middleware());
314
154
  ```
315
155
 
156
+ This automatically provides sign-up, login, logout, refresh, and session management endpoints.
157
+
316
158
  ## Requirements
317
159
 
318
160
  - **Node.js** 16+ (for backend usage)
319
- - **React** 16.8+ (for React components)
161
+ - **React** 16.8+ (for React components)
320
162
  - **React Native** 0.60+ (for mobile components)
321
163
  - **TypeScript** 4.0+ (optional but recommended)
322
164
 
323
165
  ## Troubleshooting
324
166
 
325
- ### Common Issues
167
+ ### FormData Issues in React Native/Expo
168
+
169
+ If you encounter `ReferenceError: Property 'FormData' doesn't exist` when using Expo with Hermes engine:
170
+
171
+ **For file uploads in React Native/Expo:**
172
+ - The library handles this automatically - no additional setup required
173
+ - File uploads will work with both native FormData (when available) and the polyfilled version
174
+ - Ensure you're using the latest version of the package
175
+
176
+ ### Additional Dependencies
177
+
178
+ For React Native projects, you may need to install peer dependencies:
326
179
 
327
- **"useOxyZeroConfig must be used within an OxyZeroConfigProvider"**
328
- - Make sure your component is wrapped with `<OxyZeroConfigProvider>`
180
+ ```bash
181
+ npm install axios jwt-decode invariant
182
+ ```
329
183
 
330
- **"req.user is undefined"**
331
- - Ensure the middleware is applied: `app.use('/api', createOxyAuth())`
332
- - Check that the client sends `Authorization: Bearer <token>` header
184
+ ## Important for React Native Hermes Users
185
+
186
+ If you use this package in a React Native app with the Hermes engine, you must add the following import as the very first line of your app's entry file (e.g., App.js or index.js):
333
187
 
334
- **FormData Issues in React Native/Expo**
335
- Add this import as the first line of your app entry file:
336
188
  ```js
337
189
  import 'react-native-url-polyfill/auto';
338
190
  ```
339
191
 
340
- ### Getting Help
192
+ This ensures that FormData and other web APIs are polyfilled before any dependencies are loaded. If you do not do this, you may see errors like:
341
193
 
342
- 1. Check the [Zero-Config Guide](./docs/zero-config.md) for complete examples
343
- 2. Review [Troubleshooting Guide](./docs/troubleshooting.md) for common issues
344
- 3. Open an issue on [GitHub](https://github.com/oxyhq/services/issues)
194
+ ```
195
+ ReferenceError: Property 'FormData' doesn't exist, js engine: hermes
196
+ ```
197
+
198
+ ---
345
199
 
346
200
  ## Development
347
201
 
@@ -352,17 +206,20 @@ npm install
352
206
  # Build the library
353
207
  npm run build
354
208
 
355
- # Run tests
209
+ # Run tests
356
210
  npm test
211
+
212
+ # Development mode
213
+ npm run dev
357
214
  ```
358
215
 
359
216
  ## Integration
360
217
 
361
218
  This library works with:
362
- - **[Oxy API](../api/)** - The companion authentication server
363
- - **Express.js** - Built-in zero-config middleware support
364
- - **React/React Native** - Zero-config UI components and hooks
365
- - **Next.js** - SSR/SSG authentication support
219
+ - **[Oxy API](../oxy-api/)** - The companion authentication server
220
+ - **Express.js** - Built-in middleware support
221
+ - **React/React Native** - UI components and hooks
222
+ - **Next.js** - SSR/SSG authentication
366
223
 
367
224
  ## License
368
225
 
@@ -516,9 +516,17 @@ class OxyServices {
516
516
  */
517
517
  async getCurrentUser() {
518
518
  try {
519
+ console.log('OxyServices: Fetching current user...');
519
520
  const res = await this.client.get('/users/me');
521
+ console.log('OxyServices: Current user response:', {
522
+ hasUser: !!res.data,
523
+ userLinksMetadata: res.data?.linksMetadata,
524
+ userLinks: res.data?.links,
525
+ userWebsite: res.data?.website
526
+ });
520
527
  return res.data;
521
528
  } catch (error) {
529
+ console.error('OxyServices: Error fetching current user:', error);
522
530
  throw this.handleError(error);
523
531
  }
524
532
  }
@@ -530,9 +538,12 @@ class OxyServices {
530
538
  */
531
539
  async updateProfile(updates) {
532
540
  try {
541
+ console.log('OxyServices: Updating profile with:', updates);
533
542
  const res = await this.client.put('/users/me', updates);
543
+ console.log('OxyServices: Profile update response:', res.data);
534
544
  return res.data;
535
545
  } catch (error) {
546
+ console.error('OxyServices: Error updating profile:', error);
536
547
  throw this.handleError(error);
537
548
  }
538
549
  }
@@ -1246,10 +1257,13 @@ class OxyServices {
1246
1257
  * @returns Array of user sessions
1247
1258
  */
1248
1259
  async getSessionsBySessionId(sessionId) {
1260
+ console.log('getSessionsBySessionId called with sessionId:', sessionId);
1249
1261
  try {
1250
1262
  const res = await this.client.get(`/secure-session/sessions/${sessionId}`);
1263
+ console.log('getSessionsBySessionId response:', res.data);
1251
1264
  return res.data.sessions;
1252
1265
  } catch (error) {
1266
+ console.error('getSessionsBySessionId error:', error);
1253
1267
  throw this.handleError(error);
1254
1268
  }
1255
1269
  }
@@ -1718,6 +1732,164 @@ class OxyServices {
1718
1732
  throw this.handleError(error);
1719
1733
  }
1720
1734
  }
1735
+
1736
+ /**
1737
+ * Fetch metadata for a URL (title, description, image)
1738
+ * @param url - The URL to fetch metadata for
1739
+ * @returns Promise with metadata object
1740
+ */
1741
+ async fetchLinkMetadata(url) {
1742
+ try {
1743
+ const response = await this.client.post('/link-metadata/fetch-metadata', {
1744
+ url
1745
+ });
1746
+ return response.data;
1747
+ } catch (error) {
1748
+ throw this.handleError(error);
1749
+ }
1750
+ }
1751
+
1752
+ /**
1753
+ * Search for locations using the enhanced location search API
1754
+ * @param query - Search query string
1755
+ * @param limit - Maximum number of results (default: 5)
1756
+ * @param countrycodes - Optional country codes filter (e.g., "us,ca")
1757
+ * @returns Promise with array of location results
1758
+ */
1759
+ async searchLocations(query, limit = 5, countrycodes) {
1760
+ try {
1761
+ const params = new URLSearchParams({
1762
+ query,
1763
+ limit: limit.toString()
1764
+ });
1765
+ if (countrycodes) {
1766
+ params.append('countrycodes', countrycodes);
1767
+ }
1768
+ const res = await this.client.get(`/location-search/search?${params.toString()}`);
1769
+ return res.data.results;
1770
+ } catch (error) {
1771
+ throw this.handleError(error);
1772
+ }
1773
+ }
1774
+
1775
+ /**
1776
+ * Get detailed information about a specific location by coordinates
1777
+ * @param lat - Latitude
1778
+ * @param lon - Longitude
1779
+ * @returns Promise with detailed location information
1780
+ */
1781
+ async getLocationDetails(lat, lon) {
1782
+ try {
1783
+ const res = await this.client.get(`/location-search/details?lat=${lat}&lon=${lon}`);
1784
+ return res.data.result;
1785
+ } catch (error) {
1786
+ throw this.handleError(error);
1787
+ }
1788
+ }
1789
+
1790
+ /**
1791
+ * Find locations near a point using geospatial queries
1792
+ * @param lat - Latitude
1793
+ * @param lon - Longitude
1794
+ * @param maxDistance - Maximum distance in meters (default: 10000)
1795
+ * @param limit - Maximum number of results (default: 10)
1796
+ * @param skip - Number of results to skip (default: 0)
1797
+ * @returns Promise with nearby locations
1798
+ */
1799
+ async findLocationsNear(lat, lon, maxDistance = 10000, limit = 10, skip = 0) {
1800
+ try {
1801
+ const params = new URLSearchParams({
1802
+ lat: lat.toString(),
1803
+ lon: lon.toString(),
1804
+ maxDistance: maxDistance.toString(),
1805
+ limit: limit.toString(),
1806
+ skip: skip.toString()
1807
+ });
1808
+ const res = await this.client.get(`/location-search/near?${params.toString()}`);
1809
+ return res.data;
1810
+ } catch (error) {
1811
+ throw this.handleError(error);
1812
+ }
1813
+ }
1814
+
1815
+ /**
1816
+ * Search locations in database by text
1817
+ * @param query - Search query
1818
+ * @param limit - Maximum number of results (default: 10)
1819
+ * @param skip - Number of results to skip (default: 0)
1820
+ * @param type - Filter by location type
1821
+ * @param country - Filter by country
1822
+ * @param city - Filter by city
1823
+ * @returns Promise with search results
1824
+ */
1825
+ async searchLocationsInDB(query, limit = 10, skip = 0, type, country, city) {
1826
+ try {
1827
+ const params = new URLSearchParams({
1828
+ query,
1829
+ limit: limit.toString(),
1830
+ skip: skip.toString()
1831
+ });
1832
+ if (type) params.append('type', type);
1833
+ if (country) params.append('country', country);
1834
+ if (city) params.append('city', city);
1835
+ const res = await this.client.get(`/location-search/db-search?${params.toString()}`);
1836
+ return res.data;
1837
+ } catch (error) {
1838
+ throw this.handleError(error);
1839
+ }
1840
+ }
1841
+
1842
+ /**
1843
+ * Get location statistics
1844
+ * @returns Promise with location statistics
1845
+ */
1846
+ async getLocationStats() {
1847
+ try {
1848
+ const res = await this.client.get('/location-search/stats');
1849
+ return res.data.stats;
1850
+ } catch (error) {
1851
+ throw this.handleError(error);
1852
+ }
1853
+ }
1854
+
1855
+ /**
1856
+ * Get cache statistics
1857
+ * @returns Promise with cache statistics
1858
+ */
1859
+ async getLocationCacheStats() {
1860
+ try {
1861
+ const res = await this.client.get('/location-search/cache/stats');
1862
+ return res.data.stats;
1863
+ } catch (error) {
1864
+ throw this.handleError(error);
1865
+ }
1866
+ }
1867
+
1868
+ /**
1869
+ * Clear location cache
1870
+ * @returns Promise with success status
1871
+ */
1872
+ async clearLocationCache() {
1873
+ try {
1874
+ const res = await this.client.delete('/location-search/cache');
1875
+ return res.data;
1876
+ } catch (error) {
1877
+ throw this.handleError(error);
1878
+ }
1879
+ }
1880
+
1881
+ /**
1882
+ * Get performance statistics
1883
+ * @returns Promise with performance statistics
1884
+ */
1885
+ async getLocationPerformanceStats() {
1886
+ try {
1887
+ const res = await this.client.get('/location-search/performance');
1888
+ return res.data;
1889
+ } catch (error) {
1890
+ throw this.handleError(error);
1891
+ }
1892
+ }
1721
1893
  }
1722
1894
 
1723
1895
  // Default export for backward compatibility