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

@liskhq/lisk-validator

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liskhq/lisk-validator - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0-beta.0

typedoc.json

5

dist-node/errors.js

@@ -49,8 +49,7 @@ "use strict";

super();
this.errors = exports.convertErrorsToLegacyFormat(errors);
this.errors = (0, exports.convertErrorsToLegacyFormat)(errors);
this.message = `Lisk validator found ${this.errors.length} error[s]:\n${this._compileErrors().join('\n')}`;
}
_compileErrors() {
const errorMsgs = this.errors.map(errorFormatter);
return errorMsgs;
return this.errors.map(errorFormatter);
}

@@ -57,0 +56,0 @@ }

1

dist-node/formats.d.ts

@@ -15,1 +15,2 @@ export declare const hex: (data: unknown) => boolean;

export declare const oddInteger: (data: string | number) => boolean;
export declare const lisk32: (data: string) => boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.oddInteger = exports.ipOrFQDN = exports.ip = exports.encryptedPassphrase = exports.path = exports.networkVersion = exports.version = exports.camelCase = exports.int32 = exports.uint32 = exports.uint64 = exports.int64 = exports.bytes = exports.hex = void 0;
exports.lisk32 = exports.oddInteger = exports.ipOrFQDN = exports.ip = exports.encryptedPassphrase = exports.path = exports.networkVersion = exports.version = exports.camelCase = exports.int32 = exports.uint32 = exports.uint64 = exports.int64 = exports.bytes = exports.hex = void 0;
const lisk_cryptography_1 = require("@liskhq/lisk-cryptography");
const validation_1 = require("./validation");
exports.hex = validation_1.isHexString;
exports.bytes = validation_1.isBytes;
const int64 = (data) => validation_1.isNumberString(data) && validation_1.isSInt64(BigInt(data));
const int64 = (data) => (0, validation_1.isNumberString)(data) && (0, validation_1.isSInt64)(BigInt(data));
exports.int64 = int64;
const uint64 = (data) => validation_1.isNumberString(data) && validation_1.isUInt64(BigInt(data));
const uint64 = (data) => (0, validation_1.isNumberString)(data) && (0, validation_1.isUInt64)(BigInt(data));
exports.uint64 = uint64;
const uint32 = (data) => validation_1.isNumberString(data) && validation_1.isUInt32(Number(data));
const uint32 = (data) => (0, validation_1.isNumberString)(data) && (0, validation_1.isUInt32)(Number(data));
exports.uint32 = uint32;
const int32 = (data) => validation_1.isNumberString(data) && validation_1.isSInt32(Number(data));
const int32 = (data) => (0, validation_1.isNumberString)(data) && (0, validation_1.isSInt32)(Number(data));
exports.int32 = int32;
const camelCaseRegex = /^[a-z]+((\d)|([A-Z0-9][a-zA-Z0-9]+))*([a-z0-9A-Z])?$/;
const camelCaseRegex = /^[a-z][0-9]*([A-Z][a-z]*[a-zA-Z0-9]*|[a-z][a-z]*[a-zA-Z0-9]*)?$/;
const camelCase = (data) => camelCaseRegex.exec(data) !== null;

@@ -27,3 +28,3 @@ exports.camelCase = camelCase;

const hostnameRegex = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/;
return validation_1.isIPV4(data) || hostnameRegex.test(data);
return (0, validation_1.isIPV4)(data) || hostnameRegex.test(data);
};

@@ -38,2 +39,12 @@ exports.ipOrFQDN = ipOrFQDN;

exports.oddInteger = oddInteger;
const lisk32 = (data) => {
try {
lisk_cryptography_1.address.validateLisk32Address(data);
return true;
}
catch (error) {
return false;
}
};
exports.lisk32 = lisk32;
//# sourceMappingURL=formats.js.map

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

import { validator, liskSchemaIdentifier } from './lisk_validator';
import { validator, liskSchemaIdentifier, LiskValidator } from './lisk_validator';
import { LiskErrorObject as ErrorObject } from './types';

@@ -6,2 +6,2 @@ export * from './validation';

export * from './constants';
export { validator, liskSchemaIdentifier, ErrorObject };
export { validator, liskSchemaIdentifier, ErrorObject, LiskValidator };
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -13,6 +17,7 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
exports.liskSchemaIdentifier = exports.validator = void 0;
exports.LiskValidator = exports.liskSchemaIdentifier = exports.validator = void 0;
const lisk_validator_1 = require("./lisk_validator");
Object.defineProperty(exports, "validator", { enumerable: true, get: function () { return lisk_validator_1.validator; } });
Object.defineProperty(exports, "liskSchemaIdentifier", { enumerable: true, get: function () { return lisk_validator_1.liskSchemaIdentifier; } });
Object.defineProperty(exports, "LiskValidator", { enumerable: true, get: function () { return lisk_validator_1.LiskValidator; } });
__exportStar(require("./validation"), exports);

