@oxyhq/services 5.25.0 → 5.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -8
- package/lib/commonjs/core/AuthManager.js +405 -0
- package/lib/commonjs/core/AuthManager.js.map +1 -0
- package/lib/commonjs/core/HttpService.js +39 -1
- package/lib/commonjs/core/HttpService.js.map +1 -1
- package/lib/commonjs/core/index.js +16 -0
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.fedcm.js +38 -44
- package/lib/commonjs/core/mixins/OxyServices.fedcm.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.popup.js +9 -7
- package/lib/commonjs/core/mixins/OxyServices.popup.js.map +1 -1
- package/lib/commonjs/index.js +321 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/shared/index.js +227 -0
- package/lib/commonjs/shared/index.js.map +1 -0
- package/lib/commonjs/shared/utils/colorUtils.js +161 -0
- package/lib/commonjs/shared/utils/colorUtils.js.map +1 -0
- package/lib/commonjs/shared/utils/debugUtils.js +84 -0
- package/lib/commonjs/shared/utils/debugUtils.js.map +1 -0
- package/lib/commonjs/shared/utils/errorUtils.js +190 -0
- package/lib/commonjs/shared/utils/errorUtils.js.map +1 -0
- package/lib/commonjs/shared/utils/index.js +196 -0
- package/lib/commonjs/shared/utils/index.js.map +1 -0
- package/lib/commonjs/shared/utils/networkUtils.js +213 -0
- package/lib/commonjs/shared/utils/networkUtils.js.map +1 -0
- package/lib/commonjs/shared/utils/themeUtils.js +118 -0
- package/lib/commonjs/shared/utils/themeUtils.js.map +1 -0
- package/lib/commonjs/ui/components/BottomSheetRouter.js +1 -1
- package/lib/commonjs/ui/components/FontLoader.js +1 -1
- package/lib/commonjs/ui/components/FontLoader.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedItem.js +1 -1
- package/lib/commonjs/ui/components/Header.js +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +9 -1
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/OxySignInButton.js +19 -20
- package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
- package/lib/commonjs/ui/components/ProfileCard.js +1 -1
- package/lib/commonjs/ui/components/ProfileCard.js.map +1 -1
- package/lib/commonjs/ui/components/QuickActions.js +1 -1
- package/lib/commonjs/ui/components/QuickActions.js.map +1 -1
- package/lib/commonjs/ui/components/Section.js +1 -1
- package/lib/commonjs/ui/components/SectionTitle.js +1 -1
- package/lib/commonjs/ui/components/SignInModal.js +546 -0
- package/lib/commonjs/ui/components/SignInModal.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +2 -1
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/{use-color-scheme.js → useColorScheme.js} +1 -1
- package/lib/commonjs/ui/hooks/useColorScheme.js.map +1 -0
- package/lib/commonjs/ui/hooks/useSessionSocket.js +6 -12
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/commonjs/ui/hooks/useThemeColors.js +1 -1
- package/lib/commonjs/ui/hooks/useThemeStyles.js +1 -1
- package/lib/commonjs/ui/navigation/bottomSheetManager.js +5 -2
- package/lib/commonjs/ui/navigation/bottomSheetManager.js.map +1 -1
- package/lib/commonjs/ui/navigation/routes.js +7 -8
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +7 -7
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +6 -6
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +2 -2
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +4 -4
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AppInfoScreen.js +1 -1
- package/lib/commonjs/ui/screens/EditProfileFieldScreen.js +1 -1
- package/lib/commonjs/ui/screens/FileManagementScreen.js +1 -1
- package/lib/commonjs/ui/screens/FollowersListScreen.js +18 -0
- package/lib/commonjs/ui/screens/FollowersListScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/FollowingListScreen.js +18 -0
- package/lib/commonjs/ui/screens/FollowingListScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/HelpSupportScreen.js +1 -1
- package/lib/commonjs/ui/screens/HelpSupportScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/HistoryViewScreen.js +1 -1
- package/lib/commonjs/ui/screens/LanguageSelectorScreen.js +1 -1
- package/lib/commonjs/ui/screens/LearnMoreUsernamesScreen.js +229 -0
- package/lib/commonjs/ui/screens/LearnMoreUsernamesScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/LegalDocumentsScreen.js +1 -1
- package/lib/commonjs/ui/screens/LegalDocumentsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js +9 -21
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SavesCollectionsScreen.js +1 -1
- package/lib/commonjs/ui/screens/UserListScreen.js +411 -0
- package/lib/commonjs/ui/screens/UserListScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaFAQScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +1 -1
- package/lib/commonjs/ui/stores/authStore.js +4 -6
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/utils/colorUtils.js +43 -46
- package/lib/commonjs/ui/utils/colorUtils.js.map +1 -1
- package/lib/commonjs/ui/utils/themeUtils.js +29 -39
- package/lib/commonjs/ui/utils/themeUtils.js.map +1 -1
- package/lib/commonjs/ui/utils/{user-utils.js → userUtils.js} +1 -1
- package/lib/commonjs/ui/utils/userUtils.js.map +1 -0
- package/lib/commonjs/utils/errorUtils.js +0 -13
- package/lib/commonjs/utils/errorUtils.js.map +1 -1
- package/lib/commonjs/utils/hookUtils.js +8 -8
- package/lib/commonjs/utils/hookUtils.js.map +1 -1
- package/lib/commonjs/web/WebOxyContext.js +273 -41
- package/lib/commonjs/web/WebOxyContext.js.map +1 -1
- package/lib/commonjs/web/index.js +177 -4
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web.js +12 -12
- package/lib/commonjs/web.js.map +1 -1
- package/lib/module/core/AuthManager.js +399 -0
- package/lib/module/core/AuthManager.js.map +1 -0
- package/lib/module/core/HttpService.js +39 -1
- package/lib/module/core/HttpService.js.map +1 -1
- package/lib/module/core/index.js +2 -0
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.fedcm.js +38 -44
- package/lib/module/core/mixins/OxyServices.fedcm.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.popup.js +9 -7
- package/lib/module/core/mixins/OxyServices.popup.js.map +1 -1
- package/lib/module/index.js +27 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/shared/index.js +37 -0
- package/lib/module/shared/index.js.map +1 -0
- package/lib/module/shared/utils/colorUtils.js +150 -0
- package/lib/module/shared/utils/colorUtils.js.map +1 -0
- package/lib/module/shared/utils/debugUtils.js +75 -0
- package/lib/module/shared/utils/debugUtils.js.map +1 -0
- package/lib/module/shared/utils/errorUtils.js +176 -0
- package/lib/module/shared/utils/errorUtils.js.map +1 -0
- package/lib/module/shared/utils/index.js +21 -0
- package/lib/module/shared/utils/index.js.map +1 -0
- package/lib/module/shared/utils/networkUtils.js +202 -0
- package/lib/module/shared/utils/networkUtils.js.map +1 -0
- package/lib/module/shared/utils/themeUtils.js +109 -0
- package/lib/module/shared/utils/themeUtils.js.map +1 -0
- package/lib/module/ui/components/BottomSheetRouter.js +1 -1
- package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/module/ui/components/FontLoader.js +1 -1
- package/lib/module/ui/components/FontLoader.js.map +1 -1
- package/lib/module/ui/components/GroupedItem.js +1 -1
- package/lib/module/ui/components/GroupedItem.js.map +1 -1
- package/lib/module/ui/components/Header.js +1 -1
- package/lib/module/ui/components/Header.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +9 -1
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/OxySignInButton.js +20 -21
- package/lib/module/ui/components/OxySignInButton.js.map +1 -1
- package/lib/module/ui/components/ProfileCard.js +1 -1
- package/lib/module/ui/components/ProfileCard.js.map +1 -1
- package/lib/module/ui/components/QuickActions.js +1 -1
- package/lib/module/ui/components/QuickActions.js.map +1 -1
- package/lib/module/ui/components/Section.js +1 -1
- package/lib/module/ui/components/Section.js.map +1 -1
- package/lib/module/ui/components/SectionTitle.js +1 -1
- package/lib/module/ui/components/SectionTitle.js.map +1 -1
- package/lib/module/ui/components/SignInModal.js +536 -0
- package/lib/module/ui/components/SignInModal.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +1 -1
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/{use-color-scheme.js → useColorScheme.js} +1 -1
- package/lib/module/ui/hooks/useColorScheme.js.map +1 -0
- package/lib/module/ui/hooks/useSessionSocket.js +6 -12
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/module/ui/hooks/useThemeColors.js +1 -1
- package/lib/module/ui/hooks/useThemeColors.js.map +1 -1
- package/lib/module/ui/hooks/useThemeStyles.js +1 -1
- package/lib/module/ui/hooks/useThemeStyles.js.map +1 -1
- package/lib/module/ui/navigation/bottomSheetManager.js +5 -2
- package/lib/module/ui/navigation/bottomSheetManager.js.map +1 -1
- package/lib/module/ui/navigation/routes.js +7 -8
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +7 -7
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +6 -6
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +2 -2
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +4 -4
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/module/ui/screens/EditProfileFieldScreen.js +1 -1
- package/lib/module/ui/screens/EditProfileFieldScreen.js.map +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/FollowersListScreen.js +13 -0
- package/lib/module/ui/screens/FollowersListScreen.js.map +1 -0
- package/lib/module/ui/screens/FollowingListScreen.js +13 -0
- package/lib/module/ui/screens/FollowingListScreen.js.map +1 -0
- package/lib/module/ui/screens/HelpSupportScreen.js +1 -1
- package/lib/module/ui/screens/HelpSupportScreen.js.map +1 -1
- package/lib/module/ui/screens/HistoryViewScreen.js +1 -1
- package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -1
- package/lib/module/ui/screens/LanguageSelectorScreen.js +1 -1
- package/lib/module/ui/screens/LanguageSelectorScreen.js.map +1 -1
- package/lib/module/ui/screens/LearnMoreUsernamesScreen.js +224 -0
- package/lib/module/ui/screens/LearnMoreUsernamesScreen.js.map +1 -0
- package/lib/module/ui/screens/LegalDocumentsScreen.js +1 -1
- package/lib/module/ui/screens/LegalDocumentsScreen.js.map +1 -1
- package/lib/module/ui/screens/OxyAuthScreen.js +9 -21
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js +1 -1
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +1 -1
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/SavesCollectionsScreen.js +1 -1
- package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -1
- package/lib/module/ui/screens/UserListScreen.js +405 -0
- package/lib/module/ui/screens/UserListScreen.js.map +1 -0
- package/lib/module/ui/screens/karma/KarmaAboutScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaFAQScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaFAQScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +4 -6
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/utils/colorUtils.js +7 -40
- package/lib/module/ui/utils/colorUtils.js.map +1 -1
- package/lib/module/ui/utils/themeUtils.js +7 -35
- package/lib/module/ui/utils/themeUtils.js.map +1 -1
- package/lib/module/ui/utils/{user-utils.js → userUtils.js} +1 -1
- package/lib/module/ui/utils/userUtils.js.map +1 -0
- package/lib/module/utils/errorUtils.js +0 -7
- package/lib/module/utils/errorUtils.js.map +1 -1
- package/lib/module/utils/hookUtils.js +8 -8
- package/lib/module/utils/hookUtils.js.map +1 -1
- package/lib/module/web/WebOxyContext.js +272 -41
- package/lib/module/web/WebOxyContext.js.map +1 -1
- package/lib/module/web/index.js +26 -5
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web.js +2 -1
- package/lib/module/web.js.map +1 -1
- package/lib/typescript/commonjs/core/AuthManager.d.ts +144 -0
- package/lib/typescript/commonjs/core/AuthManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/HttpService.d.ts.map +1 -1
- package/lib/typescript/commonjs/core/index.d.ts +2 -0
- package/lib/typescript/commonjs/core/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/core/mixins/OxyServices.fedcm.d.ts.map +1 -1
- package/lib/typescript/commonjs/core/mixins/OxyServices.popup.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +16 -2
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/models/session.d.ts +4 -0
- package/lib/typescript/commonjs/models/session.d.ts.map +1 -1
- package/lib/typescript/commonjs/shared/index.d.ts +29 -0
- package/lib/typescript/commonjs/shared/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/shared/utils/colorUtils.d.ts +105 -0
- package/lib/typescript/commonjs/shared/utils/colorUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/shared/utils/debugUtils.d.ts +49 -0
- package/lib/typescript/commonjs/shared/utils/debugUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/shared/utils/errorUtils.d.ts +98 -0
- package/lib/typescript/commonjs/shared/utils/errorUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/shared/utils/index.d.ts +14 -0
- package/lib/typescript/commonjs/shared/utils/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/shared/utils/networkUtils.d.ts +140 -0
- package/lib/typescript/commonjs/shared/utils/networkUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/shared/utils/themeUtils.d.ts +91 -0
- package/lib/typescript/commonjs/shared/utils/themeUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/FontLoader.d.ts +1 -1
- package/lib/typescript/commonjs/ui/components/FontLoader.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxySignInButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/SignInModal.d.ts +18 -0
- package/lib/typescript/commonjs/ui/components/SignInModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +1 -2
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/{use-color-scheme.d.ts → useColorScheme.d.ts} +1 -1
- package/lib/typescript/commonjs/ui/hooks/useColorScheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts +2 -0
- package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/routes.d.ts +1 -1
- package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/FollowersListScreen.d.ts +9 -0
- package/lib/typescript/commonjs/ui/screens/FollowersListScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/FollowingListScreen.d.ts +9 -0
- package/lib/typescript/commonjs/ui/screens/FollowingListScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/LearnMoreUsernamesScreen.d.ts +5 -0
- package/lib/typescript/commonjs/ui/screens/LearnMoreUsernamesScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/OxyAuthScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/UserListScreen.d.ts +11 -0
- package/lib/typescript/commonjs/ui/screens/UserListScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/colorUtils.d.ts +7 -11
- package/lib/typescript/commonjs/ui/utils/colorUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/themeUtils.d.ts +6 -19
- package/lib/typescript/commonjs/ui/utils/themeUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/{user-utils.d.ts → userUtils.d.ts} +1 -1
- package/lib/typescript/commonjs/ui/utils/userUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/errorUtils.d.ts +0 -6
- package/lib/typescript/commonjs/utils/errorUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/web/WebOxyContext.d.ts +117 -9
- package/lib/typescript/commonjs/web/WebOxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/web/index.d.ts +19 -8
- package/lib/typescript/commonjs/web/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/web.d.ts +2 -1
- package/lib/typescript/commonjs/web.d.ts.map +1 -1
- package/lib/typescript/module/core/AuthManager.d.ts +144 -0
- package/lib/typescript/module/core/AuthManager.d.ts.map +1 -0
- package/lib/typescript/module/core/HttpService.d.ts.map +1 -1
- package/lib/typescript/module/core/index.d.ts +2 -0
- package/lib/typescript/module/core/index.d.ts.map +1 -1
- package/lib/typescript/module/core/mixins/OxyServices.fedcm.d.ts.map +1 -1
- package/lib/typescript/module/core/mixins/OxyServices.popup.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +16 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/models/session.d.ts +4 -0
- package/lib/typescript/module/models/session.d.ts.map +1 -1
- package/lib/typescript/module/shared/index.d.ts +29 -0
- package/lib/typescript/module/shared/index.d.ts.map +1 -0
- package/lib/typescript/module/shared/utils/colorUtils.d.ts +105 -0
- package/lib/typescript/module/shared/utils/colorUtils.d.ts.map +1 -0
- package/lib/typescript/module/shared/utils/debugUtils.d.ts +49 -0
- package/lib/typescript/module/shared/utils/debugUtils.d.ts.map +1 -0
- package/lib/typescript/module/shared/utils/errorUtils.d.ts +98 -0
- package/lib/typescript/module/shared/utils/errorUtils.d.ts.map +1 -0
- package/lib/typescript/module/shared/utils/index.d.ts +14 -0
- package/lib/typescript/module/shared/utils/index.d.ts.map +1 -0
- package/lib/typescript/module/shared/utils/networkUtils.d.ts +140 -0
- package/lib/typescript/module/shared/utils/networkUtils.d.ts.map +1 -0
- package/lib/typescript/module/shared/utils/themeUtils.d.ts +91 -0
- package/lib/typescript/module/shared/utils/themeUtils.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/FontLoader.d.ts +1 -1
- package/lib/typescript/module/ui/components/FontLoader.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxySignInButton.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/SignInModal.d.ts +18 -0
- package/lib/typescript/module/ui/components/SignInModal.d.ts.map +1 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts +1 -2
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/{use-color-scheme.d.ts → useColorScheme.d.ts} +1 -1
- package/lib/typescript/module/ui/hooks/useColorScheme.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts +2 -0
- package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/routes.d.ts +1 -1
- package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/FollowersListScreen.d.ts +9 -0
- package/lib/typescript/module/ui/screens/FollowersListScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/FollowingListScreen.d.ts +9 -0
- package/lib/typescript/module/ui/screens/FollowingListScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/LearnMoreUsernamesScreen.d.ts +5 -0
- package/lib/typescript/module/ui/screens/LearnMoreUsernamesScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/UserListScreen.d.ts +11 -0
- package/lib/typescript/module/ui/screens/UserListScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/colorUtils.d.ts +7 -11
- package/lib/typescript/module/ui/utils/colorUtils.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/themeUtils.d.ts +6 -19
- package/lib/typescript/module/ui/utils/themeUtils.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/{user-utils.d.ts → userUtils.d.ts} +1 -1
- package/lib/typescript/module/ui/utils/userUtils.d.ts.map +1 -0
- package/lib/typescript/module/utils/errorUtils.d.ts +0 -6
- package/lib/typescript/module/utils/errorUtils.d.ts.map +1 -1
- package/lib/typescript/module/web/WebOxyContext.d.ts +117 -9
- package/lib/typescript/module/web/WebOxyContext.d.ts.map +1 -1
- package/lib/typescript/module/web/index.d.ts +19 -8
- package/lib/typescript/module/web/index.d.ts.map +1 -1
- package/lib/typescript/module/web.d.ts +2 -1
- package/lib/typescript/module/web.d.ts.map +1 -1
- package/package.json +8 -2
- package/src/core/AuthManager.ts +436 -0
- package/src/core/HttpService.ts +43 -1
- package/src/core/index.ts +4 -0
- package/src/core/mixins/OxyServices.fedcm.ts +37 -42
- package/src/core/mixins/OxyServices.popup.ts +10 -7
- package/src/index.ts +76 -11
- package/src/models/session.ts +4 -0
- package/src/shared/index.ts +82 -0
- package/src/shared/utils/colorUtils.ts +155 -0
- package/src/shared/utils/debugUtils.ts +73 -0
- package/src/shared/utils/errorUtils.ts +181 -0
- package/src/shared/utils/index.ts +59 -0
- package/src/shared/utils/networkUtils.ts +248 -0
- package/src/shared/utils/themeUtils.ts +115 -0
- package/src/ui/components/BottomSheetRouter.tsx +1 -1
- package/src/ui/components/FontLoader.tsx +1 -2
- package/src/ui/components/GroupedItem.tsx +1 -1
- package/src/ui/components/Header.tsx +1 -1
- package/src/ui/components/OxyProvider.tsx +10 -0
- package/src/ui/components/OxySignInButton.tsx +20 -22
- package/src/ui/components/ProfileCard.tsx +1 -1
- package/src/ui/components/QuickActions.tsx +1 -1
- package/src/ui/components/Section.tsx +1 -1
- package/src/ui/components/SectionTitle.tsx +1 -1
- package/src/ui/components/SignInModal.tsx +534 -0
- package/src/ui/context/OxyContext.tsx +1 -2
- package/src/ui/hooks/queries/queryKeys.ts +2 -2
- package/src/ui/hooks/useSessionSocket.ts +12 -17
- package/src/ui/hooks/useThemeColors.ts +1 -1
- package/src/ui/hooks/useThemeStyles.ts +1 -1
- package/src/ui/navigation/bottomSheetManager.ts +5 -1
- package/src/ui/navigation/routes.ts +8 -9
- package/src/ui/screens/AccountCenterScreen.tsx +7 -7
- package/src/ui/screens/AccountOverviewScreen.tsx +6 -6
- package/src/ui/screens/AccountSettingsScreen.tsx +2 -2
- package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
- package/src/ui/screens/AppInfoScreen.tsx +1 -1
- package/src/ui/screens/EditProfileFieldScreen.tsx +1 -1
- package/src/ui/screens/FileManagementScreen.tsx +1 -1
- package/src/ui/screens/FollowersListScreen.tsx +14 -0
- package/src/ui/screens/FollowingListScreen.tsx +14 -0
- package/src/ui/screens/HelpSupportScreen.tsx +1 -1
- package/src/ui/screens/HistoryViewScreen.tsx +1 -1
- package/src/ui/screens/LanguageSelectorScreen.tsx +1 -1
- package/src/ui/screens/LearnMoreUsernamesScreen.tsx +231 -0
- package/src/ui/screens/LegalDocumentsScreen.tsx +1 -1
- package/src/ui/screens/OxyAuthScreen.tsx +10 -21
- package/src/ui/screens/PremiumSubscriptionScreen.tsx +1 -1
- package/src/ui/screens/ProfileScreen.tsx +1 -1
- package/src/ui/screens/SavesCollectionsScreen.tsx +1 -1
- package/src/ui/screens/UserListScreen.tsx +416 -0
- package/src/ui/screens/karma/KarmaAboutScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaCenterScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaFAQScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaRewardsScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaRulesScreen.tsx +1 -1
- package/src/ui/stores/authStore.ts +5 -6
- package/src/ui/utils/colorUtils.ts +15 -43
- package/src/ui/utils/themeUtils.ts +14 -39
- package/src/utils/errorUtils.ts +1 -6
- package/src/utils/hookUtils.ts +8 -8
- package/src/web/WebOxyContext.tsx +331 -41
- package/src/web/index.ts +76 -6
- package/src/web.ts +1 -1
- package/lib/commonjs/ui/hooks/use-color-scheme.js.map +0 -1
- package/lib/commonjs/ui/utils/user-utils.js.map +0 -1
- package/lib/module/ui/hooks/use-color-scheme.js.map +0 -1
- package/lib/module/ui/utils/user-utils.js.map +0 -1
- package/lib/typescript/commonjs/ui/hooks/use-color-scheme.d.ts.map +0 -1
- package/lib/typescript/commonjs/ui/utils/user-utils.d.ts.map +0 -1
- package/lib/typescript/module/ui/hooks/use-color-scheme.d.ts.map +0 -1
- package/lib/typescript/module/ui/utils/user-utils.d.ts.map +0 -1
- /package/src/ui/hooks/{use-color-scheme.ts → useColorScheme.ts} +0 -0
- /package/src/ui/utils/{user-utils.ts → userUtils.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ A comprehensive TypeScript client library for the Oxy API providing authenticati
|
|
|
23
23
|
## ✨ Features
|
|
24
24
|
|
|
25
25
|
- 🔐 **Zero-Config Authentication**: Automatic token management and refresh
|
|
26
|
-
- 🌐 **Cross-Domain SSO**: Sign in once, authenticated everywhere (FedCM
|
|
26
|
+
- 🌐 **Cross-Domain SSO**: Sign in once, authenticated everywhere (FedCM, popup, redirect)
|
|
27
27
|
- 📱 **Universal Provider**: Single `OxyProvider` works on iOS, Android, and Web
|
|
28
28
|
- 🎨 **UI Components**: Pre-built components for auth, profiles, and more
|
|
29
29
|
- ✍️ **Inter Font Included**: Default Oxy ecosystem font with automatic loading
|
|
@@ -33,6 +33,20 @@ A comprehensive TypeScript client library for the Oxy API providing authenticati
|
|
|
33
33
|
- 🚀 **Performance Optimized**: Automatic caching with TanStack Query
|
|
34
34
|
- 🛡️ **Production Ready**: Error handling, retry logic, and security best practices
|
|
35
35
|
|
|
36
|
+
## 🏗️ Architecture
|
|
37
|
+
|
|
38
|
+
OxyServices uses a modular architecture with multiple entry points for different use cases:
|
|
39
|
+
|
|
40
|
+
| Entry Point | Use Case | Dependencies |
|
|
41
|
+
|------------|----------|--------------|
|
|
42
|
+
| `@oxyhq/services` | Expo apps (native + web) | Full (RN, Expo) |
|
|
43
|
+
| `@oxyhq/services/web` | Pure React apps (Vite, Next.js) | React only |
|
|
44
|
+
| `@oxyhq/services/core` | Node.js / Backend | None |
|
|
45
|
+
| `@oxyhq/services/shared` | Utilities anywhere | None |
|
|
46
|
+
| `@oxyhq/services/crypto` | Identity management | Node crypto |
|
|
47
|
+
|
|
48
|
+
📖 **[Complete Architecture Guide](./docs/ARCHITECTURE.md)**
|
|
49
|
+
|
|
36
50
|
## 📦 Installation
|
|
37
51
|
|
|
38
52
|
```bash
|
|
@@ -111,6 +125,25 @@ function App() {
|
|
|
111
125
|
</WebOxyProvider>
|
|
112
126
|
);
|
|
113
127
|
}
|
|
128
|
+
|
|
129
|
+
function LoginButton() {
|
|
130
|
+
const { signIn, signOut, user, isAuthenticated, isFedCMSupported } = useAuth();
|
|
131
|
+
|
|
132
|
+
if (isAuthenticated) {
|
|
133
|
+
return (
|
|
134
|
+
<div>
|
|
135
|
+
<p>Welcome, {user?.username}!</p>
|
|
136
|
+
<button onClick={signOut}>Sign Out</button>
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<button onClick={signIn}>
|
|
143
|
+
{isFedCMSupported() ? 'Sign in with Oxy' : 'Sign in'}
|
|
144
|
+
</button>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
114
147
|
```
|
|
115
148
|
|
|
116
149
|
⚠️ **Important:** If you're using Expo, always use `OxyProvider` instead - it already handles web in addition to native platforms. Never use `WebOxyProvider` in Expo apps.
|
|
@@ -127,10 +160,28 @@ import { WebOxyProvider, useAuth, OxyServices } from '@oxyhq/services/web';
|
|
|
127
160
|
import { WebOxyProvider } from '@oxyhq/services';
|
|
128
161
|
```
|
|
129
162
|
|
|
163
|
+
**Authentication Methods Available:**
|
|
164
|
+
- **FedCM** (Browser-native, Google-style) - Best UX, no popups
|
|
165
|
+
- **Popup** - OAuth2-style popup window
|
|
166
|
+
- **Redirect** - Full page redirect (fallback)
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
const { signIn, signInWithFedCM, signInWithPopup, signInWithRedirect, isFedCMSupported } = useAuth();
|
|
170
|
+
|
|
171
|
+
// Auto-select best method (FedCM → Popup → Redirect)
|
|
172
|
+
await signIn();
|
|
173
|
+
|
|
174
|
+
// Or use specific method
|
|
175
|
+
await signInWithFedCM();
|
|
176
|
+
await signInWithPopup();
|
|
177
|
+
signInWithRedirect();
|
|
178
|
+
```
|
|
179
|
+
|
|
130
180
|
**Benefits:**
|
|
131
181
|
- Smaller bundle size (no React Native dependencies)
|
|
132
182
|
- No need for react-native-web or complex build configuration
|
|
133
183
|
- Faster builds and smaller production bundles
|
|
184
|
+
- Full FedCM support for modern browsers
|
|
134
185
|
- All web-compatible features included (auth, hooks, stores, etc.)
|
|
135
186
|
|
|
136
187
|
**Note:** If you must use the main entry point (`@oxyhq/services`), you'll need to configure your bundler with react-native-web aliases. See the [Web Bundler Configuration](#web-bundler-configuration) section below.
|
|
@@ -177,16 +228,18 @@ app.listen(3000);
|
|
|
177
228
|
|
|
178
229
|
**Inter is the default font for all Oxy ecosystem apps.** This package includes the Inter font family and provides automatic font loading for both web and native platforms.
|
|
179
230
|
|
|
180
|
-
###
|
|
231
|
+
### Automatic Loading
|
|
232
|
+
|
|
233
|
+
**If you're using `OxyProvider`, fonts are loaded automatically.** No additional setup needed:
|
|
181
234
|
|
|
182
235
|
```typescript
|
|
183
|
-
import {
|
|
236
|
+
import { OxyProvider } from '@oxyhq/services';
|
|
184
237
|
|
|
185
238
|
function App() {
|
|
186
239
|
return (
|
|
187
|
-
<
|
|
240
|
+
<OxyProvider baseURL="https://api.oxy.so">
|
|
188
241
|
<YourAppContent />
|
|
189
|
-
</
|
|
242
|
+
</OxyProvider>
|
|
190
243
|
);
|
|
191
244
|
}
|
|
192
245
|
```
|
|
@@ -210,8 +263,7 @@ const styles = StyleSheet.create({
|
|
|
210
263
|
|
|
211
264
|
### Available Exports
|
|
212
265
|
|
|
213
|
-
- **`
|
|
214
|
-
- **`setupFonts()`** - Function to manually load fonts
|
|
266
|
+
- **`setupFonts()`** - Function to manually load fonts (called automatically by OxyProvider)
|
|
215
267
|
- **`fontFamilies`** - Object with all Inter weight variants (inter, interLight, interMedium, interSemiBold, interBold, interExtraBold, interBlack)
|
|
216
268
|
- **`fontStyles`** - Pre-defined text styles (titleLarge, titleMedium, titleSmall, buttonText)
|
|
217
269
|
|
|
@@ -729,7 +781,7 @@ function AuthModal({ visible, onRequestClose }: { visible: boolean; onRequestClo
|
|
|
729
781
|
<Modal visible onRequestClose={onRequestClose} animationType="slide">
|
|
730
782
|
<OxyRouter
|
|
731
783
|
oxyServices={oxyServices}
|
|
732
|
-
initialScreen="
|
|
784
|
+
initialScreen="OxyAuth"
|
|
733
785
|
onClose={onRequestClose}
|
|
734
786
|
onAuthenticated={onRequestClose}
|
|
735
787
|
theme="light"
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AuthManager = void 0;
|
|
7
|
+
exports.createAuthManager = createAuthManager;
|
|
8
|
+
/**
|
|
9
|
+
* AuthManager - Centralized Authentication Manager
|
|
10
|
+
*
|
|
11
|
+
* Provides a unified authentication interface for all platforms.
|
|
12
|
+
* Handles token storage, session management, and auth state changes.
|
|
13
|
+
*
|
|
14
|
+
* @module core/AuthManager
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* OxyServices with optional FedCM methods (provided by FedCM mixin).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Storage adapter interface for platform-agnostic storage.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Auth state change callback type.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Auth method types.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Auth manager configuration.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Storage keys used by AuthManager.
|
|
39
|
+
*/
|
|
40
|
+
const STORAGE_KEYS = {
|
|
41
|
+
ACCESS_TOKEN: 'oxy_access_token',
|
|
42
|
+
REFRESH_TOKEN: 'oxy_refresh_token',
|
|
43
|
+
SESSION: 'oxy_session',
|
|
44
|
+
USER: 'oxy_user',
|
|
45
|
+
AUTH_METHOD: 'oxy_auth_method'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Default in-memory storage for non-browser environments.
|
|
50
|
+
*/
|
|
51
|
+
class MemoryStorage {
|
|
52
|
+
store = new Map();
|
|
53
|
+
getItem(key) {
|
|
54
|
+
return this.store.get(key) ?? null;
|
|
55
|
+
}
|
|
56
|
+
setItem(key, value) {
|
|
57
|
+
this.store.set(key, value);
|
|
58
|
+
}
|
|
59
|
+
removeItem(key) {
|
|
60
|
+
this.store.delete(key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Browser localStorage adapter.
|
|
66
|
+
*/
|
|
67
|
+
class LocalStorageAdapter {
|
|
68
|
+
getItem(key) {
|
|
69
|
+
if (typeof window === 'undefined') return null;
|
|
70
|
+
try {
|
|
71
|
+
return localStorage.getItem(key);
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
setItem(key, value) {
|
|
77
|
+
if (typeof window === 'undefined') return;
|
|
78
|
+
try {
|
|
79
|
+
localStorage.setItem(key, value);
|
|
80
|
+
} catch {
|
|
81
|
+
// Storage full or blocked
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
removeItem(key) {
|
|
85
|
+
if (typeof window === 'undefined') return;
|
|
86
|
+
try {
|
|
87
|
+
localStorage.removeItem(key);
|
|
88
|
+
} catch {
|
|
89
|
+
// Ignore errors
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* AuthManager - Centralized authentication management.
|
|
96
|
+
*
|
|
97
|
+
* Provides a single point of control for:
|
|
98
|
+
* - Token storage and retrieval
|
|
99
|
+
* - Session management
|
|
100
|
+
* - Auth state change notifications
|
|
101
|
+
* - Multiple auth method support
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const authManager = new AuthManager(oxyServices);
|
|
106
|
+
*
|
|
107
|
+
* // Listen for auth changes
|
|
108
|
+
* authManager.onAuthStateChange((user) => {
|
|
109
|
+
* console.log('Auth state changed:', user);
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* // Handle successful auth
|
|
113
|
+
* await authManager.handleAuthSuccess(session);
|
|
114
|
+
*
|
|
115
|
+
* // Sign out
|
|
116
|
+
* await authManager.signOut();
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
class AuthManager {
|
|
120
|
+
listeners = new Set();
|
|
121
|
+
currentUser = null;
|
|
122
|
+
refreshTimer = null;
|
|
123
|
+
constructor(oxyServices, config = {}) {
|
|
124
|
+
this.oxyServices = oxyServices;
|
|
125
|
+
this.config = {
|
|
126
|
+
storage: config.storage ?? this.getDefaultStorage(),
|
|
127
|
+
autoRefresh: config.autoRefresh ?? true,
|
|
128
|
+
refreshBuffer: config.refreshBuffer ?? 5 * 60 * 1000 // 5 minutes
|
|
129
|
+
};
|
|
130
|
+
this.storage = this.config.storage;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get default storage based on environment.
|
|
135
|
+
*/
|
|
136
|
+
getDefaultStorage() {
|
|
137
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
138
|
+
return new LocalStorageAdapter();
|
|
139
|
+
}
|
|
140
|
+
return new MemoryStorage();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Subscribe to auth state changes.
|
|
145
|
+
*
|
|
146
|
+
* @param callback - Function called when auth state changes
|
|
147
|
+
* @returns Unsubscribe function
|
|
148
|
+
*/
|
|
149
|
+
onAuthStateChange(callback) {
|
|
150
|
+
this.listeners.add(callback);
|
|
151
|
+
// Call immediately with current state
|
|
152
|
+
callback(this.currentUser);
|
|
153
|
+
return () => {
|
|
154
|
+
this.listeners.delete(callback);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Notify all listeners of auth state change.
|
|
160
|
+
*/
|
|
161
|
+
notifyListeners() {
|
|
162
|
+
for (const listener of this.listeners) {
|
|
163
|
+
try {
|
|
164
|
+
listener(this.currentUser);
|
|
165
|
+
} catch {
|
|
166
|
+
// Ignore listener errors
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Handle successful authentication.
|
|
173
|
+
*
|
|
174
|
+
* @param session - Session response from auth
|
|
175
|
+
* @param method - Auth method used
|
|
176
|
+
*/
|
|
177
|
+
async handleAuthSuccess(session, method = 'credentials') {
|
|
178
|
+
// Store tokens
|
|
179
|
+
if (session.accessToken) {
|
|
180
|
+
await this.storage.setItem(STORAGE_KEYS.ACCESS_TOKEN, session.accessToken);
|
|
181
|
+
this.oxyServices.httpService.setTokens(session.accessToken);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Store refresh token if available
|
|
185
|
+
if (session.refreshToken) {
|
|
186
|
+
await this.storage.setItem(STORAGE_KEYS.REFRESH_TOKEN, session.refreshToken);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Store session info
|
|
190
|
+
await this.storage.setItem(STORAGE_KEYS.SESSION, JSON.stringify({
|
|
191
|
+
sessionId: session.sessionId,
|
|
192
|
+
deviceId: session.deviceId,
|
|
193
|
+
expiresAt: session.expiresAt
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
// Store user only if it has valid required fields (not an empty placeholder)
|
|
197
|
+
if (session.user && typeof session.user.id === 'string' && session.user.id.length > 0) {
|
|
198
|
+
await this.storage.setItem(STORAGE_KEYS.USER, JSON.stringify(session.user));
|
|
199
|
+
this.currentUser = session.user;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Store auth method
|
|
203
|
+
await this.storage.setItem(STORAGE_KEYS.AUTH_METHOD, method);
|
|
204
|
+
|
|
205
|
+
// Setup auto-refresh if enabled
|
|
206
|
+
if (this.config.autoRefresh && session.expiresAt) {
|
|
207
|
+
this.setupTokenRefresh(session.expiresAt);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Notify listeners
|
|
211
|
+
this.notifyListeners();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Setup automatic token refresh.
|
|
216
|
+
*/
|
|
217
|
+
setupTokenRefresh(expiresAt) {
|
|
218
|
+
if (this.refreshTimer) {
|
|
219
|
+
clearTimeout(this.refreshTimer);
|
|
220
|
+
}
|
|
221
|
+
const expiresAtMs = new Date(expiresAt).getTime();
|
|
222
|
+
const now = Date.now();
|
|
223
|
+
const refreshAt = expiresAtMs - this.config.refreshBuffer;
|
|
224
|
+
const delay = Math.max(0, refreshAt - now);
|
|
225
|
+
if (delay > 0) {
|
|
226
|
+
this.refreshTimer = setTimeout(() => {
|
|
227
|
+
this.refreshToken().catch(() => {
|
|
228
|
+
// Refresh failed, user will need to re-auth
|
|
229
|
+
});
|
|
230
|
+
}, delay);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Refresh the access token.
|
|
236
|
+
*/
|
|
237
|
+
async refreshToken() {
|
|
238
|
+
const refreshToken = await this.storage.getItem(STORAGE_KEYS.REFRESH_TOKEN);
|
|
239
|
+
if (!refreshToken) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
// Cast httpService to proper type (needed due to mixin composition)
|
|
244
|
+
const httpService = this.oxyServices.httpService;
|
|
245
|
+
const response = await httpService.request({
|
|
246
|
+
method: 'POST',
|
|
247
|
+
url: '/api/auth/refresh',
|
|
248
|
+
data: {
|
|
249
|
+
refreshToken
|
|
250
|
+
},
|
|
251
|
+
cache: false
|
|
252
|
+
});
|
|
253
|
+
await this.handleAuthSuccess(response, 'credentials');
|
|
254
|
+
return true;
|
|
255
|
+
} catch {
|
|
256
|
+
// Refresh failed, clear session and update state
|
|
257
|
+
await this.clearSession();
|
|
258
|
+
this.currentUser = null;
|
|
259
|
+
this.notifyListeners();
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Sign out and clear all auth data.
|
|
266
|
+
*/
|
|
267
|
+
async signOut() {
|
|
268
|
+
// Clear refresh timer
|
|
269
|
+
if (this.refreshTimer) {
|
|
270
|
+
clearTimeout(this.refreshTimer);
|
|
271
|
+
this.refreshTimer = null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Revoke FedCM credential if supported
|
|
275
|
+
try {
|
|
276
|
+
const services = this.oxyServices;
|
|
277
|
+
if (services.revokeFedCMCredential) {
|
|
278
|
+
await services.revokeFedCMCredential();
|
|
279
|
+
}
|
|
280
|
+
} catch {
|
|
281
|
+
// Ignore FedCM errors
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Clear HTTP client tokens
|
|
285
|
+
this.oxyServices.httpService.setTokens('');
|
|
286
|
+
|
|
287
|
+
// Clear storage
|
|
288
|
+
await this.clearSession();
|
|
289
|
+
|
|
290
|
+
// Update state and notify
|
|
291
|
+
this.currentUser = null;
|
|
292
|
+
this.notifyListeners();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Clear session data from storage.
|
|
297
|
+
*/
|
|
298
|
+
async clearSession() {
|
|
299
|
+
await this.storage.removeItem(STORAGE_KEYS.ACCESS_TOKEN);
|
|
300
|
+
await this.storage.removeItem(STORAGE_KEYS.REFRESH_TOKEN);
|
|
301
|
+
await this.storage.removeItem(STORAGE_KEYS.SESSION);
|
|
302
|
+
await this.storage.removeItem(STORAGE_KEYS.USER);
|
|
303
|
+
await this.storage.removeItem(STORAGE_KEYS.AUTH_METHOD);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Get current user.
|
|
308
|
+
*/
|
|
309
|
+
getCurrentUser() {
|
|
310
|
+
return this.currentUser;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Check if user is authenticated.
|
|
315
|
+
*/
|
|
316
|
+
isAuthenticated() {
|
|
317
|
+
return this.currentUser !== null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Get stored access token.
|
|
322
|
+
*/
|
|
323
|
+
async getAccessToken() {
|
|
324
|
+
return this.storage.getItem(STORAGE_KEYS.ACCESS_TOKEN);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Get the auth method used for current session.
|
|
329
|
+
*/
|
|
330
|
+
async getAuthMethod() {
|
|
331
|
+
const method = await this.storage.getItem(STORAGE_KEYS.AUTH_METHOD);
|
|
332
|
+
return method;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Initialize auth state from storage.
|
|
337
|
+
*
|
|
338
|
+
* Call this on app startup to restore previous session.
|
|
339
|
+
*/
|
|
340
|
+
async initialize() {
|
|
341
|
+
try {
|
|
342
|
+
// Try to restore user from storage
|
|
343
|
+
const userJson = await this.storage.getItem(STORAGE_KEYS.USER);
|
|
344
|
+
if (userJson) {
|
|
345
|
+
this.currentUser = JSON.parse(userJson);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Restore token to HTTP client
|
|
349
|
+
const token = await this.storage.getItem(STORAGE_KEYS.ACCESS_TOKEN);
|
|
350
|
+
if (token) {
|
|
351
|
+
this.oxyServices.httpService.setTokens(token);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Check session expiry
|
|
355
|
+
const sessionJson = await this.storage.getItem(STORAGE_KEYS.SESSION);
|
|
356
|
+
if (sessionJson) {
|
|
357
|
+
const session = JSON.parse(sessionJson);
|
|
358
|
+
if (session.expiresAt) {
|
|
359
|
+
const expiresAt = new Date(session.expiresAt).getTime();
|
|
360
|
+
if (expiresAt <= Date.now()) {
|
|
361
|
+
// Session expired, try refresh
|
|
362
|
+
const refreshed = await this.refreshToken();
|
|
363
|
+
if (!refreshed) {
|
|
364
|
+
await this.clearSession();
|
|
365
|
+
this.currentUser = null;
|
|
366
|
+
}
|
|
367
|
+
} else if (this.config.autoRefresh) {
|
|
368
|
+
// Setup refresh timer
|
|
369
|
+
this.setupTokenRefresh(session.expiresAt);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return this.currentUser;
|
|
374
|
+
} catch {
|
|
375
|
+
// Failed to restore, start fresh
|
|
376
|
+
await this.clearSession();
|
|
377
|
+
this.currentUser = null;
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Destroy the auth manager and clean up resources.
|
|
384
|
+
*/
|
|
385
|
+
destroy() {
|
|
386
|
+
if (this.refreshTimer) {
|
|
387
|
+
clearTimeout(this.refreshTimer);
|
|
388
|
+
this.refreshTimer = null;
|
|
389
|
+
}
|
|
390
|
+
this.listeners.clear();
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Create an AuthManager instance.
|
|
396
|
+
*
|
|
397
|
+
* @param oxyServices - OxyServices instance
|
|
398
|
+
* @param config - Optional configuration
|
|
399
|
+
* @returns AuthManager instance
|
|
400
|
+
*/
|
|
401
|
+
exports.AuthManager = AuthManager;
|
|
402
|
+
function createAuthManager(oxyServices, config) {
|
|
403
|
+
return new AuthManager(oxyServices, config);
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=AuthManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["STORAGE_KEYS","ACCESS_TOKEN","REFRESH_TOKEN","SESSION","USER","AUTH_METHOD","MemoryStorage","store","Map","getItem","key","get","setItem","value","set","removeItem","delete","LocalStorageAdapter","window","localStorage","AuthManager","listeners","Set","currentUser","refreshTimer","constructor","oxyServices","config","storage","getDefaultStorage","autoRefresh","refreshBuffer","onAuthStateChange","callback","add","notifyListeners","listener","handleAuthSuccess","session","method","accessToken","httpService","setTokens","refreshToken","JSON","stringify","sessionId","deviceId","expiresAt","user","id","length","setupTokenRefresh","clearTimeout","expiresAtMs","Date","getTime","now","refreshAt","delay","Math","max","setTimeout","catch","response","request","url","data","cache","clearSession","signOut","services","revokeFedCMCredential","getCurrentUser","isAuthenticated","getAccessToken","getAuthMethod","initialize","userJson","parse","token","sessionJson","refreshed","destroy","clear","exports","createAuthManager"],"sourceRoot":"../../../src","sources":["core/AuthManager.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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ACxBC,MAA0B,EACb;EACb,OAAO,IAAIP,WAAW,CAACM,WAAW,EAAEC,MAAM,CAAC;AAC7C","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ var _requestUtils = require("../utils/requestUtils.js");
|
|
|
9
9
|
var _asyncUtils = require("../utils/asyncUtils.js");
|
|
10
10
|
var _errorUtils = require("../utils/errorUtils.js");
|
|
11
11
|
var _jwtDecode = require("jwt-decode");
|
|
12
|
+
var _reactNative = require("react-native");
|
|
12
13
|
/**
|
|
13
14
|
* Unified HTTP Service
|
|
14
15
|
*
|
|
@@ -24,6 +25,11 @@ var _jwtDecode = require("jwt-decode");
|
|
|
24
25
|
* - Request queuing
|
|
25
26
|
*/
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Check if we're running in a native app environment (React Native, not web)
|
|
30
|
+
* This is used to determine CSRF handling mode
|
|
31
|
+
*/
|
|
32
|
+
const isNativeApp = _reactNative.Platform.OS !== 'web';
|
|
27
33
|
/**
|
|
28
34
|
* Token store for authentication (singleton)
|
|
29
35
|
*/
|
|
@@ -208,6 +214,26 @@ class HttpService {
|
|
|
208
214
|
headers['X-CSRF-Token'] = csrfToken;
|
|
209
215
|
}
|
|
210
216
|
|
|
217
|
+
// Add native app header for React Native (required for CSRF validation)
|
|
218
|
+
// Native apps can't persist cookies like browsers, so the server uses
|
|
219
|
+
// header-only CSRF validation when this header is present
|
|
220
|
+
if (isNativeApp && isStateChangingMethod) {
|
|
221
|
+
headers['X-Native-App'] = 'true';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Debug logging for CSRF issues
|
|
225
|
+
if (isStateChangingMethod && __DEV__) {
|
|
226
|
+
console.log('[HttpService] CSRF Debug:', {
|
|
227
|
+
url,
|
|
228
|
+
method,
|
|
229
|
+
isNativeApp,
|
|
230
|
+
platformOS: _reactNative.Platform.OS,
|
|
231
|
+
hasCsrfToken: !!csrfToken,
|
|
232
|
+
csrfTokenLength: csrfToken?.length,
|
|
233
|
+
hasNativeAppHeader: headers['X-Native-App'] === 'true'
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
211
237
|
// Merge custom headers if provided
|
|
212
238
|
if (config.headers) {
|
|
213
239
|
Object.entries(config.headers).forEach(([key, value]) => {
|
|
@@ -380,16 +406,23 @@ class HttpService {
|
|
|
380
406
|
// Return cached token if available
|
|
381
407
|
const cachedToken = this.tokenStore.getCsrfToken();
|
|
382
408
|
if (cachedToken) {
|
|
409
|
+
if (__DEV__) console.log('[HttpService] Using cached CSRF token');
|
|
383
410
|
return cachedToken;
|
|
384
411
|
}
|
|
385
412
|
|
|
386
413
|
// Deduplicate concurrent CSRF token fetches
|
|
387
414
|
const existingPromise = this.tokenStore.getCsrfTokenFetchPromise();
|
|
388
415
|
if (existingPromise) {
|
|
416
|
+
if (__DEV__) console.log('[HttpService] Waiting for existing CSRF fetch');
|
|
389
417
|
return existingPromise;
|
|
390
418
|
}
|
|
391
419
|
const fetchPromise = (async () => {
|
|
392
420
|
try {
|
|
421
|
+
if (__DEV__) console.log('[HttpService] Fetching CSRF token from:', `${this.baseURL}/api/csrf-token`);
|
|
422
|
+
|
|
423
|
+
// Use AbortController for timeout (more compatible than AbortSignal.timeout)
|
|
424
|
+
const controller = new AbortController();
|
|
425
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
393
426
|
const response = await fetch(`${this.baseURL}/api/csrf-token`, {
|
|
394
427
|
method: 'GET',
|
|
395
428
|
headers: {
|
|
@@ -397,10 +430,13 @@ class HttpService {
|
|
|
397
430
|
},
|
|
398
431
|
credentials: 'include',
|
|
399
432
|
// Required to receive and send cookies
|
|
400
|
-
signal:
|
|
433
|
+
signal: controller.signal
|
|
401
434
|
});
|
|
435
|
+
clearTimeout(timeoutId);
|
|
436
|
+
if (__DEV__) console.log('[HttpService] CSRF fetch response:', response.status, response.ok);
|
|
402
437
|
if (response.ok) {
|
|
403
438
|
const data = await response.json();
|
|
439
|
+
if (__DEV__) console.log('[HttpService] CSRF response data:', data);
|
|
404
440
|
const token = data.csrfToken || null;
|
|
405
441
|
this.tokenStore.setCsrfToken(token);
|
|
406
442
|
this.logger.debug('CSRF token fetched');
|
|
@@ -414,9 +450,11 @@ class HttpService {
|
|
|
414
450
|
this.logger.debug('CSRF token from header');
|
|
415
451
|
return headerToken;
|
|
416
452
|
}
|
|
453
|
+
if (__DEV__) console.log('[HttpService] CSRF fetch failed with status:', response.status);
|
|
417
454
|
this.logger.warn('Failed to fetch CSRF token:', response.status);
|
|
418
455
|
return null;
|
|
419
456
|
} catch (error) {
|
|
457
|
+
if (__DEV__) console.log('[HttpService] CSRF fetch error:', error);
|
|
420
458
|
this.logger.warn('CSRF token fetch error:', error);
|
|
421
459
|
return null;
|
|
422
460
|
} finally {
|