@webority-technologies/mobile 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +399 -0
- package/lib/commonjs/api/publicClient.js +73 -0
- package/lib/commonjs/api/userClient.js +290 -0
- package/lib/commonjs/auth/authStore.js +107 -0
- package/lib/commonjs/auth/index.js +44 -0
- package/lib/commonjs/auth/jwt.js +84 -0
- package/lib/commonjs/components/Accordion/Accordion.js +257 -0
- package/lib/commonjs/components/Accordion/index.js +26 -0
- package/lib/commonjs/components/Avatar/Avatar.js +283 -0
- package/lib/commonjs/components/Avatar/index.js +26 -0
- package/lib/commonjs/components/Badge/Badge.js +212 -0
- package/lib/commonjs/components/Badge/index.js +20 -0
- package/lib/commonjs/components/Banner/Banner.js +276 -0
- package/lib/commonjs/components/Banner/index.js +20 -0
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +288 -0
- package/lib/commonjs/components/BottomNavigation/index.js +20 -0
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +367 -0
- package/lib/commonjs/components/BottomSheet/index.js +20 -0
- package/lib/commonjs/components/Button/Button.js +281 -0
- package/lib/commonjs/components/Button/index.js +20 -0
- package/lib/commonjs/components/Card/Card.js +194 -0
- package/lib/commonjs/components/Card/index.js +20 -0
- package/lib/commonjs/components/Carousel/Carousel.js +475 -0
- package/lib/commonjs/components/Carousel/index.js +20 -0
- package/lib/commonjs/components/Checkbox/Checkbox.js +165 -0
- package/lib/commonjs/components/Checkbox/index.js +20 -0
- package/lib/commonjs/components/Chip/Chip.js +272 -0
- package/lib/commonjs/components/Chip/index.js +20 -0
- package/lib/commonjs/components/DatePicker/DatePicker.js +813 -0
- package/lib/commonjs/components/DatePicker/index.js +20 -0
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +622 -0
- package/lib/commonjs/components/DateRangePicker/index.js +20 -0
- package/lib/commonjs/components/Dialog/Dialog.js +215 -0
- package/lib/commonjs/components/Dialog/index.js +20 -0
- package/lib/commonjs/components/Divider/Divider.js +118 -0
- package/lib/commonjs/components/Divider/index.js +20 -0
- package/lib/commonjs/components/Drawer/Drawer.js +344 -0
- package/lib/commonjs/components/Drawer/index.js +20 -0
- package/lib/commonjs/components/EmptyState/EmptyState.js +201 -0
- package/lib/commonjs/components/EmptyState/index.js +20 -0
- package/lib/commonjs/components/FAB/FAB.js +457 -0
- package/lib/commonjs/components/FAB/index.js +26 -0
- package/lib/commonjs/components/Field/Field.js +127 -0
- package/lib/commonjs/components/Field/index.js +20 -0
- package/lib/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.js +81 -0
- package/lib/commonjs/components/ForceUpdateDialog/index.js +20 -0
- package/lib/commonjs/components/Header/Header.js +339 -0
- package/lib/commonjs/components/Header/index.js +20 -0
- package/lib/commonjs/components/Icon/Icon.js +120 -0
- package/lib/commonjs/components/Icon/index.js +20 -0
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +463 -0
- package/lib/commonjs/components/ImageGallery/index.js +20 -0
- package/lib/commonjs/components/Input/Input.js +390 -0
- package/lib/commonjs/components/Input/index.js +20 -0
- package/lib/commonjs/components/ListItem/ListItem.js +241 -0
- package/lib/commonjs/components/ListItem/index.js +20 -0
- package/lib/commonjs/components/LoadingSpinner/LoadingSpinner.js +183 -0
- package/lib/commonjs/components/LoadingSpinner/index.js +20 -0
- package/lib/commonjs/components/Modal/Modal.js +239 -0
- package/lib/commonjs/components/Modal/index.js +20 -0
- package/lib/commonjs/components/NumberInput/NumberInput.js +392 -0
- package/lib/commonjs/components/NumberInput/index.js +20 -0
- package/lib/commonjs/components/OTPInput/OTPInput.js +375 -0
- package/lib/commonjs/components/OTPInput/index.js +20 -0
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +149 -0
- package/lib/commonjs/components/ProgressBar/index.js +20 -0
- package/lib/commonjs/components/Radio/Radio.js +160 -0
- package/lib/commonjs/components/Radio/RadioGroup.js +43 -0
- package/lib/commonjs/components/Radio/index.js +39 -0
- package/lib/commonjs/components/Rating/Rating.js +236 -0
- package/lib/commonjs/components/Rating/index.js +20 -0
- package/lib/commonjs/components/SearchBar/SearchBar.js +274 -0
- package/lib/commonjs/components/SearchBar/index.js +20 -0
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +184 -0
- package/lib/commonjs/components/SegmentedControl/index.js +20 -0
- package/lib/commonjs/components/Select/Select.js +540 -0
- package/lib/commonjs/components/Select/index.js +20 -0
- package/lib/commonjs/components/SkeletonLoader/SkeletonContent.js +191 -0
- package/lib/commonjs/components/SkeletonLoader/SkeletonLoader.js +311 -0
- package/lib/commonjs/components/SkeletonLoader/index.js +57 -0
- package/lib/commonjs/components/Slider/Slider.js +443 -0
- package/lib/commonjs/components/Slider/index.js +20 -0
- package/lib/commonjs/components/Stepper/Stepper.js +403 -0
- package/lib/commonjs/components/Stepper/index.js +20 -0
- package/lib/commonjs/components/Swipeable/Swipeable.js +349 -0
- package/lib/commonjs/components/Swipeable/index.js +20 -0
- package/lib/commonjs/components/Switch/Switch.js +173 -0
- package/lib/commonjs/components/Switch/index.js +20 -0
- package/lib/commonjs/components/Tabs/Tabs.js +204 -0
- package/lib/commonjs/components/Tabs/index.js +20 -0
- package/lib/commonjs/components/TimePicker/TimePicker.js +551 -0
- package/lib/commonjs/components/TimePicker/index.js +20 -0
- package/lib/commonjs/components/Toast/Toast.js +273 -0
- package/lib/commonjs/components/Toast/ToastProvider.js +195 -0
- package/lib/commonjs/components/Toast/index.js +39 -0
- package/lib/commonjs/components/Tooltip/Tooltip.js +363 -0
- package/lib/commonjs/components/Tooltip/index.js +20 -0
- package/lib/commonjs/components/index.js +392 -0
- package/lib/commonjs/config/index.js +63 -0
- package/lib/commonjs/formatters/currency.js +61 -0
- package/lib/commonjs/formatters/date.js +156 -0
- package/lib/commonjs/formatters/index.js +77 -0
- package/lib/commonjs/formatters/initials.js +28 -0
- package/lib/commonjs/formatters/number.js +76 -0
- package/lib/commonjs/formatters/phone.js +59 -0
- package/lib/commonjs/hooks/index.js +27 -0
- package/lib/commonjs/hooks/useDebounce.js +17 -0
- package/lib/commonjs/hooks/usePressAnimation.js +44 -0
- package/lib/commonjs/hooks/useToggle.js +22 -0
- package/lib/commonjs/index.js +628 -0
- package/lib/commonjs/initSDK.js +47 -0
- package/lib/commonjs/initUI.js +24 -0
- package/lib/commonjs/initUserAuth.js +40 -0
- package/lib/commonjs/logger/index.js +127 -0
- package/lib/commonjs/network/NetworkStatusBanner.js +89 -0
- package/lib/commonjs/network/index.js +32 -0
- package/lib/commonjs/network/networkStatus.js +88 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/permissions/index.js +180 -0
- package/lib/commonjs/storage/index.js +187 -0
- package/lib/commonjs/theme/ThemeContext.js +73 -0
- package/lib/commonjs/theme/index.js +93 -0
- package/lib/commonjs/theme/merge.js +30 -0
- package/lib/commonjs/theme/tokens.js +319 -0
- package/lib/commonjs/theme/types.js +6 -0
- package/lib/commonjs/types/vector-icons.d.js +2 -0
- package/lib/commonjs/utils/dimensions.js +31 -0
- package/lib/commonjs/utils/hapticUtils.js +57 -0
- package/lib/commonjs/utils/imageCompression.js +51 -0
- package/lib/commonjs/utils/index.js +83 -0
- package/lib/commonjs/utils/responsive.js +48 -0
- package/lib/commonjs/utils/shadows.js +12 -0
- package/lib/commonjs/utils/spacing.js +86 -0
- package/lib/commonjs/validators/index.js +165 -0
- package/lib/commonjs/versionCheck/index.js +338 -0
- package/lib/module/api/publicClient.js +69 -0
- package/lib/module/api/userClient.js +283 -0
- package/lib/module/auth/authStore.js +100 -0
- package/lib/module/auth/index.js +5 -0
- package/lib/module/auth/jwt.js +78 -0
- package/lib/module/components/Accordion/Accordion.js +251 -0
- package/lib/module/components/Accordion/index.js +4 -0
- package/lib/module/components/Avatar/Avatar.js +278 -0
- package/lib/module/components/Avatar/index.js +4 -0
- package/lib/module/components/Badge/Badge.js +208 -0
- package/lib/module/components/Badge/index.js +4 -0
- package/lib/module/components/Banner/Banner.js +272 -0
- package/lib/module/components/Banner/index.js +4 -0
- package/lib/module/components/BottomNavigation/BottomNavigation.js +284 -0
- package/lib/module/components/BottomNavigation/index.js +4 -0
- package/lib/module/components/BottomSheet/BottomSheet.js +363 -0
- package/lib/module/components/BottomSheet/index.js +4 -0
- package/lib/module/components/Button/Button.js +277 -0
- package/lib/module/components/Button/index.js +4 -0
- package/lib/module/components/Card/Card.js +190 -0
- package/lib/module/components/Card/index.js +4 -0
- package/lib/module/components/Carousel/Carousel.js +471 -0
- package/lib/module/components/Carousel/index.js +4 -0
- package/lib/module/components/Checkbox/Checkbox.js +161 -0
- package/lib/module/components/Checkbox/index.js +4 -0
- package/lib/module/components/Chip/Chip.js +268 -0
- package/lib/module/components/Chip/index.js +4 -0
- package/lib/module/components/DatePicker/DatePicker.js +808 -0
- package/lib/module/components/DatePicker/index.js +4 -0
- package/lib/module/components/DateRangePicker/DateRangePicker.js +618 -0
- package/lib/module/components/DateRangePicker/index.js +4 -0
- package/lib/module/components/Dialog/Dialog.js +210 -0
- package/lib/module/components/Dialog/index.js +4 -0
- package/lib/module/components/Divider/Divider.js +114 -0
- package/lib/module/components/Divider/index.js +4 -0
- package/lib/module/components/Drawer/Drawer.js +340 -0
- package/lib/module/components/Drawer/index.js +4 -0
- package/lib/module/components/EmptyState/EmptyState.js +197 -0
- package/lib/module/components/EmptyState/index.js +4 -0
- package/lib/module/components/FAB/FAB.js +452 -0
- package/lib/module/components/FAB/index.js +4 -0
- package/lib/module/components/Field/Field.js +123 -0
- package/lib/module/components/Field/index.js +4 -0
- package/lib/module/components/ForceUpdateDialog/ForceUpdateDialog.js +75 -0
- package/lib/module/components/ForceUpdateDialog/index.js +4 -0
- package/lib/module/components/Header/Header.js +335 -0
- package/lib/module/components/Header/index.js +4 -0
- package/lib/module/components/Icon/Icon.js +111 -0
- package/lib/module/components/Icon/index.js +4 -0
- package/lib/module/components/ImageGallery/ImageGallery.js +458 -0
- package/lib/module/components/ImageGallery/index.js +4 -0
- package/lib/module/components/Input/Input.js +384 -0
- package/lib/module/components/Input/index.js +4 -0
- package/lib/module/components/ListItem/ListItem.js +237 -0
- package/lib/module/components/ListItem/index.js +4 -0
- package/lib/module/components/LoadingSpinner/LoadingSpinner.js +179 -0
- package/lib/module/components/LoadingSpinner/index.js +4 -0
- package/lib/module/components/Modal/Modal.js +235 -0
- package/lib/module/components/Modal/index.js +4 -0
- package/lib/module/components/NumberInput/NumberInput.js +388 -0
- package/lib/module/components/NumberInput/index.js +4 -0
- package/lib/module/components/OTPInput/OTPInput.js +371 -0
- package/lib/module/components/OTPInput/index.js +4 -0
- package/lib/module/components/ProgressBar/ProgressBar.js +145 -0
- package/lib/module/components/ProgressBar/index.js +4 -0
- package/lib/module/components/Radio/Radio.js +155 -0
- package/lib/module/components/Radio/RadioGroup.js +38 -0
- package/lib/module/components/Radio/index.js +5 -0
- package/lib/module/components/Rating/Rating.js +232 -0
- package/lib/module/components/Rating/index.js +4 -0
- package/lib/module/components/SearchBar/SearchBar.js +270 -0
- package/lib/module/components/SearchBar/index.js +4 -0
- package/lib/module/components/SegmentedControl/SegmentedControl.js +180 -0
- package/lib/module/components/SegmentedControl/index.js +4 -0
- package/lib/module/components/Select/Select.js +536 -0
- package/lib/module/components/Select/index.js +4 -0
- package/lib/module/components/SkeletonLoader/SkeletonContent.js +186 -0
- package/lib/module/components/SkeletonLoader/SkeletonLoader.js +301 -0
- package/lib/module/components/SkeletonLoader/index.js +5 -0
- package/lib/module/components/Slider/Slider.js +439 -0
- package/lib/module/components/Slider/index.js +4 -0
- package/lib/module/components/Stepper/Stepper.js +399 -0
- package/lib/module/components/Stepper/index.js +4 -0
- package/lib/module/components/Swipeable/Swipeable.js +344 -0
- package/lib/module/components/Swipeable/index.js +4 -0
- package/lib/module/components/Switch/Switch.js +169 -0
- package/lib/module/components/Switch/index.js +4 -0
- package/lib/module/components/Tabs/Tabs.js +200 -0
- package/lib/module/components/Tabs/index.js +4 -0
- package/lib/module/components/TimePicker/TimePicker.js +545 -0
- package/lib/module/components/TimePicker/index.js +4 -0
- package/lib/module/components/Toast/Toast.js +268 -0
- package/lib/module/components/Toast/ToastProvider.js +187 -0
- package/lib/module/components/Toast/index.js +5 -0
- package/lib/module/components/Tooltip/Tooltip.js +358 -0
- package/lib/module/components/Tooltip/index.js +4 -0
- package/lib/module/components/index.js +47 -0
- package/lib/module/config/index.js +55 -0
- package/lib/module/formatters/currency.js +56 -0
- package/lib/module/formatters/date.js +148 -0
- package/lib/module/formatters/index.js +8 -0
- package/lib/module/formatters/initials.js +23 -0
- package/lib/module/formatters/number.js +69 -0
- package/lib/module/formatters/phone.js +53 -0
- package/lib/module/hooks/index.js +6 -0
- package/lib/module/hooks/useDebounce.js +12 -0
- package/lib/module/hooks/usePressAnimation.js +39 -0
- package/lib/module/hooks/useToggle.js +17 -0
- package/lib/module/index.js +37 -0
- package/lib/module/initSDK.js +42 -0
- package/lib/module/initUI.js +19 -0
- package/lib/module/initUserAuth.js +36 -0
- package/lib/module/logger/index.js +123 -0
- package/lib/module/network/NetworkStatusBanner.js +83 -0
- package/lib/module/network/index.js +5 -0
- package/lib/module/network/networkStatus.js +81 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permissions/index.js +177 -0
- package/lib/module/storage/index.js +183 -0
- package/lib/module/theme/ThemeContext.js +65 -0
- package/lib/module/theme/index.js +48 -0
- package/lib/module/theme/merge.js +25 -0
- package/lib/module/theme/tokens.js +315 -0
- package/lib/module/theme/types.js +4 -0
- package/lib/module/types/vector-icons.d.js +2 -0
- package/lib/module/utils/dimensions.js +4 -0
- package/lib/module/utils/hapticUtils.js +51 -0
- package/lib/module/utils/imageCompression.js +46 -0
- package/lib/module/utils/index.js +8 -0
- package/lib/module/utils/responsive.js +42 -0
- package/lib/module/utils/shadows.js +7 -0
- package/lib/module/utils/spacing.js +82 -0
- package/lib/module/validators/index.js +143 -0
- package/lib/module/versionCheck/index.js +334 -0
- package/lib/typescript/commonjs/api/publicClient.d.ts +11 -0
- package/lib/typescript/commonjs/api/userClient.d.ts +18 -0
- package/lib/typescript/commonjs/auth/authStore.d.ts +20 -0
- package/lib/typescript/commonjs/auth/index.d.ts +5 -0
- package/lib/typescript/commonjs/auth/jwt.d.ts +31 -0
- package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +33 -0
- package/lib/typescript/commonjs/components/Accordion/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +42 -0
- package/lib/typescript/commonjs/components/Avatar/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +27 -0
- package/lib/typescript/commonjs/components/Badge/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +27 -0
- package/lib/typescript/commonjs/components/Banner/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +34 -0
- package/lib/typescript/commonjs/components/BottomNavigation/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +45 -0
- package/lib/typescript/commonjs/components/BottomSheet/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Button/Button.d.ts +29 -0
- package/lib/typescript/commonjs/components/Button/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Card/Card.d.ts +29 -0
- package/lib/typescript/commonjs/components/Card/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +66 -0
- package/lib/typescript/commonjs/components/Carousel/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +24 -0
- package/lib/typescript/commonjs/components/Checkbox/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +25 -0
- package/lib/typescript/commonjs/components/Chip/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +25 -0
- package/lib/typescript/commonjs/components/DatePicker/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +32 -0
- package/lib/typescript/commonjs/components/DateRangePicker/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +25 -0
- package/lib/typescript/commonjs/components/Dialog/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Divider/Divider.d.ts +21 -0
- package/lib/typescript/commonjs/components/Divider/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +53 -0
- package/lib/typescript/commonjs/components/Drawer/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +25 -0
- package/lib/typescript/commonjs/components/EmptyState/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/FAB/FAB.d.ts +53 -0
- package/lib/typescript/commonjs/components/FAB/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Field/Field.d.ts +28 -0
- package/lib/typescript/commonjs/components/Field/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +39 -0
- package/lib/typescript/commonjs/components/ForceUpdateDialog/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Header/Header.d.ts +36 -0
- package/lib/typescript/commonjs/components/Header/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Icon/Icon.d.ts +20 -0
- package/lib/typescript/commonjs/components/Icon/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +41 -0
- package/lib/typescript/commonjs/components/ImageGallery/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Input/Input.d.ts +34 -0
- package/lib/typescript/commonjs/components/Input/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +30 -0
- package/lib/typescript/commonjs/components/ListItem/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/LoadingSpinner/LoadingSpinner.d.ts +20 -0
- package/lib/typescript/commonjs/components/LoadingSpinner/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +29 -0
- package/lib/typescript/commonjs/components/Modal/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +35 -0
- package/lib/typescript/commonjs/components/NumberInput/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +29 -0
- package/lib/typescript/commonjs/components/OTPInput/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +21 -0
- package/lib/typescript/commonjs/components/ProgressBar/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +32 -0
- package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +16 -0
- package/lib/typescript/commonjs/components/Radio/index.d.ts +5 -0
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +22 -0
- package/lib/typescript/commonjs/components/Rating/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +28 -0
- package/lib/typescript/commonjs/components/SearchBar/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +36 -0
- package/lib/typescript/commonjs/components/SegmentedControl/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Select/Select.d.ts +48 -0
- package/lib/typescript/commonjs/components/Select/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/SkeletonLoader/SkeletonContent.d.ts +29 -0
- package/lib/typescript/commonjs/components/SkeletonLoader/SkeletonLoader.d.ts +42 -0
- package/lib/typescript/commonjs/components/SkeletonLoader/index.d.ts +5 -0
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +33 -0
- package/lib/typescript/commonjs/components/Slider/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +25 -0
- package/lib/typescript/commonjs/components/Stepper/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +45 -0
- package/lib/typescript/commonjs/components/Swipeable/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +24 -0
- package/lib/typescript/commonjs/components/Switch/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +37 -0
- package/lib/typescript/commonjs/components/Tabs/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +26 -0
- package/lib/typescript/commonjs/components/TimePicker/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Toast/Toast.d.ts +30 -0
- package/lib/typescript/commonjs/components/Toast/ToastProvider.d.ts +26 -0
- package/lib/typescript/commonjs/components/Toast/index.d.ts +5 -0
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +22 -0
- package/lib/typescript/commonjs/components/Tooltip/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/index.d.ts +89 -0
- package/lib/typescript/commonjs/config/index.d.ts +40 -0
- package/lib/typescript/commonjs/formatters/currency.d.ts +24 -0
- package/lib/typescript/commonjs/formatters/date.d.ts +22 -0
- package/lib/typescript/commonjs/formatters/index.d.ts +8 -0
- package/lib/typescript/commonjs/formatters/initials.d.ts +11 -0
- package/lib/typescript/commonjs/formatters/number.d.ts +15 -0
- package/lib/typescript/commonjs/formatters/phone.d.ts +13 -0
- package/lib/typescript/commonjs/hooks/index.d.ts +6 -0
- package/lib/typescript/commonjs/hooks/useDebounce.d.ts +2 -0
- package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +14 -0
- package/lib/typescript/commonjs/hooks/useToggle.d.ts +9 -0
- package/lib/typescript/commonjs/index.d.ts +37 -0
- package/lib/typescript/commonjs/initSDK.d.ts +40 -0
- package/lib/typescript/commonjs/initUI.d.ts +12 -0
- package/lib/typescript/commonjs/initUserAuth.d.ts +22 -0
- package/lib/typescript/commonjs/logger/index.d.ts +42 -0
- package/lib/typescript/commonjs/network/NetworkStatusBanner.d.ts +19 -0
- package/lib/typescript/commonjs/network/index.d.ts +5 -0
- package/lib/typescript/commonjs/network/networkStatus.d.ts +27 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/permissions/index.d.ts +20 -0
- package/lib/typescript/commonjs/storage/index.d.ts +42 -0
- package/lib/typescript/commonjs/theme/ThemeContext.d.ts +18 -0
- package/lib/typescript/commonjs/theme/index.d.ts +13 -0
- package/lib/typescript/commonjs/theme/merge.d.ts +3 -0
- package/lib/typescript/commonjs/theme/tokens.d.ts +4 -0
- package/lib/typescript/commonjs/theme/types.d.ts +161 -0
- package/lib/typescript/commonjs/utils/dimensions.d.ts +3 -0
- package/lib/typescript/commonjs/utils/hapticUtils.d.ts +4 -0
- package/lib/typescript/commonjs/utils/imageCompression.d.ts +15 -0
- package/lib/typescript/commonjs/utils/index.d.ts +10 -0
- package/lib/typescript/commonjs/utils/responsive.d.ts +23 -0
- package/lib/typescript/commonjs/utils/shadows.d.ts +4 -0
- package/lib/typescript/commonjs/utils/spacing.d.ts +61 -0
- package/lib/typescript/commonjs/validators/index.d.ts +46 -0
- package/lib/typescript/commonjs/versionCheck/index.d.ts +59 -0
- package/lib/typescript/module/api/publicClient.d.ts +11 -0
- package/lib/typescript/module/api/userClient.d.ts +18 -0
- package/lib/typescript/module/auth/authStore.d.ts +20 -0
- package/lib/typescript/module/auth/index.d.ts +5 -0
- package/lib/typescript/module/auth/jwt.d.ts +31 -0
- package/lib/typescript/module/components/Accordion/Accordion.d.ts +33 -0
- package/lib/typescript/module/components/Accordion/index.d.ts +3 -0
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +42 -0
- package/lib/typescript/module/components/Avatar/index.d.ts +3 -0
- package/lib/typescript/module/components/Badge/Badge.d.ts +27 -0
- package/lib/typescript/module/components/Badge/index.d.ts +3 -0
- package/lib/typescript/module/components/Banner/Banner.d.ts +27 -0
- package/lib/typescript/module/components/Banner/index.d.ts +3 -0
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +34 -0
- package/lib/typescript/module/components/BottomNavigation/index.d.ts +3 -0
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +45 -0
- package/lib/typescript/module/components/BottomSheet/index.d.ts +3 -0
- package/lib/typescript/module/components/Button/Button.d.ts +29 -0
- package/lib/typescript/module/components/Button/index.d.ts +3 -0
- package/lib/typescript/module/components/Card/Card.d.ts +29 -0
- package/lib/typescript/module/components/Card/index.d.ts +3 -0
- package/lib/typescript/module/components/Carousel/Carousel.d.ts +66 -0
- package/lib/typescript/module/components/Carousel/index.d.ts +3 -0
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +24 -0
- package/lib/typescript/module/components/Checkbox/index.d.ts +3 -0
- package/lib/typescript/module/components/Chip/Chip.d.ts +25 -0
- package/lib/typescript/module/components/Chip/index.d.ts +3 -0
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +25 -0
- package/lib/typescript/module/components/DatePicker/index.d.ts +3 -0
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +32 -0
- package/lib/typescript/module/components/DateRangePicker/index.d.ts +3 -0
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +25 -0
- package/lib/typescript/module/components/Dialog/index.d.ts +3 -0
- package/lib/typescript/module/components/Divider/Divider.d.ts +21 -0
- package/lib/typescript/module/components/Divider/index.d.ts +3 -0
- package/lib/typescript/module/components/Drawer/Drawer.d.ts +53 -0
- package/lib/typescript/module/components/Drawer/index.d.ts +3 -0
- package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +25 -0
- package/lib/typescript/module/components/EmptyState/index.d.ts +3 -0
- package/lib/typescript/module/components/FAB/FAB.d.ts +53 -0
- package/lib/typescript/module/components/FAB/index.d.ts +3 -0
- package/lib/typescript/module/components/Field/Field.d.ts +28 -0
- package/lib/typescript/module/components/Field/index.d.ts +3 -0
- package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +39 -0
- package/lib/typescript/module/components/ForceUpdateDialog/index.d.ts +3 -0
- package/lib/typescript/module/components/Header/Header.d.ts +36 -0
- package/lib/typescript/module/components/Header/index.d.ts +3 -0
- package/lib/typescript/module/components/Icon/Icon.d.ts +20 -0
- package/lib/typescript/module/components/Icon/index.d.ts +3 -0
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +41 -0
- package/lib/typescript/module/components/ImageGallery/index.d.ts +3 -0
- package/lib/typescript/module/components/Input/Input.d.ts +34 -0
- package/lib/typescript/module/components/Input/index.d.ts +3 -0
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +30 -0
- package/lib/typescript/module/components/ListItem/index.d.ts +4 -0
- package/lib/typescript/module/components/LoadingSpinner/LoadingSpinner.d.ts +20 -0
- package/lib/typescript/module/components/LoadingSpinner/index.d.ts +3 -0
- package/lib/typescript/module/components/Modal/Modal.d.ts +29 -0
- package/lib/typescript/module/components/Modal/index.d.ts +3 -0
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +35 -0
- package/lib/typescript/module/components/NumberInput/index.d.ts +3 -0
- package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +29 -0
- package/lib/typescript/module/components/OTPInput/index.d.ts +3 -0
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +21 -0
- package/lib/typescript/module/components/ProgressBar/index.d.ts +3 -0
- package/lib/typescript/module/components/Radio/Radio.d.ts +32 -0
- package/lib/typescript/module/components/Radio/RadioGroup.d.ts +16 -0
- package/lib/typescript/module/components/Radio/index.d.ts +5 -0
- package/lib/typescript/module/components/Rating/Rating.d.ts +22 -0
- package/lib/typescript/module/components/Rating/index.d.ts +3 -0
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +28 -0
- package/lib/typescript/module/components/SearchBar/index.d.ts +3 -0
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +36 -0
- package/lib/typescript/module/components/SegmentedControl/index.d.ts +3 -0
- package/lib/typescript/module/components/Select/Select.d.ts +48 -0
- package/lib/typescript/module/components/Select/index.d.ts +3 -0
- package/lib/typescript/module/components/SkeletonLoader/SkeletonContent.d.ts +29 -0
- package/lib/typescript/module/components/SkeletonLoader/SkeletonLoader.d.ts +42 -0
- package/lib/typescript/module/components/SkeletonLoader/index.d.ts +5 -0
- package/lib/typescript/module/components/Slider/Slider.d.ts +33 -0
- package/lib/typescript/module/components/Slider/index.d.ts +3 -0
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +25 -0
- package/lib/typescript/module/components/Stepper/index.d.ts +3 -0
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +45 -0
- package/lib/typescript/module/components/Swipeable/index.d.ts +3 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +24 -0
- package/lib/typescript/module/components/Switch/index.d.ts +3 -0
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +37 -0
- package/lib/typescript/module/components/Tabs/index.d.ts +3 -0
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +26 -0
- package/lib/typescript/module/components/TimePicker/index.d.ts +3 -0
- package/lib/typescript/module/components/Toast/Toast.d.ts +30 -0
- package/lib/typescript/module/components/Toast/ToastProvider.d.ts +26 -0
- package/lib/typescript/module/components/Toast/index.d.ts +5 -0
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +22 -0
- package/lib/typescript/module/components/Tooltip/index.d.ts +3 -0
- package/lib/typescript/module/components/index.d.ts +89 -0
- package/lib/typescript/module/config/index.d.ts +40 -0
- package/lib/typescript/module/formatters/currency.d.ts +24 -0
- package/lib/typescript/module/formatters/date.d.ts +22 -0
- package/lib/typescript/module/formatters/index.d.ts +8 -0
- package/lib/typescript/module/formatters/initials.d.ts +11 -0
- package/lib/typescript/module/formatters/number.d.ts +15 -0
- package/lib/typescript/module/formatters/phone.d.ts +13 -0
- package/lib/typescript/module/hooks/index.d.ts +6 -0
- package/lib/typescript/module/hooks/useDebounce.d.ts +2 -0
- package/lib/typescript/module/hooks/usePressAnimation.d.ts +14 -0
- package/lib/typescript/module/hooks/useToggle.d.ts +9 -0
- package/lib/typescript/module/index.d.ts +37 -0
- package/lib/typescript/module/initSDK.d.ts +40 -0
- package/lib/typescript/module/initUI.d.ts +12 -0
- package/lib/typescript/module/initUserAuth.d.ts +22 -0
- package/lib/typescript/module/logger/index.d.ts +42 -0
- package/lib/typescript/module/network/NetworkStatusBanner.d.ts +19 -0
- package/lib/typescript/module/network/index.d.ts +5 -0
- package/lib/typescript/module/network/networkStatus.d.ts +27 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/permissions/index.d.ts +20 -0
- package/lib/typescript/module/storage/index.d.ts +42 -0
- package/lib/typescript/module/theme/ThemeContext.d.ts +18 -0
- package/lib/typescript/module/theme/index.d.ts +13 -0
- package/lib/typescript/module/theme/merge.d.ts +3 -0
- package/lib/typescript/module/theme/tokens.d.ts +4 -0
- package/lib/typescript/module/theme/types.d.ts +161 -0
- package/lib/typescript/module/utils/dimensions.d.ts +3 -0
- package/lib/typescript/module/utils/hapticUtils.d.ts +4 -0
- package/lib/typescript/module/utils/imageCompression.d.ts +15 -0
- package/lib/typescript/module/utils/index.d.ts +10 -0
- package/lib/typescript/module/utils/responsive.d.ts +23 -0
- package/lib/typescript/module/utils/shadows.d.ts +4 -0
- package/lib/typescript/module/utils/spacing.d.ts +61 -0
- package/lib/typescript/module/validators/index.d.ts +46 -0
- package/lib/typescript/module/versionCheck/index.d.ts +59 -0
- package/package.json +137 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useVersionCheck = exports.default = exports.VersionCheck = void 0;
|
|
7
|
+
var _reactNativeDeviceInfo = require("react-native-device-info");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _index = require("../config/index.js");
|
|
10
|
+
var _index2 = require("../logger/index.js");
|
|
11
|
+
// Constants
|
|
12
|
+
const MAX_RETRIES = 3;
|
|
13
|
+
const RETRY_DELAY = 3000; // 3 seconds
|
|
14
|
+
|
|
15
|
+
const getCountry = () => (0, _index.getConfigValue)('country', 'in').toLowerCase();
|
|
16
|
+
// Utility function to parse and coerce version to a valid format
|
|
17
|
+
const parseVersion = version => {
|
|
18
|
+
_index2.Logger.info(`Parsing version: ${version}`);
|
|
19
|
+
const coercedVersion = version.replace(/[^0-9.]/g, '');
|
|
20
|
+
const versionParts = coercedVersion.split('.').map(Number);
|
|
21
|
+
return {
|
|
22
|
+
major: versionParts[0] || 0,
|
|
23
|
+
minor: versionParts[1] || 0,
|
|
24
|
+
patch: versionParts[2] || 0,
|
|
25
|
+
prerelease: version.includes('-') ? version.split('-')[1] ?? '' : ''
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Utility function to compare two versions loosely
|
|
30
|
+
const diffLoose = (version1, version2) => {
|
|
31
|
+
_index2.Logger.info(`Comparing versions: ${version1} and ${version2}`);
|
|
32
|
+
if (version1 === version2) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const v1 = parseVersion(version1);
|
|
36
|
+
const v2 = parseVersion(version2);
|
|
37
|
+
if (v1.major < v2.major) {
|
|
38
|
+
return 'major';
|
|
39
|
+
}
|
|
40
|
+
if (v1.major > v2.major) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (v1.minor < v2.minor) {
|
|
44
|
+
return 'minor';
|
|
45
|
+
}
|
|
46
|
+
if (v1.minor > v2.minor) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (v1.patch < v2.patch) {
|
|
50
|
+
return 'patch';
|
|
51
|
+
}
|
|
52
|
+
if (v1.patch > v2.patch) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (v1.prerelease && !v2.prerelease) {
|
|
56
|
+
return 'prerelease';
|
|
57
|
+
}
|
|
58
|
+
if (!v1.prerelease && v2.prerelease) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (v1.prerelease < v2.prerelease) {
|
|
62
|
+
return 'prerelease';
|
|
63
|
+
}
|
|
64
|
+
if (v1.prerelease > v2.prerelease) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Function to compare current version with the latest version
|
|
71
|
+
const versionCompare = (currentVersion, latestVersion) => {
|
|
72
|
+
_index2.Logger.info(`Comparing current version: ${currentVersion} with latest version: ${latestVersion}`);
|
|
73
|
+
if (!latestVersion) {
|
|
74
|
+
return {
|
|
75
|
+
needsUpdate: false,
|
|
76
|
+
updateType: null,
|
|
77
|
+
notice: 'Error: could not get latest version'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const updateType = diffLoose(currentVersion, latestVersion);
|
|
82
|
+
return {
|
|
83
|
+
needsUpdate: !!updateType,
|
|
84
|
+
updateType
|
|
85
|
+
};
|
|
86
|
+
} catch (e) {
|
|
87
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
88
|
+
_index2.Logger.error(`Error comparing versions: ${message}`);
|
|
89
|
+
const needsUpdate = currentVersion !== latestVersion && latestVersion > currentVersion;
|
|
90
|
+
const updateType = needsUpdate ? 'minor' : null;
|
|
91
|
+
return {
|
|
92
|
+
needsUpdate,
|
|
93
|
+
updateType,
|
|
94
|
+
notice: message.replace(/^Invalid Version:/, 'Not a valid version:')
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Function to fetch version details from Google Play Store
|
|
100
|
+
const fetchAndroidVersion = async url => {
|
|
101
|
+
_index2.Logger.info(`Fetching Android version from URL: ${url}`);
|
|
102
|
+
let response;
|
|
103
|
+
try {
|
|
104
|
+
response = await fetch(url, {
|
|
105
|
+
headers: {
|
|
106
|
+
'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36',
|
|
107
|
+
'sec-fetch-site': 'same-origin'
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
} catch (error) {
|
|
111
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
112
|
+
_index2.Logger.error(`Error fetching data from Google Play Store: ${message}`);
|
|
113
|
+
throw new Error('Error fetching data from Google Play Store.');
|
|
114
|
+
}
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
if (response.status === 404) {
|
|
117
|
+
_index2.Logger.error('App with app ID not found in Google Play.');
|
|
118
|
+
throw new Error(`App with app ID not found in Google Play.`);
|
|
119
|
+
}
|
|
120
|
+
_index2.Logger.error(`Error fetching data: ${response.statusText}`);
|
|
121
|
+
throw new Error(response.statusText);
|
|
122
|
+
}
|
|
123
|
+
const text = await response.text();
|
|
124
|
+
|
|
125
|
+
// Primary regex pattern for current Play Store format
|
|
126
|
+
let versionMatch = text.match(/\[\[\[['"]((\d+\.)+\d+)['"]\]\],/);
|
|
127
|
+
|
|
128
|
+
// Alternate patterns as fallbacks
|
|
129
|
+
if (!versionMatch) {
|
|
130
|
+
// Fallback 1: Look for version in "current version" text
|
|
131
|
+
versionMatch = text.match(/Current Version[^\d]+((\d+\.)+\d+)/i);
|
|
132
|
+
}
|
|
133
|
+
if (!versionMatch) {
|
|
134
|
+
// Fallback 2: Look for itemprop="softwareVersion"
|
|
135
|
+
versionMatch = text.match(/itemprop="softwareVersion"[^>]*>((\d+\.)+\d+)</i);
|
|
136
|
+
}
|
|
137
|
+
if (!versionMatch) {
|
|
138
|
+
// Fallback 3: Try a more generic pattern for version numbers
|
|
139
|
+
const allVersions = text.match(/(\d+\.\d+(\.\d+)?)/g);
|
|
140
|
+
// If we found multiple version-like strings, use the first one
|
|
141
|
+
versionMatch = allVersions && allVersions.length > 0 ? [null, allVersions[0]] : null;
|
|
142
|
+
}
|
|
143
|
+
const version = versionMatch ? versionMatch[1] ?? null : null;
|
|
144
|
+
if (!version) {
|
|
145
|
+
_index2.Logger.warn('Could not extract version from Play Store. Using fallback method.');
|
|
146
|
+
}
|
|
147
|
+
const notesMatch = text.match(/<div itemprop="description">(.*?)<\/div>/);
|
|
148
|
+
const notes = notesMatch ? notesMatch[1] ?? '' : '';
|
|
149
|
+
return {
|
|
150
|
+
version,
|
|
151
|
+
releasedAt: new Date().toISOString(),
|
|
152
|
+
notes,
|
|
153
|
+
url,
|
|
154
|
+
lastChecked: new Date().toISOString()
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
// Function to fetch version details from Apple App Store
|
|
158
|
+
const fetchIosVersion = async url => {
|
|
159
|
+
_index2.Logger.info(`Fetching iOS version from URL: ${url}`);
|
|
160
|
+
let response;
|
|
161
|
+
try {
|
|
162
|
+
response = await fetch(url);
|
|
163
|
+
} catch {
|
|
164
|
+
_index2.Logger.error('Error connecting to iTunes.');
|
|
165
|
+
throw new Error('Error connecting to iTunes.');
|
|
166
|
+
}
|
|
167
|
+
const data = await response.json();
|
|
168
|
+
if (!data || !('results' in data)) {
|
|
169
|
+
_index2.Logger.error('Unknown error connecting to iTunes.');
|
|
170
|
+
throw new Error('Unknown error connecting to iTunes.');
|
|
171
|
+
}
|
|
172
|
+
if (!data.results.length) {
|
|
173
|
+
_index2.Logger.error('App for this bundle ID not found.');
|
|
174
|
+
throw new Error('App for this bundle ID not found.');
|
|
175
|
+
}
|
|
176
|
+
const result = data.results[0];
|
|
177
|
+
return {
|
|
178
|
+
version: result.version || null,
|
|
179
|
+
released: result.currentVersionReleaseDate || result.releaseDate || null,
|
|
180
|
+
notes: result.releaseNotes || '',
|
|
181
|
+
url: result.trackViewUrl || result.artistViewUrl || result.sellerUrl || null,
|
|
182
|
+
country: getCountry(),
|
|
183
|
+
lastChecked: new Date().toISOString()
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// Function to lookup version based on platform
|
|
188
|
+
const lookupVersion = async (platform, identifier) => {
|
|
189
|
+
_index2.Logger.info(`Looking up version for platform: ${platform}, identifier: ${identifier}`);
|
|
190
|
+
const country = getCountry();
|
|
191
|
+
const url = platform === 'ios' ? `https://itunes.apple.com/lookup?bundleId=${identifier}&country=${country}&_=${new Date().valueOf()}` : `https://play.google.com/store/apps/details?id=${identifier}&hl=${country}`;
|
|
192
|
+
return platform === 'ios' ? fetchIosVersion(url) : fetchAndroidVersion(url);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Check for new version with retry logic
|
|
197
|
+
*/
|
|
198
|
+
const checkForUpdates = async () => {
|
|
199
|
+
const platform = (0, _reactNativeDeviceInfo.getSystemName)().toLowerCase();
|
|
200
|
+
const identifier = (0, _reactNativeDeviceInfo.getBundleId)();
|
|
201
|
+
const currentVersion = (0, _reactNativeDeviceInfo.getVersion)();
|
|
202
|
+
|
|
203
|
+
// Implement retry mechanism
|
|
204
|
+
let retryCount = 0;
|
|
205
|
+
let lastError = null;
|
|
206
|
+
while (retryCount <= MAX_RETRIES) {
|
|
207
|
+
try {
|
|
208
|
+
_index2.Logger.info(`Checking if new version is available (attempt ${retryCount + 1}/${MAX_RETRIES + 1})`);
|
|
209
|
+
_index2.Logger.info(`Platform: ${platform}, identifier: ${identifier}, current version: ${currentVersion}`);
|
|
210
|
+
const latestVersionInfo = await lookupVersion(platform, identifier);
|
|
211
|
+
const comparison = versionCompare(currentVersion, latestVersionInfo.version);
|
|
212
|
+
return {
|
|
213
|
+
isNewVersionAvailable: comparison.needsUpdate,
|
|
214
|
+
updateType: comparison.updateType,
|
|
215
|
+
url: latestVersionInfo.url
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
lastError = error;
|
|
219
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
220
|
+
_index2.Logger.error(`Error checking version (attempt ${retryCount + 1}/${MAX_RETRIES + 1}): ${message}`);
|
|
221
|
+
|
|
222
|
+
// If we've reached max retries, throw the last error
|
|
223
|
+
if (retryCount === MAX_RETRIES) {
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Otherwise, wait and retry
|
|
228
|
+
retryCount++;
|
|
229
|
+
_index2.Logger.info(`Retrying version check in ${RETRY_DELAY}ms...`);
|
|
230
|
+
await new Promise(resolve => setTimeout(resolve, RETRY_DELAY));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// This should never be reached due to the throw above, but just in case
|
|
235
|
+
throw lastError instanceof Error ? lastError : new Error('Failed to check for updates after multiple attempts');
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Get fallback store URL based on platform
|
|
240
|
+
*/
|
|
241
|
+
const getFallbackStoreUrl = () => {
|
|
242
|
+
const platform = (0, _reactNativeDeviceInfo.getSystemName)().toLowerCase();
|
|
243
|
+
const bundleId = (0, _reactNativeDeviceInfo.getBundleId)();
|
|
244
|
+
const country = getCountry();
|
|
245
|
+
return platform === 'ios' ? `https://apps.apple.com/${country}/app/${bundleId}` : `https://play.google.com/store/apps/details?id=${bundleId}&hl=${country}`;
|
|
246
|
+
};
|
|
247
|
+
// Version check functionality
|
|
248
|
+
const VersionCheck = exports.VersionCheck = {
|
|
249
|
+
isNewVersionAvailable: async () => {
|
|
250
|
+
return checkForUpdates();
|
|
251
|
+
},
|
|
252
|
+
openUpdateUrl: async url => {
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
254
|
+
const {
|
|
255
|
+
Linking
|
|
256
|
+
} = require('react-native');
|
|
257
|
+
try {
|
|
258
|
+
if (url) {
|
|
259
|
+
_index2.Logger.info(`Opening app store URL: ${url}`);
|
|
260
|
+
await Linking.openURL(url);
|
|
261
|
+
} else {
|
|
262
|
+
const fallbackUrl = getFallbackStoreUrl();
|
|
263
|
+
_index2.Logger.info(`Opening fallback store URL: ${fallbackUrl}`);
|
|
264
|
+
await Linking.openURL(fallbackUrl);
|
|
265
|
+
}
|
|
266
|
+
return true;
|
|
267
|
+
} catch (error) {
|
|
268
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
269
|
+
_index2.Logger.error(`Failed to open store URL: ${message}`);
|
|
270
|
+
|
|
271
|
+
// Try with fallback URL if the original failed
|
|
272
|
+
try {
|
|
273
|
+
if (url) {
|
|
274
|
+
// Only try fallback if we were using a specific URL before
|
|
275
|
+
const fallbackUrl = getFallbackStoreUrl();
|
|
276
|
+
_index2.Logger.info(`Trying fallback store URL: ${fallbackUrl}`);
|
|
277
|
+
await Linking.openURL(fallbackUrl);
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
} catch (fallbackError) {
|
|
281
|
+
const fbMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
282
|
+
_index2.Logger.error(`Failed to open fallback URL: ${fbMessage}`);
|
|
283
|
+
}
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
getFallbackStoreUrl
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Custom hook to check for required app updates.
|
|
292
|
+
*
|
|
293
|
+
* @param isAppReady - Whether the app is ready to perform the check
|
|
294
|
+
* @param environment - The app environment (defaults to the one in config)
|
|
295
|
+
*/
|
|
296
|
+
const useVersionCheck = (isAppReady, environment = (0, _index.getConfigValue)('environment', 'Development')) => {
|
|
297
|
+
const [updateInfo, setUpdateInfo] = (0, _react.useState)({
|
|
298
|
+
isUpdateRequired: false,
|
|
299
|
+
updateUrl: null
|
|
300
|
+
});
|
|
301
|
+
(0, _react.useEffect)(() => {
|
|
302
|
+
let isMounted = true;
|
|
303
|
+
const checkVersion = async () => {
|
|
304
|
+
try {
|
|
305
|
+
// All retry logic is handled in the VersionCheck module
|
|
306
|
+
const {
|
|
307
|
+
isNewVersionAvailable,
|
|
308
|
+
url
|
|
309
|
+
} = await VersionCheck.isNewVersionAvailable();
|
|
310
|
+
if (isNewVersionAvailable && isMounted) {
|
|
311
|
+
_index2.Logger.info('Update required. URL:', url || 'Not available yet');
|
|
312
|
+
setUpdateInfo({
|
|
313
|
+
isUpdateRequired: true,
|
|
314
|
+
updateUrl: url
|
|
315
|
+
});
|
|
316
|
+
} else if (isMounted) {
|
|
317
|
+
_index2.Logger.info('App is up to date');
|
|
318
|
+
}
|
|
319
|
+
} catch (error) {
|
|
320
|
+
_index2.Logger.error('Error checking app version:', error);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// Only run version check in Production environment when app is ready
|
|
325
|
+
if (isAppReady && environment === 'Production') {
|
|
326
|
+
void checkVersion();
|
|
327
|
+
}
|
|
328
|
+
return () => {
|
|
329
|
+
isMounted = false;
|
|
330
|
+
};
|
|
331
|
+
}, [isAppReady, environment]);
|
|
332
|
+
return updateInfo;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// Export for backward compatibility
|
|
336
|
+
exports.useVersionCheck = useVersionCheck;
|
|
337
|
+
var _default = exports.default = VersionCheck;
|
|
338
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import axiosRetry from 'axios-retry';
|
|
5
|
+
import { getConfigValue } from "../config/index.js";
|
|
6
|
+
import { Logger } from "../logger/index.js";
|
|
7
|
+
|
|
8
|
+
// Define timeout for requests
|
|
9
|
+
const REQUEST_TIMEOUT = 30000; // 30 seconds
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Public Axios Client
|
|
13
|
+
* - Base URL: Set your public API base URL.
|
|
14
|
+
* - No Authorization header is attached.
|
|
15
|
+
* - Includes timeout configuration and error handling.
|
|
16
|
+
* - Handles specific HTTP status codes.
|
|
17
|
+
*/
|
|
18
|
+
const publicClient = axios.create({
|
|
19
|
+
baseURL: getConfigValue('baseUrl') ?? undefined,
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
Accept: 'application/json',
|
|
23
|
+
'Accept-Encoding': 'gzip, deflate, br'
|
|
24
|
+
},
|
|
25
|
+
timeout: REQUEST_TIMEOUT
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Configure axios-retry with modified exponential backoff
|
|
29
|
+
const retryConfig = {
|
|
30
|
+
retries: 3,
|
|
31
|
+
retryDelay: retryCount => retryCount === 0 ? 0 : Math.pow(2, retryCount) * 1000,
|
|
32
|
+
// Immediate retry for the first attempt
|
|
33
|
+
retryCondition: error => {
|
|
34
|
+
// Retry on network errors or specific status codes
|
|
35
|
+
return axiosRetry.isNetworkOrIdempotentRequestError(error) || [429, 503].includes(error.response?.status ?? 0);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
axiosRetry(publicClient, retryConfig);
|
|
39
|
+
|
|
40
|
+
// Add request interceptor for logging
|
|
41
|
+
publicClient.interceptors.request.use(config => {
|
|
42
|
+
Logger.info(`Request: ${config.method?.toUpperCase()} ${config.url}`);
|
|
43
|
+
return config;
|
|
44
|
+
}, error => {
|
|
45
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
46
|
+
Logger.error('Request error:', message);
|
|
47
|
+
return Promise.reject(error);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Add response interceptor for error handling
|
|
51
|
+
publicClient.interceptors.response.use(response => {
|
|
52
|
+
Logger.info(`Response: ${response.status} from ${response.config.url}`);
|
|
53
|
+
return response;
|
|
54
|
+
}, error => {
|
|
55
|
+
if (axios.isAxiosError(error)) {
|
|
56
|
+
const originalRequest = error.config;
|
|
57
|
+
if (!error.response) {
|
|
58
|
+
Logger.error(`Network error or no response from server: ${error.message}, URL: ${originalRequest?.url}`);
|
|
59
|
+
} else {
|
|
60
|
+
Logger.error(`Response error: ${error.response.data ?? error.message}, URL: ${originalRequest?.url}, Status: ${error.response.status}`);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
64
|
+
Logger.error(`Unknown response error: ${message}`);
|
|
65
|
+
}
|
|
66
|
+
return Promise.reject(error);
|
|
67
|
+
});
|
|
68
|
+
export default publicClient;
|
|
69
|
+
//# sourceMappingURL=publicClient.js.map
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import axios, { AxiosHeaders } from 'axios';
|
|
4
|
+
import axiosRetry, { isNetworkOrIdempotentRequestError } from 'axios-retry';
|
|
5
|
+
import { Logger } from "../logger/index.js";
|
|
6
|
+
import { getToken } from "../auth/authStore.js";
|
|
7
|
+
import { getConfigValue } from "../config/index.js";
|
|
8
|
+
// Define timeout for requests
|
|
9
|
+
const REQUEST_TIMEOUT = 30000; // 30 seconds
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Minimal Redux-store shape required by the user client to dispatch
|
|
13
|
+
* refresh-token / logout actions.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal extension of axios request config to track retry attempts.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const userClient = axios.create({
|
|
21
|
+
baseURL: getConfigValue('baseUrl') ?? undefined,
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
'Accept-Encoding': 'gzip, deflate, br'
|
|
25
|
+
},
|
|
26
|
+
timeout: REQUEST_TIMEOUT // Set timeout for all requests
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Configure axios-retry with modified exponential backoff
|
|
30
|
+
axiosRetry(userClient, {
|
|
31
|
+
retries: 3,
|
|
32
|
+
retryDelay: retryCount => retryCount === 0 ? 0 : Math.pow(2, retryCount) * 1000,
|
|
33
|
+
// Immediate retry for the first attempt
|
|
34
|
+
retryCondition: error => {
|
|
35
|
+
// Retry on network errors or specific status codes
|
|
36
|
+
const status = error.response?.status;
|
|
37
|
+
return isNetworkOrIdempotentRequestError(error) ||
|
|
38
|
+
// Use the named export
|
|
39
|
+
typeof status === 'number' && [429, 503].includes(status);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
let store;
|
|
43
|
+
let authActions = {
|
|
44
|
+
logout: () => undefined,
|
|
45
|
+
refreshToken: () => undefined
|
|
46
|
+
};
|
|
47
|
+
export const injectStore = _store => {
|
|
48
|
+
store = _store;
|
|
49
|
+
};
|
|
50
|
+
export const injectAuthActions = actions => {
|
|
51
|
+
authActions = {
|
|
52
|
+
...authActions,
|
|
53
|
+
...actions
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Single promise to track token refresh
|
|
58
|
+
let refreshTokenPromise = null;
|
|
59
|
+
|
|
60
|
+
// Queue for failed requests
|
|
61
|
+
let failedQueue = [];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Processes the queue of failed requests.
|
|
65
|
+
*/
|
|
66
|
+
const processQueue = (error, token = null) => {
|
|
67
|
+
failedQueue.forEach(({
|
|
68
|
+
resolve,
|
|
69
|
+
reject
|
|
70
|
+
}) => {
|
|
71
|
+
if (error) {
|
|
72
|
+
reject(error);
|
|
73
|
+
} else if (token !== null) {
|
|
74
|
+
resolve(token);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
failedQueue = [];
|
|
78
|
+
};
|
|
79
|
+
const getErrorMessage = error => {
|
|
80
|
+
if (error instanceof Error) {
|
|
81
|
+
return error.message;
|
|
82
|
+
}
|
|
83
|
+
if (typeof error === 'string') {
|
|
84
|
+
return error;
|
|
85
|
+
}
|
|
86
|
+
return 'Unknown error';
|
|
87
|
+
};
|
|
88
|
+
const setAuthHeader = (config, token) => {
|
|
89
|
+
if (config.headers instanceof AxiosHeaders) {
|
|
90
|
+
config.headers.set('Authorization', `Bearer ${token}`);
|
|
91
|
+
} else {
|
|
92
|
+
// Fallback in case headers were provided as a plain object.
|
|
93
|
+
config.headers = AxiosHeaders.from({
|
|
94
|
+
...config.headers,
|
|
95
|
+
Authorization: `Bearer ${token}`
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const requireStore = () => {
|
|
100
|
+
if (!store) {
|
|
101
|
+
throw new Error('User package store is not initialized. Call initUserAuth first.');
|
|
102
|
+
}
|
|
103
|
+
return store;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Attach Authorization Token Before Requests
|
|
108
|
+
*/
|
|
109
|
+
userClient.interceptors.request.use(async config => {
|
|
110
|
+
try {
|
|
111
|
+
// Skip token check for refresh token endpoint to prevent infinite loop
|
|
112
|
+
if (config.url?.includes('/Account/RefreshToken')) {
|
|
113
|
+
return config;
|
|
114
|
+
}
|
|
115
|
+
const token = await getToken('accessToken');
|
|
116
|
+
|
|
117
|
+
// Check if token exists
|
|
118
|
+
if (!token?.token) {
|
|
119
|
+
throw new Error('No access token available');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Check if token is expired
|
|
123
|
+
const currentTime = Date.now();
|
|
124
|
+
const tokenExpiry = Date.parse(token.expiry);
|
|
125
|
+
const bufferTime = 30 * 1000; // 30 seconds buffer
|
|
126
|
+
|
|
127
|
+
// If token is expired or about to expire, try to refresh it first
|
|
128
|
+
if (tokenExpiry <= currentTime + bufferTime) {
|
|
129
|
+
Logger.info('Access token expired or about to expire, refreshing before request');
|
|
130
|
+
|
|
131
|
+
// If we already have a refresh in progress, wait for it
|
|
132
|
+
if (refreshTokenPromise) {
|
|
133
|
+
Logger.info('Token refresh already in progress, waiting for completion');
|
|
134
|
+
try {
|
|
135
|
+
const newToken = await refreshTokenPromise;
|
|
136
|
+
setAuthHeader(config, newToken);
|
|
137
|
+
return config;
|
|
138
|
+
} catch (err) {
|
|
139
|
+
Logger.error('Failed to use refreshed token:', getErrorMessage(err));
|
|
140
|
+
throw err;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Start a new token refresh process
|
|
145
|
+
refreshTokenPromise = (async () => {
|
|
146
|
+
try {
|
|
147
|
+
const refreshToken = await getToken('refreshToken');
|
|
148
|
+
if (!refreshToken?.token) {
|
|
149
|
+
Logger.error('No refresh token available');
|
|
150
|
+
throw new Error('No refresh token available');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Check if refresh token is expired
|
|
154
|
+
const refreshTokenExpiry = Date.parse(refreshToken.expiry);
|
|
155
|
+
if (refreshTokenExpiry <= currentTime) {
|
|
156
|
+
Logger.error('Refresh token expired');
|
|
157
|
+
throw new Error('Refresh token expired');
|
|
158
|
+
}
|
|
159
|
+
Logger.info('Dispatching refresh token action');
|
|
160
|
+
const activeStore = requireStore();
|
|
161
|
+
const refreshResult = await activeStore.dispatch(authActions.refreshToken());
|
|
162
|
+
if (refreshResult.error) {
|
|
163
|
+
throw new Error(`Token refresh failed: ${refreshResult.error.message || 'Unknown error'}`);
|
|
164
|
+
}
|
|
165
|
+
const newAccessToken = await getToken('accessToken');
|
|
166
|
+
if (!newAccessToken?.token) {
|
|
167
|
+
throw new Error('Failed to retrieve new access token after refresh');
|
|
168
|
+
}
|
|
169
|
+
Logger.info('Token refreshed successfully before request');
|
|
170
|
+
return newAccessToken.token;
|
|
171
|
+
} catch (error) {
|
|
172
|
+
Logger.error('Token refresh failed before request:', getErrorMessage(error));
|
|
173
|
+
await requireStore().dispatch(authActions.logout());
|
|
174
|
+
throw error;
|
|
175
|
+
} finally {
|
|
176
|
+
refreshTokenPromise = null;
|
|
177
|
+
}
|
|
178
|
+
})();
|
|
179
|
+
try {
|
|
180
|
+
// Wait for the refresh to complete
|
|
181
|
+
const newToken = await refreshTokenPromise;
|
|
182
|
+
setAuthHeader(config, newToken);
|
|
183
|
+
return config;
|
|
184
|
+
} catch (err) {
|
|
185
|
+
return Promise.reject(err);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Token is valid, proceed with request
|
|
190
|
+
setAuthHeader(config, token.token);
|
|
191
|
+
return config;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
Logger.error('Failed to attach token:', getErrorMessage(error));
|
|
194
|
+
return Promise.reject(error);
|
|
195
|
+
}
|
|
196
|
+
}, error => {
|
|
197
|
+
Logger.error('Request error:', getErrorMessage(error));
|
|
198
|
+
return Promise.reject(error);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Handle Response & Token Refresh
|
|
203
|
+
*/
|
|
204
|
+
userClient.interceptors.response.use(response => response, async error => {
|
|
205
|
+
if (!axios.isAxiosError(error)) {
|
|
206
|
+
Logger.error(`Non-axios error in response interceptor: ${getErrorMessage(error)}`);
|
|
207
|
+
return Promise.reject(error);
|
|
208
|
+
}
|
|
209
|
+
const axiosError = error;
|
|
210
|
+
const originalRequest = axiosError.config;
|
|
211
|
+
if (!axiosError.response) {
|
|
212
|
+
Logger.error(`Network error or no response from server: ${axiosError.message}, URL: ${originalRequest?.url}`);
|
|
213
|
+
return Promise.reject(error);
|
|
214
|
+
}
|
|
215
|
+
if (axiosError.response.status === 401 && originalRequest && !originalRequest._retry) {
|
|
216
|
+
Logger.warn(`Unauthorized URL: ${originalRequest.url}`);
|
|
217
|
+
originalRequest._retry = true;
|
|
218
|
+
|
|
219
|
+
// If we already have a refresh in progress, queue this request
|
|
220
|
+
if (refreshTokenPromise) {
|
|
221
|
+
return new Promise((resolve, reject) => {
|
|
222
|
+
failedQueue.push({
|
|
223
|
+
resolve,
|
|
224
|
+
reject
|
|
225
|
+
});
|
|
226
|
+
}).then(token => {
|
|
227
|
+
Logger.info('Retrying request after token refresh:', originalRequest.url);
|
|
228
|
+
setAuthHeader(originalRequest, token);
|
|
229
|
+
return userClient(originalRequest);
|
|
230
|
+
}).catch(err => {
|
|
231
|
+
Logger.error('Failed to retry request after token refresh:', getErrorMessage(err));
|
|
232
|
+
return Promise.reject(err);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Start a new token refresh process and track it
|
|
237
|
+
refreshTokenPromise = (async () => {
|
|
238
|
+
try {
|
|
239
|
+
Logger.info('User Client: Refreshing token...');
|
|
240
|
+
const refreshToken = await getToken('refreshToken');
|
|
241
|
+
if (!refreshToken || !refreshToken.token) {
|
|
242
|
+
Logger.error('No refresh token available or token is invalid');
|
|
243
|
+
throw new Error('No refresh token available');
|
|
244
|
+
}
|
|
245
|
+
Logger.info('Dispatching refresh token action');
|
|
246
|
+
const activeStore = requireStore();
|
|
247
|
+
const refreshResult = await activeStore.dispatch(authActions.refreshToken());
|
|
248
|
+
if (refreshResult.error) {
|
|
249
|
+
Logger.error('Token refresh action failed:', refreshResult.error);
|
|
250
|
+
throw new Error(`Token refresh failed: ${refreshResult.error.message || 'Unknown error'}`);
|
|
251
|
+
}
|
|
252
|
+
Logger.info('Getting new access token after refresh');
|
|
253
|
+
const newAccessToken = await getToken('accessToken');
|
|
254
|
+
if (!newAccessToken?.token) {
|
|
255
|
+
throw new Error('Failed to retrieve new access token');
|
|
256
|
+
}
|
|
257
|
+
Logger.info('Token refreshed successfully');
|
|
258
|
+
processQueue(null, newAccessToken.token);
|
|
259
|
+
return newAccessToken.token;
|
|
260
|
+
} catch (refreshError) {
|
|
261
|
+
const responseData = axios.isAxiosError(refreshError) ? refreshError.response?.data : undefined;
|
|
262
|
+
Logger.error('Token refresh failed:', responseData ?? getErrorMessage(refreshError));
|
|
263
|
+
processQueue(refreshError, null);
|
|
264
|
+
await requireStore().dispatch(authActions.logout());
|
|
265
|
+
throw refreshError;
|
|
266
|
+
} finally {
|
|
267
|
+
refreshTokenPromise = null;
|
|
268
|
+
}
|
|
269
|
+
})();
|
|
270
|
+
try {
|
|
271
|
+
// Wait for the refresh token process to complete
|
|
272
|
+
const newToken = await refreshTokenPromise;
|
|
273
|
+
setAuthHeader(originalRequest, newToken);
|
|
274
|
+
return userClient(originalRequest);
|
|
275
|
+
} catch (err) {
|
|
276
|
+
return Promise.reject(err);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
Logger.error(`Response error: ${axiosError.response?.data ?? axiosError.message}, URL: ${originalRequest?.url}, Status: ${axiosError.response.status}`);
|
|
280
|
+
return Promise.reject(error);
|
|
281
|
+
});
|
|
282
|
+
export default userClient;
|
|
283
|
+
//# sourceMappingURL=userClient.js.map
|