@@ -19,0 +24,0 @@ __exportStar(require("./errors"), exports);

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

if (value === 'boolean') {
return validation_1.isBoolean(data);
return (0, validation_1.isBoolean)(data);
}
if (value === 'bytes') {
if (!validation_1.isBytes(data)) {
if (!(0, validation_1.isBytes)(data)) {
return false;

@@ -65,17 +65,30 @@ }

}
if (typeof parent.format === 'string') {
const { length } = data;
if (parent.format === 'lisk32' && length !== 20) {
validate.errors = [
{
keyword: 'dataType',
message: 'address length invalid',
params: { dataType: value, format: parent.format, length },
},
];
return false;
}
}
}
if (value === 'string') {
return validation_1.isString(data);
return (0, validation_1.isString)(data);
}
if (value === 'uint32') {
return validation_1.isUInt32(data);
return (0, validation_1.isUInt32)(data);
}
if (value === 'uint64') {
return validation_1.isUInt64(data);
return (0, validation_1.isUInt64)(data);
}
if (value === 'sint32') {
return validation_1.isSInt32(data);
return (0, validation_1.isSInt32)(data);
}
if (value === 'sint64') {
return validation_1.isSInt64(data);
return (0, validation_1.isSInt64)(data);
}

@@ -82,0 +95,0 @@ return true;

@@ -45,3 +45,2 @@ export declare const liskMetaSchema: {

};
minProperties: number;
};

@@ -48,0 +47,0 @@ required: {

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

$schema: 'http://json-schema.org/draft-07/schema#',
$id: 'http://lisk.io/lisk-schema/schema#',
$id: 'http://lisk.com/lisk-schema/schema#',
title: 'Lisk Schema',

@@ -13,3 +13,3 @@ type: 'object',

type: 'string',
const: 'http://lisk.io/lisk-schema/schema#',
const: 'http://lisk.com/lisk-schema/schema#',
format: 'uri',

@@ -50,3 +50,2 @@ },

},
minProperties: 1,
},

