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

@taquito/signer

Package Overview
Dependencies
Maintainers
4
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taquito/signer - npm Package Compare versions

Comparing version 16.1.2 to 16.2.0-beta-RC.0

11

dist/lib/derivation-tools/ecdsa.js

@@ -12,2 +12,3 @@ "use strict";

const errors_1 = require("../errors");
const core_1 = require("@taquito/core");
const seedKey = {

@@ -35,2 +36,3 @@ p256: 'Nist256p1 seed',

* @returns instance of PrivateKey non-HD keys derived
* @throws {@link InvalidBitSize} | {@link InvalidCurveError} | {@link InvalidSeedLengthError}
*/

@@ -44,7 +46,7 @@ static fromSeed(seedSrc, curve) {

if (!Object.prototype.hasOwnProperty.call(seedKey, curve)) {
throw new errors_1.InvalidCurveError(`unknown curve ${curve}`);
throw new errors_1.InvalidCurveError(`Unsupported curve "${curve}" expecting either "p256" or "secp256k1"`);
}
const c = new elliptic_1.ec(curve);
if (((_a = c.n) === null || _a === void 0 ? void 0 : _a.bitLength()) !== 256) {
throw new errors_1.InvalidBitSize(`invalid curve bit size ${(_b = c.n) === null || _b === void 0 ? void 0 : _b.bitLength()}`);
throw new errors_1.InvalidBitSize(`Invalid curve "${curve}" with bit size "${(_b = c.n) === null || _b === void 0 ? void 0 : _b.bitLength()}" expecting bit size "256"`);
}

@@ -86,3 +88,3 @@ const key = new TextEncoder().encode(seedKey[curve]);

let d = new bn_js_1.default(0);
let chain = new Uint8Array;
let chain = new Uint8Array();
let i = 0;

@@ -121,6 +123,7 @@ while (i === 0) {

* @returns Uint8Array (if contains a private key)
* @throws {@link InvalidKeyError}
*/
bytes() {
if (!this.keyPair.priv) {
throw new errors_1.PrivateKeyError('not a private key');
throw new core_1.InvalidKeyError('missing private key');
}

@@ -127,0 +130,0 @@ // pad to 32 bytes as toArray() length argument seems to be ignored (BN bug)

@@ -11,2 +11,3 @@ "use strict";

const errors_1 = require("../errors");
const core_1 = require("@taquito/core");
// MinSeedSize is the minimal allowed seed byte length

@@ -31,2 +32,3 @@ const minSeedSize = 16;

* @returns instance of PrivateKey
* @throws {@link InvalidSeedLengthError}
*/

@@ -55,3 +57,3 @@ static fromSeed(seedSrc) {

if ((index & index_1.Hard) === 0) {
throw new errors_1.InvalidDerivationPathError('Non-hardened derivation path');
throw new core_1.InvalidDerivationPathError(index.toString(), ': Non-hardened derivation path.');
}

@@ -58,0 +60,0 @@ const data = new Uint8Array(37);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Path = exports.Hard = exports.Ed25519 = exports.ECDSA = void 0;
const errors_1 = require("../errors");
const core_1 = require("@taquito/core");
exports.ECDSA = require("./ecdsa");

@@ -28,3 +28,3 @@ exports.Ed25519 = require("./ed25519");

if (p.length === 0) {
throw new errors_1.InvalidDerivationPathError(`invalid BIP32 path: ${s}`);
throw new core_1.InvalidDerivationPathError(s, `: Invalid BIP32 path`);
}

@@ -31,0 +31,0 @@ let h = 0;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseHex = void 0;
const utils_1 = require("@taquito/utils");
const core_1 = require("@taquito/core");
function parseHex(s) {

@@ -11,3 +11,3 @@ const res = [];

if (Number.isNaN(x)) {
throw new utils_1.InvalidHexStringError(`invalid hexadecimal number ${ss}`);
throw new core_1.InvalidHexStringError(ss);
}

@@ -14,0 +14,0 @@ res.push(x);

@@ -17,2 +17,3 @@ "use strict";

const elliptic_1 = require("elliptic");
const core_1 = require("@taquito/core");
const pref = {

@@ -42,2 +43,3 @@ p256: {

* @param decrypt Decrypt function
* @throws {@link InvalidKeyError}
*/

@@ -47,5 +49,6 @@ constructor(curve, key, encrypted, decrypt) {

this.key = key;
const keyPrefix = key.substr(0, encrypted ? 5 : 4);
const keyPrefix = key.substring(0, encrypted ? 5 : 4);
if (!utils_1.isValidPrefix(keyPrefix)) {
throw new utils_1.InvalidKeyError(key, 'Key contains invalid prefix');
throw new core_1.InvalidKeyError(utils_1.invalidErrorDetail(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
` expecting one of the following prefix '${utils_1.Prefix.SPSK}', '${utils_1.Prefix.SPESK}', '${utils_1.Prefix.P2SK}' or '${utils_1.Prefix.P2ESK}'.`);
}

@@ -52,0 +55,0 @@ this._key = decrypt(utils_1.b58cdecode(this.key, utils_1.prefix[keyPrefix]));

@@ -17,2 +17,3 @@ "use strict";

const typedarray_to_buffer_1 = require("typedarray-to-buffer");
const core_1 = require("@taquito/core");
/**

@@ -27,8 +28,9 @@ * @description Provide signing logic for ed25519 curve based key (tz1)

* @param decrypt Decrypt function
* @throws {@link InvalidKeyError}
*/
constructor(key, encrypted, decrypt) {
this.key = key;
const keyPrefix = key.substr(0, encrypted ? 5 : 4);
const keyPrefix = key.substring(0, encrypted ? 5 : 4);
if (!utils_1.isValidPrefix(keyPrefix)) {
throw new utils_1.InvalidKeyError(key, 'Key contains invalid prefix');
throw new core_1.InvalidKeyError(`${utils_1.invalidErrorDetail(utils_1.ValidationResult.NO_PREFIX_MATCHED)} expecting either '${utils_1.Prefix.EDESK}' or '${utils_1.Prefix.EDSK}'.`);
}

@@ -38,3 +40,3 @@ this._key = decrypt(utils_1.b58cdecode(this.key, utils_1.prefix[keyPrefix]));

if (!this._key) {
throw new utils_1.InvalidKeyError(key, 'Unable to decode');
throw new core_1.InvalidKeyError('unable to decode');
}

@@ -41,0 +43,0 @@ this.isInit = this.init();

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToBeImplemented = exports.PrivateKeyError = exports.InvalidSeedLengthError = exports.InvalidCurveError = exports.InvalidBitSize = exports.InvalidMnemonicError = exports.InvalidDerivationPathError = void 0;
class InvalidDerivationPathError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidDerivationPathError';
}
}
exports.InvalidDerivationPathError = InvalidDerivationPathError;
class InvalidMnemonicError extends Error {
constructor(message) {
super(message);
this.message = message;
exports.InvalidPassphraseError = exports.ToBeImplemented = exports.InvalidSeedLengthError = exports.InvalidCurveError = exports.InvalidBitSize = exports.InvalidMnemonicError = void 0;
const core_1 = require("@taquito/core");
/**
* @category Error
* @description Error indicates an invalid Mnemonic being passed or used
*/
class InvalidMnemonicError extends core_1.ParameterValidationError {
constructor(mnemonic) {
super();
this.mnemonic = mnemonic;
this.name = 'InvalidMnemonicError';
this.message = `Invalid mnemonic "${mnemonic}"`;
}
}
exports.InvalidMnemonicError = InvalidMnemonicError;
class InvalidBitSize extends Error {
/**
* @category Error
* @description Error indicates a curve with incorrect bit size being passed or used
*/
class InvalidBitSize extends core_1.ParameterValidationError {
constructor(message) {
super(message);
super();
this.message = message;

@@ -28,6 +30,10 @@ this.name = 'InvalidBitSize';

exports.InvalidBitSize = InvalidBitSize;
class InvalidCurveError extends Error {
constructor(curve) {
super(`This Curve is not supported: ${curve}`);
this.curve = curve;
/**
* @category Error
* @description Error indicates an unsupported cureve being passed or used
*/
class InvalidCurveError extends core_1.ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'InvalidCurveError';

@@ -37,25 +43,39 @@ }

exports.InvalidCurveError = InvalidCurveError;
class InvalidSeedLengthError extends Error {
/**
* @category Error
* @description Error indicates a seed with invalid length being passed or used
*/
class InvalidSeedLengthError extends core_1.ParameterValidationError {
constructor(seedLength) {
super(`The seed has an invalid length: ${seedLength}`);
super();
this.seedLength = seedLength;
this.name = 'InvalidSeedLengthError';
this.message = `Invalid seed length "${seedLength}" expecting length between 16 to 64.`;
}
}
exports.InvalidSeedLengthError = InvalidSeedLengthError;
class PrivateKeyError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'PrivateKeyError';
}
}
exports.PrivateKeyError = PrivateKeyError;
class ToBeImplemented extends Error {
/**
* @category Error
* @description Error indicates a feature still under developement
*/
class ToBeImplemented extends core_1.UnsupportedActionError {
constructor() {
super('This feature is under developement');
super();
this.name = 'ToBeImplemented';
this.message = 'This feature is under developement';
}
}
exports.ToBeImplemented = ToBeImplemented;
/**
* @category Error
* @description Error indicates an invalid passphrase being passed or used
*/
class InvalidPassphraseError extends core_1.ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'InvalidPassphraseError';
}
}
exports.InvalidPassphraseError = InvalidPassphraseError;
//# sourceMappingURL=errors.js.map

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

* @returns final Derivation of HD keys tezos Secret key
* @throws {@link InvalidCurveError} | {@link ToBeImplemented}
*/

@@ -40,3 +41,3 @@ const generateSecretKey = (seed, derivationPath, curve) => {

default: {
throw new errors_1.InvalidCurveError(curve);
throw new errors_1.InvalidCurveError(`Unsupported curve "${curve}" expecting one of the following "ed25519", "secp256k1", "p256" or "bip25519"`);
}

@@ -43,0 +44,0 @@ }

@@ -37,2 +37,3 @@ "use strict";

const errors_1 = require("./errors");
const core_1 = require("@taquito/core");
__exportStar(require("./import-key"), exports);

@@ -43,19 +44,9 @@ var version_1 = require("./version");

__exportStar(require("./helpers"), exports);
var errors_2 = require("./errors");
Object.defineProperty(exports, "InvalidPassphraseError", { enumerable: true, get: function () { return errors_2.InvalidPassphraseError; } });
/**
* @category Error
* @description Error that indicates an invalid passphrase being passed or used
*/
class InvalidPassphraseError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidPassphraseError';
}
}
exports.InvalidPassphraseError = InvalidPassphraseError;
/**
* @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf
*
* @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
*
* @throws {@link InvalidMnemonicError}
*/

@@ -67,2 +58,3 @@ class InMemorySigner {

* @param passphrase Passphrase to decrypt the private key if it is encrypted
* @throws {@link InvalidKeyError}
*

@@ -75,3 +67,3 @@ */

if (!passphrase) {
throw new InvalidPassphraseError('Encrypted key provided without a passphrase.');
throw new errors_1.InvalidPassphraseError('No passphrase provided to decrypt encrypted key');
}

@@ -85,3 +77,3 @@ decrypt = (constructedKey) => {

}
switch (key.substr(0, 4)) {
switch (key.substring(0, 4)) {
case 'edes':

@@ -100,3 +92,3 @@ case 'edsk':

default:
throw new utils_1.InvalidKeyError(key, 'Unsupported key type');
throw new core_1.InvalidKeyError(`${utils_1.invalidErrorDetail(utils_1.ValidationResult.NO_PREFIX_MATCHED)} expecting one of the following '${utils_1.Prefix.EDESK}', '${utils_1.Prefix.EDSK}', '${utils_1.Prefix.SPSK}', '${utils_1.Prefix.SPESK}', '${utils_1.Prefix.P2SK}' or '${utils_1.Prefix.P2ESK}'.`);
}

@@ -106,3 +98,3 @@ }

if (!Bip39.validateMnemonic(mnemonic)) {
throw new errors_1.InvalidMnemonicError(`Invalid mnemonic: ${mnemonic}`);
throw new errors_1.InvalidMnemonicError(mnemonic);
}

@@ -126,8 +118,9 @@ const seed = Bip39.mnemonicToSeedSync(mnemonic, `${email}${password}`);

* @returns InMemorySigner
* @throws {@link InvalidMnemonicError}
*/
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519' }) {
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519', }) {
// check if curve is defined if not default tz1
if (!Bip39.validateMnemonic(mnemonic)) {
// avoiding exposing mnemonic again in case of mistake making invalid
throw new errors_1.InvalidMnemonicError('Mnemonic provided is invalid');
throw new errors_1.InvalidMnemonicError(mnemonic);
}

@@ -134,0 +127,0 @@ const seed = Bip39.mnemonicToSeedSync(mnemonic, password);

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

exports.VERSION = {
"commitHash": "bcc2118ddfafc1995fd125cd74d198fda042bf48",
"version": "16.1.2"
"commitHash": "babcbaf464fd3571a3b88cf7023fefe87809d86d",
"version": "16.2.0-beta-RC.0"
};
//# sourceMappingURL=version.js.map
import { openSecretBox } from '@stablelib/nacl';
import { hash } from '@stablelib/blake2b';
import { isValidPrefix, InvalidKeyError, b58cdecode, prefix, buf2hex, b58cencode, InvalidHexStringError, hex2buf, mergebuf } from '@taquito/utils';
import { isValidPrefix, invalidErrorDetail, ValidationResult, Prefix, b58cdecode, prefix, buf2hex, b58cencode, hex2buf, mergebuf } from '@taquito/utils';
import toBuffer from 'typedarray-to-buffer';
import { generateKeyPairFromSeed, sign } from '@stablelib/ed25519';
import { InvalidKeyError, InvalidHexStringError, ParameterValidationError, UnsupportedActionError, InvalidDerivationPathError } from '@taquito/core';
import elliptic, { ec } from 'elliptic';

@@ -47,8 +48,9 @@ import pbkdf2 from 'pbkdf2';

* @param decrypt Decrypt function
* @throws {@link InvalidKeyError}
*/
constructor(key, encrypted, decrypt) {
this.key = key;
const keyPrefix = key.substr(0, encrypted ? 5 : 4);
const keyPrefix = key.substring(0, encrypted ? 5 : 4);
if (!isValidPrefix(keyPrefix)) {
throw new InvalidKeyError(key, 'Key contains invalid prefix');
throw new InvalidKeyError(`${invalidErrorDetail(ValidationResult.NO_PREFIX_MATCHED)} expecting either '${Prefix.EDESK}' or '${Prefix.EDSK}'.`);
}

@@ -58,3 +60,3 @@ this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));

if (!this._key) {
throw new InvalidKeyError(key, 'Unable to decode');
throw new InvalidKeyError('unable to decode');
}

@@ -148,2 +150,3 @@ this.isInit = this.init();

* @param decrypt Decrypt function
* @throws {@link InvalidKeyError}
*/

@@ -153,5 +156,6 @@ constructor(curve, key, encrypted, decrypt) {

this.key = key;
const keyPrefix = key.substr(0, encrypted ? 5 : 4);
const keyPrefix = key.substring(0, encrypted ? 5 : 4);
if (!isValidPrefix(keyPrefix)) {
throw new InvalidKeyError(key, 'Key contains invalid prefix');
throw new InvalidKeyError(invalidErrorDetail(ValidationResult.NO_PREFIX_MATCHED) +
` expecting one of the following prefix '${Prefix.SPSK}', '${Prefix.SPESK}', '${Prefix.P2SK}' or '${Prefix.P2ESK}'.`);
}

@@ -220,19 +224,34 @@ this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));

class InvalidDerivationPathError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidDerivationPathError';
function parseHex(s) {
const res = [];
for (let i = 0; i < s.length; i += 2) {
const ss = s.slice(i, i + 2);
const x = parseInt(ss, 16);
if (Number.isNaN(x)) {
throw new InvalidHexStringError(ss);
}
res.push(x);
}
return new Uint8Array(res);
}
class InvalidMnemonicError extends Error {
constructor(message) {
super(message);
this.message = message;
/**
* @category Error
* @description Error indicates an invalid Mnemonic being passed or used
*/
class InvalidMnemonicError extends ParameterValidationError {
constructor(mnemonic) {
super();
this.mnemonic = mnemonic;
this.name = 'InvalidMnemonicError';
this.message = `Invalid mnemonic "${mnemonic}"`;
}
}
class InvalidBitSize extends Error {
/**
* @category Error
* @description Error indicates a curve with incorrect bit size being passed or used
*/
class InvalidBitSize extends ParameterValidationError {
constructor(message) {
super(message);
super();
this.message = message;

@@ -242,41 +261,46 @@ this.name = 'InvalidBitSize';

}
class InvalidCurveError extends Error {
constructor(curve) {
super(`This Curve is not supported: ${curve}`);
this.curve = curve;
/**
* @category Error
* @description Error indicates an unsupported cureve being passed or used
*/
class InvalidCurveError extends ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'InvalidCurveError';
}
}
class InvalidSeedLengthError extends Error {
/**
* @category Error
* @description Error indicates a seed with invalid length being passed or used
*/
class InvalidSeedLengthError extends ParameterValidationError {
constructor(seedLength) {
super(`The seed has an invalid length: ${seedLength}`);
super();
this.seedLength = seedLength;
this.name = 'InvalidSeedLengthError';
this.message = `Invalid seed length "${seedLength}" expecting length between 16 to 64.`;
}
}
class PrivateKeyError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'PrivateKeyError';
}
}
class ToBeImplemented extends Error {
/**
* @category Error
* @description Error indicates a feature still under developement
*/
class ToBeImplemented extends UnsupportedActionError {
constructor() {
super('This feature is under developement');
super();
this.name = 'ToBeImplemented';
this.message = 'This feature is under developement';
}
}
function parseHex(s) {
const res = [];
for (let i = 0; i < s.length; i += 2) {
const ss = s.slice(i, i + 2);
const x = parseInt(ss, 16);
if (Number.isNaN(x)) {
throw new InvalidHexStringError(`invalid hexadecimal number ${ss}`);
}
res.push(x);
/**
* @category Error
* @description Error indicates an invalid passphrase being passed or used
*/
class InvalidPassphraseError extends ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'InvalidPassphraseError';
}
return new Uint8Array(res);
}

@@ -307,2 +331,3 @@

* @returns instance of PrivateKey non-HD keys derived
* @throws {@link InvalidBitSize} | {@link InvalidCurveError} | {@link InvalidSeedLengthError}
*/

@@ -316,7 +341,7 @@ static fromSeed(seedSrc, curve) {

if (!Object.prototype.hasOwnProperty.call(seedKey, curve)) {
throw new InvalidCurveError(`unknown curve ${curve}`);
throw new InvalidCurveError(`Unsupported curve "${curve}" expecting either "p256" or "secp256k1"`);
}
const c = new ec(curve);
if (((_a = c.n) === null || _a === void 0 ? void 0 : _a.bitLength()) !== 256) {
throw new InvalidBitSize(`invalid curve bit size ${(_b = c.n) === null || _b === void 0 ? void 0 : _b.bitLength()}`);
throw new InvalidBitSize(`Invalid curve "${curve}" with bit size "${(_b = c.n) === null || _b === void 0 ? void 0 : _b.bitLength()}" expecting bit size "256"`);
}

@@ -358,3 +383,3 @@ const key = new TextEncoder().encode(seedKey[curve]);

let d = new BN(0);
let chain = new Uint8Array;
let chain = new Uint8Array();
let i = 0;

@@ -393,6 +418,7 @@ while (i === 0) {

* @returns Uint8Array (if contains a private key)
* @throws {@link InvalidKeyError}
*/
bytes() {
if (!this.keyPair.priv) {
throw new PrivateKeyError('not a private key');
throw new InvalidKeyError('missing private key');
}

@@ -433,3 +459,3 @@ // pad to 32 bytes as toArray() length argument seems to be ignored (BN bug)

if (p.length === 0) {
throw new InvalidDerivationPathError(`invalid BIP32 path: ${s}`);
throw new InvalidDerivationPathError(s, `: Invalid BIP32 path`);
}

@@ -469,2 +495,3 @@ let h = 0;

* @returns instance of PrivateKey
* @throws {@link InvalidSeedLengthError}
*/

@@ -493,3 +520,3 @@ static fromSeed(seedSrc) {

if ((index & Hard) === 0) {
throw new InvalidDerivationPathError('Non-hardened derivation path');
throw new InvalidDerivationPathError(index.toString(), ': Non-hardened derivation path.');
}

@@ -527,2 +554,3 @@ const data = new Uint8Array(37);

* @returns final Derivation of HD keys tezos Secret key
* @throws {@link InvalidCurveError} | {@link ToBeImplemented}
*/

@@ -551,3 +579,3 @@ const generateSecretKey = (seed, derivationPath, curve) => {

default: {
throw new InvalidCurveError(curve);
throw new InvalidCurveError(`Unsupported curve "${curve}" expecting one of the following "ed25519", "secp256k1", "p256" or "bip25519"`);
}

@@ -598,22 +626,11 @@ }

const VERSION = {
"commitHash": "bcc2118ddfafc1995fd125cd74d198fda042bf48",
"version": "16.1.2"
"commitHash": "babcbaf464fd3571a3b88cf7023fefe87809d86d",
"version": "16.2.0-beta-RC.0"
};
/**
* @category Error
* @description Error that indicates an invalid passphrase being passed or used
*/
class InvalidPassphraseError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidPassphraseError';
}
}
/**
* @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf
*
* @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
*
* @throws {@link InvalidMnemonicError}
*/

@@ -625,2 +642,3 @@ class InMemorySigner {

* @param passphrase Passphrase to decrypt the private key if it is encrypted
* @throws {@link InvalidKeyError}
*

@@ -633,3 +651,3 @@ */

if (!passphrase) {
throw new InvalidPassphraseError('Encrypted key provided without a passphrase.');
throw new InvalidPassphraseError('No passphrase provided to decrypt encrypted key');
}

@@ -643,3 +661,3 @@ decrypt = (constructedKey) => {

}
switch (key.substr(0, 4)) {
switch (key.substring(0, 4)) {
case 'edes':

@@ -658,3 +676,3 @@ case 'edsk':

default:
throw new InvalidKeyError(key, 'Unsupported key type');
throw new InvalidKeyError(`${invalidErrorDetail(ValidationResult.NO_PREFIX_MATCHED)} expecting one of the following '${Prefix.EDESK}', '${Prefix.EDSK}', '${Prefix.SPSK}', '${Prefix.SPESK}', '${Prefix.P2SK}' or '${Prefix.P2ESK}'.`);
}

@@ -664,3 +682,3 @@ }

if (!Bip39.validateMnemonic(mnemonic)) {
throw new InvalidMnemonicError(`Invalid mnemonic: ${mnemonic}`);
throw new InvalidMnemonicError(mnemonic);
}

@@ -684,8 +702,9 @@ const seed = Bip39.mnemonicToSeedSync(mnemonic, `${email}${password}`);

* @returns InMemorySigner
* @throws {@link InvalidMnemonicError}
*/
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519' }) {
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519', }) {
// check if curve is defined if not default tz1
if (!Bip39.validateMnemonic(mnemonic)) {
// avoiding exposing mnemonic again in case of mistake making invalid
throw new InvalidMnemonicError('Mnemonic provided is invalid');
throw new InvalidMnemonicError(mnemonic);
}

@@ -692,0 +711,0 @@ const seed = Bip39.mnemonicToSeedSync(mnemonic, password);

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@stablelib/nacl'), require('@stablelib/blake2b'), require('@taquito/utils'), require('typedarray-to-buffer'), require('@stablelib/ed25519'), require('elliptic'), require('pbkdf2'), require('bip39'), require('@stablelib/hmac'), require('@stablelib/sha512'), require('bn.js')) :
typeof define === 'function' && define.amd ? define(['exports', '@stablelib/nacl', '@stablelib/blake2b', '@taquito/utils', 'typedarray-to-buffer', '@stablelib/ed25519', 'elliptic', 'pbkdf2', 'bip39', '@stablelib/hmac', '@stablelib/sha512', 'bn.js'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoSigner = {}, global.nacl, global.blake2b, global.utils, global.toBuffer, global.ed25519$1, global.elliptic, global.pbkdf2, global.Bip39, global.hmac, global.sha512, global.BN));
})(this, (function (exports, nacl, blake2b, utils, toBuffer, ed25519$1, elliptic, pbkdf2, Bip39, hmac, sha512, BN) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@stablelib/nacl'), require('@stablelib/blake2b'), require('@taquito/utils'), require('typedarray-to-buffer'), require('@stablelib/ed25519'), require('@taquito/core'), require('elliptic'), require('pbkdf2'), require('bip39'), require('@stablelib/hmac'), require('@stablelib/sha512'), require('bn.js')) :
typeof define === 'function' && define.amd ? define(['exports', '@stablelib/nacl', '@stablelib/blake2b', '@taquito/utils', 'typedarray-to-buffer', '@stablelib/ed25519', '@taquito/core', 'elliptic', 'pbkdf2', 'bip39', '@stablelib/hmac', '@stablelib/sha512', 'bn.js'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoSigner = {}, global.nacl, global.blake2b, global.utils, global.toBuffer, global.ed25519$1, global.core, global.elliptic, global.pbkdf2, global.Bip39, global.hmac, global.sha512, global.BN));
})(this, (function (exports, nacl, blake2b, utils, toBuffer, ed25519$1, core, elliptic, pbkdf2, Bip39, hmac, sha512, BN) { 'use strict';

@@ -67,8 +67,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

* @param decrypt Decrypt function
* @throws {@link InvalidKeyError}
*/
constructor(key, encrypted, decrypt) {
this.key = key;
const keyPrefix = key.substr(0, encrypted ? 5 : 4);
const keyPrefix = key.substring(0, encrypted ? 5 : 4);
if (!utils.isValidPrefix(keyPrefix)) {
throw new utils.InvalidKeyError(key, 'Key contains invalid prefix');
throw new core.InvalidKeyError(`${utils.invalidErrorDetail(utils.ValidationResult.NO_PREFIX_MATCHED)} expecting either '${utils.Prefix.EDESK}' or '${utils.Prefix.EDSK}'.`);
}

@@ -78,3 +79,3 @@ this._key = decrypt(utils.b58cdecode(this.key, utils.prefix[keyPrefix]));

if (!this._key) {
throw new utils.InvalidKeyError(key, 'Unable to decode');
throw new core.InvalidKeyError('unable to decode');
}

@@ -168,2 +169,3 @@ this.isInit = this.init();

* @param decrypt Decrypt function
* @throws {@link InvalidKeyError}
*/

@@ -173,5 +175,6 @@ constructor(curve, key, encrypted, decrypt) {

this.key = key;
const keyPrefix = key.substr(0, encrypted ? 5 : 4);
const keyPrefix = key.substring(0, encrypted ? 5 : 4);
if (!utils.isValidPrefix(keyPrefix)) {
throw new utils.InvalidKeyError(key, 'Key contains invalid prefix');
throw new core.InvalidKeyError(utils.invalidErrorDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
` expecting one of the following prefix '${utils.Prefix.SPSK}', '${utils.Prefix.SPESK}', '${utils.Prefix.P2SK}' or '${utils.Prefix.P2ESK}'.`);
}

@@ -240,19 +243,34 @@ this._key = decrypt(utils.b58cdecode(this.key, utils.prefix[keyPrefix]));

class InvalidDerivationPathError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidDerivationPathError';
function parseHex(s) {
const res = [];
for (let i = 0; i < s.length; i += 2) {
const ss = s.slice(i, i + 2);
const x = parseInt(ss, 16);
if (Number.isNaN(x)) {
throw new core.InvalidHexStringError(ss);
}
res.push(x);
}
return new Uint8Array(res);
}
class InvalidMnemonicError extends Error {
constructor(message) {
super(message);
this.message = message;
/**
* @category Error
* @description Error indicates an invalid Mnemonic being passed or used
*/
class InvalidMnemonicError extends core.ParameterValidationError {
constructor(mnemonic) {
super();
this.mnemonic = mnemonic;
this.name = 'InvalidMnemonicError';
this.message = `Invalid mnemonic "${mnemonic}"`;
}
}
class InvalidBitSize extends Error {
/**
* @category Error
* @description Error indicates a curve with incorrect bit size being passed or used
*/
class InvalidBitSize extends core.ParameterValidationError {
constructor(message) {
super(message);
super();
this.message = message;

@@ -262,41 +280,46 @@ this.name = 'InvalidBitSize';

}
class InvalidCurveError extends Error {
constructor(curve) {
super(`This Curve is not supported: ${curve}`);
this.curve = curve;
/**
* @category Error
* @description Error indicates an unsupported cureve being passed or used
*/
class InvalidCurveError extends core.ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'InvalidCurveError';
}
}
class InvalidSeedLengthError extends Error {
/**
* @category Error
* @description Error indicates a seed with invalid length being passed or used
*/
class InvalidSeedLengthError extends core.ParameterValidationError {
constructor(seedLength) {
super(`The seed has an invalid length: ${seedLength}`);
super();
this.seedLength = seedLength;
this.name = 'InvalidSeedLengthError';
this.message = `Invalid seed length "${seedLength}" expecting length between 16 to 64.`;
}
}
class PrivateKeyError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'PrivateKeyError';
}
}
class ToBeImplemented extends Error {
/**
* @category Error
* @description Error indicates a feature still under developement
*/
class ToBeImplemented extends core.UnsupportedActionError {
constructor() {
super('This feature is under developement');
super();
this.name = 'ToBeImplemented';
this.message = 'This feature is under developement';
}
}
function parseHex(s) {
const res = [];
for (let i = 0; i < s.length; i += 2) {
const ss = s.slice(i, i + 2);
const x = parseInt(ss, 16);
if (Number.isNaN(x)) {
throw new utils.InvalidHexStringError(`invalid hexadecimal number ${ss}`);
}
res.push(x);
/**
* @category Error
* @description Error indicates an invalid passphrase being passed or used
*/
class InvalidPassphraseError extends core.ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'InvalidPassphraseError';
}
return new Uint8Array(res);
}

@@ -327,2 +350,3 @@

* @returns instance of PrivateKey non-HD keys derived
* @throws {@link InvalidBitSize} | {@link InvalidCurveError} | {@link InvalidSeedLengthError}
*/

@@ -336,7 +360,7 @@ static fromSeed(seedSrc, curve) {

if (!Object.prototype.hasOwnProperty.call(seedKey, curve)) {
throw new InvalidCurveError(`unknown curve ${curve}`);
throw new InvalidCurveError(`Unsupported curve "${curve}" expecting either "p256" or "secp256k1"`);
}
const c = new elliptic.ec(curve);
if (((_a = c.n) === null || _a === void 0 ? void 0 : _a.bitLength()) !== 256) {
throw new InvalidBitSize(`invalid curve bit size ${(_b = c.n) === null || _b === void 0 ? void 0 : _b.bitLength()}`);
throw new InvalidBitSize(`Invalid curve "${curve}" with bit size "${(_b = c.n) === null || _b === void 0 ? void 0 : _b.bitLength()}" expecting bit size "256"`);
}

@@ -378,3 +402,3 @@ const key = new TextEncoder().encode(seedKey[curve]);

let d = new BN__default["default"](0);
let chain = new Uint8Array;
let chain = new Uint8Array();
let i = 0;

@@ -413,6 +437,7 @@ while (i === 0) {

* @returns Uint8Array (if contains a private key)
* @throws {@link InvalidKeyError}
*/
bytes() {
if (!this.keyPair.priv) {
throw new PrivateKeyError('not a private key');
throw new core.InvalidKeyError('missing private key');
}

@@ -453,3 +478,3 @@ // pad to 32 bytes as toArray() length argument seems to be ignored (BN bug)

if (p.length === 0) {
throw new InvalidDerivationPathError(`invalid BIP32 path: ${s}`);
throw new core.InvalidDerivationPathError(s, `: Invalid BIP32 path`);
}

@@ -489,2 +514,3 @@ let h = 0;

* @returns instance of PrivateKey
* @throws {@link InvalidSeedLengthError}
*/

@@ -513,3 +539,3 @@ static fromSeed(seedSrc) {

if ((index & Hard) === 0) {
throw new InvalidDerivationPathError('Non-hardened derivation path');
throw new core.InvalidDerivationPathError(index.toString(), ': Non-hardened derivation path.');
}

@@ -547,2 +573,3 @@ const data = new Uint8Array(37);

* @returns final Derivation of HD keys tezos Secret key
* @throws {@link InvalidCurveError} | {@link ToBeImplemented}
*/

@@ -571,3 +598,3 @@ const generateSecretKey = (seed, derivationPath, curve) => {

default: {
throw new InvalidCurveError(curve);
throw new InvalidCurveError(`Unsupported curve "${curve}" expecting one of the following "ed25519", "secp256k1", "p256" or "bip25519"`);
}

@@ -618,22 +645,11 @@ }

const VERSION = {
"commitHash": "bcc2118ddfafc1995fd125cd74d198fda042bf48",
"version": "16.1.2"
"commitHash": "babcbaf464fd3571a3b88cf7023fefe87809d86d",
"version": "16.2.0-beta-RC.0"
};
/**
* @category Error
* @description Error that indicates an invalid passphrase being passed or used
*/
class InvalidPassphraseError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidPassphraseError';
}
}
/**
* @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf
*
* @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
*
* @throws {@link InvalidMnemonicError}
*/

@@ -645,2 +661,3 @@ class InMemorySigner {

* @param passphrase Passphrase to decrypt the private key if it is encrypted
* @throws {@link InvalidKeyError}
*

@@ -653,3 +670,3 @@ */

if (!passphrase) {
throw new InvalidPassphraseError('Encrypted key provided without a passphrase.');
throw new InvalidPassphraseError('No passphrase provided to decrypt encrypted key');
}

@@ -663,3 +680,3 @@ decrypt = (constructedKey) => {

}
switch (key.substr(0, 4)) {
switch (key.substring(0, 4)) {
case 'edes':

@@ -678,3 +695,3 @@ case 'edsk':

default:
throw new utils.InvalidKeyError(key, 'Unsupported key type');
throw new core.InvalidKeyError(`${utils.invalidErrorDetail(utils.ValidationResult.NO_PREFIX_MATCHED)} expecting one of the following '${utils.Prefix.EDESK}', '${utils.Prefix.EDSK}', '${utils.Prefix.SPSK}', '${utils.Prefix.SPESK}', '${utils.Prefix.P2SK}' or '${utils.Prefix.P2ESK}'.`);
}

@@ -684,3 +701,3 @@ }

if (!Bip39__namespace.validateMnemonic(mnemonic)) {
throw new InvalidMnemonicError(`Invalid mnemonic: ${mnemonic}`);
throw new InvalidMnemonicError(mnemonic);
}

@@ -704,8 +721,9 @@ const seed = Bip39__namespace.mnemonicToSeedSync(mnemonic, `${email}${password}`);

* @returns InMemorySigner
* @throws {@link InvalidMnemonicError}
*/
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519' }) {
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519', }) {
// check if curve is defined if not default tz1
if (!Bip39__namespace.validateMnemonic(mnemonic)) {
// avoiding exposing mnemonic again in case of mistake making invalid
throw new InvalidMnemonicError('Mnemonic provided is invalid');
throw new InvalidMnemonicError(mnemonic);
}

@@ -712,0 +730,0 @@ const seed = Bip39__namespace.mnemonicToSeedSync(mnemonic, password);

@@ -22,2 +22,3 @@ import { ec, curve } from 'elliptic';

* @returns instance of PrivateKey non-HD keys derived
* @throws {@link InvalidBitSize} | {@link InvalidCurveError} | {@link InvalidSeedLengthError}
*/

@@ -40,2 +41,3 @@ static fromSeed(seedSrc: Uint8Array | string, curve: CurveName): PrivateKey;

* @returns Uint8Array (if contains a private key)
* @throws {@link InvalidKeyError}
*/

@@ -42,0 +44,0 @@ bytes(): Uint8Array;

@@ -15,2 +15,3 @@ import { ExtendedPrivateKey } from './index';

* @returns instance of PrivateKey
* @throws {@link InvalidSeedLengthError}
*/

@@ -17,0 +18,0 @@ static fromSeed(seedSrc: Uint8Array | string): PrivateKey;

@@ -15,2 +15,3 @@ /**

* @param decrypt Decrypt function
* @throws {@link InvalidKeyError}
*/

@@ -17,0 +18,0 @@ constructor(curve: 'p256' | 'secp256k1', key: string, encrypted: boolean, decrypt: (k: any) => any);

@@ -14,2 +14,3 @@ /**

* @param decrypt Decrypt function
* @throws {@link InvalidKeyError}
*/

@@ -16,0 +17,0 @@ constructor(key: string, encrypted: boolean, decrypt: (k: any) => any);

@@ -1,34 +0,48 @@

export declare class InvalidDerivationPathError extends Error {
message: string;
name: string;
constructor(message: string);
import { ParameterValidationError, UnsupportedActionError } from '@taquito/core';
/**
* @category Error
* @description Error indicates an invalid Mnemonic being passed or used
*/
export declare class InvalidMnemonicError extends ParameterValidationError {
mnemonic: string;
constructor(mnemonic: string);
}
export declare class InvalidMnemonicError extends Error {
/**
* @category Error
* @description Error indicates a curve with incorrect bit size being passed or used
*/
export declare class InvalidBitSize extends ParameterValidationError {
message: string;
name: string;
constructor(message: string);
}
export declare class InvalidBitSize extends Error {
/**
* @category Error
* @description Error indicates an unsupported cureve being passed or used
*/
export declare class InvalidCurveError extends ParameterValidationError {
message: string;
name: string;
constructor(message: string);
}
export declare class InvalidCurveError extends Error {
curve: string;
name: string;
constructor(curve: string);
}
export declare class InvalidSeedLengthError extends Error {
/**
* @category Error
* @description Error indicates a seed with invalid length being passed or used
*/
export declare class InvalidSeedLengthError extends ParameterValidationError {
seedLength: number;
name: string;
constructor(seedLength: number);
}
export declare class PrivateKeyError extends Error {
/**
* @category Error
* @description Error indicates a feature still under developement
*/
export declare class ToBeImplemented extends UnsupportedActionError {
constructor();
}
/**
* @category Error
* @description Error indicates an invalid passphrase being passed or used
*/
export declare class InvalidPassphraseError extends ParameterValidationError {
message: string;
name: string;
constructor(message: string);
}
export declare class ToBeImplemented extends Error {
name: string;
constructor();
}

@@ -8,3 +8,4 @@ export declare type Curves = 'ed25519' | 'secp256k1' | 'p256' | 'bip25519';

* @returns final Derivation of HD keys tezos Secret key
* @throws {@link InvalidCurveError} | {@link ToBeImplemented}
*/
export declare const generateSecretKey: (seed: Uint8Array, derivationPath: string, curve: Curves) => string;

@@ -6,11 +6,3 @@ import { Curves } from './helpers';

export * from './helpers';
/**
* @category Error
* @description Error that indicates an invalid passphrase being passed or used
*/
export declare class InvalidPassphraseError extends Error {
message: string;
name: string;
constructor(message: string);
}
export { InvalidPassphraseError } from './errors';
export interface FromMnemonicParams {

@@ -26,3 +18,3 @@ mnemonic: string;

* @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
*
* @throws {@link InvalidMnemonicError}
*/

@@ -41,4 +33,5 @@ export declare class InMemorySigner {

* @returns InMemorySigner
* @throws {@link InvalidMnemonicError}
*/
static fromMnemonic({ mnemonic, password, derivationPath, curve }: FromMnemonicParams): InMemorySigner;
static fromMnemonic({ mnemonic, password, derivationPath, curve, }: FromMnemonicParams): InMemorySigner;
/**

@@ -48,2 +41,3 @@ *

* @param passphrase Passphrase to decrypt the private key if it is encrypted
* @throws {@link InvalidKeyError}
*

@@ -50,0 +44,0 @@ */

{
"name": "@taquito/signer",
"version": "16.1.2",
"version": "16.2.0-beta-RC.0",
"description": "Provide signing functionality to be with taquito",

@@ -76,6 +76,6 @@ "keywords": [

"@stablelib/sha512": "^1.0.1",
"@taquito/taquito": "^16.1.2",
"@taquito/utils": "^16.1.2",
"@taquito/taquito": "^16.2.0-beta-RC.0",
"@taquito/utils": "^16.2.0-beta-RC.0",
"@types/bn.js": "^5.1.1",
"bip39": "^3.0.4",
"bip39": "3.0.4",
"elliptic": "^6.5.4",

@@ -116,3 +116,3 @@ "pbkdf2": "^3.1.2",

},
"gitHead": "f44e0fa20e017142543cf0ad49fc8220021f6d1c"
"gitHead": "a909a1e61a626eb5a2e9ad269a80a96aceff4e28"
}

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

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