Socket
Socket
Sign inDemoInstall

@ethersproject/hash

Package Overview
Dependencies
25
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.5 to 5.0.6

lib.esm/id.d.ts

2

lib.esm/_version.d.ts

@@ -1,1 +0,1 @@

export declare const version = "hash/5.0.5";
export declare const version = "hash/5.0.6";

@@ -1,2 +0,2 @@

export const version = "hash/5.0.5";
export const version = "hash/5.0.6";
//# sourceMappingURL=_version.js.map

@@ -1,6 +0,5 @@

import { Bytes } from "@ethersproject/bytes";
export declare function isValidName(name: string): boolean;
export declare function namehash(name: string): string;
export declare function id(text: string): string;
export declare const messagePrefix = "\u0019Ethereum Signed Message:\n";
export declare function hashMessage(message: Bytes | string): string;
import { id } from "./id";
import { isValidName, namehash } from "./namehash";
import { hashMessage, messagePrefix } from "./message";
import { TypedDataEncoder as _TypedDataEncoder } from "./typed-data";
export { id, namehash, isValidName, messagePrefix, hashMessage, _TypedDataEncoder, };
"use strict";
import { concat, hexlify } from "@ethersproject/bytes";
import { nameprep, toUtf8Bytes } from "@ethersproject/strings";
import { keccak256 } from "@ethersproject/keccak256";
import { Logger } from "@ethersproject/logger";
import { version } from "./_version";
const logger = new Logger(version);
///////////////////////////////
const Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
const Partition = new RegExp("^((.*)\\.)?([^.]+)$");
export function isValidName(name) {
try {
const comps = name.split(".");
for (let i = 0; i < comps.length; i++) {
if (nameprep(comps[i]).length === 0) {
throw new Error("empty");
}
}
return true;
}
catch (error) { }
return false;
}
export function namehash(name) {
/* istanbul ignore if */
if (typeof (name) !== "string") {
logger.throwArgumentError("invalid address - " + String(name), "name", name);
}
let result = Zeros;
while (name.length) {
const partition = name.match(Partition);
const label = toUtf8Bytes(nameprep(partition[3]));
result = keccak256(concat([result, keccak256(label)]));
name = partition[2] || "";
}
return hexlify(result);
}
export function id(text) {
return keccak256(toUtf8Bytes(text));
}
export const messagePrefix = "\x19Ethereum Signed Message:\n";
export function hashMessage(message) {
if (typeof (message) === "string") {
message = toUtf8Bytes(message);
}
return keccak256(concat([
toUtf8Bytes(messagePrefix),
toUtf8Bytes(String(message.length)),
message
]));
}
import { id } from "./id";
import { isValidName, namehash } from "./namehash";
import { hashMessage, messagePrefix } from "./message";
import { TypedDataEncoder as _TypedDataEncoder } from "./typed-data";
export { id, namehash, isValidName, messagePrefix, hashMessage, _TypedDataEncoder, };
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

export declare const version = "hash/5.0.5";
export declare const version = "hash/5.0.6";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "hash/5.0.5";
exports.version = "hash/5.0.6";
//# sourceMappingURL=_version.js.map

@@ -1,6 +0,5 @@

import { Bytes } from "@ethersproject/bytes";
export declare function isValidName(name: string): boolean;
export declare function namehash(name: string): string;
export declare function id(text: string): string;
export declare const messagePrefix = "\u0019Ethereum Signed Message:\n";
export declare function hashMessage(message: Bytes | string): string;
import { id } from "./id";
import { isValidName, namehash } from "./namehash";
import { hashMessage, messagePrefix } from "./message";
import { TypedDataEncoder as _TypedDataEncoder } from "./typed-data";
export { id, namehash, isValidName, messagePrefix, hashMessage, _TypedDataEncoder, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bytes_1 = require("@ethersproject/bytes");
var strings_1 = require("@ethersproject/strings");
var keccak256_1 = require("@ethersproject/keccak256");
var logger_1 = require("@ethersproject/logger");
var _version_1 = require("./_version");
var logger = new logger_1.Logger(_version_1.version);
///////////////////////////////
var Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
var Partition = new RegExp("^((.*)\\.)?([^.]+)$");
function isValidName(name) {
try {
var comps = name.split(".");
for (var i = 0; i < comps.length; i++) {
if (strings_1.nameprep(comps[i]).length === 0) {
throw new Error("empty");
}
}
return true;
}
catch (error) { }
return false;
}
exports.isValidName = isValidName;
function namehash(name) {
/* istanbul ignore if */
if (typeof (name) !== "string") {
logger.throwArgumentError("invalid address - " + String(name), "name", name);
}
var result = Zeros;
while (name.length) {
var partition = name.match(Partition);
var label = strings_1.toUtf8Bytes(strings_1.nameprep(partition[3]));
result = keccak256_1.keccak256(bytes_1.concat([result, keccak256_1.keccak256(label)]));
name = partition[2] || "";
}
return bytes_1.hexlify(result);
}
exports.namehash = namehash;
function id(text) {
return keccak256_1.keccak256(strings_1.toUtf8Bytes(text));
}
exports.id = id;
exports.messagePrefix = "\x19Ethereum Signed Message:\n";
function hashMessage(message) {
if (typeof (message) === "string") {
message = strings_1.toUtf8Bytes(message);
}
return keccak256_1.keccak256(bytes_1.concat([
strings_1.toUtf8Bytes(exports.messagePrefix),
strings_1.toUtf8Bytes(String(message.length)),
message
]));
}
exports.hashMessage = hashMessage;
var id_1 = require("./id");
exports.id = id_1.id;
var namehash_1 = require("./namehash");
exports.isValidName = namehash_1.isValidName;
exports.namehash = namehash_1.namehash;
var message_1 = require("./message");
exports.hashMessage = message_1.hashMessage;
exports.messagePrefix = message_1.messagePrefix;
var typed_data_1 = require("./typed-data");
exports._TypedDataEncoder = typed_data_1.TypedDataEncoder;
//# sourceMappingURL=index.js.map
{
"author": "Richard Moore <me@ricmoo.com>",
"dependencies": {
"@ethersproject/abstract-signer": "^5.0.6",
"@ethersproject/address": "^5.0.5",
"@ethersproject/bignumber": "^5.0.8",
"@ethersproject/bytes": "^5.0.4",
"@ethersproject/keccak256": "^5.0.3",
"@ethersproject/logger": "^5.0.5",
"@ethersproject/properties": "^5.0.4",
"@ethersproject/strings": "^5.0.4"

@@ -11,3 +15,3 @@ },

"ethereum": "donations.ethers.eth",
"gitHead": "ffa4a2d0549fe2c606bda3130f4a3f3d788f8dcf",
"gitHead": "86146650d83865d83b10867e9592923eada5d7cc",
"keywords": [

@@ -31,5 +35,5 @@ "Ethereum",

},
"tarballHash": "0x531ad5d951cfc5739f4169e065b67b30811c4505f045b9f79dc6fef38b1541a0",
"tarballHash": "0xd3ced44284f7527cca27da2835c7eaeb117480dc6d459415ece6a672679cd538",
"types": "./lib/index.d.ts",
"version": "5.0.5"
"version": "5.0.6"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc