Skip to content

Commit

Permalink
Fix security warning (#506)
Browse files Browse the repository at this point in the history
* Upgrade to next 14.2.21

Fix security warnings

* Pin react 18.3.1

* React always a peer dependency in packages

* Pin tailwind to 3.4.13

* pin typescript to 5.6.2

* pin postcss to 8.4.47

* pin eslint

* pin @types/node

* pin @heroicons/react

* Remove dependency on @ethersproject/hash

* Add changeset
  • Loading branch information
lightwalker-eth authored Dec 26, 2024
1 parent 505f340 commit c748998
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 229 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-drinks-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@namehash/ens-utils": patch
---

Remove dependency on @ethersproject/hash
1 change: 0 additions & 1 deletion packages/ens-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
},
"dependencies": {
"@adraffy/ens-normalize": "1.11.0",
"@ethersproject/hash": "5.7.0",
"date-fns": "3.3.1",
"decimal.js": "10.4.3",
"viem": "2.21.16"
Expand Down
13 changes: 13 additions & 0 deletions packages/ens-utils/src/hashutils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@ import { describe, it, expect } from "vitest";
import {
isEncodedLabelhash,
isKeccak256Hash,
labelhash,
normalizeEncodedLabelhash,
normalizeKeccak256Hash,
} from "./hashutils";

describe("labelhash", () => {
it("correctly hashes an empty label", () => {
const result = labelhash("");
expect(result).toBe("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
});

it("correctly hashes a non-empty label", () => {
const result = labelhash("example");
expect(result).toBe("0x6fd43e7cffc31bb581d7421c8698e29aa2bd8e7186a394b85299908b4eb9b175");
});
});

describe("isKeccak256Hash", () => {
it("valid Keccak256Hash: with prefix all lowercase", () => {
const result = isKeccak256Hash(
Expand Down
6 changes: 3 additions & 3 deletions packages/ens-utils/src/hashutils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { id } from "@ethersproject/hash";
import { keccak256, toHex } from 'viem'

/**
* Simple wrapper around the viem implementation of `labelhash` that returns a generic string instead.
* @param label label to hash
* @param label label to hash (as a utf-8 string)
* @returns keccak-256 hash of the label
*/
export function labelhash(label: string): string {
return id(label);
return keccak256(toHex(label));
}

const keccak256Regex = /^(?:0x)?[0-9a-f]{64}$/i;
Expand Down
225 changes: 0 additions & 225 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c748998

Please sign in to comment.