chore(deps): update dependency universal-cookie to v8 (#2512)
* fix(deps): update dependency universal-cookie to v8 * refactor: validate typing of universal-cookie usages --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Braden MacDonald <braden@opencraft.com>
This commit is contained in:
38
package-lock.json
generated
38
package-lock.json
generated
@@ -74,7 +74,7 @@
|
||||
"redux-thunk": "^2.4.1",
|
||||
"reselect": "^4.1.5",
|
||||
"tinymce": "^5.10.4",
|
||||
"universal-cookie": "^4.0.4",
|
||||
"universal-cookie": "^8.0.0",
|
||||
"uuid": "^11.1.0",
|
||||
"xmlchecker": "^0.1.0",
|
||||
"yup": "0.32.11"
|
||||
@@ -2703,6 +2703,25 @@
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@edx/frontend-platform/node_modules/cookie": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
|
||||
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@edx/frontend-platform/node_modules/universal-cookie": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz",
|
||||
"integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/cookie": "^0.3.3",
|
||||
"cookie": "^0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@edx/new-relic-source-map-webpack-plugin": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@edx/new-relic-source-map-webpack-plugin/-/new-relic-source-map-webpack-plugin-2.1.0.tgz",
|
||||
@@ -27905,22 +27924,21 @@
|
||||
}
|
||||
},
|
||||
"node_modules/universal-cookie": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz",
|
||||
"integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-8.0.1.tgz",
|
||||
"integrity": "sha512-B6ks9FLLnP1UbPPcveOidfvB9pHjP+wekP2uRYB9YDfKVpvcjKgy1W5Zj+cEXJ9KTPnqOKGfVDQBmn8/YCQfRg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/cookie": "^0.3.3",
|
||||
"cookie": "^0.4.0"
|
||||
"cookie": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/universal-cookie/node_modules/cookie": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
|
||||
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz",
|
||||
"integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
"redux-thunk": "^2.4.1",
|
||||
"reselect": "^4.1.5",
|
||||
"tinymce": "^5.10.4",
|
||||
"universal-cookie": "^4.0.4",
|
||||
"universal-cookie": "^8.0.0",
|
||||
"uuid": "^11.1.0",
|
||||
"xmlchecker": "^0.1.0",
|
||||
"yup": "0.32.11"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import {
|
||||
@@ -27,7 +26,7 @@ import ExportModalError from './export-modal-error/ExportModalError';
|
||||
import ExportFooter from './export-footer/ExportFooter';
|
||||
import ExportStepper from './export-stepper/ExportStepper';
|
||||
|
||||
const CourseExportPage = ({ courseId }) => {
|
||||
const CourseExportPage = ({ courseId }: { courseId: string }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useDispatch();
|
||||
const exportTriggered = useSelector(getExportTriggered);
|
||||
@@ -128,8 +127,4 @@ const CourseExportPage = ({ courseId }) => {
|
||||
);
|
||||
};
|
||||
|
||||
CourseExportPage.propTypes = {
|
||||
courseId: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default CourseExportPage;
|
||||
@@ -88,7 +88,7 @@ export function fetchExportStatus(courseId) {
|
||||
|
||||
dispatch(updateLoadingStatus({ status: RequestStatus.SUCCESSFUL }));
|
||||
return true;
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (error.response && error.response.status === 403) {
|
||||
dispatch(updateLoadingStatus({ status: RequestStatus.DENIED }));
|
||||
} else {
|
||||
@@ -14,7 +14,7 @@ Object.defineProperty(window, 'location', {
|
||||
describe('setExportCookie', () => {
|
||||
it('should set the export cookie with the provided date and completed status', () => {
|
||||
const cookiesSetMock = jest.spyOn(Cookies.prototype, 'set');
|
||||
const date = '2023-07-24';
|
||||
const date = moment('2023-07-24').valueOf();
|
||||
const completed = true;
|
||||
setExportCookie(date, completed);
|
||||
|
||||
@@ -7,11 +7,11 @@ import { LAST_EXPORT_COOKIE_NAME, SUCCESS_DATE_FORMAT } from './data/constants';
|
||||
/**
|
||||
* Sets an export-related cookie with the provided information.
|
||||
*
|
||||
* @param {Date} date - Date of export.
|
||||
* @param date - Date of export (unix timestamp).
|
||||
* @param {boolean} completed - Indicates if export was completed successfully.
|
||||
* @returns {void}
|
||||
*/
|
||||
export const setExportCookie = (date, completed) => {
|
||||
export const setExportCookie = (date: number, completed: boolean): void => {
|
||||
const cookies = new Cookies();
|
||||
cookies.set(LAST_EXPORT_COOKIE_NAME, { date, completed }, { path: window.location.pathname });
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable max-len */
|
||||
import React, { useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import {
|
||||
@@ -24,7 +23,7 @@ import ImportSidebar from './import-sidebar/ImportSidebar';
|
||||
import FileSection from './file-section/FileSection';
|
||||
import messages from './messages';
|
||||
|
||||
const CourseImportPage = ({ courseId }) => {
|
||||
const CourseImportPage = ({ courseId }: { courseId: string }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useDispatch();
|
||||
const cookies = new Cookies();
|
||||
@@ -104,8 +103,4 @@ const CourseImportPage = ({ courseId }) => {
|
||||
);
|
||||
};
|
||||
|
||||
CourseImportPage.propTypes = {
|
||||
courseId: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default CourseImportPage;
|
||||
@@ -30,7 +30,7 @@ export function fetchImportStatus(courseId, fileName) {
|
||||
}
|
||||
dispatch(updateLoadingStatus(RequestStatus.SUCCESSFUL));
|
||||
return true;
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (error.response && error.response.status === 403) {
|
||||
dispatch(updateLoadingStatus(RequestStatus.DENIED));
|
||||
} else {
|
||||
@@ -1,4 +1,5 @@
|
||||
import Cookies from 'universal-cookie';
|
||||
import moment from 'moment';
|
||||
|
||||
import { LAST_IMPORT_COOKIE_NAME } from './data/constants';
|
||||
import { setImportCookie } from './utils';
|
||||
@@ -13,7 +14,7 @@ Object.defineProperty(window, 'location', {
|
||||
describe('setImportCookie', () => {
|
||||
it('should set the import cookie with the provided data', () => {
|
||||
const cookiesSetMock = jest.spyOn(Cookies.prototype, 'set');
|
||||
const date = '2023-07-24';
|
||||
const date = moment('2023-07-24').valueOf();
|
||||
const completed = true;
|
||||
const fileName = 'testFileName.test';
|
||||
setImportCookie(date, completed, fileName);
|
||||
@@ -5,12 +5,11 @@ import { LAST_IMPORT_COOKIE_NAME } from './data/constants';
|
||||
/**
|
||||
* Sets an import-related cookie with the provided information.
|
||||
*
|
||||
* @param {Date} date - Date of import.
|
||||
* @param date - Date of import (unix timestamp).
|
||||
* @param {boolean} completed - Indicates if import was completed successfully.
|
||||
* @param {string} fileName - File name.
|
||||
* @returns {void}
|
||||
*/
|
||||
export const setImportCookie = (date, completed, fileName) => {
|
||||
export const setImportCookie = (date: number, completed: boolean, fileName: string): void => {
|
||||
const cookies = new Cookies();
|
||||
cookies.set(LAST_IMPORT_COOKIE_NAME, { date, completed, fileName }, { path: window.location.pathname });
|
||||
};
|
||||
Reference in New Issue
Block a user