@databiosphere/findable-ui 46.1.3 → 47.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +2 -1
- package/.github/copilot-instructions.md +176 -0
- package/.github/workflows/release-please.yml +8 -4
- package/.github/workflows/run-checks.yml +2 -2
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +26 -0
- package/README.md +4 -10
- package/docs/TRUSTED_PUBLISHING.md +133 -0
- package/lib/common/utils.js +1 -1
- package/lib/components/DataDictionary/components/Table/columns/columnDef.d.ts +6 -0
- package/lib/components/DataDictionary/components/Table/columns/columnDef.js +33 -0
- package/lib/components/DataDictionary/components/Table/columns/columnIdentifier.d.ts +5 -0
- package/lib/components/DataDictionary/components/Table/columns/columnIdentifier.js +5 -0
- package/lib/components/DataDictionary/components/Table/columns/types.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/columns/types.js +1 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +4 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.js +1 -0
- package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.d.ts +4 -0
- package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.js +23 -0
- package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +8 -0
- package/lib/components/DataDictionary/hooks/UseDataDictionary/types.js +1 -0
- package/lib/components/DataDictionary/hooks/UseLayoutSpacing/hook.d.ts +2 -0
- package/lib/components/DataDictionary/hooks/UseLayoutSpacing/hook.js +10 -0
- package/lib/components/DataDictionary/hooks/UseLayoutSpacing/types.d.ts +7 -0
- package/lib/components/DataDictionary/hooks/UseLayoutSpacing/types.js +1 -0
- package/lib/components/Detail/components/Table/components/TableHead/tableHead.d.ts +8 -0
- package/lib/components/Detail/components/Table/components/TableHead/tableHead.js +36 -0
- package/lib/components/Filter/components/Filter/filter.stories.d.ts +25 -0
- package/lib/components/Filter/components/Filter/filter.stories.js +42 -0
- package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +16 -0
- package/lib/components/Filter/components/FilterTag/filterTag.stories.js +17 -0
- package/lib/components/Filter/components/Filters/filters.stories.d.ts +6 -0
- package/lib/components/Filter/components/Filters/filters.stories.js +91 -0
- package/lib/components/Filter/components/SearchAllFilters/components/AutocompletePopper/autocompletePopper.styles.d.ts +3 -0
- package/lib/components/Filter/components/SearchAllFilters/components/AutocompletePopper/autocompletePopper.styles.js +15 -0
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.stories.d.ts +6 -0
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.stories.js +82 -0
- package/lib/components/Filter/components/SearchAllFiltersSearch/components/SearchCloseButton/searchCloseButton.d.ts +1 -0
- package/lib/components/Filter/components/SearchAllFiltersSearch/components/SearchCloseButton/searchCloseButton.js +14 -0
- package/lib/components/Filter/components/SearchAllFiltersSearch/searchAllFiltersSearch.d.ts +2 -0
- package/lib/components/Filter/components/SearchAllFiltersSearch/searchAllFiltersSearch.js +12 -0
- package/lib/components/Filter/components/SearchAllFiltersSearch/searchAllFiltersSearch.styles.d.ts +5 -0
- package/lib/components/Filter/components/SearchAllFiltersSearch/searchAllFiltersSearch.styles.js +34 -0
- package/lib/components/Index/components/Cell/cell.d.ts +7 -0
- package/lib/components/Index/components/Cell/cell.js +10 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/chartView.d.ts +2 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/chartView.js +20 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/chartView.styles.d.ts +13 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/chartView.styles.js +12 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/barX/constants.d.ts +10 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/barX/constants.js +10 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/barX/plot.d.ts +3 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/barX/plot.js +91 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/barX/utils.d.ts +132 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/barX/utils.js +230 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/chart.d.ts +2 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/chart.js +7 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/chart.styles.d.ts +3 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/chart.styles.js +29 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/constants.d.ts +1 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/constants.js +1 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/stories/args.d.ts +4 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/stories/args.js +70 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/stories/chart.stories.d.ts +7 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/stories/chart.stories.js +18 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/types.d.ts +6 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/components/Chart/types.js +1 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/constants.d.ts +1 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/constants.js +1 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/hooks/UseChartView/types.d.ts +7 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/hooks/UseChartView/types.js +1 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/hooks/UseChartView/useChartView.d.ts +3 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/hooks/UseChartView/useChartView.js +11 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/stories/args.d.ts +3 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/stories/args.js +97 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/stories/chartView.stories.d.ts +6 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/stories/chartView.stories.js +15 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/types.d.ts +8 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/types.js +1 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/utils.d.ts +14 -0
- package/lib/components/Index/components/EntitiesView/components/ChartView/utils.js +23 -0
- package/lib/components/Index/components/EntitiesView/components/EntityList/entityList.d.ts +3 -0
- package/lib/components/Index/components/EntitiesView/components/EntityList/entityList.js +14 -0
- package/lib/components/Index/components/EntitiesView/components/EntityList/types.d.ts +6 -0
- package/lib/components/Index/components/EntitiesView/components/EntityList/types.js +1 -0
- package/lib/components/Index/components/EntitiesView/constants.d.ts +1 -0
- package/lib/components/Index/components/EntitiesView/constants.js +1 -0
- package/lib/components/Index/components/EntitiesView/entitiesView.d.ts +2 -0
- package/lib/components/Index/components/EntitiesView/entitiesView.js +15 -0
- package/lib/components/Index/components/EntitiesView/entitiesView.styles.d.ts +3 -0
- package/lib/components/Index/components/EntitiesView/entitiesView.styles.js +20 -0
- package/lib/components/Index/components/EntitiesView/hooks/UseEntitiesView/hook.d.ts +2 -0
- package/lib/components/Index/components/EntitiesView/hooks/UseEntitiesView/hook.js +14 -0
- package/lib/components/Index/components/EntitiesView/hooks/UseEntitiesView/types.d.ts +13 -0
- package/lib/components/Index/components/EntitiesView/hooks/UseEntitiesView/types.js +5 -0
- package/lib/components/Index/components/EntitiesView/stories/entitiesView.stories.d.ts +8 -0
- package/lib/components/Index/components/EntitiesView/stories/entitiesView.stories.js +50 -0
- package/lib/components/Index/components/EntitiesView/types.d.ts +8 -0
- package/lib/components/Index/components/EntitiesView/types.js +1 -0
- package/lib/components/Index/components/Hero/components/ExportButton/exportButton.d.ts +1 -0
- package/lib/components/Index/components/Hero/components/ExportButton/exportButton.js +13 -0
- package/lib/components/Index/components/Hero/components/ExportButton/exportButton.styles.d.ts +3 -0
- package/lib/components/Index/components/Hero/components/ExportButton/exportButton.styles.js +13 -0
- package/lib/components/Index/components/Hero/components/Summaries/stories/summaries.stories.d.ts +6 -0
- package/lib/components/Index/components/Hero/components/Summaries/stories/summaries.stories.js +14 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.d.ts +9 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.js +12 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.stories.d.ts +13 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.stories.js +18 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.styles.d.ts +7 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.styles.js +26 -0
- package/lib/components/Index/components/Hero/hero.d.ts +11 -0
- package/lib/components/Index/components/Hero/hero.js +12 -0
- package/lib/components/Index/components/Hero/hero.stories.d.ts +23 -0
- package/lib/components/Index/components/Hero/hero.stories.js +22 -0
- package/lib/components/Index/components/Hero/hero.styles.d.ts +16 -0
- package/lib/components/Index/components/Hero/hero.styles.js +44 -0
- package/lib/components/Index/components/Hero/stories/hero.stories.d.ts +6 -0
- package/lib/components/Index/components/Hero/stories/hero.stories.js +16 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.d.ts +8 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.js +57 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.styles.d.ts +4 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.styles.js +10 -0
- package/lib/components/Index/components/NTag/nTag.d.ts +10 -0
- package/lib/components/Index/components/NTag/nTag.js +8 -0
- package/lib/components/Index/components/NTagCell/nTagCell.d.ts +11 -0
- package/lib/components/Index/components/NTagCell/nTagCell.js +29 -0
- package/lib/components/Index/components/NTagCell/nTagCell.stories.d.ts +5 -0
- package/lib/components/Index/components/NTagCell/nTagCell.stories.js +16 -0
- package/lib/components/Index/components/Tabs/common/utils.d.ts +8 -0
- package/lib/components/Index/components/Tabs/common/utils.js +19 -0
- package/lib/components/Index/components/Tabs/tabs.d.ts +1 -0
- package/lib/components/Index/components/Tabs/tabs.js +20 -0
- package/lib/components/Index/components/TitleCell/titleCell.d.ts +6 -0
- package/lib/components/Index/components/TitleCell/titleCell.js +10 -0
- package/lib/components/Index/components/TitleCell/titleCell.styles.d.ts +3 -0
- package/lib/components/Index/components/TitleCell/titleCell.styles.js +6 -0
- package/lib/components/Index/index.stories.d.ts +6 -0
- package/lib/components/Index/index.stories.js +26 -0
- package/lib/components/Index/stories/index.stories.d.ts +6 -0
- package/lib/components/Index/stories/index.stories.js +17 -0
- package/lib/components/Layout/components/BackPage/components/BackPageHero/backPageHero.stories.d.ts +6 -0
- package/lib/components/Layout/components/BackPage/components/BackPageHero/backPageHero.stories.js +10 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.stories.d.ts +5 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.stories.js +29 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.d.ts +6 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +13 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +36 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.js +9 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.d.ts +5 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +10 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +36 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.js +9 -0
- package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
- package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
- package/lib/components/Layout/components/Outline/common/constants.d.ts +2 -0
- package/lib/components/Layout/components/Outline/common/constants.js +1 -0
- package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +1 -1
- package/lib/components/Login/login.stories.d.ts +6 -0
- package/lib/components/Login/login.stories.js +31 -0
- package/lib/components/Redirect/redirect.js +6 -1
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.d.ts +16 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +28 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.d.ts +5 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.js +46 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +3 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +21 -0
- package/lib/components/Table/components/DownloadEntityResults/downloadEntityResults.d.ts +6 -0
- package/lib/components/Table/components/DownloadEntityResults/downloadEntityResults.js +17 -0
- package/lib/components/Table/components/EntityViewToggle/entityViewToggle.d.ts +2 -0
- package/lib/components/Table/components/EntityViewToggle/entityViewToggle.js +37 -0
- package/lib/components/Table/components/Pagination/pagination.d.ts +9 -0
- package/lib/components/Table/components/Pagination/pagination.js +19 -0
- package/lib/components/Table/components/Pagination/pagination.stories.d.ts +28 -0
- package/lib/components/Table/components/Pagination/pagination.stories.js +24 -0
- package/lib/components/Table/components/Pagination/pagination.styles.d.ts +4 -0
- package/lib/components/Table/components/Pagination/pagination.styles.js +15 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/constants.d.ts +3 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/constants.js +3 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/hook.d.ts +8 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/hook.js +18 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/types.d.ts +4 -0
- package/lib/components/Table/components/TableBody/hooks/virtualizer/types.js +1 -0
- package/lib/components/Table/components/TableBody/utils.d.ts +12 -0
- package/lib/components/Table/components/TableBody/utils.js +17 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.js +1 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/types.js +1 -0
- package/lib/components/TableCreator/common/constants.d.ts +6 -0
- package/lib/components/TableCreator/common/constants.js +19 -0
- package/lib/components/TableCreator/common/entities.d.ts +5 -0
- package/lib/components/TableCreator/common/entities.js +1 -0
- package/lib/components/TableCreator/tableCreator.styles.d.ts +4 -0
- package/lib/components/TableCreator/tableCreator.styles.js +4 -0
- package/lib/components/common/Alert/alert.stories.d.ts +6 -0
- package/lib/components/common/Alert/alert.stories.js +36 -0
- package/lib/components/common/Alert/components/AlertText/alertText.styles.d.ts +4 -0
- package/lib/components/common/Alert/components/AlertText/alertText.styles.js +19 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.d.ts +7 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.js +5 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.styles.d.ts +3 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.styles.js +19 -0
- package/lib/components/common/Banner/components/DismissibleBanner/dismissibleBanner.d.ts +10 -0
- package/lib/components/common/Banner/components/DismissibleBanner/dismissibleBanner.js +16 -0
- package/lib/components/common/Banner/components/SessionTimeout/sessionTimeout.styles.d.ts +3 -0
- package/lib/components/common/Banner/components/SessionTimeout/sessionTimeout.styles.js +21 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.d.ts +3 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.js +6 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.styles.d.ts +7 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.styles.js +11 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.d.ts +5 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.js +10 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.d.ts +3 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.js +9 -0
- package/lib/components/common/ToggleButtonGroup/toggleButtonGroup.js +2 -1
- package/lib/hooks/useAuthentication/common/constants.d.ts +4 -0
- package/lib/hooks/useAuthentication/common/constants.js +19 -0
- package/lib/hooks/useAuthentication/common/entities.d.ts +25 -0
- package/lib/hooks/useAuthentication/common/entities.js +11 -0
- package/lib/hooks/useAuthentication/common/utils.d.ts +15 -0
- package/lib/hooks/useAuthentication/common/utils.js +25 -0
- package/lib/hooks/useAuthentication/useAuthentication.d.ts +6 -0
- package/lib/hooks/useAuthentication/useAuthentication.js +9 -0
- package/lib/hooks/useAuthentication/useAuthenticationComplete.d.ts +6 -0
- package/lib/hooks/useAuthentication/useAuthenticationComplete.js +55 -0
- package/lib/hooks/useAuthentication/useAuthenticationForm.d.ts +20 -0
- package/lib/hooks/useAuthentication/useAuthenticationForm.js +88 -0
- package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.d.ts +18 -0
- package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.js +50 -0
- package/lib/hooks/useAuthentication/useAuthenticationStatus.d.ts +20 -0
- package/lib/hooks/useAuthentication/useAuthenticationStatus.js +32 -0
- package/lib/hooks/useAuthentication/useFetchGoogleProfile.d.ts +21 -0
- package/lib/hooks/useAuthentication/useFetchGoogleProfile.js +41 -0
- package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.d.ts +18 -0
- package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.js +62 -0
- package/lib/hooks/useAuthentication/useFetchTerraProfile.d.ts +24 -0
- package/lib/hooks/useAuthentication/useFetchTerraProfile.js +62 -0
- package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.d.ts +15 -0
- package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.js +62 -0
- package/lib/hooks/useAuthentication/useTokenClient.d.ts +11 -0
- package/lib/hooks/useAuthentication/useTokenClient.js +29 -0
- package/lib/hooks/useAuthenticationConfig.d.ts +6 -0
- package/lib/hooks/useAuthenticationConfig.js +14 -0
- package/lib/hooks/useCategoryConfigs.d.ts +6 -0
- package/lib/hooks/useCategoryConfigs.js +17 -0
- package/lib/hooks/useEntityListRelatedView.d.ts +15 -0
- package/lib/hooks/useEntityListRelatedView.js +62 -0
- package/lib/hooks/useExploreMode.d.ts +14 -0
- package/lib/hooks/useExploreMode.js +20 -0
- package/lib/hooks/useFileLocation.js +1 -1
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.d.ts +15 -0
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.js +27 -0
- package/lib/hooks/useFileManifest/useFileManifestURL.d.ts +5 -0
- package/lib/hooks/useFileManifest/useFileManifestURL.js +11 -0
- package/lib/hooks/useFileManifest/useRequestFileManifest.d.ts +9 -0
- package/lib/hooks/useFileManifest/useRequestFileManifest.js +37 -0
- package/lib/hooks/useLayoutState.d.ts +6 -0
- package/lib/hooks/useLayoutState.js +9 -0
- package/lib/hooks/useMenu.d.ts +10 -0
- package/lib/hooks/useMenu.js +17 -0
- package/lib/hooks/useMenuWithPosition.d.ts +14 -0
- package/lib/hooks/useMenuWithPosition.js +33 -0
- package/lib/hooks/useScroll.d.ts +10 -0
- package/lib/hooks/useScroll.js +12 -0
- package/lib/hooks/useSessionTimeout.d.ts +11 -0
- package/lib/hooks/useSessionTimeout.js +28 -0
- package/lib/providers/authentication.d.ts +51 -0
- package/lib/providers/authentication.js +110 -0
- package/lib/providers/layoutState.d.ts +40 -0
- package/lib/providers/layoutState.js +47 -0
- package/lib/styles/common/mixins/colors.d.ts +25 -0
- package/lib/styles/common/mixins/colors.js +32 -0
- package/lib/styles/common/mixins/fonts.d.ts +16 -0
- package/lib/styles/common/mixins/fonts.js +30 -0
- package/lib/styles/common/mixins/shadows.d.ts +3 -0
- package/lib/styles/common/mixins/shadows.js +4 -0
- package/lib/styles/common/mui/palette.d.ts +47 -0
- package/lib/styles/common/mui/palette.js +47 -0
- package/lib/theme/common/entities.d.ts +6 -0
- package/lib/theme/common/entities.js +1 -0
- package/package.json +8 -9
- package/src/common/utils.ts +1 -1
- package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +1 -1
- package/src/components/Redirect/redirect.tsx +5 -1
- package/src/components/common/ToggleButtonGroup/toggleButtonGroup.tsx +1 -1
- package/src/hooks/useFileLocation.ts +1 -1
- package/types/data-explorer-ui.d.ts +7 -6
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { ButtonSecondary } from "../ButtonSecondary/buttonSecondary";
|
|
3
|
+
export const LoginButton = styled(ButtonSecondary) `
|
|
4
|
+
.MuiButton-endIcon {
|
|
5
|
+
margin-right: -6px;
|
|
6
|
+
}
|
|
7
|
+
`;
|
|
8
|
+
export const LoginButtonText = styled.span `
|
|
9
|
+
flex: 1;
|
|
10
|
+
text-align: left;
|
|
11
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LoadingIcon } from "../../../CustomIcon/components/LoadingIcon/loadingIcon";
|
|
3
|
+
import { MockIconButtonPrimary } from "../../iconButton.styles";
|
|
4
|
+
/**
|
|
5
|
+
* Mock "loading" icon button - a placeholder element styled like a primary icon button without the use of a button element.
|
|
6
|
+
*/
|
|
7
|
+
export const LoadingIconButton = () => {
|
|
8
|
+
return (React.createElement(MockIconButtonPrimary, null,
|
|
9
|
+
React.createElement(LoadingIcon, { fontSize: "small" })));
|
|
10
|
+
};
|
package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, unknown>;
|
|
2
|
+
export default _default;
|
|
3
|
+
export declare const LoadingIconButtonStory: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, unknown>;
|
package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LoadingIconButton } from "./loadingIconButton";
|
|
3
|
+
export default {
|
|
4
|
+
component: LoadingIconButton,
|
|
5
|
+
title: "Components/Common/IconButton/Download",
|
|
6
|
+
};
|
|
7
|
+
const LoadingIconButtonTemplate = () => React.createElement(LoadingIconButton, null);
|
|
8
|
+
export const LoadingIconButtonStory = LoadingIconButtonTemplate.bind({});
|
|
9
|
+
LoadingIconButtonStory.args = {};
|
|
@@ -22,7 +22,8 @@ export const ToggleButtonGroup = ({ toggleButtons, ...props }) => {
|
|
|
22
22
|
const onChangeToggleButton = (mouseEvent, newToggleValue, onToggleFn) => {
|
|
23
23
|
if (newToggleValue) {
|
|
24
24
|
setToggleValue(newToggleValue);
|
|
25
|
-
|
|
25
|
+
if (onToggleFn)
|
|
26
|
+
onToggleFn();
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
return (React.createElement(MToggleButtonGroup, { exclusive: true, onChange: (e, value) => onChangeToggleButton(e, value, getSelectedToggleButtonAction(toggleButtons, value)), value: toggleValue, ...props }, toggleButtons.map(({ label, value }) => (React.createElement(MToggleButton, { key: label, value: value }, label)))));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LoginResponse, LoginStatus } from "./entities";
|
|
2
|
+
export declare const LOGIN_STATUS_FAILED: LoginStatus<LoginResponse>;
|
|
3
|
+
export declare const LOGIN_STATUS_NOT_STARTED: LoginStatus<LoginResponse>;
|
|
4
|
+
export declare const LOGIN_STATUS_NOT_SUPPORTED: LoginStatus<LoginResponse>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { REQUEST_STATUS } from "./entities";
|
|
2
|
+
export const LOGIN_STATUS_FAILED = {
|
|
3
|
+
isSuccess: false,
|
|
4
|
+
isSupported: true,
|
|
5
|
+
requestStatus: REQUEST_STATUS.FAILED,
|
|
6
|
+
response: undefined,
|
|
7
|
+
};
|
|
8
|
+
export const LOGIN_STATUS_NOT_STARTED = {
|
|
9
|
+
isSuccess: false,
|
|
10
|
+
isSupported: true,
|
|
11
|
+
requestStatus: REQUEST_STATUS.NOT_STARTED,
|
|
12
|
+
response: undefined,
|
|
13
|
+
};
|
|
14
|
+
export const LOGIN_STATUS_NOT_SUPPORTED = {
|
|
15
|
+
isSuccess: false,
|
|
16
|
+
isSupported: false,
|
|
17
|
+
requestStatus: REQUEST_STATUS.NOT_STARTED,
|
|
18
|
+
response: undefined,
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GoogleResponse } from "../useFetchGoogleProfile";
|
|
2
|
+
import { TerraNIHResponse } from "../useFetchTerraNIHProfile";
|
|
3
|
+
import { TerraResponse } from "../useFetchTerraProfile";
|
|
4
|
+
import { TerraTermsOfServiceResponse } from "../useFetchTerraTermsOfService";
|
|
5
|
+
export declare enum AUTHENTICATION_STATUS {
|
|
6
|
+
COMPLETED = "COMPLETED",
|
|
7
|
+
INCOMPLETE = "INCOMPLETE"
|
|
8
|
+
}
|
|
9
|
+
export type LoginResponse = GoogleResponse | TerraResponse | TerraNIHResponse | TerraTermsOfServiceResponse;
|
|
10
|
+
export interface LoginResponseError {
|
|
11
|
+
message: string;
|
|
12
|
+
source: string;
|
|
13
|
+
statusCode: number;
|
|
14
|
+
}
|
|
15
|
+
export interface LoginStatus<T> {
|
|
16
|
+
isSuccess: boolean;
|
|
17
|
+
isSupported: boolean;
|
|
18
|
+
requestStatus: REQUEST_STATUS;
|
|
19
|
+
response: T | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare enum REQUEST_STATUS {
|
|
22
|
+
COMPLETED = "COMPLETED",
|
|
23
|
+
FAILED = "FAILED",
|
|
24
|
+
NOT_STARTED = "NOT_STARTED"
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var AUTHENTICATION_STATUS;
|
|
2
|
+
(function (AUTHENTICATION_STATUS) {
|
|
3
|
+
AUTHENTICATION_STATUS["COMPLETED"] = "COMPLETED";
|
|
4
|
+
AUTHENTICATION_STATUS["INCOMPLETE"] = "INCOMPLETE";
|
|
5
|
+
})(AUTHENTICATION_STATUS || (AUTHENTICATION_STATUS = {}));
|
|
6
|
+
export var REQUEST_STATUS;
|
|
7
|
+
(function (REQUEST_STATUS) {
|
|
8
|
+
REQUEST_STATUS["COMPLETED"] = "COMPLETED";
|
|
9
|
+
REQUEST_STATUS["FAILED"] = "FAILED";
|
|
10
|
+
REQUEST_STATUS["NOT_STARTED"] = "NOT_STARTED";
|
|
11
|
+
})(REQUEST_STATUS || (REQUEST_STATUS = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LoginResponse, LoginStatus } from "./entities";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the options for an authentication request.
|
|
4
|
+
* @param token - Token.
|
|
5
|
+
* @returns request options.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getAuthenticationRequestOptions(token: string): RequestInit;
|
|
8
|
+
/**
|
|
9
|
+
* Returns login status.
|
|
10
|
+
* An undefined endpoint will return a not supported login status,
|
|
11
|
+
* otherwise a not started login status is returned.
|
|
12
|
+
* @param endpoint - Endpoint.
|
|
13
|
+
* @returns initial login status.
|
|
14
|
+
*/
|
|
15
|
+
export declare function initLoginStatus(endpoint?: string): LoginStatus<LoginResponse>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LOGIN_STATUS_NOT_STARTED, LOGIN_STATUS_NOT_SUPPORTED, } from "./constants";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the options for an authentication request.
|
|
4
|
+
* @param token - Token.
|
|
5
|
+
* @returns request options.
|
|
6
|
+
*/
|
|
7
|
+
export function getAuthenticationRequestOptions(token) {
|
|
8
|
+
const headers = new Headers();
|
|
9
|
+
headers.append("authorization", "Bearer " + token);
|
|
10
|
+
return { headers };
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns login status.
|
|
14
|
+
* An undefined endpoint will return a not supported login status,
|
|
15
|
+
* otherwise a not started login status is returned.
|
|
16
|
+
* @param endpoint - Endpoint.
|
|
17
|
+
* @returns initial login status.
|
|
18
|
+
*/
|
|
19
|
+
export function initLoginStatus(endpoint) {
|
|
20
|
+
if (!endpoint) {
|
|
21
|
+
// Endpoint not supported.
|
|
22
|
+
return LOGIN_STATUS_NOT_SUPPORTED;
|
|
23
|
+
}
|
|
24
|
+
return LOGIN_STATUS_NOT_STARTED;
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { AuthContext } from "../../providers/authentication";
|
|
3
|
+
/**
|
|
4
|
+
* Returns authentication context.
|
|
5
|
+
* @returns authentication context.
|
|
6
|
+
*/
|
|
7
|
+
export const useAuthentication = () => {
|
|
8
|
+
return useContext(AuthContext);
|
|
9
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AUTHENTICATION_STATUS } from "./common/entities";
|
|
2
|
+
/**
|
|
3
|
+
* Handles the completion of the authentication process.
|
|
4
|
+
* @param authenticationStatus - Authentication status.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useAuthenticationComplete: (authenticationStatus: AUTHENTICATION_STATUS) => void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Router, { useRouter } from "next/router";
|
|
2
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import { escapeRegExp } from "../../common/utils";
|
|
4
|
+
import { ROUTE_LOGIN } from "../../providers/authentication";
|
|
5
|
+
import { INACTIVITY_PARAM } from "../useSessionTimeout";
|
|
6
|
+
import { AUTHENTICATION_STATUS } from "./common/entities";
|
|
7
|
+
/**
|
|
8
|
+
* Handles the completion of the authentication process.
|
|
9
|
+
* @param authenticationStatus - Authentication status.
|
|
10
|
+
*/
|
|
11
|
+
export const useAuthenticationComplete = (authenticationStatus) => {
|
|
12
|
+
const { asPath } = useRouter();
|
|
13
|
+
const routeHistoryRef = useRef(initRouteHistory(asPath));
|
|
14
|
+
// Maintain a history of routes that have been visited prior to authentication.
|
|
15
|
+
routeHistoryRef.current = useMemo(() => updateRouteHistory(routeHistoryRef.current, asPath), [asPath]);
|
|
16
|
+
// Redirect to the previous route after authentication is completed.
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (authenticationStatus === AUTHENTICATION_STATUS.COMPLETED) {
|
|
19
|
+
Router.push(routeHistoryRef.current);
|
|
20
|
+
}
|
|
21
|
+
}, [authenticationStatus]);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Initializes route history with the current path.
|
|
25
|
+
* Returns base path if current path is the login route.
|
|
26
|
+
* @param path - current browser path.
|
|
27
|
+
* @returns path to be used as the initial route history.
|
|
28
|
+
*/
|
|
29
|
+
function initRouteHistory(path) {
|
|
30
|
+
return path === ROUTE_LOGIN ? "/" : removeInactivityTimeoutQueryParam(path);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Removes the inactivity timeout query parameter from the path.
|
|
34
|
+
* the inactivity timeout parameter is used to indicate that the session has timed out; remove the parameter to
|
|
35
|
+
* clear the session timeout banner after the user logs in again.
|
|
36
|
+
* @param path - Path.
|
|
37
|
+
* @returns path without the inactivity timeout query parameter.
|
|
38
|
+
*/
|
|
39
|
+
function removeInactivityTimeoutQueryParam(path) {
|
|
40
|
+
const regex = new RegExp(`\\?${escapeRegExp(INACTIVITY_PARAM)}(?:$|[=&].*)`);
|
|
41
|
+
return path.replace(regex, "");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Updates route history with the current path, unless the current path is the LoginView page.
|
|
45
|
+
* @param prevPath - route history path.
|
|
46
|
+
* @param path - current browser path.
|
|
47
|
+
* @returns updated path to be used as the route history.
|
|
48
|
+
*/
|
|
49
|
+
function updateRouteHistory(prevPath, path) {
|
|
50
|
+
let currentPath = prevPath;
|
|
51
|
+
if (path !== ROUTE_LOGIN) {
|
|
52
|
+
currentPath = path;
|
|
53
|
+
}
|
|
54
|
+
return removeInactivityTimeoutQueryParam(currentPath);
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface OnboardingStatus {
|
|
2
|
+
active: boolean;
|
|
3
|
+
completed: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare enum ONBOARDING_STEP {
|
|
6
|
+
NIH_ACCOUNT = 3,
|
|
7
|
+
TERRA_ACCOUNT = 1,
|
|
8
|
+
TERRA_TOS = 2
|
|
9
|
+
}
|
|
10
|
+
interface UseAuthenticationForm {
|
|
11
|
+
isComplete: boolean;
|
|
12
|
+
isReady: boolean;
|
|
13
|
+
onboardingStatusByStep: Map<ONBOARDING_STEP, OnboardingStatus>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Handles authentication form onboarding.
|
|
17
|
+
* @returns onboarding steps and corresponding status.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useAuthenticationForm: () => UseAuthenticationForm;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AUTHENTICATION_STATUS, } from "./common/entities";
|
|
2
|
+
import { useAuthentication } from "./useAuthentication";
|
|
3
|
+
export var ONBOARDING_STEP;
|
|
4
|
+
(function (ONBOARDING_STEP) {
|
|
5
|
+
ONBOARDING_STEP[ONBOARDING_STEP["NIH_ACCOUNT"] = 3] = "NIH_ACCOUNT";
|
|
6
|
+
ONBOARDING_STEP[ONBOARDING_STEP["TERRA_ACCOUNT"] = 1] = "TERRA_ACCOUNT";
|
|
7
|
+
ONBOARDING_STEP[ONBOARDING_STEP["TERRA_TOS"] = 2] = "TERRA_TOS";
|
|
8
|
+
})(ONBOARDING_STEP || (ONBOARDING_STEP = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Handles authentication form onboarding.
|
|
11
|
+
* @returns onboarding steps and corresponding status.
|
|
12
|
+
*/
|
|
13
|
+
export const useAuthenticationForm = () => {
|
|
14
|
+
const authentication = useAuthentication();
|
|
15
|
+
const isReady = authentication.authenticationStatus === AUTHENTICATION_STATUS.COMPLETED;
|
|
16
|
+
const loginStatuses = concatLoginStatuses(authentication).filter(filterLoginStatus);
|
|
17
|
+
const onboardingStatusByStep = getOnboardingStatusByStep(loginStatuses);
|
|
18
|
+
const isComplete = isAuthenticationComplete(onboardingStatusByStep);
|
|
19
|
+
return {
|
|
20
|
+
isComplete,
|
|
21
|
+
isReady,
|
|
22
|
+
onboardingStatusByStep,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Returns true if all authentication steps are complete.
|
|
27
|
+
* @param onboardingStatusByStep - Onboarding status by step.
|
|
28
|
+
* @returns true if all authentication steps are complete.
|
|
29
|
+
*/
|
|
30
|
+
function isAuthenticationComplete(onboardingStatusByStep) {
|
|
31
|
+
for (const { completed } of onboardingStatusByStep.values()) {
|
|
32
|
+
if (!completed) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns all login statuses, ordered by onboarding step.
|
|
40
|
+
* @param authentication - Authentication.
|
|
41
|
+
* @returns login statuses.
|
|
42
|
+
*/
|
|
43
|
+
function concatLoginStatuses(authentication) {
|
|
44
|
+
const { terraNIHProfileLoginStatus, terraProfileLoginStatus, terraTOSLoginStatus, } = authentication;
|
|
45
|
+
return [
|
|
46
|
+
terraProfileLoginStatus,
|
|
47
|
+
terraTOSLoginStatus,
|
|
48
|
+
terraNIHProfileLoginStatus,
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns true if login is supported.
|
|
53
|
+
* @param loginStatus - Login status.
|
|
54
|
+
* @returns true if login is supported.
|
|
55
|
+
*/
|
|
56
|
+
function filterLoginStatus(loginStatus) {
|
|
57
|
+
return loginStatus.isSupported;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns a map of onboarding steps and their status.
|
|
61
|
+
* @param loginStatuses - Login statuses.
|
|
62
|
+
* @returns map of onboarding steps and their status.
|
|
63
|
+
*/
|
|
64
|
+
function getOnboardingStatusByStep(loginStatuses) {
|
|
65
|
+
const onboardingStatusByStep = new Map();
|
|
66
|
+
for (let i = 0; i < loginStatuses.length; i++) {
|
|
67
|
+
const { isSuccess } = loginStatuses[i];
|
|
68
|
+
onboardingStatusByStep.set(i + 1, {
|
|
69
|
+
active: isStepActive(isSuccess, onboardingStatusByStep),
|
|
70
|
+
completed: isSuccess,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return onboardingStatusByStep;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns true if step is active.
|
|
77
|
+
* @param isSuccess - Response is successful.
|
|
78
|
+
* @param onboardingStatusByStep - Onboarding status by step.
|
|
79
|
+
* @returns true if step is active.
|
|
80
|
+
*/
|
|
81
|
+
function isStepActive(isSuccess, onboardingStatusByStep) {
|
|
82
|
+
for (const { active } of onboardingStatusByStep.values()) {
|
|
83
|
+
if (active) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return !isSuccess;
|
|
88
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface UseAuthenticationNIHExpiry {
|
|
2
|
+
isReady: boolean;
|
|
3
|
+
linkExpired?: boolean;
|
|
4
|
+
linkExpireTime?: number;
|
|
5
|
+
linkWillExpire?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Handles authentication NIH expiry.
|
|
9
|
+
* @returns NIH expiry status.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useAuthenticationNIHExpiry: () => UseAuthenticationNIHExpiry;
|
|
12
|
+
/**
|
|
13
|
+
* Calculates the remaining time in seconds until the given expiration time.
|
|
14
|
+
* @param expireTime - Expire time in seconds.
|
|
15
|
+
* @returns remaining time in seconds.
|
|
16
|
+
*/
|
|
17
|
+
export declare function expireTimeInSeconds(expireTime: number): number;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { REQUEST_STATUS } from "./common/entities";
|
|
2
|
+
import { useAuthentication } from "./useAuthentication";
|
|
3
|
+
const WARNING_WINDOW_SECONDS = 60 * 60 * 24 * 5; // 5 days.
|
|
4
|
+
/**
|
|
5
|
+
* Handles authentication NIH expiry.
|
|
6
|
+
* @returns NIH expiry status.
|
|
7
|
+
*/
|
|
8
|
+
export const useAuthenticationNIHExpiry = () => {
|
|
9
|
+
const authentication = useAuthentication();
|
|
10
|
+
const { terraNIHProfileLoginStatus } = authentication;
|
|
11
|
+
const { requestStatus, response } = terraNIHProfileLoginStatus;
|
|
12
|
+
const { linkExpireTime } = response || {};
|
|
13
|
+
const isReady = requestStatus === REQUEST_STATUS.COMPLETED;
|
|
14
|
+
const linkExpired = hasLinkedNIHAccountExpired(linkExpireTime);
|
|
15
|
+
const linkWillExpire = isLinkedNIHAccountWillExpire(linkExpireTime);
|
|
16
|
+
return {
|
|
17
|
+
isReady,
|
|
18
|
+
linkExpireTime,
|
|
19
|
+
linkExpired,
|
|
20
|
+
linkWillExpire,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Calculates the remaining time in seconds until the given expiration time.
|
|
25
|
+
* @param expireTime - Expire time in seconds.
|
|
26
|
+
* @returns remaining time in seconds.
|
|
27
|
+
*/
|
|
28
|
+
export function expireTimeInSeconds(expireTime) {
|
|
29
|
+
return expireTime - Date.now() / 1000;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if the linked NIH account has expired.
|
|
33
|
+
* @param expireTime - Expire time in seconds.
|
|
34
|
+
* @returns true if the linked NIH account has expired.
|
|
35
|
+
*/
|
|
36
|
+
function hasLinkedNIHAccountExpired(expireTime) {
|
|
37
|
+
if (!expireTime)
|
|
38
|
+
return;
|
|
39
|
+
return expireTimeInSeconds(expireTime) < 0;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if the linked NIH account will expire in less than a week.
|
|
43
|
+
* @param expireTime - Expire time in seconds.
|
|
44
|
+
* @returns true if the linked NIH account will expire in less than a week.
|
|
45
|
+
*/
|
|
46
|
+
function isLinkedNIHAccountWillExpire(expireTime) {
|
|
47
|
+
if (!expireTime)
|
|
48
|
+
return;
|
|
49
|
+
return expireTimeInSeconds(expireTime) < WARNING_WINDOW_SECONDS;
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AUTHENTICATION_STATUS, LoginResponse, LoginStatus } from "./common/entities";
|
|
2
|
+
import { GoogleResponse } from "./useFetchGoogleProfile";
|
|
3
|
+
import { TerraNIHResponse } from "./useFetchTerraNIHProfile";
|
|
4
|
+
import { TerraResponse } from "./useFetchTerraProfile";
|
|
5
|
+
import { TerraTermsOfServiceResponse } from "./useFetchTerraTermsOfService";
|
|
6
|
+
/**
|
|
7
|
+
* Handles the status of the authentication process.
|
|
8
|
+
* @param userProfileLoginStatus - User profile login status.
|
|
9
|
+
* @param terraProfileLoginStatus - Terra profile login status.
|
|
10
|
+
* @param terraTOSLoginStatus - Terra terms of service login status.
|
|
11
|
+
* @param terraNIHProfileLoginStatus - Terra NIH profile login status.
|
|
12
|
+
* @returns authentication status.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useAuthenticationStatus: (userProfileLoginStatus: LoginStatus<GoogleResponse>, terraProfileLoginStatus: LoginStatus<TerraResponse>, terraTOSLoginStatus: LoginStatus<TerraTermsOfServiceResponse>, terraNIHProfileLoginStatus: LoginStatus<TerraNIHResponse>) => AUTHENTICATION_STATUS;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the authentication status ("INCOMPLETE" or "COMPLETE").
|
|
17
|
+
* @param loginStatuses - Login statuses.
|
|
18
|
+
* @returns authentication status.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAuthenticationStatus(loginStatuses: LoginStatus<LoginResponse>[]): AUTHENTICATION_STATUS;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AUTHENTICATION_STATUS, REQUEST_STATUS, } from "./common/entities";
|
|
2
|
+
/**
|
|
3
|
+
* Handles the status of the authentication process.
|
|
4
|
+
* @param userProfileLoginStatus - User profile login status.
|
|
5
|
+
* @param terraProfileLoginStatus - Terra profile login status.
|
|
6
|
+
* @param terraTOSLoginStatus - Terra terms of service login status.
|
|
7
|
+
* @param terraNIHProfileLoginStatus - Terra NIH profile login status.
|
|
8
|
+
* @returns authentication status.
|
|
9
|
+
*/
|
|
10
|
+
export const useAuthenticationStatus = (userProfileLoginStatus, terraProfileLoginStatus, terraTOSLoginStatus, terraNIHProfileLoginStatus) => {
|
|
11
|
+
return getAuthenticationStatus([
|
|
12
|
+
terraNIHProfileLoginStatus,
|
|
13
|
+
terraProfileLoginStatus,
|
|
14
|
+
terraTOSLoginStatus,
|
|
15
|
+
userProfileLoginStatus,
|
|
16
|
+
]);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Returns the authentication status ("INCOMPLETE" or "COMPLETE").
|
|
20
|
+
* @param loginStatuses - Login statuses.
|
|
21
|
+
* @returns authentication status.
|
|
22
|
+
*/
|
|
23
|
+
export function getAuthenticationStatus(loginStatuses) {
|
|
24
|
+
for (const loginStatus of loginStatuses) {
|
|
25
|
+
if (!loginStatus.isSupported)
|
|
26
|
+
continue;
|
|
27
|
+
if (loginStatus.requestStatus === REQUEST_STATUS.NOT_STARTED) {
|
|
28
|
+
return AUTHENTICATION_STATUS.INCOMPLETE;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return AUTHENTICATION_STATUS.COMPLETED;
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LoginStatus } from "./common/entities";
|
|
2
|
+
export type UserProfile = GoogleResponse;
|
|
3
|
+
export interface GoogleResponse {
|
|
4
|
+
email: string;
|
|
5
|
+
email_verified: boolean;
|
|
6
|
+
family_name: string;
|
|
7
|
+
given_name: string;
|
|
8
|
+
hd: string;
|
|
9
|
+
locale: string;
|
|
10
|
+
name: string;
|
|
11
|
+
picture: string;
|
|
12
|
+
sub: string;
|
|
13
|
+
}
|
|
14
|
+
type Status = LoginStatus<GoogleResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns user profile login status from configured endpoint.
|
|
17
|
+
* @param token - Token.
|
|
18
|
+
* @returns google profile login status.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useFetchGoogleProfile: (token?: string) => Status;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { useAuthenticationConfig } from "../useAuthenticationConfig";
|
|
3
|
+
import { LOGIN_STATUS_FAILED, LOGIN_STATUS_NOT_STARTED, } from "./common/constants";
|
|
4
|
+
import { REQUEST_STATUS } from "./common/entities";
|
|
5
|
+
import { getAuthenticationRequestOptions } from "./common/utils";
|
|
6
|
+
/**
|
|
7
|
+
* Returns user profile login status from configured endpoint.
|
|
8
|
+
* @param token - Token.
|
|
9
|
+
* @returns google profile login status.
|
|
10
|
+
*/
|
|
11
|
+
export const useFetchGoogleProfile = (token) => {
|
|
12
|
+
const authenticationConfig = useAuthenticationConfig();
|
|
13
|
+
const { googleGISAuthConfig: { googleProfileEndpoint: endpoint } = {} } = authenticationConfig;
|
|
14
|
+
const [loginStatus, setLoginStatus] = useState(LOGIN_STATUS_NOT_STARTED);
|
|
15
|
+
// Fetch google user profile.
|
|
16
|
+
const fetchEndpointData = useCallback((endpoint, accessToken) => {
|
|
17
|
+
fetch(endpoint, getAuthenticationRequestOptions(accessToken))
|
|
18
|
+
.then((response) => response.json())
|
|
19
|
+
.then((profile) => {
|
|
20
|
+
setLoginStatus((prevStatus) => ({
|
|
21
|
+
...prevStatus,
|
|
22
|
+
isSuccess: true,
|
|
23
|
+
requestStatus: REQUEST_STATUS.COMPLETED,
|
|
24
|
+
response: profile,
|
|
25
|
+
}));
|
|
26
|
+
})
|
|
27
|
+
.catch((err) => {
|
|
28
|
+
console.log(err); // TODO handle error.
|
|
29
|
+
setLoginStatus(LOGIN_STATUS_FAILED);
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
// Fetches user profile.
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!token)
|
|
35
|
+
return;
|
|
36
|
+
if (!endpoint)
|
|
37
|
+
return;
|
|
38
|
+
fetchEndpointData(endpoint, token);
|
|
39
|
+
}, [endpoint, fetchEndpointData, token]);
|
|
40
|
+
return loginStatus;
|
|
41
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LoginStatus } from "./common/entities";
|
|
2
|
+
interface DatasetPermission {
|
|
3
|
+
authorized: boolean;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
type Status = LoginStatus<TerraNIHResponse>;
|
|
7
|
+
export interface TerraNIHResponse {
|
|
8
|
+
datasetPermissions: DatasetPermission[];
|
|
9
|
+
linkedNihUsername: string;
|
|
10
|
+
linkExpireTime: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns Terra NIH login status from configured endpoint.
|
|
14
|
+
* @param token - Token.
|
|
15
|
+
* @returns Terra NIH login status.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useFetchTerraNIHProfile: (token?: string) => Status;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { useAuthenticationConfig } from "../useAuthenticationConfig";
|
|
3
|
+
import { LOGIN_STATUS_FAILED } from "./common/constants";
|
|
4
|
+
import { REQUEST_STATUS, } from "./common/entities";
|
|
5
|
+
import { getAuthenticationRequestOptions, initLoginStatus, } from "./common/utils";
|
|
6
|
+
/**
|
|
7
|
+
* Returns Terra NIH login status from configured endpoint.
|
|
8
|
+
* @param token - Token.
|
|
9
|
+
* @returns Terra NIH login status.
|
|
10
|
+
*/
|
|
11
|
+
export const useFetchTerraNIHProfile = (token) => {
|
|
12
|
+
const authenticationConfig = useAuthenticationConfig();
|
|
13
|
+
const { terraAuthConfig: { terraNIHProfileEndpoint: endpoint } = {} } = authenticationConfig;
|
|
14
|
+
const [loginStatus, setLoginStatus] = useState(initLoginStatus(endpoint));
|
|
15
|
+
// Fetch Terra NIH account profile.
|
|
16
|
+
const fetchEndpointData = useCallback((endpoint, accessToken) => {
|
|
17
|
+
fetch(endpoint, getAuthenticationRequestOptions(accessToken))
|
|
18
|
+
.then((response) => response.json())
|
|
19
|
+
.then((response) => {
|
|
20
|
+
if (isResponseError(response)) {
|
|
21
|
+
setLoginStatus(LOGIN_STATUS_FAILED);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
setLoginStatus((prevStatus) => ({
|
|
25
|
+
...prevStatus,
|
|
26
|
+
isSuccess: isResponseSuccess(response),
|
|
27
|
+
requestStatus: REQUEST_STATUS.COMPLETED,
|
|
28
|
+
response,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
.catch((err) => {
|
|
33
|
+
console.log(err); // TODO handle error.
|
|
34
|
+
setLoginStatus(LOGIN_STATUS_FAILED);
|
|
35
|
+
});
|
|
36
|
+
}, []);
|
|
37
|
+
// Fetches Terra NIH account profile.
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!token)
|
|
40
|
+
return;
|
|
41
|
+
if (!endpoint)
|
|
42
|
+
return;
|
|
43
|
+
fetchEndpointData(endpoint, token);
|
|
44
|
+
}, [endpoint, fetchEndpointData, token]);
|
|
45
|
+
return loginStatus;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Returns true if response is an error response.
|
|
49
|
+
* @param response - Response.
|
|
50
|
+
* @returns true if response is an error response.
|
|
51
|
+
*/
|
|
52
|
+
function isResponseError(response) {
|
|
53
|
+
return Boolean(response.statusCode);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns true if the user accepted terms of service version is current.
|
|
57
|
+
* @param response - Response.
|
|
58
|
+
* @returns true if response is successful.
|
|
59
|
+
*/
|
|
60
|
+
function isResponseSuccess(response) {
|
|
61
|
+
return Boolean(response.linkedNihUsername);
|
|
62
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LoginStatus } from "./common/entities";
|
|
2
|
+
type Status = LoginStatus<TerraResponse>;
|
|
3
|
+
export interface TerraResponse {
|
|
4
|
+
enabled: TerraResponseEnabled;
|
|
5
|
+
userInfo: TerraResponseUserInfo;
|
|
6
|
+
}
|
|
7
|
+
interface TerraResponseEnabled {
|
|
8
|
+
adminEnabled: boolean;
|
|
9
|
+
allUsersGroup: boolean;
|
|
10
|
+
google: boolean;
|
|
11
|
+
ldap: boolean;
|
|
12
|
+
tosAccepted: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface TerraResponseUserInfo {
|
|
15
|
+
userEmail: string;
|
|
16
|
+
userSubjectId: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns Terra profile login status from configured endpoint.
|
|
20
|
+
* @param token - Token.
|
|
21
|
+
* @returns Terra profile login status.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useFetchTerraProfile: (token?: string) => Status;
|
|
24
|
+
export {};
|