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

aigis

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aigis - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

194

index.js

@@ -5,3 +5,3 @@ //-----------------------------------------------------

// Site: 666.io
// Version: 0.00.016
// Version: 0.00.017
//

@@ -122,15 +122,20 @@ //-----------------------------------------------------

if(typeof(schemaData) === "string") {
nameFunc = schemaData;
schemaData = {};
}
else if(typeof(schemaData) === "object") {
nameFunc = schemaData.type || schemaData.use;
switch(typeof(schemaData)) {
case "string":
nameFunc = schemaData;
schemaData = {};
if(typeof(schemaData.on) !== "undefined" && schemaData.on != optScenario)
continue;
break;
case "object":
nameFunc = schemaData.type || schemaData.use;
if(checkScenario(schemaData.on, optScenario))
continue;
break;
default:
throw new Error("[!] Typenize | schemaData: " + schemaData);
}
else {
throw new Error("[!] Typenize | schemaData: " + schemaData);
}

@@ -178,15 +183,20 @@ if(nameFunc[0] === "?") {

if(typeof(schemaData) === "string") {
nameFunc = schemaData;
schemaData = {};
}
else if(typeof(schemaData) === "object") {
nameFunc = schemaData.type || schemaData.use;
switch(typeof(schemaData)) {
case "string":
nameFunc = schemaData;
schemaData = {};
if(typeof(schemaData.on) !== "undefined" && schemaData.on != optScenario)
continue;
break;
case "object":
nameFunc = schemaData.type || schemaData.use;
if(checkScenario(schemaData.on, optScenario))
continue;
break;
default:
throw new Error("[!] Sanitize | schemaData: " + schemaData);
}
else {
throw new Error("[!] Sanitize | schemaData: " + schemaData);
}

@@ -236,15 +246,20 @@ if(nameFunc[0] === "?") {

if(typeof(schemaData) === "string") {
nameFunc = schemaData;
schemaData = {};
}
else if(typeof(schemaData) === "object") {
nameFunc = schemaData.rule || schemaData.use;
switch(typeof(schemaData)) {
case "string":
nameFunc = schemaData;
schemaData = {};
if(typeof(schemaData.on) !== "undefined" && schemaData.on != optScenario)
continue;
break;
case "object":
nameFunc = schemaData.rule || schemaData.use;
if(checkScenario(schemaData.on, optScenario))
continue;
break;
default:
throw new Error("[!] Validation | schemaData: " + schemaData);
}
else {
throw new Error("[!] Validation | schemaData: " + schemaData);
}

@@ -441,2 +456,9 @@ if(nameFunc[0] === "?") {

if(options.onlyDigits)
input = input.replace(/\D/g, "");
else if(options.onlyAlphanumeric)
input = input.replace(/[\W_]/g, "");
else if(options.onlyWordchar)
input = input.replace(/\W/g, "");
if(options.trim)

@@ -454,9 +476,2 @@ input = input.trim();

if(options.onlyDigits)
input = input.replace(/\D/g, "");
else if(options.onlyAlphanumeric)
input = input.replace(/[\W_]/g, "");
else if(options.onlyWordchar)
input = input.replace(/\W/g, "");
//------------]>

@@ -579,6 +594,6 @@

return !(
(typeof(options.min) !== "undefined" && input.length < options.min) ||
(typeof(options.max) !== "undefined" && input.length > options.max) ||
(typeof(options.pattern) !== "undefined" && !options.pattern.test(input)) ||
(typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1)
(typeof(options.min) !== "undefined" && input.length < options.min) ||
(typeof(options.max) !== "undefined" && input.length > options.max) ||
(typeof(options.pattern) !== "undefined" && !options.pattern.test(input)) ||
(typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1)
);

@@ -591,7 +606,7 @@

return !(
(input !== parseInt(input, 10)) ||
(typeof(options.min) !== "undefined" && input < options.min) ||
(typeof(options.max) !== "undefined" && input > options.max) ||
(typeof(options.divisibleBy) !== "undefined" && (input % options.divisibleBy) !== 0) ||
(typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1)
(input !== parseInt(input, 10)) ||
(typeof(options.min) !== "undefined" && input < options.min) ||
(typeof(options.max) !== "undefined" && input > options.max) ||
(typeof(options.divisibleBy) !== "undefined" && (input % options.divisibleBy) !== 0) ||
(typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1)
);

@@ -604,6 +619,6 @@

return !(
(typeof(options.min) !== "undefined" && input < options.min) ||
(typeof(options.max) !== "undefined" && input > options.max) ||
(typeof(options.divisibleBy) !== "undefined" && (input % options.divisibleBy) !== 0) ||
(typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1)
(typeof(options.min) !== "undefined" && input < options.min) ||
(typeof(options.max) !== "undefined" && input > options.max) ||
(typeof(options.divisibleBy) !== "undefined" && (input % options.divisibleBy) !== 0) ||
(typeof(options.enum) !== "undefined" && options.enum.indexOf(input) === -1)
);

@@ -616,4 +631,4 @@

return !(
(typeof(options.min) !== "undefined" && input < options.min) ||
(typeof(options.max) !== "undefined" && input > options.max)
(typeof(options.min) !== "undefined" && input < options.min) ||
(typeof(options.max) !== "undefined" && input > options.max)
);

@@ -636,4 +651,4 @@

return !(
(typeof(options.min) !== "undefined" && input.length < options.min) ||
(typeof(options.max) !== "undefined" && input.length > options.max)
(typeof(options.min) !== "undefined" && input.length < options.min) ||
(typeof(options.max) !== "undefined" && input.length > options.max)
);

@@ -647,9 +662,13 @@

case "required":
return !(
input === null || typeof(input) === "undefined" ||
(typeof(input) === "number" && input !== input) ||
(typeof(input) === "string" && !input.length) ||
(input instanceof(Date) && !input.getTime())
);
switch(typeof(input)) {
case "number": return !isNaN(input);
case "string": return input.length > 0;
default:
if(input instanceof(Date))
return !!input.getTime();
}
return false;
case "equal":

@@ -784,33 +803,17 @@ var d;

case "ip":
if(!input || typeof(input) !== "string")
return false;
//------------------------]>
///---)>
case "ip.v4":
return typeof(input) === "string" && (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/).test(input);
var version = options.version,
ipV4 = function() {
if((/^(\d?\d?\d)\.(\d?\d?\d)\.(\d?\d?\d)\.(\d?\d?\d)$/).test(input)) {
var parts = input.split(".").sort();
// no need to check for < 0 as regex won't match in that case
return !(parts[3] > 255);
}
};
case "ip.v6":
return typeof(input) === "string" && (/^::|^::1|^([a-fA-F0-9]{1,4}::?){1,7}([a-fA-F0-9]{1,4})$/).test(input);
///---)>
case "ip":
var version = options.version;
if(version && version != 4 && version != 6)
return false;
return version ? $validate("ip.v" + version, input) : ($validate("ip.v4", input) || $validate("ip.v6", input));
if(!version && !ipV4() && !(/^::|^::1|^([a-fA-F0-9]{1,4}::?){1,7}([a-fA-F0-9]{1,4})$/).test(input))
return false;
//------------------------]>
if(version == 4 && !ipV4())
return false;
if(version == 6 && !(/^::|^::1|^([a-fA-F0-9]{1,4}::?){1,7}([a-fA-F0-9]{1,4})$/).test(input))
return false;
return true;
case "ascii":

@@ -887,2 +890,15 @@ return typeof(input) === "string" && (/^[\x00-\x7F]+$/).test(input);

function checkScenario(x, y) {
switch(typeof(x)) {
case "undefined": return false;
case "string": return x !== y;
default:
if(Array.isArray(x))
return x.indexOf(y) === -1;
}
throw new Error("[!] checkScenario: strange type - " + x);
}
function wFuncStore(name, func, store) {

@@ -889,0 +905,0 @@ if(name === null)

{
"name": "aigis",
"version": "0.0.16",
"version": "0.0.17",
"description": "Simple and Powerful module for strict data control",

@@ -40,4 +40,4 @@

"_id": "aigis@0.0.16",
"_id": "aigis@0.0.17",
"_from": "aigis@"
}

@@ -95,3 +95,3 @@ `npm install aigis -g`

String:
default (stop chain) -> enum (stop chain) -> [l|r]trim -> max -> only[Digits|Alphanumeric|Wordchar] -> [r]trim -> [uppercase|lowercase] -> escape
default (stop chain) -> enum (stop chain) -> only[Digits|Alphanumeric|Wordchar] -> [l|r]trim -> max -> [r]trim -> [uppercase|lowercase] -> escape

@@ -140,4 +140,8 @@ Number:

| phone | `ru-RU`, `zh-CN`, `en-ZA`, `en-AU`, `en-HK`, `fr-FR`, `pt-PT`, `el-GR` | locale (def: "ru-RU") |
| uuid | - | version (def: 3,4,5) |
| ip | - | version (def: 4,6) |
| uuid | - | version (def: 3,4,5) |
| | - ||
| ip | This function simply check whether the address is a valid IPv4 or IPv6 address | version (def: 4,6) |
| ip.v4 | - | - |
| ip.v6 | - | - |
| | - ||
| ascii | - | - |

@@ -144,0 +148,0 @@ | base64 | - | - |

@@ -58,10 +58,6 @@ //-----------------------------------------------------

$typenize(schema, data); //_ { name: ' XX + ', pts: -60 }
$sanitize(schema, data); //_ { name: 'XX', pts: 30 }
$validate(schema, data); //_ false
console.log(JSON.stringify({
"T0": $typenize(schema, data),
"T1": $sanitize(schema, data),
"T2": $validate(schema, data)
"T0": $typenize(schema, data), //_ { name: ' XX + ', pts: -60, ...}
"T1": $sanitize(schema, data), //_ { name: 'XX', pts: 30, ... }
"T2": $validate(schema, data) //_ false
}, null, "\t"));

@@ -68,0 +64,0 @@

@@ -449,2 +449,3 @@ //-----------------------------------------------------

testV(false, "ip", "");
testV(false, "ip", "-100.005.055.0");
testV(false, "ip", "100.005.055.");

@@ -456,2 +457,3 @@ testV(false, "ip", "100.005.055.x");

testV(true, "ip", "2001:db8::7");
testV(true, "ip", "::");
testV(false, "ip", "2001:xb8::7");

@@ -458,0 +460,0 @@

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