From 06e75115de588e14f08c19aab485c5ee45bc8035 Mon Sep 17 00:00:00 2001 From: Sebastian Kobori Date: Wed, 26 Jun 2024 21:55:27 -0400 Subject: [PATCH] Reverted History Major version bump, fixed linter errors --- package-lock.json | 137 ++++++---------------------- package.json | 4 +- src/components/SignInButton.tsx | 6 +- src/libs/ajax/OAuth2.ts | 4 +- src/libs/ajax/User.ts | 12 +-- src/libs/auth/RedirectFromOAuth.tsx | 2 +- src/libs/auth/auth.ts | 5 +- 7 files changed, 45 insertions(+), 125 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7c698b73b..24d90fe4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,7 @@ "@babel/plugin-proposal-class-properties": "7.18.6", "@babel/preset-react": "7.24.7", "@types/dompurify": "3.0.5", - "@types/history": "5.0.0", + "@types/history": "4.7.11", "@types/lodash": "4.17.5", "@types/react": "18.3.3", "@types/react-modal": "3.16.3", @@ -70,7 +70,7 @@ "eslint-plugin-flowtype": "8.0.3", "eslint-plugin-react": "7.34.3", "google-auth-library": "9.11.0", - "history": "5.3.0", + "history": "4.10.1", "html-webpack-plugin": "5.6.0", "prop-types": "15.8.1", "react-error-overlay": "6.0.11", @@ -4487,14 +4487,10 @@ } }, "node_modules/@types/history": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@types/history/-/history-5.0.0.tgz", - "integrity": "sha512-hy8b7Y1J8OGe6LbAjj3xniQrj3v6lsivCcrmf4TzSgPzLkhIeKgc5IZnT7ReIqmEuodjfO8EYAuoFvIrHi/+jQ==", - "deprecated": "This is a stub types definition. history provides its own type definitions, so you do not need this installed.", - "dev": true, - "dependencies": { - "history": "*" - } + "version": "4.7.11", + "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", + "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", + "dev": true }, "node_modules/@types/html-minifier-terser": { "version": "6.1.0", @@ -4660,18 +4656,6 @@ "@types/react-router": "*" } }, - "node_modules/@types/react-router-dom/node_modules/@types/history": { - "version": "4.7.11", - "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", - "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", - "dev": true - }, - "node_modules/@types/react-router/node_modules/@types/history": { - "version": "4.7.11", - "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", - "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", - "dev": true - }, "node_modules/@types/react-transition-group": { "version": "4.4.10", "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.10.tgz", @@ -11253,12 +11237,16 @@ } }, "node_modules/history": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz", - "integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==", - "dev": true, + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", + "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", "dependencies": { - "@babel/runtime": "^7.7.6" + "@babel/runtime": "^7.1.2", + "loose-envify": "^1.2.0", + "resolve-pathname": "^3.0.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0", + "value-equal": "^1.0.1" } }, "node_modules/hoist-non-react-statics": { @@ -18704,32 +18692,6 @@ "react": ">=15" } }, - "node_modules/react-router-dom/node_modules/history": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", - "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", - "dependencies": { - "@babel/runtime": "^7.1.2", - "loose-envify": "^1.2.0", - "resolve-pathname": "^3.0.0", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0", - "value-equal": "^1.0.1" - } - }, - "node_modules/react-router/node_modules/history": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", - "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", - "dependencies": { - "@babel/runtime": "^7.1.2", - "loose-envify": "^1.2.0", - "resolve-pathname": "^3.0.0", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0", - "value-equal": "^1.0.1" - } - }, "node_modules/react-router/node_modules/mini-create-react-context": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz", @@ -26136,13 +26098,10 @@ } }, "@types/history": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@types/history/-/history-5.0.0.tgz", - "integrity": "sha512-hy8b7Y1J8OGe6LbAjj3xniQrj3v6lsivCcrmf4TzSgPzLkhIeKgc5IZnT7ReIqmEuodjfO8EYAuoFvIrHi/+jQ==", - "dev": true, - "requires": { - "history": "*" - } + "version": "4.7.11", + "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", + "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", + "dev": true }, "@types/html-minifier-terser": { "version": "6.1.0", @@ -26295,14 +26254,6 @@ "requires": { "@types/history": "^4.7.11", "@types/react": "*" - }, - "dependencies": { - "@types/history": { - "version": "4.7.11", - "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", - "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", - "dev": true - } } }, "@types/react-router-dom": { @@ -26314,14 +26265,6 @@ "@types/history": "^4.7.11", "@types/react": "*", "@types/react-router": "*" - }, - "dependencies": { - "@types/history": { - "version": "4.7.11", - "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", - "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", - "dev": true - } } }, "@types/react-transition-group": { @@ -31186,12 +31129,16 @@ "dev": true }, "history": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz", - "integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==", - "dev": true, + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", + "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", "requires": { - "@babel/runtime": "^7.7.6" + "@babel/runtime": "^7.1.2", + "loose-envify": "^1.2.0", + "resolve-pathname": "^3.0.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0", + "value-equal": "^1.0.1" } }, "hoist-non-react-statics": { @@ -36373,19 +36320,6 @@ "tiny-warning": "^1.0.0" }, "dependencies": { - "history": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", - "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", - "requires": { - "@babel/runtime": "^7.1.2", - "loose-envify": "^1.2.0", - "resolve-pathname": "^3.0.0", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0", - "value-equal": "^1.0.1" - } - }, "mini-create-react-context": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz", @@ -36414,21 +36348,6 @@ "react-router": "5.2.1", "tiny-invariant": "^1.0.2", "tiny-warning": "^1.0.0" - }, - "dependencies": { - "history": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", - "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", - "requires": { - "@babel/runtime": "^7.1.2", - "loose-envify": "^1.2.0", - "resolve-pathname": "^3.0.0", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0", - "value-equal": "^1.0.1" - } - } } }, "react-scripts": { diff --git a/package.json b/package.json index 924687e64..ac786b361 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@babel/plugin-proposal-class-properties": "7.18.6", "@babel/preset-react": "7.24.7", "@types/dompurify": "3.0.5", - "@types/history": "5.0.0", + "@types/history": "4.7.11", "@types/lodash": "4.17.5", "@types/react": "18.3.3", "@types/react-modal": "3.16.3", @@ -79,7 +79,7 @@ "eslint-plugin-flowtype": "8.0.3", "eslint-plugin-react": "7.34.3", "google-auth-library": "9.11.0", - "history": "5.3.0", + "history": "4.10.1", "html-webpack-plugin": "5.6.0", "prop-types": "15.8.1", "react-error-overlay": "6.0.11", diff --git a/src/components/SignInButton.tsx b/src/components/SignInButton.tsx index b145af497..017da569c 100644 --- a/src/components/SignInButton.tsx +++ b/src/components/SignInButton.tsx @@ -23,8 +23,6 @@ interface ErrorInfo { description?: string; } -type ErrorDisplay = ErrorInfo | JSX.Element; - interface HttpError extends Error { status?: number; } @@ -34,9 +32,11 @@ export const SignInButton = (props: SignInButtonProps) => { const [isLoading, setIsLoading] = useState(false); const [showError, setShowError] = useState(false); const { style } = props; + const history = useHistory(); - const onSuccess = async (response: OidcUser) => { + // eslint-disable-next-line no-unused-vars + const onSuccess = async (_: OidcUser) => { const redirectTo = getRedirectTo(); const shouldRedirect = shouldRedirectTo(redirectTo); diff --git a/src/libs/ajax/OAuth2.ts b/src/libs/ajax/OAuth2.ts index 7f1f264bb..23c84c504 100644 --- a/src/libs/ajax/OAuth2.ts +++ b/src/libs/ajax/OAuth2.ts @@ -1,5 +1,5 @@ -import axios from "axios"; -import { Config } from "../config"; +import axios from 'axios'; +import { Config } from '../config'; export interface OAuthConfig { clientId: string; diff --git a/src/libs/ajax/User.ts b/src/libs/ajax/User.ts index cae5438a9..a4f53fa06 100644 --- a/src/libs/ajax/User.ts +++ b/src/libs/ajax/User.ts @@ -4,15 +4,15 @@ import { Config } from '../config'; import axios from 'axios'; import { getApiUrl, fetchOk, fetchAny } from '../ajax'; -export type UserRoleName = - 'Admin' | 'Chairperson' | 'Member' | 'Researcher' | +export type UserRoleName = + 'Admin' | 'Chairperson' | 'Member' | 'Researcher' | 'Alumni' | 'SigningOfficial' | 'DataSubmitter' | 'All'; export interface UserRole { - roleId: number, + roleId: number, name: UserRoleName, - userId: number, - userRoleId: number, + userId: number, + userRoleId: number, } export interface DuosUser { @@ -83,7 +83,7 @@ export const User = { update: async (user, userId) => { const url = `${await getApiUrl()}/api/user/${userId}`; // We should not be updating the user's create date, associated institution, or library cards - let filteredUser = flow( + const filteredUser = flow( cloneDeep, unset('updatedUser.createDate'), unset('updatedUser.institution'), diff --git a/src/libs/auth/RedirectFromOAuth.tsx b/src/libs/auth/RedirectFromOAuth.tsx index 55c1db60f..6f5b689a7 100644 --- a/src/libs/auth/RedirectFromOAuth.tsx +++ b/src/libs/auth/RedirectFromOAuth.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React from 'react'; import { createRoot } from 'react-dom/client'; import { OidcBroker } from './oidcBroker'; import { Spinner } from '../../components/Spinner'; diff --git a/src/libs/auth/auth.ts b/src/libs/auth/auth.ts index e65262df2..fbe813150 100644 --- a/src/libs/auth/auth.ts +++ b/src/libs/auth/auth.ts @@ -1,4 +1,4 @@ -/* +/* This file should abstract out the oidcBroker actions and implement DUOS specific auth login (signIn, signOut, etc.) */ @@ -21,7 +21,8 @@ export const Auth = { const um: UserManager = OidcBroker.getUserManager(); // UserManager events. // For details of each event, see https://authts.github.io/oidc-client-ts/classes/UserManagerEvents.html - um.events.addUserLoaded((user: OidcUser) => { + // eslint-disable-next-line no-unused-vars + um.events.addUserLoaded((_: OidcUser) => { //TODO: DUOS-3072 Add metrics for user loaded }); um.events.addAccessTokenExpiring((): void => {