Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

conseiljs-softsigner

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conseiljs-softsigner - npm Package Compare versions

Comparing version 5.0.4-beta.1 to 5.0.4

8

dist/KeyStoreUtils.js

@@ -59,6 +59,6 @@ "use strict";

const seed = yield bip39.mnemonicToSeed(mnemonic, password);
if (derivationPath !== undefined) {
const sk = (Ed25519.derivePath(derivationPath, seed.toString("hex"))).key;
const p = Ed25519.derivePath(derivationPath, seed.toString("hex"));
keys = yield recoverKeys(Buffer.concat([p.key, p.chainCode]));
if (derivationPath !== undefined && derivationPath.length > 0) {
const keySource = Ed25519.derivePath(derivationPath, seed.toString("hex"));
const combinedKey = Buffer.concat([keySource.key, keySource.chainCode]);
keys = yield recoverKeys(combinedKey);
}

@@ -65,0 +65,0 @@ else {

@@ -5,14 +5,11 @@ /// <reference types="node" />

readonly _secretKey: Buffer;
private _passphrase;
private _isEncrypted;
private _salt;
private _key;
private _lockTimout;
private _unlocked;
private constructor();
getSignerCurve(): SignerCurve;
static createSigner(secretKey: Buffer, validity?: number): Promise<Signer>;
static createSigner(secretKey: Buffer, password?: string): Promise<Signer>;
private getKey;
signOperation(bytes: Buffer): Promise<Buffer>;
signText(message: string): Promise<string>;
signTextHash(message: string): Promise<string>;
signOperation(bytes: Buffer, password?: string): Promise<Buffer>;
signText(message: string, password?: string): Promise<string>;
signTextHash(message: string, password?: string): Promise<string>;
}

@@ -11,24 +11,10 @@ "use strict";

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const GeneratePassword = __importStar(require("generate-password"));
const conseiljs_1 = require("conseiljs");
const CryptoUtils_1 = require("./utils/CryptoUtils");
class SoftSigner {
constructor(secretKey, validity = -1, passphrase = '', salt) {
constructor(secretKey, isEncrypted = false, salt) {
this._secretKey = secretKey;
this._lockTimout = validity;
this._passphrase = passphrase;
this._isEncrypted = isEncrypted;
this._salt = salt ? salt : Buffer.alloc(0);
this._unlocked = validity < 0;
this._key = Buffer.alloc(0);
if (validity < 0) {
this._key = secretKey;
}
}

@@ -38,50 +24,34 @@ getSignerCurve() {

}
static createSigner(secretKey, validity = 60) {
static createSigner(secretKey, password = '') {
return __awaiter(this, void 0, void 0, function* () {
if (validity >= 0) {
const passphrase = GeneratePassword.generate({ length: 32, numbers: true, symbols: true, lowercase: true, uppercase: true });
if (password.length > 0) {
const salt = yield CryptoUtils_1.CryptoUtils.generateSaltForPwHash();
secretKey = yield CryptoUtils_1.CryptoUtils.encryptMessage(secretKey, passphrase, salt);
return new SoftSigner(secretKey, validity, passphrase, salt);
const encryptedKey = yield CryptoUtils_1.CryptoUtils.encryptMessage(secretKey, password, salt);
return new SoftSigner(encryptedKey, true, salt);
}
else {
return new SoftSigner(secretKey);
}
return new SoftSigner(secretKey);
});
}
getKey() {
getKey(password = '') {
return __awaiter(this, void 0, void 0, function* () {
if (!this._unlocked) {
const k = yield CryptoUtils_1.CryptoUtils.decryptMessage(this._secretKey, this._passphrase, this._salt);
if (this._lockTimout == 0) {
return k;
}
this._key = k;
this._unlocked = true;
if (this._lockTimout > 0) {
setTimeout(() => {
this._key = Buffer.alloc(0);
this._unlocked = false;
}, this._lockTimout * 1000);
}
return this._key;
if (this._isEncrypted && password.length > 0) {
return yield CryptoUtils_1.CryptoUtils.decryptMessage(this._secretKey, password, this._salt);
}
return this._key;
return this._secretKey;
});
}
signOperation(bytes) {
signOperation(bytes, password = '') {
return __awaiter(this, void 0, void 0, function* () {
return CryptoUtils_1.CryptoUtils.signDetached(conseiljs_1.TezosMessageUtils.simpleHash(bytes, 32), yield this.getKey());
return CryptoUtils_1.CryptoUtils.signDetached(conseiljs_1.TezosMessageUtils.simpleHash(bytes, 32), yield this.getKey(password));
});
}
signText(message) {
signText(message, password = '') {
return __awaiter(this, void 0, void 0, function* () {
const messageSig = yield CryptoUtils_1.CryptoUtils.signDetached(Buffer.from(message, 'utf8'), yield this.getKey());
const messageSig = yield CryptoUtils_1.CryptoUtils.signDetached(Buffer.from(message, 'utf8'), yield this.getKey(password));
return conseiljs_1.TezosMessageUtils.readSignatureWithHint(messageSig, 'edsig');
});
}
signTextHash(message) {
signTextHash(message, password = '') {
return __awaiter(this, void 0, void 0, function* () {
const messageHash = conseiljs_1.TezosMessageUtils.simpleHash(Buffer.from(message, 'utf8'), 32);
const messageSig = yield CryptoUtils_1.CryptoUtils.signDetached(messageHash, yield this.getKey());
const messageSig = yield this.signOperation(Buffer.from(message, 'utf8'), password);
return conseiljs_1.TezosMessageUtils.readSignatureWithHint(messageSig, 'edsig');

@@ -88,0 +58,0 @@ });

{
"name": "conseiljs-softsigner",
"version": "5.0.4-beta.1",
"version": "5.0.4",
"description": "ConseilJS software signer plugin for ConseilJS-core. Supports the ED25519 curve via libsodium for tz1-address operations.",

@@ -66,6 +66,5 @@ "browser": "dist/index.js",

"dependencies": {
"bip39": "3.0.2",
"conseiljs": "5.0.5",
"bip39": "3.0.3",
"conseiljs": "5.0.7",
"ed25519-hd-key": "1.1.2",
"generate-password": "1.5.1",
"libsodium-wrappers-sumo": "0.7.8",

@@ -75,5 +74,5 @@ "secp256k1": "4.0.2"

"devDependencies": {
"@types/chai": "4.2.12",
"@types/chai": "4.2.14",
"@types/chai-as-promised": "7.1.3",
"@types/mocha": "8.0.3",
"@types/mocha": "8.2.0",
"@types/nock": "11.1.0",

@@ -83,8 +82,8 @@ "@types/node": "14.0.13",

"awesome-typescript-loader": "5.2.1",
"chai": "4.2.0",
"chai": "4.3.0",
"chai-as-promised": "7.1.1",
"copyfiles": "2.3.0",
"copyfiles": "2.4.1",
"coveralls": "3.1.0",
"eslint": "7.10.0",
"mocha": "8.1.3",
"eslint": "7.15.0",
"mocha": "8.2.1",
"nyc": "15.1.0",

@@ -100,4 +99,4 @@ "terser-webpack-plugin": "3.0.3",

"engines": {
"node": ">=12.16.3",
"npm": ">=6.14.4"
"node": ">=12.20.1",
"npm": ">=6.14.10"
},

@@ -104,0 +103,0 @@ "eslintConfig": {

@@ -51,3 +51,3 @@ # ConseilJS-softsigner

<script src="https://cdn.jsdelivr.net/gh/cryptonomic/conseiljs-softsigner/dist-web/conseiljs-softsigner.min.js"
integrity="sha384-CQKOqv+EzdQn751Q3h+QC6RjW4euhK6HyntuKRHQe6aQl3/0bAeQVcyKZzsywE4D"
integrity="sha384-5jDKotRViAmj5dYnobDcthO+GCIv7TtF+YMqQgJBD2fCYBUZtdZ2GaetkcaXIo7u"
crossorigin="anonymous"></script>

@@ -54,0 +54,0 @@ <script>

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc