@verdaccio/ui-theme 3.1.0 → 6.0.0-6-next.11
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/.babelrc +33 -0
- package/.eslintrc +115 -0
- package/.stylelintrc +40 -0
- package/CHANGELOG.md +152 -554
- package/LICENSE +1 -1
- package/README.md +22 -95
- package/config/env.js +9 -0
- package/jest/api/packages.json +42 -0
- package/jest/identity.js +29 -0
- package/jest/jest.config.js +39 -0
- package/jest/jestEnvironment.js +1 -0
- package/jest/server-handlers.ts +9 -0
- package/jest/server.ts +6 -0
- package/jest/setup-env.ts +15 -0
- package/jest/setup.ts +31 -0
- package/jest/unit/components/__mocks__/api.ts +47 -0
- package/jest/unit/components/__mocks__/token.ts +31 -0
- package/jest/unit/components/store/login.ts +23 -0
- package/jest/unit/components/store/logo.ts +7 -0
- package/jest/unit/components/store/package.ts +174 -0
- package/jest/unit/components/store/packageMeta.ts +592 -0
- package/jest/unit/empty.ts +1 -0
- package/lib/constants.ts +9 -0
- package/package.json +153 -228
- package/src/App/App.test.tsx +123 -0
- package/src/App/App.tsx +54 -0
- package/src/App/AppError.tsx +38 -0
- package/src/App/AppRoute.tsx +63 -0
- package/src/App/Footer/Footer.test.tsx +20 -0
- package/src/App/Footer/Footer.tsx +111 -0
- package/src/App/Footer/__snapshots__/Footer.test.tsx.snap +456 -0
- package/src/App/Footer/index.ts +1 -0
- package/src/App/Footer/styles.ts +44 -0
- package/src/App/Header/Header.test.tsx +152 -0
- package/src/App/Header/Header.tsx +74 -0
- package/src/App/Header/HeaderGreetings.tsx +22 -0
- package/src/App/Header/HeaderInfoDialog.tsx +19 -0
- package/src/App/Header/HeaderLeft.tsx +31 -0
- package/src/App/Header/HeaderMenu.tsx +65 -0
- package/src/App/Header/HeaderRight.tsx +118 -0
- package/src/App/Header/HeaderToolTip.tsx +19 -0
- package/src/App/Header/HeaderToolTipIcon.tsx +75 -0
- package/src/App/Header/LanguageSwitch.tsx +125 -0
- package/src/App/Header/LoginDialog/LoginDialog.test.tsx +112 -0
- package/src/App/Header/LoginDialog/LoginDialog.tsx +81 -0
- package/src/App/Header/LoginDialog/LoginDialogCloseButton.tsx +32 -0
- package/src/App/Header/LoginDialog/LoginDialogForm.tsx +97 -0
- package/src/App/Header/LoginDialog/LoginDialogFormError.tsx +43 -0
- package/src/App/Header/LoginDialog/LoginDialogHeader.tsx +48 -0
- package/src/App/Header/LoginDialog/__snapshots__/LoginDialog.test.tsx.snap +3 -0
- package/src/App/Header/LoginDialog/index.ts +1 -0
- package/src/App/Header/RegistryInfoContent/RegistryInfoContent.test.tsx +27 -0
- package/src/App/Header/RegistryInfoContent/RegistryInfoContent.tsx +155 -0
- package/src/App/Header/RegistryInfoContent/index.ts +1 -0
- package/src/App/Header/RegistryInfoDialog/RegistryInfoDialog.tsx +30 -0
- package/src/App/Header/RegistryInfoDialog/index.ts +1 -0
- package/src/App/Header/RegistryInfoDialog/styles.ts +16 -0
- package/src/App/Header/RegistryInfoDialog/types.ts +7 -0
- package/src/App/Header/Search/Search.test.tsx +168 -0
- package/src/App/Header/Search/Search.tsx +127 -0
- package/src/App/Header/Search/SearchAdornment.tsx +18 -0
- package/src/App/Header/Search/__snapshots__/Search.test.tsx.snap +101 -0
- package/src/App/Header/Search/index.ts +1 -0
- package/src/App/Header/index.ts +1 -0
- package/src/App/Header/styles.ts +89 -0
- package/src/App/index.ts +1 -0
- package/src/App/utils/loadable.tsx +10 -0
- package/src/components/.eslintrc +7 -0
- package/src/components/ActionBar/ActionBar.test.tsx +91 -0
- package/src/components/ActionBar/ActionBar.tsx +45 -0
- package/src/components/ActionBar/ActionBarAction.tsx +75 -0
- package/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap +122 -0
- package/src/components/ActionBar/index.ts +1 -0
- package/src/components/AppBar.tsx +10 -0
- package/src/components/Author/Author.test.tsx +75 -0
- package/src/components/Author/Author.tsx +47 -0
- package/src/components/Author/__snapshots__/Author.test.tsx.snap +353 -0
- package/src/components/Author/index.ts +1 -0
- package/src/components/Author/styles.ts +23 -0
- package/src/components/AutoComplete/AutoComplete.tsx +179 -0
- package/src/components/AutoComplete/AutoCompleteV2.tsx +296 -0
- package/src/components/AutoComplete/index.ts +1 -0
- package/src/components/AutoComplete/styles.tsx +58 -0
- package/src/components/AutoComplete/useAutoComplete.tsx +61 -0
- package/src/components/Avatar.tsx +3 -0
- package/src/components/Box.tsx +8 -0
- package/src/components/Button.tsx +10 -0
- package/src/components/Card.tsx +10 -0
- package/src/components/CardActions.tsx +13 -0
- package/src/components/CardContent.tsx +10 -0
- package/src/components/Chip.tsx +10 -0
- package/src/components/CircularProgress.tsx +15 -0
- package/src/components/CopyToClipBoard.tsx +45 -0
- package/src/components/Dialog.tsx +10 -0
- package/src/components/DialogActions.tsx +16 -0
- package/src/components/DialogContent.tsx +16 -0
- package/src/components/DialogTitle.tsx +10 -0
- package/src/components/Divider.tsx +10 -0
- package/src/components/FloatingActionButton.tsx +12 -0
- package/src/components/FormControl.tsx +10 -0
- package/src/components/FormHelperText.tsx +16 -0
- package/src/components/Grid.tsx +10 -0
- package/src/components/Heading.tsx +15 -0
- package/src/components/IconButton.tsx +10 -0
- package/src/components/Icons/.eslintrc +5 -0
- package/src/components/Icons/Earth.tsx +36 -0
- package/src/components/Icons/FileBinary.tsx +20 -0
- package/src/components/Icons/Law.tsx +20 -0
- package/src/components/Icons/License.tsx +18 -0
- package/src/components/Icons/Time.tsx +19 -0
- package/src/components/Icons/Version.tsx +20 -0
- package/src/components/Icons/index.ts +5 -0
- package/src/components/Input.tsx +10 -0
- package/src/components/InputAdornment/InputAdornment.tsx +16 -0
- package/src/components/InputAdornment/index.ts +1 -0
- package/src/components/InputLabel.tsx +10 -0
- package/src/components/Label/Label.test.tsx +15 -0
- package/src/components/Label/Label.tsx +35 -0
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +14 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/Link.tsx +39 -0
- package/src/components/List.tsx +10 -0
- package/src/components/ListItem.tsx +23 -0
- package/src/components/ListItemText.tsx +16 -0
- package/src/components/Loading/Loading.test.tsx +12 -0
- package/src/components/Loading/Loading.tsx +17 -0
- package/src/components/Loading/Spinner/Spinner.test.tsx +14 -0
- package/src/components/Loading/Spinner/Spinner.tsx +35 -0
- package/src/components/Loading/Spinner/__snapshots__/Spinner.test.tsx.snap +148 -0
- package/src/components/Loading/Spinner/index.tsx +1 -0
- package/src/components/Loading/__snapshots__/Loading.test.tsx.snap +86 -0
- package/src/components/Loading/index.ts +1 -0
- package/src/components/Loading/styles.ts +17 -0
- package/src/components/Logo/Logo.test.tsx +12 -0
- package/src/components/Logo/Logo.tsx +55 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +19 -0
- package/src/components/Logo/img/logo-black-and-white.svg +1 -0
- package/src/components/Logo/img/logo.svg +1 -0
- package/src/components/Logo/index.ts +1 -0
- package/src/components/Menu.tsx +10 -0
- package/src/components/MenuItem.tsx +25 -0
- package/src/components/NotFound/NotFound.tsx +52 -0
- package/src/components/NotFound/Notfound.test.tsx +37 -0
- package/src/components/NotFound/__snapshots__/Notfound.test.tsx.snap +44 -0
- package/src/components/NotFound/img/package.svg +1 -0
- package/src/components/NotFound/index.ts +1 -0
- package/src/components/NotFound/styles.ts +40 -0
- package/src/components/Paper.tsx +10 -0
- package/src/components/SnackbarContent.tsx +15 -0
- package/src/components/SvgIcon.tsx +38 -0
- package/src/components/Tab.tsx +10 -0
- package/src/components/Tabs.tsx +14 -0
- package/src/components/Text/Text.tsx +17 -0
- package/src/components/Text/TextConfig.ts +7 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/TextField/TextField.test.tsx +16 -0
- package/src/components/TextField/TextField.tsx +23 -0
- package/src/components/TextField/__snapshots__/TextField.test.tsx.snap +19 -0
- package/src/components/TextField/index.ts +1 -0
- package/src/components/Toolbar.tsx +10 -0
- package/src/components/Tooltip.tsx +25 -0
- package/src/design-tokens/ResetStyles.tsx +44 -0
- package/src/design-tokens/StyleBaseline.tsx +14 -0
- package/src/design-tokens/ThemeContext.ts +13 -0
- package/src/design-tokens/ThemeProvider.tsx +44 -0
- package/src/design-tokens/emotion.ts +5 -0
- package/src/design-tokens/load-dayjs-locale.ts +98 -0
- package/src/design-tokens/theme.ts +159 -0
- package/src/design-tokens/useLocalStorage.ts +40 -0
- package/src/design-tokens/useOnClickOutside.ts +28 -0
- package/src/design-tokens/useTheme.ts +7 -0
- package/src/i18n/ABOUT_TRANSLATIONS.md +13 -0
- package/src/i18n/config.ts +52 -0
- package/src/i18n/crowdin/ui.json +170 -0
- package/src/i18n/deprecated_translations_dont_use/cs-CZ.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/de-DE.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/en-US.json +170 -0
- package/src/i18n/deprecated_translations_dont_use/es-ES.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/fr-FR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/ja-JP.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/km-KH.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/pt-BR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/ru-RU.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/tr-TR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/uk-UA.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/zh-CN.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/zh-TW.json +165 -0
- package/src/i18n/enabledLanguages.ts +35 -0
- package/src/index.tsx +36 -0
- package/src/lib/constants.ts +9 -0
- package/src/pages/Version/DetailContainer/Dependencies/Dependencies.test.tsx +93 -0
- package/src/pages/Version/DetailContainer/Dependencies/Dependencies.tsx +100 -0
- package/src/pages/Version/DetailContainer/Dependencies/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Dependencies/styles.ts +26 -0
- package/src/pages/Version/DetailContainer/Dependencies/types.ts +7 -0
- package/src/pages/Version/DetailContainer/Deprecated/Deprecated.test.tsx +34 -0
- package/src/pages/Version/DetailContainer/Deprecated/Deprecated.tsx +31 -0
- package/src/pages/Version/DetailContainer/Deprecated/index.ts +1 -0
- package/src/pages/Version/DetailContainer/DetailContainer.test.tsx +13 -0
- package/src/pages/Version/DetailContainer/DetailContainer.tsx +37 -0
- package/src/pages/Version/DetailContainer/DetailContainerContent.tsx +41 -0
- package/src/pages/Version/DetailContainer/DetailContainerContentReadme.tsx +19 -0
- package/src/pages/Version/DetailContainer/DetailContainerTabs.tsx +36 -0
- package/src/pages/Version/DetailContainer/NoItems/NoItems.tsx +16 -0
- package/src/pages/Version/DetailContainer/NoItems/Noitems.test.tsx +16 -0
- package/src/pages/Version/DetailContainer/NoItems/__snapshots__/Noitems.test.tsx.snap +9 -0
- package/src/pages/Version/DetailContainer/NoItems/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Readme/Readme.spec.tsx +19 -0
- package/src/pages/Version/DetailContainer/Readme/Readme.tsx +22 -0
- package/src/pages/Version/DetailContainer/Readme/__snapshots__/Readme.spec.tsx.snap +94 -0
- package/src/pages/Version/DetailContainer/Readme/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Readme/types.ts +3 -0
- package/src/pages/Version/DetailContainer/UpLinks/UpLinks.test.tsx +58 -0
- package/src/pages/Version/DetailContainer/UpLinks/UpLinks.tsx +45 -0
- package/src/pages/Version/DetailContainer/UpLinks/__snapshots__/UpLinks.test.tsx.snap +247 -0
- package/src/pages/Version/DetailContainer/UpLinks/index.ts +1 -0
- package/src/pages/Version/DetailContainer/UpLinks/styles.ts +24 -0
- package/src/pages/Version/DetailContainer/Versions/Versions.test.tsx +60 -0
- package/src/pages/Version/DetailContainer/Versions/Versions.tsx +41 -0
- package/src/pages/Version/DetailContainer/Versions/VersionsHistoryList.tsx +40 -0
- package/src/pages/Version/DetailContainer/Versions/VersionsTagList.tsx +28 -0
- package/src/pages/Version/DetailContainer/Versions/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailContainer/Versions/__snapshots__/Versions.test.tsx.snap +3 -0
- package/src/pages/Version/DetailContainer/Versions/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Versions/styles.ts +30 -0
- package/src/pages/Version/DetailContainer/__snapshots__/DetailContainer.test.tsx.snap +103 -0
- package/src/pages/Version/DetailContainer/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/DetailSidebar.tsx +55 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarFundButton.test.tsx +111 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarFundButton.tsx +53 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarTitle.tsx +40 -0
- package/src/pages/Version/DetailSidebar/Developers/Developers.test.tsx +117 -0
- package/src/pages/Version/DetailSidebar/Developers/Developers.tsx +90 -0
- package/src/pages/Version/DetailSidebar/Developers/DevelopersTitle.tsx +32 -0
- package/src/pages/Version/DetailSidebar/Developers/__snapshots__/Developers.test.tsx.snap +380 -0
- package/src/pages/Version/DetailSidebar/Developers/get-unique-developer-values.ts +16 -0
- package/src/pages/Version/DetailSidebar/Developers/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Developers/styles.ts +31 -0
- package/src/pages/Version/DetailSidebar/Dist/Dist.test.tsx +78 -0
- package/src/pages/Version/DetailSidebar/Dist/Dist.tsx +49 -0
- package/src/pages/Version/DetailSidebar/Dist/__snapshots__/Dist.test.tsx.snap +602 -0
- package/src/pages/Version/DetailSidebar/Dist/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Dist/styles.ts +27 -0
- package/src/pages/Version/DetailSidebar/Engines/Engines.test.tsx +71 -0
- package/src/pages/Version/DetailSidebar/Engines/Engines.tsx +58 -0
- package/src/pages/Version/DetailSidebar/Engines/img/node.png +0 -0
- package/src/pages/Version/DetailSidebar/Engines/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Engines/styles.ts +14 -0
- package/src/pages/Version/DetailSidebar/Install/Install.test.tsx +64 -0
- package/src/pages/Version/DetailSidebar/Install/Install.tsx +52 -0
- package/src/pages/Version/DetailSidebar/Install/InstallListItem.tsx +97 -0
- package/src/pages/Version/DetailSidebar/Install/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailSidebar/Install/img/npm.svg +15 -0
- package/src/pages/Version/DetailSidebar/Install/img/pnpm.svg +1 -0
- package/src/pages/Version/DetailSidebar/Install/img/yarn.svg +1 -0
- package/src/pages/Version/DetailSidebar/Install/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Repository/Repository.test.tsx +78 -0
- package/src/pages/Version/DetailSidebar/Repository/Repository.tsx +93 -0
- package/src/pages/Version/DetailSidebar/Repository/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailSidebar/Repository/__snapshots__/Repository.test.tsx.snap +3 -0
- package/src/pages/Version/DetailSidebar/Repository/img/git.png +0 -0
- package/src/pages/Version/DetailSidebar/Repository/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/index.ts +1 -0
- package/src/pages/Version/Version.test.tsx +68 -0
- package/src/pages/Version/Version.tsx +41 -0
- package/src/pages/Version/VersionContextProvider.tsx +43 -0
- package/src/pages/Version/VersionLayout.tsx +20 -0
- package/src/pages/Version/__partials__/data.json +5984 -0
- package/src/pages/Version/context.ts +10 -0
- package/src/pages/Version/get-route-package-name.ts +9 -0
- package/src/pages/Version/index.ts +4 -0
- package/src/pages/Version/version-config.ts +19 -0
- package/src/pages/home/Home.tsx +25 -0
- package/src/pages/home/PackageList/Help/Help.test.tsx +12 -0
- package/src/pages/home/PackageList/Help/Help.tsx +56 -0
- package/src/pages/home/PackageList/Help/__snapshots__/Help.test.tsx.snap +159 -0
- package/src/pages/home/PackageList/Help/index.ts +1 -0
- package/src/pages/home/PackageList/Help/styles.ts +13 -0
- package/src/pages/home/PackageList/Package/Package.test.tsx +56 -0
- package/src/pages/home/PackageList/Package/Package.tsx +253 -0
- package/src/pages/home/PackageList/Package/Tag/Tag.test.tsx +16 -0
- package/src/pages/home/PackageList/Package/Tag/Tag.tsx +11 -0
- package/src/pages/home/PackageList/Package/Tag/__snapshots__/Tag.test.tsx.snap +21 -0
- package/src/pages/home/PackageList/Package/Tag/index.ts +1 -0
- package/src/pages/home/PackageList/Package/Tag/styles.ts +11 -0
- package/src/pages/home/PackageList/Package/index.ts +1 -0
- package/src/pages/home/PackageList/Package/styles.ts +112 -0
- package/src/pages/home/PackageList/PackageList.tsx +81 -0
- package/src/pages/home/PackageList/Packagelist.test.tsx +60 -0
- package/src/pages/home/PackageList/index.ts +1 -0
- package/src/pages/home/index.ts +1 -0
- package/src/providers/API/api.test.ts +136 -0
- package/src/providers/API/api.ts +73 -0
- package/src/providers/API/storage.ts +12 -0
- package/src/providers/config/AppConfigurationProvider.tsx +57 -0
- package/src/providers/config/index.ts +1 -0
- package/src/store/index.ts +1 -0
- package/src/store/models/configuration.ts +42 -0
- package/src/store/models/download.ts +31 -0
- package/src/store/models/index.ts +17 -0
- package/src/store/models/login.ts +90 -0
- package/src/store/models/manifest.ts +91 -0
- package/src/store/models/packages.ts +36 -0
- package/src/store/models/search.ts +81 -0
- package/src/store/store.ts +15 -0
- package/src/template/favicon.ico +0 -0
- package/src/template/index.html +21 -0
- package/src/utils/.eslintrc +5 -0
- package/src/utils/cli-utils.test.ts +66 -0
- package/src/utils/cli-utils.ts +38 -0
- package/src/utils/colors.ts +1 -0
- package/src/utils/constants.ts +5 -0
- package/src/utils/file-size.ts +13 -0
- package/src/utils/i18nForTests.ts +25 -0
- package/src/utils/login.test.ts +71 -0
- package/src/utils/login.ts +44 -0
- package/src/utils/package.test.ts +101 -0
- package/src/utils/package.ts +105 -0
- package/src/utils/sec-utils.ts +15 -0
- package/src/utils/storage.ts +12 -0
- package/src/utils/test-react-testing-library.tsx +38 -0
- package/src/utils/url.test.ts +28 -0
- package/src/utils/url.ts +58 -0
- package/src/utils/windows.ts +3 -0
- package/static/favicon.ico +0 -0
- package/static/index.html +21 -0
- package/static/main.c57129036f278d0c7acf.js +2 -0
- package/static/main.c57129036f278d0c7acf.js.LICENSE.txt +1456 -0
- package/static/manifest.json +5 -17
- package/static/runtime.c57129036f278d0c7acf.js +2 -0
- package/static/{runtime.f6e570dfe38870a45bf5.js.LICENSE.txt → runtime.c57129036f278d0c7acf.js.LICENSE.txt} +2 -2
- package/static/vendors.c57129036f278d0c7acf.js +2 -0
- package/static/vendors.c57129036f278d0c7acf.js.LICENSE.txt +2932 -0
- package/tools/.eslintrc +14 -0
- package/tools/_verdaccio.config.yaml +59 -0
- package/tools/dev.server.js +48 -0
- package/tools/getPackageJson.js +25 -0
- package/tools/verdaccio.js +31 -0
- package/tools/webpack.config.js +82 -0
- package/tools/webpack.dev.config.babel.js +60 -0
- package/tools/webpack.prod.config.babel.js +81 -0
- package/tsconfig.build.json +24 -0
- package/tsconfig.json +27 -0
- package/types/custom.d.ts +9 -0
- package/types/files.d.ts +9 -0
- package/types/index.ts +12 -0
- package/types/jest-dom.d.ts +1 -0
- package/types/packageMeta.ts +82 -0
- package/static/238.f6e570dfe38870a45bf5.js +0 -2
- package/static/238.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/718.f6e570dfe38870a45bf5.js +0 -2
- package/static/718.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/73.f6e570dfe38870a45bf5.js +0 -2
- package/static/73.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Dependencies.f6e570dfe38870a45bf5.js +0 -2
- package/static/Dependencies.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Dist.f6e570dfe38870a45bf5.js +0 -2
- package/static/Dist.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Engines.f6e570dfe38870a45bf5.js +0 -2
- package/static/Engines.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Home.f6e570dfe38870a45bf5.js +0 -2
- package/static/Home.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Install.f6e570dfe38870a45bf5.js +0 -2
- package/static/Install.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/NotFound.f6e570dfe38870a45bf5.js +0 -2
- package/static/NotFound.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Provider.f6e570dfe38870a45bf5.js +0 -2
- package/static/Provider.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Repository.f6e570dfe38870a45bf5.js +0 -2
- package/static/Repository.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/UpLinks.f6e570dfe38870a45bf5.js +0 -2
- package/static/UpLinks.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Version.f6e570dfe38870a45bf5.js +0 -2
- package/static/Version.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Versions.f6e570dfe38870a45bf5.js +0 -2
- package/static/Versions.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/main.f6e570dfe38870a45bf5.js +0 -2
- package/static/main.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/runtime.f6e570dfe38870a45bf5.js +0 -2
- package/static/vendors.f6e570dfe38870a45bf5.js +0 -2
- package/static/vendors.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -98
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createModel } from '@rematch/core';
|
|
2
|
+
import i18next from 'i18next';
|
|
3
|
+
|
|
4
|
+
import { HEADERS } from '../../lib/constants';
|
|
5
|
+
import API from '../../providers/API/api';
|
|
6
|
+
import storage from '../../utils/storage';
|
|
7
|
+
|
|
8
|
+
import type { RootModel } from '.';
|
|
9
|
+
|
|
10
|
+
export type LoginError = {
|
|
11
|
+
type: string;
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type LoginResponse = {
|
|
16
|
+
username: string | null;
|
|
17
|
+
token: string | null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type LoginBody = {
|
|
21
|
+
error?: LoginError;
|
|
22
|
+
} & LoginResponse;
|
|
23
|
+
|
|
24
|
+
const token = storage.getItem('token');
|
|
25
|
+
const username = storage.getItem('username');
|
|
26
|
+
const defaultUserState: LoginBody = {
|
|
27
|
+
token,
|
|
28
|
+
username,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const login = createModel<RootModel>()({
|
|
32
|
+
state: {
|
|
33
|
+
username: defaultUserState.username,
|
|
34
|
+
token: defaultUserState.token,
|
|
35
|
+
},
|
|
36
|
+
reducers: {
|
|
37
|
+
logOutUser(state) {
|
|
38
|
+
storage.removeItem('username');
|
|
39
|
+
storage.removeItem('token');
|
|
40
|
+
return {
|
|
41
|
+
...state,
|
|
42
|
+
username: null,
|
|
43
|
+
token: null,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
addError(state, error: LoginError) {
|
|
47
|
+
return {
|
|
48
|
+
...state,
|
|
49
|
+
error,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
clearError(state) {
|
|
53
|
+
return {
|
|
54
|
+
...state,
|
|
55
|
+
error: undefined,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
logInUser(state, response: LoginResponse) {
|
|
59
|
+
// we might persist this in another way with
|
|
60
|
+
storage.setItem('username', response.username as string);
|
|
61
|
+
storage.setItem('token', response.token as string);
|
|
62
|
+
return {
|
|
63
|
+
...state,
|
|
64
|
+
token: response.token as string,
|
|
65
|
+
username: response.username as string,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
effects: (dispatch) => ({
|
|
70
|
+
async getUser({ username, password }, state) {
|
|
71
|
+
const basePath = state.configuration.config.base;
|
|
72
|
+
try {
|
|
73
|
+
const payload: LoginResponse = await API.request(`${basePath}-/verdaccio/login`, 'POST', {
|
|
74
|
+
body: JSON.stringify({ username, password }),
|
|
75
|
+
headers: {
|
|
76
|
+
Accept: HEADERS.JSON,
|
|
77
|
+
'Content-Type': HEADERS.JSON,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
dispatch.login.logInUser(payload);
|
|
81
|
+
dispatch.packages.getPackages();
|
|
82
|
+
} catch (error: any) {
|
|
83
|
+
dispatch.login.addError({
|
|
84
|
+
type: 'error',
|
|
85
|
+
description: i18next.t('form-validation.unable-to-sign-in'),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createModel } from '@rematch/core';
|
|
2
|
+
import { Package } from '@verdaccio/types';
|
|
3
|
+
import { PackageMetaInterface } from 'types/packageMeta';
|
|
4
|
+
|
|
5
|
+
import API from '../../providers/API/api';
|
|
6
|
+
|
|
7
|
+
import type { RootModel } from '.';
|
|
8
|
+
|
|
9
|
+
function isPackageVersionValid(
|
|
10
|
+
packageMeta: Partial<PackageMetaInterface>,
|
|
11
|
+
packageVersion?: string
|
|
12
|
+
): boolean {
|
|
13
|
+
if (!packageVersion || typeof packageVersion === 'undefined') {
|
|
14
|
+
// if is undefined, that means versions does not exist, we continue
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (packageMeta.versions) {
|
|
19
|
+
return Object.keys(packageMeta.versions).includes(packageVersion);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const manifest = createModel<RootModel>()({
|
|
26
|
+
state: {},
|
|
27
|
+
reducers: {
|
|
28
|
+
notFound(state) {
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
hasNotBeenFound: true,
|
|
32
|
+
manifest: undefined,
|
|
33
|
+
packageName: undefined,
|
|
34
|
+
packageVersion: undefined,
|
|
35
|
+
readme: undefined,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
clearError(state) {
|
|
39
|
+
return {
|
|
40
|
+
...state,
|
|
41
|
+
isError: null,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
isError(state) {
|
|
45
|
+
return {
|
|
46
|
+
...state,
|
|
47
|
+
isError: true,
|
|
48
|
+
hasNotBeenFound: false,
|
|
49
|
+
manifest: undefined,
|
|
50
|
+
packageName: undefined,
|
|
51
|
+
packageVersion: undefined,
|
|
52
|
+
readme: undefined,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
saveManifest(state, { packageName, packageVersion, manifest, readme }) {
|
|
56
|
+
return {
|
|
57
|
+
...state,
|
|
58
|
+
manifest,
|
|
59
|
+
packageName,
|
|
60
|
+
packageVersion,
|
|
61
|
+
readme,
|
|
62
|
+
hasNotBeenFound: false,
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
effects: (dispatch) => ({
|
|
67
|
+
async getManifest({ packageName, packageVersion }, state) {
|
|
68
|
+
const basePath = state.configuration.config.base;
|
|
69
|
+
try {
|
|
70
|
+
if (!isPackageVersionValid(packageName, packageVersion)) {
|
|
71
|
+
throw new Error('not found');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const manifest: Package = await API.request(
|
|
75
|
+
`${basePath}-/verdaccio/sidebar/${packageName}${
|
|
76
|
+
packageVersion ? `?v=${packageVersion}` : ''
|
|
77
|
+
}`
|
|
78
|
+
);
|
|
79
|
+
const readme: string = await API.request<string>(
|
|
80
|
+
`${basePath}-/verdaccio/package/readme/${packageName}${
|
|
81
|
+
packageVersion ? `?v=${packageVersion}` : ''
|
|
82
|
+
}`,
|
|
83
|
+
'GET'
|
|
84
|
+
);
|
|
85
|
+
dispatch.manifest.saveManifest({ packageName, packageVersion, manifest, readme });
|
|
86
|
+
} catch (error: any) {
|
|
87
|
+
dispatch.manifest.notFound();
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createModel } from '@rematch/core';
|
|
2
|
+
import { Package } from '@verdaccio/types';
|
|
3
|
+
|
|
4
|
+
import API from '../../providers/API/api';
|
|
5
|
+
|
|
6
|
+
import type { RootModel } from '.';
|
|
7
|
+
|
|
8
|
+
export const packages = createModel<RootModel>()({
|
|
9
|
+
state: {
|
|
10
|
+
response: [] as Package[],
|
|
11
|
+
},
|
|
12
|
+
reducers: {
|
|
13
|
+
savePackages(state, response: Package[]) {
|
|
14
|
+
return {
|
|
15
|
+
...state,
|
|
16
|
+
response,
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
effects: (dispatch) => ({
|
|
21
|
+
async getPackages(_payload, state) {
|
|
22
|
+
const basePath = state.configuration.config.base;
|
|
23
|
+
try {
|
|
24
|
+
const payload: Package[] = await API.request(`${basePath}-/verdaccio/packages`, 'GET');
|
|
25
|
+
dispatch.packages.savePackages(payload);
|
|
26
|
+
} catch (error: any) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.error({
|
|
29
|
+
title: 'Warning',
|
|
30
|
+
message: `Unable to load package list: ${error.message}`,
|
|
31
|
+
});
|
|
32
|
+
// TODO: handle error, display something retry or something
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createModel } from '@rematch/core';
|
|
2
|
+
import { Package } from '@verdaccio/types';
|
|
3
|
+
|
|
4
|
+
import API from '../../providers/API/api';
|
|
5
|
+
|
|
6
|
+
import type { RootModel } from '.';
|
|
7
|
+
|
|
8
|
+
const CONSTANTS = {
|
|
9
|
+
API_DELAY: 300,
|
|
10
|
+
ABORT_ERROR: 'AbortError',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type SearchState = {
|
|
14
|
+
suggestions: Partial<Package>[];
|
|
15
|
+
controller: AbortController[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const search = createModel<RootModel>()({
|
|
19
|
+
state: {
|
|
20
|
+
suggestions: [],
|
|
21
|
+
controller: [],
|
|
22
|
+
} as SearchState,
|
|
23
|
+
reducers: {
|
|
24
|
+
clearRequestQueue(state) {
|
|
25
|
+
const controllers = state.controller;
|
|
26
|
+
controllers.forEach((request) => request.abort());
|
|
27
|
+
return {
|
|
28
|
+
...state,
|
|
29
|
+
controller: [],
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
addControllerToQueue(state, { controller }: { controller: AbortController }) {
|
|
33
|
+
const currentControllers = state.controller;
|
|
34
|
+
return {
|
|
35
|
+
...state,
|
|
36
|
+
controller: [...currentControllers, controller],
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
setError(state) {
|
|
40
|
+
return {
|
|
41
|
+
...state,
|
|
42
|
+
isError: true,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
saveSearch(state, { suggestions }: { suggestions: Partial<Package>[] }) {
|
|
46
|
+
return {
|
|
47
|
+
...state,
|
|
48
|
+
suggestions,
|
|
49
|
+
isError: null,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
effects: (dispatch) => ({
|
|
54
|
+
async getSuggestions({ value }, state) {
|
|
55
|
+
const basePath = state.configuration.config.base;
|
|
56
|
+
try {
|
|
57
|
+
const controller = new window.AbortController();
|
|
58
|
+
dispatch.search.addControllerToQueue({ controller });
|
|
59
|
+
const signal = controller.signal;
|
|
60
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility
|
|
61
|
+
// FUTURE: signal is not well supported for IE and Samsung Browser
|
|
62
|
+
const suggestions: Partial<Package>[] = await API.request(
|
|
63
|
+
`${basePath}-/verdaccio/search/${encodeURIComponent(value)}`,
|
|
64
|
+
'GET',
|
|
65
|
+
{
|
|
66
|
+
signal,
|
|
67
|
+
headers: {},
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
dispatch.search.saveSearch({ suggestions });
|
|
72
|
+
} catch (error: any) {
|
|
73
|
+
if (error.name === CONSTANTS.ABORT_ERROR) {
|
|
74
|
+
dispatch.search.saveSearch({ suggestions: [] });
|
|
75
|
+
} else {
|
|
76
|
+
dispatch.search.setError();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { init, RematchDispatch, RematchRootState } from '@rematch/core';
|
|
2
|
+
import loadingPlugin, { ExtraModelsFromLoading } from '@rematch/loading';
|
|
3
|
+
|
|
4
|
+
import { models, RootModel } from './models';
|
|
5
|
+
|
|
6
|
+
type FullModel = ExtraModelsFromLoading<RootModel>;
|
|
7
|
+
|
|
8
|
+
export const store = init<RootModel, FullModel>({
|
|
9
|
+
models,
|
|
10
|
+
plugins: [loadingPlugin()],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type Store = typeof store;
|
|
14
|
+
export type Dispatch = RematchDispatch<RootModel>;
|
|
15
|
+
export type RootState = RematchRootState<RootModel, FullModel>;
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en-us">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<title>
|
|
7
|
+
<%= htmlWebpackPlugin.options.title %>
|
|
8
|
+
</title>
|
|
9
|
+
<base href="<%= htmlWebpackPlugin.options.basePath %>">
|
|
10
|
+
<link rel="icon" type="image/png" href="<%= htmlWebpackPlugin.options.faviIcoPath %>" />
|
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
+
<script>
|
|
13
|
+
window.__VERDACCIO_BASENAME_UI_OPTIONS = JSON.parse('<%= htmlWebpackPlugin.options.__UI_OPTIONS %>');
|
|
14
|
+
</script>
|
|
15
|
+
</head>
|
|
16
|
+
|
|
17
|
+
<body class="body">
|
|
18
|
+
<div id="root"></div>
|
|
19
|
+
</body>
|
|
20
|
+
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
import { copyToClipBoardUtility, getCLISetConfigRegistry } from './cli-utils';
|
|
4
|
+
|
|
5
|
+
describe('copyToClipBoardUtility', () => {
|
|
6
|
+
let originalGetSelection: typeof window.getSelection;
|
|
7
|
+
|
|
8
|
+
const mockGetSelectionResult = {
|
|
9
|
+
removeAllRanges: jest.fn(),
|
|
10
|
+
addRange: jest.fn(),
|
|
11
|
+
};
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
originalGetSelection = window.getSelection;
|
|
14
|
+
|
|
15
|
+
window.getSelection = jest.fn().mockReturnValue(mockGetSelectionResult);
|
|
16
|
+
});
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
window.getSelection = originalGetSelection;
|
|
19
|
+
jest.restoreAllMocks();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('should call the DOM APIs', () => {
|
|
23
|
+
// Given
|
|
24
|
+
const testEvent: { preventDefault: Function } = {
|
|
25
|
+
preventDefault: jest.fn(),
|
|
26
|
+
};
|
|
27
|
+
const testCopy = 'copy text';
|
|
28
|
+
const spys = {
|
|
29
|
+
createElement: jest.spyOn(document, 'createElement'),
|
|
30
|
+
execCommand: jest.spyOn(document, 'execCommand'),
|
|
31
|
+
appendChild: jest.spyOn(document.body, 'appendChild'),
|
|
32
|
+
removeChild: jest.spyOn(document.body, 'removeChild'),
|
|
33
|
+
};
|
|
34
|
+
const expectedDiv = document.createElement('div');
|
|
35
|
+
expectedDiv.innerText = testCopy;
|
|
36
|
+
|
|
37
|
+
// When
|
|
38
|
+
const copyFunc = copyToClipBoardUtility(testCopy);
|
|
39
|
+
copyFunc(testEvent as SyntheticEvent<HTMLElement>);
|
|
40
|
+
|
|
41
|
+
// Then
|
|
42
|
+
expect(mockGetSelectionResult.removeAllRanges).toHaveBeenCalledWith();
|
|
43
|
+
expect(mockGetSelectionResult.addRange).toHaveBeenCalled();
|
|
44
|
+
expect(spys.createElement).toHaveBeenCalledWith('div');
|
|
45
|
+
expect(spys.appendChild).toHaveBeenCalledWith(expectedDiv);
|
|
46
|
+
expect(spys.execCommand).toHaveBeenCalledWith('copy');
|
|
47
|
+
expect(spys.removeChild).toHaveBeenCalledWith(expectedDiv);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('getCLISetRegistry', () => {
|
|
52
|
+
const command = 'npm set';
|
|
53
|
+
const scope = '@testscope';
|
|
54
|
+
const blankScope = '';
|
|
55
|
+
const url = 'https://test.local';
|
|
56
|
+
|
|
57
|
+
test('should return ":" separated string when scope is set', () => {
|
|
58
|
+
expect(getCLISetConfigRegistry(command, scope, url)).toEqual(
|
|
59
|
+
`${command} ${scope}:registry ${url}`
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('should not output scope when scope is not set', () => {
|
|
64
|
+
expect(getCLISetConfigRegistry(command, blankScope, url)).toEqual(`${command} registry ${url}`);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
export const copyToClipBoardUtility =
|
|
4
|
+
(str: string): ((e: SyntheticEvent<HTMLElement>) => void) =>
|
|
5
|
+
(event: SyntheticEvent<HTMLElement>): void => {
|
|
6
|
+
event.preventDefault();
|
|
7
|
+
|
|
8
|
+
const node = document.createElement('div');
|
|
9
|
+
node.innerText = str;
|
|
10
|
+
if (document.body) {
|
|
11
|
+
document.body.appendChild(node);
|
|
12
|
+
|
|
13
|
+
const range = document.createRange();
|
|
14
|
+
const selection = window.getSelection() as Selection;
|
|
15
|
+
range.selectNodeContents(node);
|
|
16
|
+
selection.removeAllRanges();
|
|
17
|
+
selection.addRange(range);
|
|
18
|
+
document.execCommand('copy');
|
|
19
|
+
document.body.removeChild(node);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function getCLISetConfigRegistry(
|
|
24
|
+
command: string,
|
|
25
|
+
scope: string,
|
|
26
|
+
registryUrl: string
|
|
27
|
+
): string {
|
|
28
|
+
// if there is a scope defined there needs to be a ":" separator between the scope and the registry
|
|
29
|
+
return `${command} ${scope}${scope !== '' ? ':' : ''}registry ${registryUrl}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getCLISetRegistry(command: string, registryUrl: string): string {
|
|
33
|
+
return `${command} --registry ${registryUrl}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getCLIChangePassword(command: string, registryUrl: string): string {
|
|
37
|
+
return `${command} profile set password --registry ${registryUrl}`;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PRIMARY_COLOR = '#4b5e40';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default function fileSizeSI(
|
|
2
|
+
a: number,
|
|
3
|
+
b?: typeof Math,
|
|
4
|
+
c?: (p: number) => number,
|
|
5
|
+
d?: number,
|
|
6
|
+
e?: number
|
|
7
|
+
): string {
|
|
8
|
+
return (
|
|
9
|
+
((b = Math), (c = b.log), (d = 1e3), (e = (c(a) / c(d)) | 0), a / b.pow(d, e)).toFixed(2) +
|
|
10
|
+
' ' +
|
|
11
|
+
(e ? 'kMGTPEZY'[--e] + 'B' : 'Bytes')
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import i18n from 'i18next';
|
|
2
|
+
import { initReactI18next } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
// NOTE: not used yet, but should replace the original implementation
|
|
5
|
+
|
|
6
|
+
// https://react.i18next.com/misc/testing#testing-without-stubbing
|
|
7
|
+
|
|
8
|
+
i18n.use(initReactI18next).init({
|
|
9
|
+
lng: 'en',
|
|
10
|
+
fallbackLng: 'en',
|
|
11
|
+
|
|
12
|
+
// have a common namespace used around the full app
|
|
13
|
+
ns: ['translations'],
|
|
14
|
+
defaultNS: 'translations',
|
|
15
|
+
|
|
16
|
+
debug: false,
|
|
17
|
+
|
|
18
|
+
interpolation: {
|
|
19
|
+
escapeValue: false, // not needed for react!!
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
resources: { en: { translations: {} } },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export default i18n;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// eslint-disable-next-line jest/no-mocks-import
|
|
2
|
+
import {
|
|
3
|
+
generateTokenWithTimeRange,
|
|
4
|
+
generateTokenWithExpirationAsString,
|
|
5
|
+
generateTokenWithOutExpiration,
|
|
6
|
+
generateInvalidToken,
|
|
7
|
+
} from '../../jest/unit/components/__mocks__/token';
|
|
8
|
+
|
|
9
|
+
import { isTokenExpire } from './login';
|
|
10
|
+
|
|
11
|
+
/* eslint-disable no-console */
|
|
12
|
+
console.error = jest.fn();
|
|
13
|
+
|
|
14
|
+
jest.mock('verdaccio-ui/providers/API/api', () => ({
|
|
15
|
+
// eslint-disable-next-line jest/no-mocks-import
|
|
16
|
+
request: require('../../jest/unit/components/__mocks__/api').default.request,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.mock('i18next', () => {
|
|
20
|
+
const translationEN = require('../../i18n/translations/ui.json');
|
|
21
|
+
return {
|
|
22
|
+
t: (key: string) => {
|
|
23
|
+
const splittedKey = key.split('.');
|
|
24
|
+
let result = translationEN;
|
|
25
|
+
|
|
26
|
+
for (const element of splittedKey) {
|
|
27
|
+
result = result[element];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return result;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('isTokenExpire', (): void => {
|
|
36
|
+
test('isTokenExpire - null is not a valid payload', (): void => {
|
|
37
|
+
expect(isTokenExpire(null)).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('isTokenExpire - token is not a valid payload', (): void => {
|
|
41
|
+
expect(isTokenExpire('not_a_valid_token')).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('isTokenExpire - token should not expire in 24 hrs range', (): void => {
|
|
45
|
+
const token = generateTokenWithTimeRange(24);
|
|
46
|
+
expect(isTokenExpire(token)).toBeFalsy();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('isTokenExpire - token should expire for current time', (): void => {
|
|
50
|
+
const token = generateTokenWithTimeRange();
|
|
51
|
+
expect(isTokenExpire(token)).toBeTruthy();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('isTokenExpire - token expiration is not available', (): void => {
|
|
55
|
+
const token = generateTokenWithOutExpiration();
|
|
56
|
+
expect(isTokenExpire(token)).toBeTruthy();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('isTokenExpire - token is not a valid json token', (): void => {
|
|
60
|
+
const token = generateInvalidToken();
|
|
61
|
+
const errorToken = new SyntaxError('Unexpected token i in JSON at position 0');
|
|
62
|
+
const result = ['Invalid token:', errorToken, 'xxxxxx.aW52YWxpZHRva2Vu.xxxxxx'];
|
|
63
|
+
expect(isTokenExpire(token)).toBeTruthy();
|
|
64
|
+
expect(console.error).toHaveBeenCalledWith(...result);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('isTokenExpire - token expiration is not a number', (): void => {
|
|
68
|
+
const token = generateTokenWithExpirationAsString();
|
|
69
|
+
expect(isTokenExpire(token)).toBeTruthy();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Base64 } from 'js-base64';
|
|
2
|
+
import isNumber from 'lodash/isNumber';
|
|
3
|
+
import isString from 'lodash/isString';
|
|
4
|
+
|
|
5
|
+
export function isTokenExpire(token: string | null): boolean {
|
|
6
|
+
if (!isString(token)) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const [, payload] = token.split('.');
|
|
11
|
+
|
|
12
|
+
if (!payload) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let exp: number;
|
|
17
|
+
try {
|
|
18
|
+
exp = JSON.parse(Base64.decode(payload)).exp;
|
|
19
|
+
} catch (error: any) {
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.error('Invalid token:', error, token);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!exp || !isNumber(exp)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
// Report as expire before (real expire time - 30s)
|
|
29
|
+
const jsTimestamp = exp * 1000 - 30000;
|
|
30
|
+
const expired = Date.now() >= jsTimestamp;
|
|
31
|
+
|
|
32
|
+
return expired;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface LoginBody {
|
|
36
|
+
username?: string;
|
|
37
|
+
token?: string;
|
|
38
|
+
error?: LoginError;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface LoginError {
|
|
42
|
+
type: string;
|
|
43
|
+
description: string;
|
|
44
|
+
}
|