Socket
Socket
Sign inDemoInstall

arbundles

Package Overview
Dependencies
Maintainers
3
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arbundles - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

9

build/node/cjs/src/signing/chains/ethereumSigner.js

@@ -17,5 +17,6 @@ "use strict";

const secp256k1_2 = __importDefault(require("secp256k1"));
const utils_1 = require("ethers/lib/utils");
const base64url_1 = __importDefault(require("base64url"));
const ethers_1 = require("ethers");
const bytes_1 = require("@ethersproject/bytes");
const wallet_1 = require("@ethersproject/wallet");
const hash_1 = require("@ethersproject/hash");
class EthereumSigner extends secp256k1_1.default {

@@ -32,3 +33,3 @@ get publicKey() {

return __awaiter(this, void 0, void 0, function* () {
const wallet = new ethers_1.ethers.Wallet(this._key);
const wallet = new wallet_1.Wallet(this._key);
return wallet.signMessage(message).then((r) => Buffer.from(r.slice(2), "hex"));

@@ -43,3 +44,3 @@ // below doesn't work due to lacking correct v derivation.

// return ethers.utils.verifyMessage(message, signature) === address;
return secp256k1_2.default.ecdsaVerify(signature.length === 65 ? signature.slice(0, -1) : signature, (0, utils_1.arrayify)((0, utils_1.hashMessage)(message)), typeof pk === "string" ? base64url_1.default.toBuffer(pk) : pk);
return secp256k1_2.default.ecdsaVerify(signature.length === 65 ? signature.slice(0, -1) : signature, (0, bytes_1.arrayify)((0, hash_1.hashMessage)(message)), typeof pk === "string" ? base64url_1.default.toBuffer(pk) : pk);
});

@@ -46,0 +47,0 @@ }

/// <reference types="node" />
import { ethers } from "ethers";
import type { Web3Provider, JsonRpcSigner } from "@ethersproject/providers";
import type { Signer } from "../index";
import { SignatureConfig } from "../../constants";
export default class InjectedEthereumSigner implements Signer {
protected signer: ethers.providers.JsonRpcSigner;
protected signer: JsonRpcSigner;
publicKey: Buffer;

@@ -11,3 +11,3 @@ readonly ownerLength: number;

readonly signatureType: SignatureConfig;
constructor(provider: ethers.providers.Web3Provider);
constructor(provider: Web3Provider);
setPublicKey(): Promise<void>;

@@ -14,0 +14,0 @@ sign(message: Uint8Array): Promise<Uint8Array>;

@@ -12,4 +12,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const ethers_1 = require("ethers");
const hash_1 = require("@ethersproject/hash");
const signing_key_1 = require("@ethersproject/signing-key");
const constants_1 = require("../../constants");
const bytes_1 = require("@ethersproject/bytes");
const transactions_1 = require("@ethersproject/transactions");
const wallet_1 = require("@ethersproject/wallet");
class InjectedEthereumSigner {

@@ -26,5 +30,5 @@ constructor(provider) {

const signedMsg = yield this.signer.signMessage(address);
const hash = yield ethers_1.ethers.utils.hashMessage(address);
const recoveredKey = ethers_1.ethers.utils.recoverPublicKey(ethers_1.ethers.utils.arrayify(hash), signedMsg);
this.publicKey = Buffer.from(ethers_1.ethers.utils.arrayify(recoveredKey));
const hash = yield (0, hash_1.hashMessage)(address);
const recoveredKey = (0, signing_key_1.recoverPublicKey)((0, bytes_1.arrayify)(hash), signedMsg);
this.publicKey = Buffer.from((0, bytes_1.arrayify)(recoveredKey));
});

@@ -42,4 +46,4 @@ }

static verify(pk, message, signature) {
const address = ethers_1.ethers.utils.computeAddress(pk);
return ethers_1.ethers.utils.verifyMessage(message, signature) === address;
const address = (0, transactions_1.computeAddress)(pk);
return (0, wallet_1.verifyMessage)(message, signature) === address;
}

@@ -46,0 +50,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

const constants_1 = require("../../constants");
const utils_1 = require("ethers/lib/utils");
const wallet_1 = require("@ethersproject/wallet");
const injectedEthereumSigner_1 = __importDefault(require("./injectedEthereumSigner"));

@@ -44,3 +44,3 @@ const TypedEthereumSigner_1 = require("./TypedEthereumSigner");

const address = pk;
const addr = (0, utils_1.verifyTypedData)(TypedEthereumSigner_1.domain, TypedEthereumSigner_1.types, { address, "Transaction hash": message }, signature);
const addr = (0, wallet_1.verifyTypedData)(TypedEthereumSigner_1.domain, TypedEthereumSigner_1.types, { address, "Transaction hash": message }, signature);
return address === addr;

@@ -47,0 +47,0 @@ }

