From dbe7853d4ff30be502a5a13059dfe585fb4e80a0 Mon Sep 17 00:00:00 2001 From: Benjamin Ell-Jones <56438486+Ben-EJ@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:09:48 +0100 Subject: [PATCH] Changed hashing library to fix: BUG Sort out the colour updates for the measurement station lines #257 (#279) --- air-quality-ui/package-lock.json | 6 ++++++ air-quality-ui/package.json | 1 + air-quality-ui/src/services/echarts-service.ts | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/air-quality-ui/package-lock.json b/air-quality-ui/package-lock.json index dd003189..4b92594d 100644 --- a/air-quality-ui/package-lock.json +++ b/air-quality-ui/package-lock.json @@ -17,6 +17,7 @@ "echarts": "^5.5.0", "echarts-for-react": "^3.0.2", "jest-each": "^29.7.0", + "js-sha1": "^0.7.0", "luxon": "^3.4.4", "maplibre-gl": "^4.5.0", "prettier": "^3.3.2", @@ -8744,6 +8745,11 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/js-sha1": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/js-sha1/-/js-sha1-0.7.0.tgz", + "integrity": "sha512-oQZ1Mo7440BfLSv9TX87VNEyU52pXPVG19F9PL3gTgNt0tVxlZ8F4O6yze3CLuLx28TxotxvlyepCNaaV0ZjMw==" + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", diff --git a/air-quality-ui/package.json b/air-quality-ui/package.json index b257b885..63ddb9ab 100644 --- a/air-quality-ui/package.json +++ b/air-quality-ui/package.json @@ -23,6 +23,7 @@ "echarts": "^5.5.0", "echarts-for-react": "^3.0.2", "jest-each": "^29.7.0", + "js-sha1": "^0.7.0", "luxon": "^3.4.4", "maplibre-gl": "^4.5.0", "prettier": "^3.3.2", diff --git a/air-quality-ui/src/services/echarts-service.ts b/air-quality-ui/src/services/echarts-service.ts index b5422386..e2ba3f28 100644 --- a/air-quality-ui/src/services/echarts-service.ts +++ b/air-quality-ui/src/services/echarts-service.ts @@ -1,3 +1,4 @@ +import { sha1 } from 'js-sha1' import { DateTime } from 'luxon' /** @@ -38,7 +39,7 @@ export const textToColor = async (text: string): Promise => { const generateHash = async (text: string): Promise => { const encoder = new TextEncoder() const data = encoder.encode(text) - return await crypto.subtle.digest('SHA-256', data) + return await sha1.arrayBuffer(data) } // Convert the hash to a hexadecimal string