ecies-geth
Advanced tools
Comparing version 1.7.1 to 1.7.2
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
declare global { | ||
@@ -53,5 +52,5 @@ interface Window { | ||
export declare const encrypt: (publicKeyTo: Buffer, msg: Buffer, opts?: { | ||
iv?: Buffer | undefined; | ||
ephemPrivateKey?: Buffer | undefined; | ||
} | undefined) => Promise<Buffer>; | ||
iv?: Buffer; | ||
ephemPrivateKey?: Buffer; | ||
}) => Promise<Buffer>; | ||
/** | ||
@@ -58,0 +57,0 @@ * Decrypt message using given private key. |
@@ -75,3 +75,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decrypt = exports.encrypt = exports.derive = exports.verify = exports.sign = exports.getPublic = exports.kdf = void 0; | ||
@@ -87,3 +87,3 @@ /** | ||
var crypto = window.crypto || window.msCrypto; // eslint-disable-line @typescript-eslint/no-non-null-assertion | ||
var subtle = crypto.subtle || crypto.webkitSubtle; // eslint-disable-line @typescript-eslint/no-non-null-assertion | ||
var subtle = crypto.subtle || crypto.webkitSubtle; | ||
/* eslint-enable @typescript-eslint/strict-boolean-expressions */ | ||
@@ -180,3 +180,3 @@ if (subtle === undefined || crypto === undefined) { | ||
else { | ||
resolve(Buffer.from(ec.sign(msg, privateKey, { canonical: true }).toDER('hex'), 'hex')); // eslint-disable-line @typescript-eslint/no-unsafe-argument | ||
resolve(Buffer.from(ec.sign(msg, privateKey, { canonical: true }).toDER('hex'), 'hex')); | ||
} | ||
@@ -211,3 +211,3 @@ }); }; | ||
} | ||
catch (e) { | ||
catch (_) { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
reject(new Error('Invalid arguments')); | ||
@@ -253,3 +253,2 @@ } | ||
return __generator(this, function (_a) { | ||
/* eslint-disable @typescript-eslint/strict-boolean-expressions */ | ||
opts = opts || {}; | ||
@@ -262,4 +261,3 @@ ephemPrivateKey = opts.ephemPrivateKey || randomBytes(32); | ||
return __generator(this, function (_a) { | ||
iv = opts.iv || randomBytes(16) // eslint-disable-line @typescript-eslint/no-non-null-assertion | ||
; | ||
iv = opts.iv || randomBytes(16); | ||
encryptionKey = hash.slice(0, 16); | ||
@@ -277,5 +275,3 @@ return [2 /*return*/, aesCtrEncrypt(iv, encryptionKey, msg) | ||
}); | ||
}); }) | ||
/* eslint-enable @typescript-eslint/strict-boolean-expressions */ | ||
]; | ||
}); })]; | ||
}); | ||
@@ -332,1 +328,2 @@ }); }; | ||
/* eslint-enable @typescript-eslint/unbound-method */ | ||
//# sourceMappingURL=browser.js.map |
@@ -25,14 +25,15 @@ "use strict"; | ||
*/ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// try to use secp256k1, fallback to browser implementation | ||
try { | ||
module.exports = require('./node'); // eslint-disable-line @typescript-eslint/no-unsafe-assignment | ||
module.exports = require('./node'); // eslint-disable-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-require-imports | ||
} | ||
catch (e) { | ||
if (process.env.ECCRYPTO_NO_FALLBACK) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions | ||
if (typeof process !== 'undefined' && process.env.ECCRYPTO_NO_FALLBACK) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions | ||
throw e; | ||
} | ||
else { | ||
module.exports = require('./browser'); // eslint-disable-line @typescript-eslint/no-unsafe-assignment | ||
module.exports = require('./browser'); // eslint-disable-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-require-imports | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -25,3 +25,3 @@ "use strict"; | ||
*/ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.KeyPath = exports.Path = void 0; | ||
@@ -74,1 +74,2 @@ var Path = function (account, scope, keyIndex) { return ({ | ||
exports.KeyPath = KeyPath; | ||
//# sourceMappingURL=model.js.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
export declare const kdf: (secret: Buffer, outputLength: number) => Promise<Buffer>; | ||
@@ -45,5 +44,5 @@ /** | ||
export declare const encrypt: (publicKeyTo: Buffer, msg: Buffer, opts?: { | ||
iv?: Buffer | undefined; | ||
ephemPrivateKey?: Buffer | undefined; | ||
} | undefined) => Promise<Buffer>; | ||
iv?: Buffer; | ||
ephemPrivateKey?: Buffer; | ||
}) => Promise<Buffer>; | ||
/** | ||
@@ -50,0 +49,0 @@ * Decrypt message using given private key. |
@@ -78,3 +78,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decrypt = exports.encrypt = exports.derive = exports.verify = exports.sign = exports.getPublic = exports.kdf = void 0; | ||
@@ -151,3 +151,3 @@ /** | ||
? reject(new Error('Private key should be 32 bytes long')) | ||
: resolve(Buffer.from(secp256k1_1["default"].publicKeyConvert(secp256k1_1["default"].publicKeyCreate(privateKey), false))); | ||
: resolve(Buffer.from(secp256k1_1.default.publicKeyConvert(secp256k1_1.default.publicKeyCreate(privateKey), false))); | ||
} // See https://github.com/wanderer/secp256k1-node/issues/46 | ||
@@ -175,4 +175,4 @@ ); }; | ||
var padded = pad32(msg); | ||
var signed = secp256k1_1["default"].ecdsaSign(padded, privateKey).signature; | ||
resolve(Buffer.from(secp256k1_1["default"].signatureExport(signed))); | ||
var signed = secp256k1_1.default.ecdsaSign(padded, privateKey).signature; | ||
resolve(Buffer.from(secp256k1_1.default.signatureExport(signed))); | ||
} | ||
@@ -202,4 +202,4 @@ }); }; | ||
try { | ||
var signed = secp256k1_1["default"].signatureImport(sig); | ||
if (secp256k1_1["default"].ecdsaVerify(signed, passed, publicKey)) { | ||
var signed = secp256k1_1.default.signatureImport(sig); | ||
if (secp256k1_1.default.ecdsaVerify(signed, passed, publicKey)) { | ||
resolve(true); | ||
@@ -211,3 +211,3 @@ } | ||
} | ||
catch (e) { | ||
catch (_) { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
reject(new Error('Invalid signature')); | ||
@@ -254,3 +254,2 @@ } | ||
return __generator(this, function (_a) { | ||
/* eslint-disable @typescript-eslint/strict-boolean-expressions */ | ||
opts = opts || {}; | ||
@@ -264,4 +263,3 @@ ephemPrivateKey = opts.ephemPrivateKey || (0, crypto_1.randomBytes)(32); | ||
encryptionKey = hash.slice(0, 16); | ||
iv = opts.iv || (0, crypto_1.randomBytes)(16) // eslint-disable-line @typescript-eslint/no-non-null-assertion | ||
; | ||
iv = opts.iv || (0, crypto_1.randomBytes)(16); | ||
macKey = sha256(hash.slice(16)); | ||
@@ -274,5 +272,3 @@ cipherText = aes128CtrEncrypt(iv, encryptionKey, msg); | ||
}); | ||
}); }) | ||
/* eslint-enable @typescript-eslint/strict-boolean-expressions */ | ||
]; | ||
}); })]; | ||
}); | ||
@@ -322,1 +318,2 @@ }); }; | ||
__exportStar(require("./model"), exports); | ||
//# sourceMappingURL=node.js.map |
{ | ||
"name": "ecies-geth", | ||
"version": "1.7.1", | ||
"version": "1.7.2", | ||
"description": "JavaScript Elliptic Curve Integrated Encryption Scheme (ECIES) Library - Based off Geth's implementation", | ||
@@ -9,8 +9,8 @@ "main": "dist/lib/src/typescript/index.js", | ||
"scripts": { | ||
"compile": "eslint lib --ext .ts && tsc", | ||
"fix": "eslint lib --ext .ts --fix", | ||
"test-browser": "tsc && browserify ./dist/test/src/typescript/browser.spec.js -o dist/test/src/typescript/index.js && npx live-server --port=9001 --mount=/:test/src/typescript", | ||
"compile": "eslint lib/**/*.ts && tsc", | ||
"fix": "eslint lib/**/*.ts --fix", | ||
"test-browser": "tsc && browserify ./dist/test/src/typescript/browser.spec.js -o dist/test/src/typescript/index.js --node && npx live-server --port=10001 --mount=/:test/src/typescript", | ||
"test-node": "tsc && mocha 'test/src/typescript/node.spec.ts' --require ts-node/register", | ||
"test": "tsc && mocha 'test/src/typescript/node.spec.ts' --require ts-node/register && browserify ./dist/test/src/typescript/browser.spec.js -o dist/test/src/typescript/index.js && live-server --port=9001 --mount=/:test/src/typescript", | ||
"fix-test": "eslint test --ext .ts --fix" | ||
"test": "tsc && mocha 'test/src/typescript/node.spec.ts' --require ts-node/register && browserify ./dist/test/src/typescript/browser.spec.js -o dist/test/src/typescript/index.js --node && live-server --port=10001 --mount=/:test/src/typescript", | ||
"fix-test": "eslint test/**/*.ts --fix" | ||
}, | ||
@@ -40,23 +40,26 @@ "repository": { | ||
"dependencies": { | ||
"elliptic": "^6.5.5", | ||
"elliptic": "^6.5.7", | ||
"secp256k1": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.3.14", | ||
"@types/chai-as-promised": "^7.1.8", | ||
"@eslint/eslintrc": "^3.1.0", | ||
"@eslint/js": "^9.10.0", | ||
"@types/chai": "^4.3.19", | ||
"@types/elliptic": "^6.4.18", | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "^20.11.30", | ||
"@types/mocha": "^10.0.7", | ||
"@types/node": "^22.5.4", | ||
"@types/secp256k1": "^4.0.6", | ||
"@typescript-eslint/eslint-plugin": "^7.3.1", | ||
"@typescript-eslint/parser": "^7.3.1", | ||
"@typescript-eslint/eslint-plugin": "^8.4.0", | ||
"@typescript-eslint/parser": "^8.4.0", | ||
"browserify": "^17.0.0", | ||
"chai": "^4.4.0", | ||
"chai-as-promised": "^7.1.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-no-loops": "~0.3.0", | ||
"mocha": "^10.3.0", | ||
"chai": "^4.5.0", | ||
"eslint": "^9.10.0", | ||
"eslint-plugin-no-loops": "~0.4.0", | ||
"globals": "^15.9.0", | ||
"mocha": "^10.7.3", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.4.3" | ||
"typescript": "^5.5.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80723
22
19
1068
Updatedelliptic@^6.5.7