Skip to content

Commit 51131b8

Browse files
karinathomasbbcpvaliani
andauthoredMar 13, 2025··
WORLDSERVICE-185: Replace uuid with crypto.randomUUID (#12361)
* Replace references of uuid with crypto.randomUUID * Delete incorrect import * Update test * Update bundle size :grimace: * Fix tests * Use original mock value * Fix test * Mocking of uuid * Linting * Fix test * Mock UUID * Fix tests * Correct uuid format * Correct uuid format * Correct uuid format * Remove console log * Fix test * Enforce SSL encryption of cookie * Remove outdated package * Increase bundle size * Mock optimizely in tests * Fix tests * Remove unnecessary line --------- Co-authored-by: Pedram <72317734+pvaliani@users.noreply.github.com>
1 parent 00327ef commit 51131b8

File tree

30 files changed

+1753
-1629
lines changed

30 files changed

+1753
-1629
lines changed
 

‎.github/dependabot.yml

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ updates:
1515
update-types: ['version-update:semver-major']
1616
- dependency-name: '@typescript-eslint/eslint-plugin'
1717
update-types: ['version-update:semver-major']
18-
# Opera Mini unsupported packages
19-
- dependency-name: 'uuid' # https://github.com/bbc/simorgh/pull/11840
20-
- dependency-name: '@types/uuid' # https://github.com/bbc/simorgh/pull/11840
2118
# https://jira.dev.bbc.co.uk/browse/NEWSWORLDSERVICE-1478 react-router & react-router-dom
2219
- dependency-name: 'react-router-dom'
2320
- dependency-name: 'react-router'
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

‎data/mundo/send/u50853489.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"privacyNotice": {
1313
"default": "<p>Si bien leemos lo mensajes que recibimos, no podemos garantizar que responderemos a todos.</p>\n<p>Los datos personales que proporcione ser&aacute;n procesados por la BBC y cualquier proveedor de servicios relevante del que dependamos para respaldar nuestros sistemas de quejas y de participaci&oacute;n de la audiencia con el fin manejar sus comentarios. La BBC y nuestros proveedores de servicios retendr&aacute;n sus datos de acuerdo con nuestra pol&iacute;tica de retenci&oacute;n y el Reglamento General de Protecci&oacute;n de Datos.</p>\n<p>La BBC procesa sus datos sobre la base de sus intereses leg&iacute;timos como organizaci&oacute;n de medios para responder a los comentarios y preocupaciones de la audiencia. Visite la <a href=\"https://www.bbc.com/mundo/institucional-36400009\">Cl&aacute;usula de privacidad</a> y <a href=\"http://www.bbc.co.uk/usingthebbc/cookies/\">Cookies</a> de la BBC para obtener m&aacute;s informaci&oacute;n sobre c&oacute;mo la BBC maneja sus datos. Si presenta una queja ante la BBC sobre c&oacute;mo manejamos sus datos personales y usted no est&aacute; satisfecho con nuestra respuesta, puede presentar una queja ante la Oficina del Comisionado de Informaci&oacute;n de Reino Unido.</p>",
1414
"url": "https://www.bbc.com/mundo/institucional-36400009",
15-
"additional": ""
15+
"additional": ""
1616
},
1717
"settings": {
1818
"moderationRequired": false,

‎package.json

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
],
1111
"resolutions": {
1212
"@optimizely/js-sdk-utils": "0.4.0",
13-
"uuid": "3.4.0",
1413
"winston@3.8.2": "patch:winston@npm:3.8.2#.yarn/patches/winston-npm-3.8.2-2035e9cac4.patch",
1514
"cookie": "0.7.1",
1615
"react-is": "19.0.0"
@@ -128,7 +127,6 @@
128127
"react-router-dom": "5.3.4",
129128
"undici": "7.4.0",
130129
"url-parse": "1.5.10",
131-
"uuid": "8.3.2",
132130
"winston": "patch:winston@3.8.2#./patches/winston-file-descriptor.patch"
133131
},
134132
"devDependencies": {
@@ -186,7 +184,6 @@
186184
"@types/react-router-dom": "5.3.3",
187185
"@types/testing-library__react": "10.2.0",
188186
"@types/url-parse": "^1.4.8",
189-
"@types/uuid": "^9.0.8",
190187
"@typescript-eslint/eslint-plugin": "5.62.0",
191188
"@typescript-eslint/parser": "8.26.1",
192189
"amphtml-validator": "1.0.38",

‎scripts/bundleSize/bundleSizeConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
* We are allowing a variance of -5 on `MIN_SIZE` and +5 on `MAX_SIZE` to avoid the need for frequent changes, as bundle sizes can fluctuate
88
*/
99

10-
export const MIN_SIZE = 759 - 5;
11-
export const MAX_SIZE = 1213 + 5;
10+
export const MIN_SIZE = 779 - 5;
11+
export const MAX_SIZE = 1244 + 5;

‎src/app/contexts/UserContext/index.test.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const DummyComponentWithContext = () => (
3838
</UserContextProvider>
3939
);
4040

41+
jest.mock('#app/lib/utilities/getUUID', () =>
42+
jest.fn().mockImplementation(() => '12345678-abcd-1fed-0123-a1b2c3d4e5f6'),
43+
);
44+
4145
describe('UserContext', () => {
4246
beforeEach(() => {
4347
(getCookiePolicy as jest.Mock).mockReturnValue('111');

‎src/app/contexts/UserContext/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import React, {
55
SetStateAction,
66
useMemo,
77
} from 'react';
8-
import { v4 as uuid } from 'uuid';
98
import Cookie from 'js-cookie';
109
import onClient from '#app/lib/utilities/onClient';
1110
import isOperaProxy from '#app/lib/utilities/isOperaProxy';
1211
import setCookie from '#app/lib/utilities/setCookie';
12+
import getUUID from '#app/lib/utilities/getUUID';
1313
import { getCookiePolicy, personalisationEnabled } from './cookies';
1414
import Chartbeat from './Chartbeat';
1515

@@ -29,7 +29,7 @@ const cknsMvtCookie = () => {
2929
const cookieValue = Cookie.get(cookieName);
3030

3131
if (!cookieValue) {
32-
const cookieUuid = uuid();
32+
const cookieUuid = getUUID();
3333
setCookie({ name: cookieName, value: cookieUuid });
3434
}
3535
};

0 commit comments

Comments
 (0)
Please sign in to comment.