@@ -53,0 +52,0 @@ required: {

@@ -1,9 +0,8 @@

import Ajv, { AnySchema, ValidateFunction } from 'ajv';
import { LiskErrorObject } from './types';
import Ajv, { SchemaObject, ValidateFunction } from 'ajv';
export declare const liskSchemaIdentifier: string;
declare class LiskValidator {
export declare class LiskValidator {
private readonly _validator;
constructor();
validate(schema: object, data: object): LiskErrorObject[];
validateSchema(schema: AnySchema | boolean): ReadonlyArray<LiskErrorObject>;
validate<T = Record<string, unknown>>(schema: object, data: unknown): asserts data is T;
validateSchema(schema: object): asserts schema is SchemaObject;
compile(schema: object | boolean): ValidateFunction;

@@ -13,2 +12,1 @@ removeSchema(schemaKeyRef?: object | string | RegExp | boolean): Ajv;

export declare const validator: LiskValidator;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validator = exports.liskSchemaIdentifier = void 0;
exports.validator = exports.LiskValidator = exports.liskSchemaIdentifier = void 0;
const ajv_1 = require("ajv");

@@ -22,3 +22,3 @@ const ajv_formats_1 = require("ajv-formats");

});
ajv_formats_1.default(this._validator);
(0, ajv_formats_1.default)(this._validator);
for (const formatName of Object.keys(formats)) {

@@ -40,11 +40,9 @@ this._validator.addFormat(formatName, formats[formatName]);

if (!this._validator.validate(schema, data)) {
return errors_1.convertErrorsToLegacyFormat(this._validator.errors);
throw new errors_1.LiskValidationError((0, errors_1.convertErrorsToLegacyFormat)(this._validator.errors));
}
return [];
}
validateSchema(schema) {
if (!this._validator.validateSchema(schema)) {
return errors_1.convertErrorsToLegacyFormat(this._validator.errors);
throw new errors_1.LiskValidationError((0, errors_1.convertErrorsToLegacyFormat)(this._validator.errors));
}
return [];
}

@@ -74,3 +72,4 @@ compile(schema) {

}
exports.LiskValidator = LiskValidator;
exports.validator = new LiskValidator();
//# sourceMappingURL=lisk_validator.js.map

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

const keyRegExp = /[a-zA-Z0-9]{2,15}/;
const valueRegExp = /[a-f0-9]{1,512}/;
const valueRegExp = /[a-z0-9+-]{1,512}/;
const keyValueRegExp = new RegExp(`${keyRegExp.source}=${valueRegExp.source}`);

@@ -56,5 +56,5 @@ const encryptedPassphraseRegExp = new RegExp(`^(${keyValueRegExp.source})(?:&(${keyValueRegExp.source})){0,10}$`);

exports.isEncryptedPassphrase = isEncryptedPassphrase;
const isSemVer = (version) => !!semver_1.valid(version);
const isSemVer = (version) => !!(0, semver_1.valid)(version);
exports.isSemVer = isSemVer;
const isRangedSemVer = (version) => !!semver_1.validRange(version);
const isRangedSemVer = (version) => !!(0, semver_1.validRange)(version);
exports.isRangedSemVer = isRangedSemVer;

@@ -71,3 +71,3 @@ exports.isLessThanRangedVersion = semver_1.ltr;

exports.isIPV6 = isIPV6;
const isIP = (data) => exports.isIPV4(data) || exports.isIPV6(data);
const isIP = (data) => (0, exports.isIPV4)(data) || (0, exports.isIPV6)(data);
exports.isIP = isIP;

@@ -74,0 +74,0 @@ const isPort = (port) => validator_1.default.isPort(port);

{
"name": "@liskhq/lisk-validator",
"version": "0.6.2",
"version": "0.7.0-beta.0",
"description": "Validation library according to the Lisk protocol",
"author": "Lisk Foundation <admin@lisk.io>, lightcurve GmbH <admin@lightcurve.io>",
"author": "Lisk Foundation <admin@lisk.com>, lightcurve GmbH <admin@lightcurve.io>",
"license": "Apache-2.0",

@@ -28,44 +28,43 @@ "keywords": [

"format": "prettier --write '**/*'",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"test": "jest",
"test:coverage": "jest --coverage=true --coverage-reporters=text",
"test:ci": "jest --coverage=true --coverage-reporters=json --verbose",
"test:ci": "jest --coverage=true --coverage-reporters=json",
"test:watch": "npm test -- --watch",
"prebuild": "rm -r dist-node/* || mkdir dist-node || true",
"build": "tsc",
"build:check": "node -e \"require('./dist-node')\"",
"prepublishOnly": "npm run lint && npm test && npm run build && npm run build:check"
"build:check": "node -e \"require('./dist-node')\""
},
"dependencies": {
"@liskhq/lisk-cryptography": "^3.2.1",
"@liskhq/lisk-cryptography": "^4.0.0-beta.0",
"ajv": "8.1.0",
"ajv-formats": "2.0.2",
"ajv-formats": "2.1.1",
"debug": "4.3.4",
"semver": "7.3.5",
"semver": "7.3.8",
"validator": "13.7.0"
},
"devDependencies": {
"@types/jest": "26.0.21",
"@types/jest-when": "2.7.2",
"@types/node": "16.11.26",
"@types/semver": "7.3.4",
"@types/validator": "13.1.3",
"@typescript-eslint/eslint-plugin": "4.19.0",
"@typescript-eslint/parser": "4.19.0",
"eslint": "7.22.0",
"@types/jest": "29.2.3",
"@types/jest-when": "3.5.2",
"@types/node": "16.18.3",
"@types/semver": "7.3.13",
"@types/validator": "13.7.10",
"@typescript-eslint/eslint-plugin": "5.44.0",
"@typescript-eslint/parser": "5.44.0",
"eslint": "8.28.0",
"eslint-config-lisk-base": "2.0.1",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "24.3.2",
"jest": "26.6.3",
"jest-extended": "0.11.5",
"jest-when": "3.2.1",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "27.1.6",
"jest": "29.3.1",
"jest-extended": "3.2.0",
"jest-when": "3.5.2",
"lodash.clonedeep": "4.5.0",
"prettier": "2.2.1",
"source-map-support": "0.5.19",
"ts-jest": "26.5.4",
"ts-node": "9.1.1",
"tsconfig-paths": "3.9.0",
"typescript": "4.2.3"
"prettier": "2.8.0",
"source-map-support": "0.5.21",
"ts-jest": "29.0.3",
"ts-node": "10.9.1",
"tsconfig-paths": "4.1.0",
"typescript": "5.0.2"
}
}

@@ -28,2 +28,2 @@ # @liskhq/lisk-validator

[lisk core github]: https://github.com/LiskHQ/lisk
[lisk documentation site]: https://lisk.io/documentation/lisk-elements
[lisk documentation site]: https://lisk.com/documentation/lisk-sdk/references/lisk-elements/validator.html

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