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

kscryp

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kscryp - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

2

package.json
{
"name": "kscryp",
"version": "1.0.10",
"version": "1.0.11",
"description": "Cryptography package with support for: JWT, RSA, MD5, SHA, Base64, HEX, JSON, Basic",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -232,3 +232,3 @@ # Ks Cryp

`;
const resObj = target.decode(srtObj, "json", { defaultValue: null, strict: true });
const resObj = target.decode(srtObj, "json", { clean: true });
console.log(

@@ -235,0 +235,0 @@ resObj.name === "PIL W2F",

@@ -18,2 +18,35 @@ const KsDriver = require("../KsDriver");

#clean(val) {
if (typeof val !== "string") {
return val;
}
return val
.replace(/\\r|\r|\n|\\n/g, "")
.replace(/{[\s|\\]+"/g, '{"')
.replace(/[\s|\\]+"[\s|,]*}/g, '"}')
.replace(/\[[\s|\\]+"/g, '["')
.replace(/[\s|\\]+"[\s|,]*\]/g, '"]')
.replace(/,[\s|\\]+"/g, ',"')
.replace(/[\s|\\]+"\s*,/g, '",')
.replace(/:[\s|\\]+"/g, ':"')
.replace(/[\s|\\]+"\s*:/g, '":')
.replace(/[\s|'|"]+{/g, '{')
.replace(/}[\s|'|"]+/g, '}')
.replace(/[\s|'|"]+\[/g, '[')
.replace(/\][\s|'|"]+/g, ']')
.replace(/\][\s|,]+\]/g, ']]')
.replace(/\}[\s|,]+\]/g, '}]')
.replace(/\][\s|,]+\}/g, ']}')
.replace(/\}[\s|,]+\}/g, '}}')
.replace(/true[\s|,]+\}/g, 'true}')
.replace(/false[\s|,]+\}/g, 'false}')
.replace(/true[\s|,]+\]/g, 'true]')
.replace(/false[\s|,]+\]/g, 'false]')
;
}
encode(value, options) {

@@ -23,2 +56,3 @@ options = options || {};

options.validType = "object";
options.clean && (value = this.#clean(value));
return this.respond(value, null, options) ?? JSON.stringify(value, this.#check());

@@ -35,9 +69,3 @@ }

options.validType = "string";
if (typeof (value) === "string" && options.strict) {
value = value
.replace(/\\"/g, '"')
.replace(/"{/g, '{')
.replace(/}"/g, '}')
.replace(/\\r|\r|\n|\\n/g, "");
}
options.clean && (value = this.#clean(value));
return this.respond(value, null, options) ?? JSON.parse(value);

@@ -44,0 +72,0 @@ }

@@ -34,13 +34,32 @@ const target = require("../")

\\"PAL\\":\\"PT
PAL\\"}"
PAL\\" ,
\\"content\\": \\"<tr class=\\"table er-hw\\" role=\\"row\\">
<span style=\\"color: rgb(0,51,102);\\"> '.' </tr>\\"
,
\\"P1\\": { \\"d\\": true , ,},
\\"P2\\": { \\"d\\": false , ,},
\\"P3\\": { \\"d\\": \\"1\\" , ,,},
\\"A1\\": [true , , ,],
\\"A2\\": [false , , ,],
\\"A3\\": [\\"1\\" , ,],
\\"A3\\": [{}, {}, ,], ,,
}"
`;
const resObj1 = target.decode(srtObj1, "json", { defaultValue: null, strict: true });
const resObj2 = target.decode(srtObj2, "json", { defaultValue: null, strict: true });
const srtObj4 = '"{ \\"ito\\": \\"adm\\"}"';
const srtObj6 = "'\"{\\\\\\\"W2F\\\\\":\\\\\"PILOT 'mito' \\\" W2F\\\\\" ,\\\\\"PAL\\\\\":\\\\\"PILOT PAL\\\\\"}\"'";
const resObj1 = target.decode(srtObj1, "json", { clean: true });
const resObj2 = target.decode(srtObj2, "json", { clean: true });
const resObj3 = target.decode(srtObj2, "json");
const resObj4 = target.decode(srtObj4, "json");
const resObj5 = target.decode(srtObj4, "json", { clean: true });
const resObj6 = target.decode(srtObj6, "json", { clean: true });
expect(resObj1).toBeInstanceOf(Object);
expect(resObj2).toBeInstanceOf(Object);
expect(resObj5).toBeInstanceOf(Object);
expect(resObj6).toBeInstanceOf(Object);
expect(resObj1.W2F).toBe("PIL W2F");
expect(resObj2.W2F).toBe("PIL W2F");
expect(resObj3).toBe(srtObj2);
expect(typeof resObj4).toBe("string");
});

@@ -47,0 +66,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