@@ -16,4 +16,3 @@ "use strict";

exports.DOMAIN = exports.MESSAGE = exports.types = exports.domain = void 0;
const ethers_1 = require("ethers");
const utils_1 = require("ethers/lib/utils");
const wallet_1 = require("@ethersproject/wallet");
const constants_1 = require("../../constants");

@@ -29,3 +28,3 @@ const keccak256_1 = __importDefault(require("../keccak256"));

this.address = "0x" + (0, keccak256_1.default)(super.publicKey.slice(1)).slice(-20).toString("hex");
this.signer = new ethers_1.Wallet(key);
this.signer = new wallet_1.Wallet(key);
}

@@ -47,3 +46,3 @@ get publicKey() {

const address = pk.toString();
const addr = (0, utils_1.verifyTypedData)(exports.domain, exports.types, { address, "Transaction hash": message }, signature);
const addr = (0, wallet_1.verifyTypedData)(exports.domain, exports.types, { address, "Transaction hash": message }, signature);
return address.toLowerCase() === addr.toLowerCase();

@@ -50,0 +49,0 @@ });

import Secp256k1 from "../keys/secp256k1.js";
import secp256k1 from "secp256k1";
import { arrayify, hashMessage } from "ethers/lib/utils.js";
import base64url from "base64url";
import { ethers } from "ethers";
import { arrayify } from "@ethersproject/bytes";
import { Wallet } from "@ethersproject/wallet";
import { hashMessage } from "@ethersproject/hash";
export default class EthereumSigner extends Secp256k1 {

@@ -16,3 +17,3 @@ get publicKey() {

async sign(message) {
const wallet = new ethers.Wallet(this._key);
const wallet = new Wallet(this._key);
return wallet.signMessage(message).then((r) => Buffer.from(r.slice(2), "hex"));

@@ -19,0 +20,0 @@ // below doesn't work due to lacking correct v derivation.

/// <reference types="node" />
import { ethers } from "ethers";
import type { Web3Provider, JsonRpcSigner } from "@ethersproject/providers";
import type { Signer } from "../index.js";
import { SignatureConfig } from "../../constants.js";
export default class InjectedEthereumSigner implements Signer {
protected signer: ethers.providers.JsonRpcSigner;
protected signer: JsonRpcSigner;
publicKey: Buffer;

@@ -11,3 +11,3 @@ readonly ownerLength: number;

readonly signatureType: SignatureConfig;
constructor(provider: ethers.providers.Web3Provider);
constructor(provider: Web3Provider);
setPublicKey(): Promise<void>;

@@ -14,0 +14,0 @@ sign(message: Uint8Array): Promise<Uint8Array>;

@@ -1,3 +0,7 @@

import { ethers } from "ethers";
import { hashMessage } from "@ethersproject/hash";
import { recoverPublicKey } from "@ethersproject/signing-key";
import { SignatureConfig, SIG_CONFIG } from "../../constants.js";
import { arrayify } from "@ethersproject/bytes";
import { computeAddress } from "@ethersproject/transactions";
import { verifyMessage } from "@ethersproject/wallet";
export default class InjectedEthereumSigner {

@@ -15,5 +19,5 @@ signer;

const signedMsg = await this.signer.signMessage(address);
const hash = await ethers.utils.hashMessage(address);
const recoveredKey = ethers.utils.recoverPublicKey(ethers.utils.arrayify(hash), signedMsg);
this.publicKey = Buffer.from(ethers.utils.arrayify(recoveredKey));
const hash = await hashMessage(address);
const recoveredKey = recoverPublicKey(arrayify(hash), signedMsg);
this.publicKey = Buffer.from(arrayify(recoveredKey));
}

@@ -28,6 +32,6 @@ async sign(message) {

static verify(pk, message, signature) {
const address = ethers.utils.computeAddress(pk);
return ethers.utils.verifyMessage(message, signature) === address;
const address = computeAddress(pk);
return verifyMessage(message, signature) === address;
}
}
//# sourceMappingURL=injectedEthereumSigner.js.map
import { SignatureConfig, SIG_CONFIG } from "../../constants.js";
import { verifyTypedData } from "ethers/lib/utils.js";
import { verifyTypedData } from "@ethersproject/wallet";
import InjectedEthereumSigner from "./injectedEthereumSigner.js";

@@ -4,0 +4,0 @@ import { domain, types } from "./TypedEthereumSigner.js";

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

import { Wallet } from "ethers";
import { verifyTypedData } from "ethers/lib/utils.js";
import { Wallet, verifyTypedData } from "@ethersproject/wallet";
import { SignatureConfig, SIG_CONFIG } from "../../constants.js";

@@ -4,0 +3,0 @@ import keccak256 from "../keccak256.js";

@@ -17,5 +17,6 @@ "use strict";

const secp256k1_2 = __importDefault(require("secp256k1"));
const utils_1 = require("ethers/lib/utils");
const base64url_1 = __importDefault(require("base64url"));
const ethers_1 = require("ethers");
const bytes_1 = require("@ethersproject/bytes");
const wallet_1 = require("@ethersproject/wallet");
const hash_1 = require("@ethersproject/hash");
class EthereumSigner extends secp256k1_1.default {

@@ -32,3 +33,3 @@ get publicKey() {

return __awaiter(this, void 0, void 0, function* () {
const wallet = new ethers_1.ethers.Wallet(this._key);
const wallet = new wallet_1.Wallet(this._key);
return wallet.signMessage(message).then((r) => Buffer.from(r.slice(2), "hex"));

@@ -43,3 +44,3 @@ // below doesn't work due to lacking correct v derivation.

// return ethers.utils.verifyMessage(message, signature) === address;
return secp256k1_2.default.ecdsaVerify(signature.length === 65 ? signature.slice(0, -1) : signature, (0, utils_1.arrayify)((0, utils_1.hashMessage)(message)), typeof pk === "string" ? base64url_1.default.toBuffer(pk) : pk);
return secp256k1_2.default.ecdsaVerify(signature.length === 65 ? signature.slice(0, -1) : signature, (0, bytes_1.arrayify)((0, hash_1.hashMessage)(message)), typeof pk === "string" ? base64url_1.default.toBuffer(pk) : pk);
});

@@ -46,0 +47,0 @@ }

/// <reference types="node" />
import { ethers } from "ethers";
import type { Web3Provider, JsonRpcSigner } from "@ethersproject/providers";
import type { Signer } from "../index";
import { SignatureConfig } from "../../constants";
export default class InjectedEthereumSigner implements Signer {
protected signer: ethers.providers.JsonRpcSigner;
protected signer: JsonRpcSigner;
publicKey: Buffer;

@@ -11,3 +11,3 @@ readonly ownerLength: number;

readonly signatureType: SignatureConfig;
constructor(provider: ethers.providers.Web3Provider);
constructor(provider: Web3Provider);
setPublicKey(): Promise<void>;

@@ -14,0 +14,0 @@ sign(message: Uint8Array): Promise<Uint8Array>;

@@ -12,4 +12,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const ethers_1 = require("ethers");
const hash_1 = require("@ethersproject/hash");
const signing_key_1 = require("@ethersproject/signing-key");
const constants_1 = require("../../constants");
const bytes_1 = require("@ethersproject/bytes");
const transactions_1 = require("@ethersproject/transactions");
const wallet_1 = require("@ethersproject/wallet");
class InjectedEthereumSigner {

@@ -26,5 +30,5 @@ constructor(provider) {

const signedMsg = yield this.signer.signMessage(address);
const hash = yield ethers_1.ethers.utils.hashMessage(address);
const recoveredKey = ethers_1.ethers.utils.recoverPublicKey(ethers_1.ethers.utils.arrayify(hash), signedMsg);
this.publicKey = Buffer.from(ethers_1.ethers.utils.arrayify(recoveredKey));
const hash = yield (0, hash_1.hashMessage)(address);
const recoveredKey = (0, signing_key_1.recoverPublicKey)((0, bytes_1.arrayify)(hash), signedMsg);
this.publicKey = Buffer.from((0, bytes_1.arrayify)(recoveredKey));
});

@@ -42,4 +46,4 @@ }

static verify(pk, message, signature) {
const address = ethers_1.ethers.utils.computeAddress(pk);
return ethers_1.ethers.utils.verifyMessage(message, signature) === address;
const address = (0, transactions_1.computeAddress)(pk);
return (0, wallet_1.verifyMessage)(message, signature) === address;
}

@@ -46,0 +50,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

const constants_1 = require("../../constants");
const utils_1 = require("ethers/lib/utils");
const wallet_1 = require("@ethersproject/wallet");
const injectedEthereumSigner_1 = __importDefault(require("./injectedEthereumSigner"));

@@ -44,3 +44,3 @@ const TypedEthereumSigner_1 = require("./TypedEthereumSigner");

const address = pk;
const addr = (0, utils_1.verifyTypedData)(TypedEthereumSigner_1.domain, TypedEthereumSigner_1.types, { address, "Transaction hash": message }, signature);
const addr = (0, wallet_1.verifyTypedData)(TypedEthereumSigner_1.domain, TypedEthereumSigner_1.types, { address, "Transaction hash": message }, signature);
return address === addr;

@@ -47,0 +47,0 @@ }

@@ -16,4 +16,3 @@ "use strict";

exports.DOMAIN = exports.MESSAGE = exports.types = exports.domain = void 0;
const ethers_1 = require("ethers");
const utils_1 = require("ethers/lib/utils");
const wallet_1 = require("@ethersproject/wallet");
const constants_1 = require("../../constants");

@@ -29,3 +28,3 @@ const keccak256_1 = __importDefault(require("../keccak256"));

this.address = "0x" + (0, keccak256_1.default)(super.publicKey.slice(1)).slice(-20).toString("hex");
this.signer = new ethers_1.Wallet(key);
this.signer = new wallet_1.Wallet(key);
}

@@ -47,3 +46,3 @@ get publicKey() {

const address = pk.toString();
const addr = (0, utils_1.verifyTypedData)(exports.domain, exports.types, { address, "Transaction hash": message }, signature);
const addr = (0, wallet_1.verifyTypedData)(exports.domain, exports.types, { address, "Transaction hash": message }, signature);
return address.toLowerCase() === addr.toLowerCase();

@@ -50,0 +49,0 @@ });

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

import { ethers } from "ethers";
import { Wallet } from "@ethersproject/wallet";
import { createData, TypedEthereumSigner } from "../../index.js";
import Crypto from "crypto";
const wallet = new ethers.Wallet("0x37929fc21ab44ace162318acbbf4d24a41270b2aee18fd1cfb22e3fc3f4b4024");
const randWallet = ethers.Wallet.createRandom();
const wallet = new Wallet("0x37929fc21ab44ace162318acbbf4d24a41270b2aee18fd1cfb22e3fc3f4b4024");
const randWallet = Wallet.createRandom();
describe("Typed ethereum signer", function () {

@@ -7,0 +7,0 @@ describe("sign & verify", () => {

import Secp256k1 from "../keys/secp256k1.js";
import secp256k1 from "secp256k1";
import { arrayify, hashMessage } from "ethers/lib/utils.js";
import base64url from "base64url";
import { ethers } from "ethers";
import { arrayify } from "@ethersproject/bytes";
import { Wallet } from "@ethersproject/wallet";
import { hashMessage } from "@ethersproject/hash";
export default class EthereumSigner extends Secp256k1 {

@@ -16,3 +17,3 @@ get publicKey() {

async sign(message) {
const wallet = new ethers.Wallet(this._key);
const wallet = new Wallet(this._key);
return wallet.signMessage(message).then((r) => Buffer.from(r.slice(2), "hex"));

@@ -19,0 +20,0 @@ // below doesn't work due to lacking correct v derivation.

/// <reference types="node" />
import { ethers } from "ethers";
import type { Web3Provider, JsonRpcSigner } from "@ethersproject/providers";
import type { Signer } from "../index.js";
import { SignatureConfig } from "../../constants.js";
export default class InjectedEthereumSigner implements Signer {
protected signer: ethers.providers.JsonRpcSigner;
protected signer: JsonRpcSigner;
publicKey: Buffer;

@@ -11,3 +11,3 @@ readonly ownerLength: number;

readonly signatureType: SignatureConfig;
constructor(provider: ethers.providers.Web3Provider);
constructor(provider: Web3Provider);
setPublicKey(): Promise<void>;

@@ -14,0 +14,0 @@ sign(message: Uint8Array): Promise<Uint8Array>;

@@ -1,3 +0,7 @@

import { ethers } from "ethers";
import { hashMessage } from "@ethersproject/hash";
import { recoverPublicKey } from "@ethersproject/signing-key";
import { SignatureConfig, SIG_CONFIG } from "../../constants.js";
import { arrayify } from "@ethersproject/bytes";
import { computeAddress } from "@ethersproject/transactions";
import { verifyMessage } from "@ethersproject/wallet";
export default class InjectedEthereumSigner {

@@ -15,5 +19,5 @@ signer;

const signedMsg = await this.signer.signMessage(address);
const hash = await ethers.utils.hashMessage(address);
const recoveredKey = ethers.utils.recoverPublicKey(ethers.utils.arrayify(hash), signedMsg);
this.publicKey = Buffer.from(ethers.utils.arrayify(recoveredKey));
const hash = await hashMessage(address);
const recoveredKey = recoverPublicKey(arrayify(hash), signedMsg);
this.publicKey = Buffer.from(arrayify(recoveredKey));
}

@@ -28,6 +32,6 @@ async sign(message) {

static verify(pk, message, signature) {
const address = ethers.utils.computeAddress(pk);
return ethers.utils.verifyMessage(message, signature) === address;
const address = computeAddress(pk);
return verifyMessage(message, signature) === address;
}
}
//# sourceMappingURL=injectedEthereumSigner.js.map
import { SignatureConfig, SIG_CONFIG } from "../../constants.js";
import { verifyTypedData } from "ethers/lib/utils.js";
import { verifyTypedData } from "@ethersproject/wallet";
import InjectedEthereumSigner from "./injectedEthereumSigner.js";

@@ -4,0 +4,0 @@ import { domain, types } from "./TypedEthereumSigner.js";

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

import { Wallet } from "ethers";
import { verifyTypedData } from "ethers/lib/utils.js";
import { Wallet, verifyTypedData } from "@ethersproject/wallet";
import { SignatureConfig, SIG_CONFIG } from "../../constants.js";

@@ -4,0 +3,0 @@ import keccak256 from "../keccak256.js";

{
"name": "arbundles",
"version": "0.9.2",
"version": "0.9.3",
"description": "Arweave bundling library",

@@ -132,2 +132,8 @@ "author": "Josh Benaron <joshbenaron@gmail.com>",

"dependencies": {
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/hash": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@ethersproject/signing-key": "^5.7.0",
"@ethersproject/transactions": "^5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@noble/ed25519": "^1.6.1",

@@ -137,3 +143,2 @@ "arweave": "=1.11.8",

"bs58": "^4.0.1",
"ethers": "=5.7.2",
"keccak": "^3.0.2",

@@ -140,0 +145,0 @@ "secp256k1": "^4.0.2"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc