@oxyhq/services 5.26.4 → 5.27.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/dist/web/oxy-services.esm.js +2 -0
- package/dist/web/oxy-services.esm.js.map +1 -0
- package/dist/web/types/assets/icons/OxyServices.d.ts +28 -0
- package/dist/web/types/assets/illustrations/HighFive.d.ts +8 -0
- package/dist/web/types/constants/version.d.ts +13 -0
- package/dist/web/types/core/AuthManager.d.ts +143 -0
- package/dist/web/types/core/CrossDomainAuth.d.ts +160 -0
- package/dist/web/types/core/HttpService.d.ts +163 -0
- package/dist/web/types/core/OxyServices.base.d.ts +126 -0
- package/dist/web/types/core/OxyServices.d.ts +81 -0
- package/dist/web/types/core/OxyServices.errors.d.ts +11 -0
- package/dist/web/types/core/index.d.ts +20 -0
- package/dist/web/types/core/mixins/OxyServices.analytics.d.ts +66 -0
- package/dist/web/types/core/mixins/OxyServices.assets.d.ts +135 -0
- package/dist/web/types/core/mixins/OxyServices.auth.d.ts +186 -0
- package/dist/web/types/core/mixins/OxyServices.developer.d.ts +99 -0
- package/dist/web/types/core/mixins/OxyServices.devices.d.ts +96 -0
- package/dist/web/types/core/mixins/OxyServices.features.d.ts +228 -0
- package/dist/web/types/core/mixins/OxyServices.fedcm.d.ts +200 -0
- package/dist/web/types/core/mixins/OxyServices.karma.d.ts +85 -0
- package/dist/web/types/core/mixins/OxyServices.language.d.ts +81 -0
- package/dist/web/types/core/mixins/OxyServices.location.d.ts +64 -0
- package/dist/web/types/core/mixins/OxyServices.payment.d.ts +111 -0
- package/dist/web/types/core/mixins/OxyServices.popup.d.ts +205 -0
- package/dist/web/types/core/mixins/OxyServices.privacy.d.ts +122 -0
- package/dist/web/types/core/mixins/OxyServices.redirect.d.ts +245 -0
- package/dist/web/types/core/mixins/OxyServices.security.d.ts +78 -0
- package/dist/web/types/core/mixins/OxyServices.user.d.ts +184 -0
- package/dist/web/types/core/mixins/OxyServices.utility.d.ts +93 -0
- package/dist/web/types/core/mixins/index.d.ts +30 -0
- package/dist/web/types/core/mixins/mixinHelpers.d.ts +31 -0
- package/dist/web/types/crypto/index.d.ts +11 -0
- package/dist/web/types/crypto/keyManager.d.ts +189 -0
- package/dist/web/types/crypto/polyfill.d.ts +12 -0
- package/dist/web/types/crypto/recoveryPhrase.d.ts +58 -0
- package/dist/web/types/crypto/signatureService.d.ts +86 -0
- package/dist/web/types/i18n/index.d.ts +3 -0
- package/dist/web/types/index.d.ts +62 -0
- package/dist/web/types/lib/sonner-safe.d.ts +8 -0
- package/dist/web/types/lib/sonner.d.ts +11 -0
- package/dist/web/types/lib/sonner.web.d.ts +14 -0
- package/dist/web/types/models/interfaces.d.ts +415 -0
- package/dist/web/types/models/session.d.ts +27 -0
- package/dist/web/types/node/index.d.ts +9 -0
- package/dist/web/types/shared/index.d.ts +28 -0
- package/dist/web/types/shared/utils/colorUtils.d.ts +104 -0
- package/dist/web/types/shared/utils/debugUtils.d.ts +48 -0
- package/dist/web/types/shared/utils/errorUtils.d.ts +97 -0
- package/dist/web/types/shared/utils/index.d.ts +13 -0
- package/dist/web/types/shared/utils/networkUtils.d.ts +139 -0
- package/dist/web/types/shared/utils/themeUtils.d.ts +90 -0
- package/dist/web/types/ui/client.d.ts +33 -0
- package/dist/web/types/ui/components/ActivityIndicator.d.ts +44 -0
- package/dist/web/types/ui/components/AnimationExample.d.ts +3 -0
- package/dist/web/types/ui/components/AutoHeightScrollView.d.ts +22 -0
- package/dist/web/types/ui/components/Avatar.d.ts +60 -0
- package/dist/web/types/ui/components/BottomSheet.d.ts +28 -0
- package/dist/web/types/ui/components/BottomSheetRouter.d.ts +8 -0
- package/dist/web/types/ui/components/CrossFadeIcon.d.ts +26 -0
- package/dist/web/types/ui/components/EmptyState.d.ts +7 -0
- package/dist/web/types/ui/components/ErrorBoundary.d.ts +30 -0
- package/dist/web/types/ui/components/FollowButton.d.ts +17 -0
- package/dist/web/types/ui/components/FontLoader.d.ts +14 -0
- package/dist/web/types/ui/components/GroupedItem.d.ts +23 -0
- package/dist/web/types/ui/components/GroupedSection.d.ts +24 -0
- package/dist/web/types/ui/components/Header.d.ts +37 -0
- package/dist/web/types/ui/components/HelperText.d.ts +46 -0
- package/dist/web/types/ui/components/Icon.d.ts +59 -0
- package/dist/web/types/ui/components/IconButton/IconButton.d.ts +98 -0
- package/dist/web/types/ui/components/IconButton/utils.d.ts +18 -0
- package/dist/web/types/ui/components/LoadingState.d.ts +8 -0
- package/dist/web/types/ui/components/OxyLogo.d.ts +28 -0
- package/dist/web/types/ui/components/OxyPayButton.d.ts +28 -0
- package/dist/web/types/ui/components/OxyProvider.d.ts +33 -0
- package/dist/web/types/ui/components/OxySignInButton.d.ts +64 -0
- package/dist/web/types/ui/components/ProfileCard.d.ts +17 -0
- package/dist/web/types/ui/components/QuickActions.d.ts +14 -0
- package/dist/web/types/ui/components/Section.d.ts +11 -0
- package/dist/web/types/ui/components/SectionTitle.d.ts +9 -0
- package/dist/web/types/ui/components/SettingRow.d.ts +19 -0
- package/dist/web/types/ui/components/SignInModal.d.ts +17 -0
- package/dist/web/types/ui/components/StepBasedScreen.d.ts +25 -0
- package/dist/web/types/ui/components/Surface.d.ts +75 -0
- package/dist/web/types/ui/components/TextField/Addons/Outline.d.ts +15 -0
- package/dist/web/types/ui/components/TextField/Addons/Underline.d.ts +18 -0
- package/dist/web/types/ui/components/TextField/Adornment/TextFieldAdornment.d.ts +44 -0
- package/dist/web/types/ui/components/TextField/Adornment/TextFieldAffix.d.ts +72 -0
- package/dist/web/types/ui/components/TextField/Adornment/TextFieldIcon.d.ts +77 -0
- package/dist/web/types/ui/components/TextField/Adornment/enums.d.ts +12 -0
- package/dist/web/types/ui/components/TextField/Adornment/types.d.ts +11 -0
- package/dist/web/types/ui/components/TextField/Adornment/utils.d.ts +11 -0
- package/dist/web/types/ui/components/TextField/Label/InputLabel.d.ts +4 -0
- package/dist/web/types/ui/components/TextField/Label/LabelBackground.d.ts +3 -0
- package/dist/web/types/ui/components/TextField/TextFieldFlat.d.ts +3 -0
- package/dist/web/types/ui/components/TextField/TextFieldOutlined.d.ts +3 -0
- package/dist/web/types/ui/components/TextField/constants.d.ts +31 -0
- package/dist/web/types/ui/components/TextField/helpers.d.ts +96 -0
- package/dist/web/types/ui/components/TextField/types.d.ts +155 -0
- package/dist/web/types/ui/components/TextField.d.ts +191 -0
- package/dist/web/types/ui/components/TouchableRipple/Pressable.d.ts +12 -0
- package/dist/web/types/ui/components/TouchableRipple/TouchableRipple.d.ts +61 -0
- package/dist/web/types/ui/components/TouchableRipple/utils.d.ts +10 -0
- package/dist/web/types/ui/components/Typography/AnimatedText.d.ts +34 -0
- package/dist/web/types/ui/components/Typography/types.d.ts +18 -0
- package/dist/web/types/ui/components/WebOxyProvider.d.ts +51 -0
- package/dist/web/types/ui/components/feedback/FormInput.d.ts +19 -0
- package/dist/web/types/ui/components/feedback/ProgressIndicator.d.ts +10 -0
- package/dist/web/types/ui/components/feedback/constants.d.ts +4 -0
- package/dist/web/types/ui/components/feedback/feedbackStyles.d.ts +279 -0
- package/dist/web/types/ui/components/feedback/index.d.ts +6 -0
- package/dist/web/types/ui/components/feedback/types.d.ts +45 -0
- package/dist/web/types/ui/components/feedback/useFeedbackForm.d.ts +8 -0
- package/dist/web/types/ui/components/fileManagement/AnimatedButton.d.ts +15 -0
- package/dist/web/types/ui/components/fileManagement/FileDetailsModal.d.ts +14 -0
- package/dist/web/types/ui/components/fileManagement/FileViewer.d.ts +17 -0
- package/dist/web/types/ui/components/fileManagement/UploadPreview.d.ts +20 -0
- package/dist/web/types/ui/components/fileManagement/styles.d.ts +859 -0
- package/dist/web/types/ui/components/icon/FAIRWalletIcon.d.ts +8 -0
- package/dist/web/types/ui/components/icon/OxyIcon.d.ts +9 -0
- package/dist/web/types/ui/components/icon/index.d.ts +3 -0
- package/dist/web/types/ui/components/index.d.ts +16 -0
- package/dist/web/types/ui/components/internal/GroupedPillButtons.d.ts +17 -0
- package/dist/web/types/ui/components/internal/PinInput.d.ts +22 -0
- package/dist/web/types/ui/components/modals/DeleteAccountModal.d.ts +18 -0
- package/dist/web/types/ui/components/modals/index.d.ts +1 -0
- package/dist/web/types/ui/components/payment/PaymentDetailsStep.d.ts +20 -0
- package/dist/web/types/ui/components/payment/PaymentMethodStep.d.ts +13 -0
- package/dist/web/types/ui/components/payment/PaymentReviewStep.d.ts +15 -0
- package/dist/web/types/ui/components/payment/PaymentSuccessStep.d.ts +9 -0
- package/dist/web/types/ui/components/payment/PaymentSummaryStep.d.ts +14 -0
- package/dist/web/types/ui/components/payment/constants.d.ts +6 -0
- package/dist/web/types/ui/components/payment/index.d.ts +8 -0
- package/dist/web/types/ui/components/payment/paymentStyles.d.ts +395 -0
- package/dist/web/types/ui/components/payment/types.d.ts +39 -0
- package/dist/web/types/ui/components/photogrid/JustifiedPhotoGrid.d.ts +26 -0
- package/dist/web/types/ui/components/styles/overlay.d.ts +3 -0
- package/dist/web/types/ui/components/styles/shadow.d.ts +2 -0
- package/dist/web/types/ui/components/theming.d.ts +7 -0
- package/dist/web/types/ui/components/types.d.ts +79 -0
- package/dist/web/types/ui/components/utils/forwardRef.d.ts +11 -0
- package/dist/web/types/ui/components/utils/hasTouchHandler.d.ts +5 -0
- package/dist/web/types/ui/components/utils/roundLayoutSize.d.ts +1 -0
- package/dist/web/types/ui/components/utils/splitStyles.d.ts +19 -0
- package/dist/web/types/ui/constants/iconColors.d.ts +129 -0
- package/dist/web/types/ui/constants/spacing.d.ts +32 -0
- package/dist/web/types/ui/constants/theme.d.ts +96 -0
- package/dist/web/types/ui/context/OxyContext.d.ts +74 -0
- package/dist/web/types/ui/context/ThemeContext.d.ts +18 -0
- package/dist/web/types/ui/context/hooks/useAuthOperations.d.ts +39 -0
- package/dist/web/types/ui/context/hooks/useDeviceManagement.d.ts +26 -0
- package/dist/web/types/ui/context/hooks/useLanguageManagement.d.ts +24 -0
- package/dist/web/types/ui/context/hooks/useSessionManagement.d.ts +40 -0
- package/dist/web/types/ui/hooks/index.d.ts +6 -0
- package/dist/web/types/ui/hooks/mutations/index.d.ts +8 -0
- package/dist/web/types/ui/hooks/mutations/mutationFactory.d.ts +75 -0
- package/dist/web/types/ui/hooks/mutations/useAccountMutations.d.ts +68 -0
- package/dist/web/types/ui/hooks/mutations/useServicesMutations.d.ts +22 -0
- package/dist/web/types/ui/hooks/queries/index.d.ts +10 -0
- package/dist/web/types/ui/hooks/queries/queryKeys.d.ts +64 -0
- package/dist/web/types/ui/hooks/queries/useAccountQueries.d.ts +42 -0
- package/dist/web/types/ui/hooks/queries/useSecurityQueries.d.ts +14 -0
- package/dist/web/types/ui/hooks/queries/useServicesQueries.d.ts +31 -0
- package/dist/web/types/ui/hooks/queryClient.d.ts +18 -0
- package/dist/web/types/ui/hooks/useAssets.d.ts +34 -0
- package/dist/web/types/ui/hooks/useAsyncAction.d.ts +50 -0
- package/dist/web/types/ui/hooks/useAuth.d.ts +73 -0
- package/dist/web/types/ui/hooks/useColorScheme.d.ts +7 -0
- package/dist/web/types/ui/hooks/useDeviceManagement.d.ts +26 -0
- package/dist/web/types/ui/hooks/useFileDownloadUrl.d.ts +18 -0
- package/dist/web/types/ui/hooks/useFileFiltering.d.ts +28 -0
- package/dist/web/types/ui/hooks/useFollow.d.ts +61 -0
- package/dist/web/types/ui/hooks/useFollow.types.d.ts +32 -0
- package/dist/web/types/ui/hooks/useI18n.d.ts +4 -0
- package/dist/web/types/ui/hooks/useLanguageManagement.d.ts +24 -0
- package/dist/web/types/ui/hooks/useProfileEditing.d.ts +35 -0
- package/dist/web/types/ui/hooks/useQueryClient.d.ts +6 -0
- package/dist/web/types/ui/hooks/useSessionManagement.d.ts +40 -0
- package/dist/web/types/ui/hooks/useSessionSocket.d.ts +13 -0
- package/dist/web/types/ui/hooks/useSettingToggle.d.ts +56 -0
- package/dist/web/types/ui/hooks/useStorage.d.ts +15 -0
- package/dist/web/types/ui/hooks/useThemeColors.d.ts +93 -0
- package/dist/web/types/ui/hooks/useThemeStyles.d.ts +44 -0
- package/dist/web/types/ui/hooks/useWebSSO.d.ts +57 -0
- package/dist/web/types/ui/index.d.ts +7 -0
- package/dist/web/types/ui/isFrontend.d.ts +2 -0
- package/dist/web/types/ui/navigation/bottomSheetManager.d.ts +26 -0
- package/dist/web/types/ui/navigation/routes.d.ts +5 -0
- package/dist/web/types/ui/screens/AccountCenterScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/AccountOverviewScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/AccountSettingsScreen.d.ts +7 -0
- package/dist/web/types/ui/screens/AccountSwitcherScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/AccountVerificationScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/AppInfoScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/EditProfileFieldScreen.d.ts +12 -0
- package/dist/web/types/ui/screens/FAQScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/FeedbackScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/FileManagementScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/FollowersListScreen.d.ts +8 -0
- package/dist/web/types/ui/screens/FollowingListScreen.d.ts +8 -0
- package/dist/web/types/ui/screens/HelpSupportScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/HistoryViewScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/LanguageSelectorScreen.d.ts +6 -0
- package/dist/web/types/ui/screens/LearnMoreUsernamesScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/LegalDocumentsScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/OxyAuthScreen.d.ts +16 -0
- package/dist/web/types/ui/screens/PaymentGatewayScreen.d.ts +14 -0
- package/dist/web/types/ui/screens/PremiumSubscriptionScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/PrivacySettingsScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/ProfileScreen.d.ts +8 -0
- package/dist/web/types/ui/screens/SavesCollectionsScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/SearchSettingsScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/SessionManagementScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/UserLinksScreen.d.ts +14 -0
- package/dist/web/types/ui/screens/UserListScreen.d.ts +10 -0
- package/dist/web/types/ui/screens/WelcomeNewUserScreen.d.ts +12 -0
- package/dist/web/types/ui/screens/karma/KarmaAboutScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/karma/KarmaCenterScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/karma/KarmaFAQScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/karma/KarmaLeaderboardScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/karma/KarmaRewardsScreen.d.ts +4 -0
- package/dist/web/types/ui/screens/karma/KarmaRulesScreen.d.ts +4 -0
- package/dist/web/types/ui/server.d.ts +42 -0
- package/dist/web/types/ui/stores/accountStore.d.ts +33 -0
- package/dist/web/types/ui/stores/assetStore.d.ts +53 -0
- package/dist/web/types/ui/stores/authStore.d.ts +16 -0
- package/dist/web/types/ui/stores/fileStore.d.ts +30 -0
- package/dist/web/types/ui/stores/followStore.d.ts +24 -0
- package/dist/web/types/ui/styles/authStyles.d.ts +331 -0
- package/dist/web/types/ui/styles/fonts.d.ts +20 -0
- package/dist/web/types/ui/styles/index.d.ts +4 -0
- package/dist/web/types/ui/styles/spacing.d.ts +48 -0
- package/dist/web/types/ui/styles/theme.d.ts +67 -0
- package/dist/web/types/ui/types/fileManagement.d.ts +40 -0
- package/dist/web/types/ui/types/navigation.d.ts +36 -0
- package/dist/web/types/ui/utils/authHelpers.d.ts +98 -0
- package/dist/web/types/ui/utils/avatarUtils.d.ts +33 -0
- package/dist/web/types/ui/utils/colorUtils.d.ts +9 -0
- package/dist/web/types/ui/utils/confirmAction.d.ts +6 -0
- package/dist/web/types/ui/utils/errorHandlers.d.ts +34 -0
- package/dist/web/types/ui/utils/fileManagement.d.ts +86 -0
- package/dist/web/types/ui/utils/iconNames.d.ts +111 -0
- package/dist/web/types/ui/utils/sessionHelpers.d.ts +63 -0
- package/dist/web/types/ui/utils/storageHelpers.d.ts +27 -0
- package/dist/web/types/ui/utils/themeUtils.d.ts +10 -0
- package/dist/web/types/ui/utils/userUtils.d.ts +28 -0
- package/dist/web/types/utils/apiUtils.d.ts +53 -0
- package/dist/web/types/utils/asyncUtils.d.ts +58 -0
- package/dist/web/types/utils/cache.d.ts +127 -0
- package/dist/web/types/utils/deviceManager.d.ts +65 -0
- package/dist/web/types/utils/errorUtils.d.ts +46 -0
- package/dist/web/types/utils/hookUtils.d.ts +101 -0
- package/dist/web/types/utils/index.d.ts +6 -0
- package/dist/web/types/utils/languageUtils.d.ts +37 -0
- package/dist/web/types/utils/loggerUtils.d.ts +48 -0
- package/dist/web/types/utils/platform.d.ts +40 -0
- package/dist/web/types/utils/platformInit.d.ts +8 -0
- package/dist/web/types/utils/requestUtils.d.ts +123 -0
- package/dist/web/types/utils/sessionUtils.d.ts +54 -0
- package/dist/web/types/utils/validationUtils.d.ts +85 -0
- package/dist/web/types/web/WebOxyContext.d.ts +151 -0
- package/dist/web/types/web/index.d.ts +52 -0
- package/dist/web/types/web.d.ts +53 -0
- package/package.json +20 -6
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ViewStyle } from 'react-native';
|
|
3
|
+
interface OxyLogoProps {
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
style?: ViewStyle;
|
|
7
|
+
/**
|
|
8
|
+
* Primary fill color for the logo
|
|
9
|
+
* If not provided, the theme's primary color will be used
|
|
10
|
+
*/
|
|
11
|
+
fillColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Secondary fill color for the inner glow effect
|
|
14
|
+
* If not provided, a lighter shade of the fillColor will be used
|
|
15
|
+
*/
|
|
16
|
+
secondaryFillColor?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Theme to use for the logo colors
|
|
19
|
+
* @default 'light'
|
|
20
|
+
*/
|
|
21
|
+
theme?: 'light' | 'dark';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* SVG logo component for Oxy
|
|
25
|
+
* This component renders the Oxy logo as an SVG and uses theme colors by default
|
|
26
|
+
*/
|
|
27
|
+
export declare const OxyServicesLogo: React.FC<OxyLogoProps>;
|
|
28
|
+
export default OxyServicesLogo;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package version and metadata constants
|
|
3
|
+
* This file is auto-generated to avoid runtime dependency on package.json
|
|
4
|
+
*/
|
|
5
|
+
export declare const packageInfo: {
|
|
6
|
+
readonly name: "@oxyhq/services";
|
|
7
|
+
readonly version: "5.2.1";
|
|
8
|
+
readonly description: "Reusable OxyHQ module to handle authentication, user management, karma system and more 🚀";
|
|
9
|
+
readonly main: "lib/commonjs/node/index.js";
|
|
10
|
+
readonly module: "lib/module/node/index.js";
|
|
11
|
+
readonly types: "lib/typescript/node/index.d.ts";
|
|
12
|
+
};
|
|
13
|
+
export declare const name: "@oxyhq/services", version: "5.2.1", description: "Reusable OxyHQ module to handle authentication, user management, karma system and more 🚀";
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthManager - Centralized Authentication Manager
|
|
3
|
+
*
|
|
4
|
+
* Provides a unified authentication interface for all platforms.
|
|
5
|
+
* Handles token storage, session management, and auth state changes.
|
|
6
|
+
*
|
|
7
|
+
* @module core/AuthManager
|
|
8
|
+
*/
|
|
9
|
+
import type { OxyServices } from './OxyServices';
|
|
10
|
+
import type { SessionLoginResponse, MinimalUserData } from '../models/session';
|
|
11
|
+
/**
|
|
12
|
+
* Storage adapter interface for platform-agnostic storage.
|
|
13
|
+
*/
|
|
14
|
+
export interface StorageAdapter {
|
|
15
|
+
getItem: (key: string) => Promise<string | null> | string | null;
|
|
16
|
+
setItem: (key: string, value: string) => Promise<void> | void;
|
|
17
|
+
removeItem: (key: string) => Promise<void> | void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Auth state change callback type.
|
|
21
|
+
*/
|
|
22
|
+
export type AuthStateChangeCallback = (user: MinimalUserData | null) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Auth method types.
|
|
25
|
+
*/
|
|
26
|
+
export type AuthMethod = 'fedcm' | 'popup' | 'redirect' | 'credentials' | 'identity';
|
|
27
|
+
/**
|
|
28
|
+
* Auth manager configuration.
|
|
29
|
+
*/
|
|
30
|
+
export interface AuthManagerConfig {
|
|
31
|
+
/** Storage adapter (localStorage, AsyncStorage, etc.) */
|
|
32
|
+
storage?: StorageAdapter;
|
|
33
|
+
/** Whether to auto-refresh tokens */
|
|
34
|
+
autoRefresh?: boolean;
|
|
35
|
+
/** Token refresh interval in milliseconds (default: 5 minutes before expiry) */
|
|
36
|
+
refreshBuffer?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* AuthManager - Centralized authentication management.
|
|
40
|
+
*
|
|
41
|
+
* Provides a single point of control for:
|
|
42
|
+
* - Token storage and retrieval
|
|
43
|
+
* - Session management
|
|
44
|
+
* - Auth state change notifications
|
|
45
|
+
* - Multiple auth method support
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const authManager = new AuthManager(oxyServices);
|
|
50
|
+
*
|
|
51
|
+
* // Listen for auth changes
|
|
52
|
+
* authManager.onAuthStateChange((user) => {
|
|
53
|
+
* console.log('Auth state changed:', user);
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Handle successful auth
|
|
57
|
+
* await authManager.handleAuthSuccess(session);
|
|
58
|
+
*
|
|
59
|
+
* // Sign out
|
|
60
|
+
* await authManager.signOut();
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare class AuthManager {
|
|
64
|
+
private oxyServices;
|
|
65
|
+
private storage;
|
|
66
|
+
private listeners;
|
|
67
|
+
private currentUser;
|
|
68
|
+
private refreshTimer;
|
|
69
|
+
private config;
|
|
70
|
+
constructor(oxyServices: OxyServices, config?: AuthManagerConfig);
|
|
71
|
+
/**
|
|
72
|
+
* Get default storage based on environment.
|
|
73
|
+
*/
|
|
74
|
+
private getDefaultStorage;
|
|
75
|
+
/**
|
|
76
|
+
* Subscribe to auth state changes.
|
|
77
|
+
*
|
|
78
|
+
* @param callback - Function called when auth state changes
|
|
79
|
+
* @returns Unsubscribe function
|
|
80
|
+
*/
|
|
81
|
+
onAuthStateChange(callback: AuthStateChangeCallback): () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Notify all listeners of auth state change.
|
|
84
|
+
*/
|
|
85
|
+
private notifyListeners;
|
|
86
|
+
/**
|
|
87
|
+
* Handle successful authentication.
|
|
88
|
+
*
|
|
89
|
+
* @param session - Session response from auth
|
|
90
|
+
* @param method - Auth method used
|
|
91
|
+
*/
|
|
92
|
+
handleAuthSuccess(session: SessionLoginResponse, method?: AuthMethod): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Setup automatic token refresh.
|
|
95
|
+
*/
|
|
96
|
+
private setupTokenRefresh;
|
|
97
|
+
/**
|
|
98
|
+
* Refresh the access token.
|
|
99
|
+
*/
|
|
100
|
+
refreshToken(): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Sign out and clear all auth data.
|
|
103
|
+
*/
|
|
104
|
+
signOut(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Clear session data from storage.
|
|
107
|
+
*/
|
|
108
|
+
private clearSession;
|
|
109
|
+
/**
|
|
110
|
+
* Get current user.
|
|
111
|
+
*/
|
|
112
|
+
getCurrentUser(): MinimalUserData | null;
|
|
113
|
+
/**
|
|
114
|
+
* Check if user is authenticated.
|
|
115
|
+
*/
|
|
116
|
+
isAuthenticated(): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Get stored access token.
|
|
119
|
+
*/
|
|
120
|
+
getAccessToken(): Promise<string | null>;
|
|
121
|
+
/**
|
|
122
|
+
* Get the auth method used for current session.
|
|
123
|
+
*/
|
|
124
|
+
getAuthMethod(): Promise<AuthMethod | null>;
|
|
125
|
+
/**
|
|
126
|
+
* Initialize auth state from storage.
|
|
127
|
+
*
|
|
128
|
+
* Call this on app startup to restore previous session.
|
|
129
|
+
*/
|
|
130
|
+
initialize(): Promise<MinimalUserData | null>;
|
|
131
|
+
/**
|
|
132
|
+
* Destroy the auth manager and clean up resources.
|
|
133
|
+
*/
|
|
134
|
+
destroy(): void;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create an AuthManager instance.
|
|
138
|
+
*
|
|
139
|
+
* @param oxyServices - OxyServices instance
|
|
140
|
+
* @param config - Optional configuration
|
|
141
|
+
* @returns AuthManager instance
|
|
142
|
+
*/
|
|
143
|
+
export declare function createAuthManager(oxyServices: OxyServices, config?: AuthManagerConfig): AuthManager;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-Domain Authentication Helper
|
|
3
|
+
*
|
|
4
|
+
* Provides a simplified API for cross-domain SSO authentication that automatically
|
|
5
|
+
* selects the best authentication method based on browser capabilities:
|
|
6
|
+
*
|
|
7
|
+
* 1. FedCM (if supported) - Modern, Google-style browser-native auth
|
|
8
|
+
* 2. Popup (fallback) - OAuth2-style popup window
|
|
9
|
+
* 3. Redirect (final fallback) - Traditional full-page redirect
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { CrossDomainAuth } from '@oxyhq/services';
|
|
14
|
+
*
|
|
15
|
+
* const auth = new CrossDomainAuth(oxyServices);
|
|
16
|
+
*
|
|
17
|
+
* // Automatic method selection
|
|
18
|
+
* const session = await auth.signIn();
|
|
19
|
+
*
|
|
20
|
+
* // Or use specific method
|
|
21
|
+
* const session = await auth.signInWithPopup();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import type { OxyServices } from './OxyServices';
|
|
25
|
+
import type { SessionLoginResponse } from '../models/session';
|
|
26
|
+
export interface CrossDomainAuthOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Preferred authentication method
|
|
29
|
+
* - 'auto': Automatically select best method (default)
|
|
30
|
+
* - 'fedcm': Use FedCM (browser-native)
|
|
31
|
+
* - 'popup': Use popup window
|
|
32
|
+
* - 'redirect': Use full-page redirect
|
|
33
|
+
*/
|
|
34
|
+
method?: 'auto' | 'fedcm' | 'popup' | 'redirect';
|
|
35
|
+
/**
|
|
36
|
+
* Custom redirect URI (for redirect method)
|
|
37
|
+
*/
|
|
38
|
+
redirectUri?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to open signup page instead of login
|
|
41
|
+
*/
|
|
42
|
+
isSignup?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Popup window dimensions (for popup method)
|
|
45
|
+
*/
|
|
46
|
+
popupDimensions?: {
|
|
47
|
+
width?: number;
|
|
48
|
+
height?: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Callback when auth method is selected
|
|
52
|
+
*/
|
|
53
|
+
onMethodSelected?: (method: 'fedcm' | 'popup' | 'redirect') => void;
|
|
54
|
+
}
|
|
55
|
+
export declare class CrossDomainAuth {
|
|
56
|
+
private oxyServices;
|
|
57
|
+
constructor(oxyServices: OxyServices);
|
|
58
|
+
/**
|
|
59
|
+
* Sign in with automatic method selection
|
|
60
|
+
*
|
|
61
|
+
* Tries methods in this order:
|
|
62
|
+
* 1. FedCM (if supported and not in private browsing)
|
|
63
|
+
* 2. Popup (if not blocked)
|
|
64
|
+
* 3. Redirect (always works)
|
|
65
|
+
*
|
|
66
|
+
* @param options - Authentication options
|
|
67
|
+
* @returns Session with user data and access token
|
|
68
|
+
*/
|
|
69
|
+
signIn(options?: CrossDomainAuthOptions): Promise<SessionLoginResponse | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Automatic sign-in with progressive enhancement
|
|
72
|
+
*
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
private autoSignIn;
|
|
76
|
+
/**
|
|
77
|
+
* Sign in using FedCM (Federated Credential Management)
|
|
78
|
+
*
|
|
79
|
+
* Best method - browser-native, no popups, Google-like experience
|
|
80
|
+
*/
|
|
81
|
+
signInWithFedCM(options?: CrossDomainAuthOptions): Promise<SessionLoginResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Sign in using popup window
|
|
84
|
+
*
|
|
85
|
+
* Good method - preserves app state, no full page reload
|
|
86
|
+
*/
|
|
87
|
+
signInWithPopup(options?: CrossDomainAuthOptions): Promise<SessionLoginResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Sign in using full-page redirect
|
|
90
|
+
*
|
|
91
|
+
* Fallback method - works everywhere but loses app state
|
|
92
|
+
*/
|
|
93
|
+
signInWithRedirect(options?: CrossDomainAuthOptions): void;
|
|
94
|
+
/**
|
|
95
|
+
* Handle redirect callback
|
|
96
|
+
*
|
|
97
|
+
* Call this on app startup to check if we're returning from auth redirect
|
|
98
|
+
*/
|
|
99
|
+
handleRedirectCallback(): SessionLoginResponse | null;
|
|
100
|
+
/**
|
|
101
|
+
* Silent sign-in (check for existing session)
|
|
102
|
+
*
|
|
103
|
+
* Tries to automatically sign in without user interaction.
|
|
104
|
+
* Works with both FedCM and popup/iframe methods.
|
|
105
|
+
*
|
|
106
|
+
* @returns Session if user is already signed in, null otherwise
|
|
107
|
+
*/
|
|
108
|
+
silentSignIn(): Promise<SessionLoginResponse | null>;
|
|
109
|
+
/**
|
|
110
|
+
* Restore session from storage
|
|
111
|
+
*
|
|
112
|
+
* For redirect method - restores previously authenticated session from localStorage
|
|
113
|
+
*/
|
|
114
|
+
restoreSession(): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Check if FedCM is supported in current browser
|
|
117
|
+
*/
|
|
118
|
+
isFedCMSupported(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Get recommended authentication method for current environment
|
|
121
|
+
*
|
|
122
|
+
* @returns Recommended method name and reason
|
|
123
|
+
*/
|
|
124
|
+
getRecommendedMethod(): {
|
|
125
|
+
method: 'fedcm' | 'popup' | 'redirect';
|
|
126
|
+
reason: string;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Initialize cross-domain auth on app startup
|
|
130
|
+
*
|
|
131
|
+
* This handles:
|
|
132
|
+
* 1. Redirect callback (if returning from auth.oxy.so)
|
|
133
|
+
* 2. Session restoration (from localStorage)
|
|
134
|
+
* 3. Silent sign-in (check for existing SSO session)
|
|
135
|
+
*
|
|
136
|
+
* @returns Session if user is authenticated, null otherwise
|
|
137
|
+
*/
|
|
138
|
+
initialize(): Promise<SessionLoginResponse | null>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Helper function to create CrossDomainAuth instance
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* import { createCrossDomainAuth } from '@oxyhq/services';
|
|
146
|
+
*
|
|
147
|
+
* const oxyServices = new OxyServices({ baseURL: 'https://api.oxy.so' });
|
|
148
|
+
* const auth = createCrossDomainAuth(oxyServices);
|
|
149
|
+
*
|
|
150
|
+
* // On app startup
|
|
151
|
+
* const session = await auth.initialize();
|
|
152
|
+
* if (session) {
|
|
153
|
+
* console.log('User is signed in:', session.user);
|
|
154
|
+
* }
|
|
155
|
+
*
|
|
156
|
+
* // Sign in button click
|
|
157
|
+
* const session = await auth.signIn();
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function createCrossDomainAuth(oxyServices: OxyServices): CrossDomainAuth;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified HTTP Service
|
|
3
|
+
*
|
|
4
|
+
* Consolidates HttpClient + RequestManager into a single efficient class.
|
|
5
|
+
* Uses native fetch instead of axios for smaller bundle size.
|
|
6
|
+
*
|
|
7
|
+
* Handles:
|
|
8
|
+
* - Authentication (token management, auto-refresh)
|
|
9
|
+
* - Caching (TTL-based)
|
|
10
|
+
* - Deduplication (concurrent requests)
|
|
11
|
+
* - Retry logic
|
|
12
|
+
* - Error handling
|
|
13
|
+
* - Request queuing
|
|
14
|
+
*/
|
|
15
|
+
import type { OxyConfig } from '../models/interfaces';
|
|
16
|
+
export interface RequestOptions {
|
|
17
|
+
cache?: boolean;
|
|
18
|
+
cacheTTL?: number;
|
|
19
|
+
deduplicate?: boolean;
|
|
20
|
+
retry?: boolean;
|
|
21
|
+
maxRetries?: number;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
interface RequestConfig extends RequestOptions {
|
|
27
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
28
|
+
url: string;
|
|
29
|
+
data?: unknown;
|
|
30
|
+
params?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Unified HTTP Service
|
|
34
|
+
*
|
|
35
|
+
* Consolidates HttpClient + RequestManager into a single efficient class.
|
|
36
|
+
* Uses native fetch instead of axios for smaller bundle size.
|
|
37
|
+
*/
|
|
38
|
+
export declare class HttpService {
|
|
39
|
+
private baseURL;
|
|
40
|
+
private tokenStore;
|
|
41
|
+
private cache;
|
|
42
|
+
private deduplicator;
|
|
43
|
+
private requestQueue;
|
|
44
|
+
private logger;
|
|
45
|
+
private config;
|
|
46
|
+
private requestMetrics;
|
|
47
|
+
constructor(config: OxyConfig);
|
|
48
|
+
/**
|
|
49
|
+
* Robust FormData detection that works in browser and Node.js environments
|
|
50
|
+
* Checks multiple conditions to handle different FormData implementations
|
|
51
|
+
*/
|
|
52
|
+
private isFormData;
|
|
53
|
+
/**
|
|
54
|
+
* Main request method - handles everything in one place
|
|
55
|
+
*/
|
|
56
|
+
request<T = unknown>(config: RequestConfig): Promise<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Generate cache key efficiently
|
|
59
|
+
* Uses simple hash for large objects to avoid expensive JSON.stringify
|
|
60
|
+
*/
|
|
61
|
+
private generateCacheKey;
|
|
62
|
+
/**
|
|
63
|
+
* Build full URL with query params
|
|
64
|
+
*/
|
|
65
|
+
private buildURL;
|
|
66
|
+
/**
|
|
67
|
+
* Fetch CSRF token from server (with deduplication)
|
|
68
|
+
* Required for state-changing requests (POST, PUT, PATCH, DELETE)
|
|
69
|
+
*/
|
|
70
|
+
private fetchCsrfToken;
|
|
71
|
+
/**
|
|
72
|
+
* Get auth header with automatic token refresh
|
|
73
|
+
*/
|
|
74
|
+
private getAuthHeader;
|
|
75
|
+
/**
|
|
76
|
+
* Unwrap standardized API response format
|
|
77
|
+
*/
|
|
78
|
+
private unwrapResponse;
|
|
79
|
+
/**
|
|
80
|
+
* Update request metrics
|
|
81
|
+
*/
|
|
82
|
+
private updateMetrics;
|
|
83
|
+
/**
|
|
84
|
+
* GET request convenience method
|
|
85
|
+
*/
|
|
86
|
+
get<T = unknown>(url: string, config?: Omit<RequestConfig, 'method' | 'url'>): Promise<{
|
|
87
|
+
data: T;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* POST request convenience method
|
|
91
|
+
* Supports FormData uploads - Content-Type will be set automatically for FormData
|
|
92
|
+
* @param url - Request URL
|
|
93
|
+
* @param data - Request body (can be FormData for file uploads)
|
|
94
|
+
* @param config - Request configuration including optional headers
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const formData = new FormData();
|
|
98
|
+
* formData.append('file', file);
|
|
99
|
+
* await api.post('/upload', formData, { headers: { 'X-Custom-Header': 'value' } });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
post<T = unknown>(url: string, data?: unknown, config?: Omit<RequestConfig, 'method' | 'url' | 'data'>): Promise<{
|
|
103
|
+
data: T;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* PUT request convenience method
|
|
107
|
+
* Supports FormData uploads - Content-Type will be set automatically for FormData
|
|
108
|
+
* @param url - Request URL
|
|
109
|
+
* @param data - Request body (can be FormData for file uploads)
|
|
110
|
+
* @param config - Request configuration including optional headers
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const formData = new FormData();
|
|
114
|
+
* formData.append('file', file);
|
|
115
|
+
* await api.put('/upload', formData, { headers: { 'X-Custom-Header': 'value' } });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
put<T = unknown>(url: string, data?: unknown, config?: Omit<RequestConfig, 'method' | 'url' | 'data'>): Promise<{
|
|
119
|
+
data: T;
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* PATCH request convenience method
|
|
123
|
+
* Supports FormData uploads - Content-Type will be set automatically for FormData
|
|
124
|
+
* @param url - Request URL
|
|
125
|
+
* @param data - Request body (can be FormData for file uploads)
|
|
126
|
+
* @param config - Request configuration including optional headers
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const formData = new FormData();
|
|
130
|
+
* formData.append('file', file);
|
|
131
|
+
* await api.patch('/upload', formData, { headers: { 'X-Custom-Header': 'value' } });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
patch<T = unknown>(url: string, data?: unknown, config?: Omit<RequestConfig, 'method' | 'url' | 'data'>): Promise<{
|
|
135
|
+
data: T;
|
|
136
|
+
}>;
|
|
137
|
+
delete<T = unknown>(url: string, config?: Omit<RequestConfig, 'method' | 'url'>): Promise<{
|
|
138
|
+
data: T;
|
|
139
|
+
}>;
|
|
140
|
+
setTokens(accessToken: string, refreshToken?: string): void;
|
|
141
|
+
clearTokens(): void;
|
|
142
|
+
getAccessToken(): string | null;
|
|
143
|
+
hasAccessToken(): boolean;
|
|
144
|
+
getBaseURL(): string;
|
|
145
|
+
clearCache(): void;
|
|
146
|
+
clearCacheEntry(key: string): void;
|
|
147
|
+
getCacheStats(): {
|
|
148
|
+
size: number;
|
|
149
|
+
hits: number;
|
|
150
|
+
misses: number;
|
|
151
|
+
hitRate: number;
|
|
152
|
+
};
|
|
153
|
+
getMetrics(): {
|
|
154
|
+
totalRequests: number;
|
|
155
|
+
successfulRequests: number;
|
|
156
|
+
failedRequests: number;
|
|
157
|
+
cacheHits: number;
|
|
158
|
+
cacheMisses: number;
|
|
159
|
+
averageResponseTime: number;
|
|
160
|
+
};
|
|
161
|
+
static __resetTokensForTests(): void;
|
|
162
|
+
}
|
|
163
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { OxyConfig as OxyConfigBase } from '../models/interfaces';
|
|
2
|
+
import { HttpService, type RequestOptions } from './HttpService';
|
|
3
|
+
export interface OxyConfig extends OxyConfigBase {
|
|
4
|
+
cloudURL?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Base class for OxyServices with core infrastructure
|
|
8
|
+
*/
|
|
9
|
+
export declare class OxyServicesBase {
|
|
10
|
+
httpService: HttpService;
|
|
11
|
+
cloudURL: string;
|
|
12
|
+
config: OxyConfig;
|
|
13
|
+
constructor(...args: any[]);
|
|
14
|
+
static __resetTokensForTests(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Make a request with all performance optimizations
|
|
17
|
+
* This is the main method for all API calls - ensures authentication and performance features
|
|
18
|
+
*/
|
|
19
|
+
makeRequest<T>(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Get the configured Oxy API base URL
|
|
22
|
+
*/
|
|
23
|
+
getBaseURL(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get the HTTP service instance
|
|
26
|
+
* Useful for advanced use cases where direct access to the HTTP service is needed
|
|
27
|
+
*/
|
|
28
|
+
getClient(): HttpService;
|
|
29
|
+
/**
|
|
30
|
+
* Get performance metrics
|
|
31
|
+
*/
|
|
32
|
+
getMetrics(): {
|
|
33
|
+
totalRequests: number;
|
|
34
|
+
successfulRequests: number;
|
|
35
|
+
failedRequests: number;
|
|
36
|
+
cacheHits: number;
|
|
37
|
+
cacheMisses: number;
|
|
38
|
+
averageResponseTime: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Clear request cache
|
|
42
|
+
*/
|
|
43
|
+
clearCache(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Clear specific cache entry
|
|
46
|
+
*/
|
|
47
|
+
clearCacheEntry(key: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get cache statistics
|
|
50
|
+
*/
|
|
51
|
+
getCacheStats(): {
|
|
52
|
+
size: number;
|
|
53
|
+
hits: number;
|
|
54
|
+
misses: number;
|
|
55
|
+
hitRate: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Get the configured Oxy Cloud (file storage/CDN) URL
|
|
59
|
+
*/
|
|
60
|
+
getCloudURL(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Set authentication tokens
|
|
63
|
+
*/
|
|
64
|
+
setTokens(accessToken: string, refreshToken?: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Clear stored authentication tokens
|
|
67
|
+
*/
|
|
68
|
+
clearTokens(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get the current user ID from the access token
|
|
71
|
+
*/
|
|
72
|
+
getCurrentUserId(): string | null;
|
|
73
|
+
/**
|
|
74
|
+
* Check if the client has a valid access token (public method)
|
|
75
|
+
*/
|
|
76
|
+
hasValidToken(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Get the raw access token (for constructing anchor URLs when needed)
|
|
79
|
+
*/
|
|
80
|
+
getAccessToken(): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* Wait for authentication to be ready
|
|
83
|
+
*
|
|
84
|
+
* Optimized for high-scale usage with immediate synchronous check and adaptive polling.
|
|
85
|
+
* Returns immediately if token is already available (0ms delay), otherwise uses
|
|
86
|
+
* adaptive polling that starts fast (50ms) and gradually increases to reduce CPU usage.
|
|
87
|
+
*
|
|
88
|
+
* @param timeoutMs Maximum time to wait in milliseconds (default: 5000ms)
|
|
89
|
+
* @returns Promise that resolves to true if authentication is ready, false if timeout
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const isReady = await oxyServices.waitForAuth(3000);
|
|
94
|
+
* if (isReady) {
|
|
95
|
+
* // Proceed with authenticated operations
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
waitForAuth(timeoutMs?: number): Promise<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* Execute a function with automatic authentication retry logic
|
|
102
|
+
* This handles the common case where API calls are made before authentication completes
|
|
103
|
+
*/
|
|
104
|
+
withAuthRetry<T>(operation: () => Promise<T>, operationName: string, options?: {
|
|
105
|
+
maxRetries?: number;
|
|
106
|
+
retryDelay?: number;
|
|
107
|
+
authTimeoutMs?: number;
|
|
108
|
+
}): Promise<T>;
|
|
109
|
+
/**
|
|
110
|
+
* Validate the current access token with the server
|
|
111
|
+
*/
|
|
112
|
+
validate(): Promise<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* Centralized error handling
|
|
115
|
+
*/
|
|
116
|
+
handleError(error: unknown): Error;
|
|
117
|
+
/**
|
|
118
|
+
* Health check endpoint
|
|
119
|
+
*/
|
|
120
|
+
healthCheck(): Promise<{
|
|
121
|
+
status: string;
|
|
122
|
+
users?: number;
|
|
123
|
+
timestamp?: string;
|
|
124
|
+
[key: string]: any;
|
|
125
|
+
}>;
|
|
126
|
+
}
|