@oxyhq/services 5.7.5 → 5.8.2
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.
- package/README.md +76 -76
- package/lib/commonjs/core/index.js +177 -102
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/index.js +69 -28
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/Avatar.js +15 -6
- package/lib/commonjs/ui/components/Avatar.js.map +1 -1
- package/lib/commonjs/ui/components/FollowButton.js +100 -12
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedItem.js +58 -13
- package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedSection.js +7 -1
- package/lib/commonjs/ui/components/GroupedSection.js.map +1 -1
- package/lib/commonjs/ui/components/Header.js +356 -0
- package/lib/commonjs/ui/components/Header.js.map +1 -0
- package/lib/commonjs/ui/components/OxyProvider.js +28 -7
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/index.js +7 -0
- package/lib/commonjs/ui/components/index.js.map +1 -1
- package/lib/commonjs/ui/components/internal/GroupedPillButtons.js +1 -1
- package/lib/commonjs/ui/components/internal/GroupedPillButtons.js.map +1 -1
- package/lib/commonjs/ui/components/internal/TextField.js +606 -546
- package/lib/commonjs/ui/components/internal/TextField.js.map +1 -1
- package/lib/commonjs/ui/components/internal/TextField.md +436 -0
- package/lib/commonjs/ui/context/OxyContext.js +181 -199
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/index.js +6 -0
- package/lib/commonjs/ui/hooks/index.js.map +1 -1
- package/lib/commonjs/ui/hooks/useFollow.js +59 -2
- package/lib/commonjs/ui/hooks/useFollow.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionSocket.js +5 -2
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/commonjs/ui/navigation/OxyRouter.js +11 -1
- package/lib/commonjs/ui/navigation/OxyRouter.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +6 -6
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountManagementDemo.js +3 -3
- package/lib/commonjs/ui/screens/AccountManagementDemo.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +241 -598
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +1160 -406
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +135 -237
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AppInfoScreen.js +246 -463
- package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FeedbackScreen.js +3 -3
- package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +808 -650
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +214 -37
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/RecoverAccountScreen.js +51 -72
- package/lib/commonjs/ui/screens/RecoverAccountScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SessionManagementScreen.js +11 -29
- package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js +30 -303
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignUpScreen.js +4 -4
- package/lib/commonjs/ui/screens/SignUpScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/UserLinksScreen.js +90 -0
- package/lib/commonjs/ui/screens/UserLinksScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js +19 -31
- package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js.map +1 -1
- package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js +7 -10
- package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js.map +1 -1
- package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js +11 -5
- package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js.map +1 -1
- package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js +11 -4
- package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js +9 -6
- package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +3 -30
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaFAQScreen.js +37 -46
- package/lib/commonjs/ui/screens/karma/KarmaFAQScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +9 -12
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +9 -12
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +9 -12
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js +36 -6
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/stores/followStore.js +106 -1
- package/lib/commonjs/ui/stores/followStore.js.map +1 -1
- package/lib/commonjs/ui/styles/authStyles.js +337 -0
- package/lib/commonjs/ui/styles/authStyles.js.map +1 -0
- package/lib/commonjs/ui/styles/index.js +11 -0
- package/lib/commonjs/ui/styles/index.js.map +1 -1
- package/lib/module/core/index.js +177 -41
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/index.js +24 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/Avatar.js +15 -6
- package/lib/module/ui/components/Avatar.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +101 -13
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/module/ui/components/GroupedItem.js +59 -14
- package/lib/module/ui/components/GroupedItem.js.map +1 -1
- package/lib/module/ui/components/GroupedSection.js +7 -1
- package/lib/module/ui/components/GroupedSection.js.map +1 -1
- package/lib/module/ui/components/Header.js +351 -0
- package/lib/module/ui/components/Header.js.map +1 -0
- package/lib/module/ui/components/OxyProvider.js +30 -9
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/index.js +1 -0
- package/lib/module/ui/components/index.js.map +1 -1
- package/lib/module/ui/components/internal/GroupedPillButtons.js +1 -1
- package/lib/module/ui/components/internal/GroupedPillButtons.js.map +1 -1
- package/lib/module/ui/components/internal/TextField.js +607 -547
- package/lib/module/ui/components/internal/TextField.js.map +1 -1
- package/lib/module/ui/components/internal/TextField.md +436 -0
- package/lib/module/ui/context/OxyContext.js +180 -198
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/index.js +1 -1
- package/lib/module/ui/hooks/index.js.map +1 -1
- package/lib/module/ui/hooks/useFollow.js +57 -1
- package/lib/module/ui/hooks/useFollow.js.map +1 -1
- package/lib/module/ui/hooks/useSessionSocket.js +5 -2
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/module/ui/navigation/OxyRouter.js +11 -1
- package/lib/module/ui/navigation/OxyRouter.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +6 -6
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountManagementDemo.js +3 -3
- package/lib/module/ui/screens/AccountManagementDemo.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +242 -597
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +1161 -407
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +135 -237
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js +248 -465
- package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js +3 -3
- package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js +809 -651
- package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +214 -37
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/RecoverAccountScreen.js +53 -74
- package/lib/module/ui/screens/RecoverAccountScreen.js.map +1 -1
- package/lib/module/ui/screens/SessionManagementScreen.js +11 -29
- package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/SignInScreen.js +32 -305
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/ui/screens/SignUpScreen.js +5 -5
- package/lib/module/ui/screens/SignUpScreen.js.map +1 -1
- package/lib/module/ui/screens/UserLinksScreen.js +85 -0
- package/lib/module/ui/screens/UserLinksScreen.js.map +1 -0
- package/lib/module/ui/screens/internal/SignInPasswordStep.js +19 -31
- package/lib/module/ui/screens/internal/SignInPasswordStep.js.map +1 -1
- package/lib/module/ui/screens/internal/SignInUsernameStep.js +7 -10
- package/lib/module/ui/screens/internal/SignInUsernameStep.js.map +1 -1
- package/lib/module/ui/screens/internal/SignUpIdentityStep.js +11 -5
- package/lib/module/ui/screens/internal/SignUpIdentityStep.js.map +1 -1
- package/lib/module/ui/screens/internal/SignUpSecurityStep.js +11 -4
- package/lib/module/ui/screens/internal/SignUpSecurityStep.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaAboutScreen.js +9 -6
- package/lib/module/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js +3 -30
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaFAQScreen.js +37 -46
- package/lib/module/ui/screens/karma/KarmaFAQScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +9 -12
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +9 -12
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js +9 -12
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +36 -6
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/stores/followStore.js +106 -1
- package/lib/module/ui/stores/followStore.js.map +1 -1
- package/lib/module/ui/styles/authStyles.js +332 -0
- package/lib/module/ui/styles/authStyles.js.map +1 -0
- package/lib/module/ui/styles/index.js +1 -0
- package/lib/module/ui/styles/index.js.map +1 -1
- package/lib/typescript/core/index.d.ts +68 -24
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +13 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/Avatar.d.ts.map +1 -1
- package/lib/typescript/ui/components/FollowButton.d.ts +1 -0
- package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/ui/components/GroupedItem.d.ts +6 -0
- package/lib/typescript/ui/components/GroupedItem.d.ts.map +1 -1
- package/lib/typescript/ui/components/GroupedSection.d.ts +6 -0
- package/lib/typescript/ui/components/GroupedSection.d.ts.map +1 -1
- package/lib/typescript/ui/components/Header.d.ts +24 -0
- package/lib/typescript/ui/components/Header.d.ts.map +1 -0
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/components/index.d.ts +1 -0
- package/lib/typescript/ui/components/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/internal/TextField.d.ts +31 -16
- package/lib/typescript/ui/components/internal/TextField.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +5 -2
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/index.d.ts +1 -1
- package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useFollow.d.ts +20 -0
- package/lib/typescript/ui/hooks/useFollow.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/OxyRouter.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/types.d.ts +9 -2
- package/lib/typescript/ui/navigation/types.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AppInfoScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/ProfileScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts +5 -1
- package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SessionManagementScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SignInScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/UserLinksScreen.d.ts +15 -0
- package/lib/typescript/ui/screens/UserLinksScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts +1 -1
- package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts.map +1 -1
- package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts +0 -1
- package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts.map +1 -1
- package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts.map +1 -1
- package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaAboutScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaCenterScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaFAQScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaLeaderboardScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaRewardsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaRulesScreen.d.ts.map +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts +3 -1
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/ui/stores/followStore.d.ts +10 -0
- package/lib/typescript/ui/stores/followStore.d.ts.map +1 -1
- package/lib/typescript/ui/styles/authStyles.d.ts +326 -0
- package/lib/typescript/ui/styles/authStyles.d.ts.map +1 -0
- package/lib/typescript/ui/styles/index.d.ts +1 -0
- package/lib/typescript/ui/styles/index.d.ts.map +1 -1
- package/package.json +1 -4
- package/src/core/index.ts +195 -41
- package/src/index.ts +64 -4
- package/src/ui/components/Avatar.tsx +11 -5
- package/src/ui/components/FollowButton.tsx +95 -11
- package/src/ui/components/GroupedItem.tsx +57 -9
- package/src/ui/components/GroupedSection.tsx +12 -0
- package/src/ui/components/Header.tsx +405 -0
- package/src/ui/components/OxyProvider.tsx +37 -15
- package/src/ui/components/index.ts +1 -0
- package/src/ui/components/internal/GroupedPillButtons.tsx +1 -1
- package/src/ui/components/internal/TextField.md +436 -0
- package/src/ui/components/internal/TextField.tsx +720 -620
- package/src/ui/context/OxyContext.tsx +211 -195
- package/src/ui/hooks/index.ts +1 -1
- package/src/ui/hooks/useFollow.ts +63 -0
- package/src/ui/hooks/useSessionSocket.ts +5 -2
- package/src/ui/navigation/OxyRouter.tsx +11 -1
- package/src/ui/navigation/types.ts +10 -2
- package/src/ui/screens/AccountCenterScreen.tsx +5 -5
- package/src/ui/screens/AccountManagementDemo.tsx +9 -9
- package/src/ui/screens/AccountOverviewScreen.tsx +265 -414
- package/src/ui/screens/AccountSettingsScreen.tsx +1173 -403
- package/src/ui/screens/AccountSwitcherScreen.tsx +158 -202
- package/src/ui/screens/AppInfoScreen.tsx +270 -497
- package/src/ui/screens/FeedbackScreen.tsx +3 -3
- package/src/ui/screens/PaymentGatewayScreen.tsx +668 -365
- package/src/ui/screens/ProfileScreen.tsx +196 -33
- package/src/ui/screens/RecoverAccountScreen.tsx +46 -74
- package/src/ui/screens/SessionManagementScreen.tsx +14 -22
- package/src/ui/screens/SignInScreen.tsx +27 -294
- package/src/ui/screens/SignUpScreen.tsx +5 -5
- package/src/ui/screens/UserLinksScreen.tsx +96 -0
- package/src/ui/screens/internal/SignInPasswordStep.tsx +11 -22
- package/src/ui/screens/internal/SignInUsernameStep.tsx +3 -10
- package/src/ui/screens/internal/SignUpIdentityStep.tsx +2 -5
- package/src/ui/screens/internal/SignUpSecurityStep.tsx +3 -4
- package/src/ui/screens/karma/KarmaAboutScreen.tsx +9 -2
- package/src/ui/screens/karma/KarmaCenterScreen.tsx +1 -20
- package/src/ui/screens/karma/KarmaFAQScreen.tsx +40 -24
- package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +9 -3
- package/src/ui/screens/karma/KarmaRewardsScreen.tsx +9 -3
- package/src/ui/screens/karma/KarmaRulesScreen.tsx +9 -3
- package/src/ui/stores/authStore.ts +34 -7
- package/src/ui/stores/followStore.ts +102 -1
- package/src/ui/styles/authStyles.ts +352 -0
- package/src/ui/styles/index.ts +1 -0
- package/lib/commonjs/core/auth-manager.js +0 -440
- package/lib/commonjs/core/auth-manager.js.map +0 -1
- package/lib/commonjs/core/use-auth.js +0 -244
- package/lib/commonjs/core/use-auth.js.map +0 -1
- package/lib/module/core/auth-manager.js +0 -432
- package/lib/module/core/auth-manager.js.map +0 -1
- package/lib/module/core/use-auth.js +0 -235
- package/lib/module/core/use-auth.js.map +0 -1
- package/lib/typescript/core/auth-manager.d.ts +0 -136
- package/lib/typescript/core/auth-manager.d.ts.map +0 -1
- package/lib/typescript/core/use-auth.d.ts +0 -79
- package/lib/typescript/core/use-auth.d.ts.map +0 -1
- package/src/__tests__/middleware.test.ts +0 -105
- package/src/__tests__/setup.ts +0 -10
- package/src/__tests__/zero-config-auth.test.ts +0 -607
- package/src/core/auth-manager.ts +0 -500
- package/src/core/use-auth.tsx +0 -245
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useState","useEffect","useCallback","useContext","createContext","getAuthManager","initializeAuth","jsx","_jsx","AuthContext","AuthProvider","children","baseURL","state","setState","isAuthenticated","isLoading","user","error","authManager","unsubscribe","onAuthStateChange","authState","prevState","login","username","password","prev","Error","message","register","email","logout","console","getCurrentUser","checkUsernameAvailability","checkEmailAvailability","clearError","contextValue","Provider","value","useAuth","context","withAuth","Component","options","redirectTo","LoadingComponent","requireAuth","AuthenticatedComponent","props","useOxyClient","getClient","useAuthStatus","useCurrentUser","refetch"],"sourceRoot":"../../../src","sources":["core/use-auth.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,EAAEC,aAAa,QAAmB,OAAO;AAC9F,SAAgCC,cAAc,EAAEC,cAAc,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAmBvF,MAAMC,WAAW,gBAAGL,aAAa,CAA0B,IAAI,CAAC;AAOhE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,YAAYA,CAAC;EAAEC,QAAQ;EAAEC,OAAO,GAAG;AAAwC,CAAC,EAAE;EAC5F,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGd,QAAQ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Manager
|
|
3
|
-
*
|
|
4
|
-
* This module provides automatic token management, session handling,
|
|
5
|
-
* and seamless authentication for Oxy services.
|
|
6
|
-
*/
|
|
7
|
-
import { AxiosInstance } from 'axios';
|
|
8
|
-
interface AuthTokens {
|
|
9
|
-
accessToken: string;
|
|
10
|
-
refreshToken: string;
|
|
11
|
-
}
|
|
12
|
-
interface AuthState {
|
|
13
|
-
isAuthenticated: boolean;
|
|
14
|
-
user: any | null;
|
|
15
|
-
tokens: AuthTokens | null;
|
|
16
|
-
}
|
|
17
|
-
interface LoginCredentials {
|
|
18
|
-
username: string;
|
|
19
|
-
password: string;
|
|
20
|
-
}
|
|
21
|
-
interface LoginResponse {
|
|
22
|
-
success: boolean;
|
|
23
|
-
accessToken: string;
|
|
24
|
-
refreshToken: string;
|
|
25
|
-
user: any;
|
|
26
|
-
message?: string;
|
|
27
|
-
}
|
|
28
|
-
export declare class AuthenticationManager {
|
|
29
|
-
private client;
|
|
30
|
-
private tokens;
|
|
31
|
-
private user;
|
|
32
|
-
private refreshPromise;
|
|
33
|
-
private listeners;
|
|
34
|
-
private storageKey;
|
|
35
|
-
constructor(baseURL: string);
|
|
36
|
-
/**
|
|
37
|
-
* Setup axios interceptors for automatic token management
|
|
38
|
-
*/
|
|
39
|
-
private setupInterceptors;
|
|
40
|
-
/**
|
|
41
|
-
* Check if endpoint is public (doesn't require authentication)
|
|
42
|
-
*/
|
|
43
|
-
private isPublicEndpoint;
|
|
44
|
-
/**
|
|
45
|
-
* Initialize authentication state from persistent storage
|
|
46
|
-
*/
|
|
47
|
-
private initializeFromStorage;
|
|
48
|
-
/**
|
|
49
|
-
* Validate stored tokens without making network calls if possible
|
|
50
|
-
*/
|
|
51
|
-
private validateStoredTokens;
|
|
52
|
-
/**
|
|
53
|
-
* Ensure we have a valid access token
|
|
54
|
-
*/
|
|
55
|
-
private ensureValidToken;
|
|
56
|
-
/**
|
|
57
|
-
* Login with credentials
|
|
58
|
-
*/
|
|
59
|
-
login(credentials: LoginCredentials): Promise<LoginResponse>;
|
|
60
|
-
/**
|
|
61
|
-
* Register new user
|
|
62
|
-
*/
|
|
63
|
-
register(userData: {
|
|
64
|
-
username: string;
|
|
65
|
-
email: string;
|
|
66
|
-
password: string;
|
|
67
|
-
}): Promise<LoginResponse>;
|
|
68
|
-
/**
|
|
69
|
-
* Logout user and clear all tokens
|
|
70
|
-
*/
|
|
71
|
-
logout(): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Refresh access token using refresh token
|
|
74
|
-
*/
|
|
75
|
-
private refreshTokens;
|
|
76
|
-
/**
|
|
77
|
-
* Perform the actual token refresh
|
|
78
|
-
*/
|
|
79
|
-
private performTokenRefresh;
|
|
80
|
-
/**
|
|
81
|
-
* Set tokens and persist to storage
|
|
82
|
-
*/
|
|
83
|
-
private setTokens;
|
|
84
|
-
/**
|
|
85
|
-
* Fetch current user profile
|
|
86
|
-
*/
|
|
87
|
-
private fetchCurrentUser;
|
|
88
|
-
/**
|
|
89
|
-
* Get current authentication state
|
|
90
|
-
*/
|
|
91
|
-
getAuthState(): AuthState;
|
|
92
|
-
/**
|
|
93
|
-
* Get current user (loads if not cached)
|
|
94
|
-
*/
|
|
95
|
-
getCurrentUser(): Promise<any>;
|
|
96
|
-
/**
|
|
97
|
-
* Subscribe to authentication state changes
|
|
98
|
-
*/
|
|
99
|
-
onAuthStateChange(callback: (state: AuthState) => void): () => void;
|
|
100
|
-
/**
|
|
101
|
-
* Notify all listeners of state changes
|
|
102
|
-
*/
|
|
103
|
-
private notifyStateChange;
|
|
104
|
-
/**
|
|
105
|
-
* Format error responses consistently
|
|
106
|
-
*/
|
|
107
|
-
private formatError;
|
|
108
|
-
/**
|
|
109
|
-
* Get authenticated HTTP client for making API calls
|
|
110
|
-
*/
|
|
111
|
-
getClient(): AxiosInstance;
|
|
112
|
-
/**
|
|
113
|
-
* Check username availability
|
|
114
|
-
*/
|
|
115
|
-
checkUsernameAvailability(username: string): Promise<{
|
|
116
|
-
available: boolean;
|
|
117
|
-
message: string;
|
|
118
|
-
}>;
|
|
119
|
-
/**
|
|
120
|
-
* Check email availability
|
|
121
|
-
*/
|
|
122
|
-
checkEmailAvailability(email: string): Promise<{
|
|
123
|
-
available: boolean;
|
|
124
|
-
message: string;
|
|
125
|
-
}>;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Initialize global authentication manager
|
|
129
|
-
*/
|
|
130
|
-
export declare function initializeAuth(baseURL: string): AuthenticationManager;
|
|
131
|
-
/**
|
|
132
|
-
* Get global authentication manager instance
|
|
133
|
-
*/
|
|
134
|
-
export declare function getAuthManager(): AuthenticationManager;
|
|
135
|
-
export {};
|
|
136
|
-
//# sourceMappingURL=auth-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../../../src/core/auth-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAE,aAAa,EAA0C,MAAM,OAAO,CAAC;AAIrF,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AASD,UAAU,SAAS;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IACjB,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CAC3B;AAED,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,IAAI,CAAoB;I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AAE,SAAS,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAY9F;AAKD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAKrE;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,qBAAqB,CAKtD"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zero-Config Authentication Hook for React/React Native
|
|
3
|
-
*
|
|
4
|
-
* Provides automatic authentication state management with minimal setup required.
|
|
5
|
-
*/
|
|
6
|
-
import { ReactNode } from 'react';
|
|
7
|
-
interface AuthState {
|
|
8
|
-
isAuthenticated: boolean;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
user: any | null;
|
|
11
|
-
error: string | null;
|
|
12
|
-
}
|
|
13
|
-
interface AuthContextValue extends AuthState {
|
|
14
|
-
login: (username: string, password: string) => Promise<void>;
|
|
15
|
-
register: (username: string, email: string, password: string) => Promise<void>;
|
|
16
|
-
logout: () => Promise<void>;
|
|
17
|
-
getCurrentUser: () => Promise<any>;
|
|
18
|
-
checkUsernameAvailability: (username: string) => Promise<{
|
|
19
|
-
available: boolean;
|
|
20
|
-
message: string;
|
|
21
|
-
}>;
|
|
22
|
-
checkEmailAvailability: (email: string) => Promise<{
|
|
23
|
-
available: boolean;
|
|
24
|
-
message: string;
|
|
25
|
-
}>;
|
|
26
|
-
clearError: () => void;
|
|
27
|
-
}
|
|
28
|
-
interface AuthProviderProps {
|
|
29
|
-
children: ReactNode;
|
|
30
|
-
baseURL?: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Authentication Provider Component
|
|
34
|
-
*
|
|
35
|
-
* Wrap your app with this provider to enable zero-config authentication.
|
|
36
|
-
* All authentication state will be automatically managed.
|
|
37
|
-
*/
|
|
38
|
-
export declare function AuthProvider({ children, baseURL }: AuthProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
-
/**
|
|
40
|
-
* Authentication Hook
|
|
41
|
-
*
|
|
42
|
-
* Use this hook in any component to access authentication state and methods.
|
|
43
|
-
* No additional setup required - just wrap your app with AuthProvider.
|
|
44
|
-
*/
|
|
45
|
-
export declare function useAuth(): AuthContextValue;
|
|
46
|
-
/**
|
|
47
|
-
* Higher-Order Component for authentication
|
|
48
|
-
*
|
|
49
|
-
* Wraps a component to ensure user is authenticated before rendering.
|
|
50
|
-
* Automatically redirects to login if not authenticated.
|
|
51
|
-
*/
|
|
52
|
-
export declare function withAuth<P extends object>(Component: React.ComponentType<P>, options?: {
|
|
53
|
-
redirectTo?: () => void;
|
|
54
|
-
LoadingComponent?: React.ComponentType;
|
|
55
|
-
requireAuth?: boolean;
|
|
56
|
-
}): (props: P) => import("react/jsx-runtime").JSX.Element | null;
|
|
57
|
-
/**
|
|
58
|
-
* Hook for authenticated API calls
|
|
59
|
-
*
|
|
60
|
-
* Returns an authenticated HTTP client that automatically handles tokens.
|
|
61
|
-
*/
|
|
62
|
-
export declare function useOxyClient(): import("axios").AxiosInstance;
|
|
63
|
-
/**
|
|
64
|
-
* Hook for authentication status only (minimal re-renders)
|
|
65
|
-
*/
|
|
66
|
-
export declare function useAuthStatus(): {
|
|
67
|
-
isAuthenticated: boolean;
|
|
68
|
-
isLoading: boolean;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Hook for current user data
|
|
72
|
-
*/
|
|
73
|
-
export declare function useCurrentUser(): {
|
|
74
|
-
user: any | null;
|
|
75
|
-
isLoading: boolean;
|
|
76
|
-
refetch: () => Promise<any>;
|
|
77
|
-
};
|
|
78
|
-
export {};
|
|
79
|
-
//# sourceMappingURL=use-auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-auth.d.ts","sourceRoot":"","sources":["../../../src/core/use-auth.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA+D,SAAS,EAAE,MAAM,OAAO,CAAC;AAG/F,UAAU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OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,gBAAgB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;CAClB,IAQiC,OAAO,CAAC,oDAwBhD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,kCAG3B;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI;IAAE,eAAe,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAGhF;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI;IAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;CAAE,CAQtG"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { OxyServices } from '../core';
|
|
2
|
-
import jwt from 'jsonwebtoken';
|
|
3
|
-
|
|
4
|
-
// Mock axios
|
|
5
|
-
jest.mock('axios', () => ({
|
|
6
|
-
create: jest.fn(() => ({
|
|
7
|
-
get: jest.fn(),
|
|
8
|
-
post: jest.fn(),
|
|
9
|
-
put: jest.fn(),
|
|
10
|
-
delete: jest.fn(),
|
|
11
|
-
interceptors: {
|
|
12
|
-
request: { use: jest.fn() },
|
|
13
|
-
response: { use: jest.fn() }
|
|
14
|
-
},
|
|
15
|
-
defaults: { baseURL: 'http://localhost:3001' }
|
|
16
|
-
}))
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
describe('createAuthenticateTokenMiddleware', () => {
|
|
20
|
-
let oxyServices: OxyServices;
|
|
21
|
-
let mockReq: any;
|
|
22
|
-
let mockRes: any;
|
|
23
|
-
let mockNext: any;
|
|
24
|
-
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
oxyServices = new OxyServices({ baseURL: 'http://localhost:3001' });
|
|
27
|
-
|
|
28
|
-
mockReq = {
|
|
29
|
-
headers: {
|
|
30
|
-
authorization: 'Bearer test-token'
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
mockRes = {
|
|
35
|
-
status: jest.fn().mockReturnThis(),
|
|
36
|
-
json: jest.fn()
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
mockNext = jest.fn();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should create middleware function', () => {
|
|
43
|
-
const middleware = oxyServices.createAuthenticateTokenMiddleware();
|
|
44
|
-
expect(typeof middleware).toBe('function');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should handle missing token', async () => {
|
|
48
|
-
mockReq.headers.authorization = undefined;
|
|
49
|
-
|
|
50
|
-
const middleware = oxyServices.createAuthenticateTokenMiddleware();
|
|
51
|
-
await middleware(mockReq, mockRes, mockNext);
|
|
52
|
-
|
|
53
|
-
expect(mockRes.status).toHaveBeenCalledWith(401);
|
|
54
|
-
expect(mockRes.json).toHaveBeenCalledWith({
|
|
55
|
-
message: 'Access token required',
|
|
56
|
-
code: 'MISSING_TOKEN'
|
|
57
|
-
});
|
|
58
|
-
expect(mockNext).not.toHaveBeenCalled();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should handle invalid authorization header format', async () => {
|
|
62
|
-
mockReq.headers.authorization = 'InvalidFormat test-token';
|
|
63
|
-
|
|
64
|
-
const middleware = oxyServices.createAuthenticateTokenMiddleware();
|
|
65
|
-
await middleware(mockReq, mockRes, mockNext);
|
|
66
|
-
|
|
67
|
-
expect(mockRes.status).toHaveBeenCalledWith(401);
|
|
68
|
-
expect(mockRes.json).toHaveBeenCalledWith({
|
|
69
|
-
message: 'Access token required',
|
|
70
|
-
code: 'MISSING_TOKEN'
|
|
71
|
-
});
|
|
72
|
-
expect(mockNext).not.toHaveBeenCalled();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should call custom error handler when provided', async () => {
|
|
76
|
-
mockReq.headers.authorization = undefined;
|
|
77
|
-
const customErrorHandler = jest.fn();
|
|
78
|
-
|
|
79
|
-
const middleware = oxyServices.createAuthenticateTokenMiddleware({
|
|
80
|
-
onError: customErrorHandler
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
await middleware(mockReq, mockRes, mockNext);
|
|
84
|
-
|
|
85
|
-
expect(customErrorHandler).toHaveBeenCalledWith({
|
|
86
|
-
message: 'Access token required',
|
|
87
|
-
code: 'MISSING_TOKEN',
|
|
88
|
-
status: 401
|
|
89
|
-
});
|
|
90
|
-
expect(mockNext).not.toHaveBeenCalled();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should set loadFullUser to true by default', () => {
|
|
94
|
-
const middleware = oxyServices.createAuthenticateTokenMiddleware();
|
|
95
|
-
// This is an internal implementation detail, but we can verify the function exists
|
|
96
|
-
expect(typeof middleware).toBe('function');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should accept loadFullUser option', () => {
|
|
100
|
-
const middleware = oxyServices.createAuthenticateTokenMiddleware({
|
|
101
|
-
loadFullUser: false
|
|
102
|
-
});
|
|
103
|
-
expect(typeof middleware).toBe('function');
|
|
104
|
-
});
|
|
105
|
-
});
|