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

@aml-org/amf-custom-validator

Package Overview
Dependencies
Maintainers
11
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aml-org/amf-custom-validator - npm Package Compare versions

Comparing version 0.1.0-SNAPSHOT.30 to 0.1.0-SNAPSHOT.31

46

index.js

@@ -7,4 +7,4 @@ require(__dirname + "/lib/wasm_exec");

let INIT = false
let go = new Go();
let initialized = false
let go = null;

@@ -20,33 +20,39 @@ const run = function(profile, data, debug) {

const validateCustomProfile = function(profile, data, debug, cb) {
if (INIT) {
if (initialized) {
let res = run(profile, data, debug);
cb(res,null);
} else {
if(!wasm_gz || !wasm) {
wasm_gz = fs.readFileSync(__dirname + "/lib/main.wasm.gz")
wasm = pako.ungzip(wasm_gz)
}
if (WebAssembly) {
WebAssembly.instantiate(wasm, go.importObject).then((result) => {
go.run(result.instance);
INIT = true;
let res = run(profile, data, debug);
cb(res,null);
});
} else {
cb(null,new Error("WebAssembly is not supported in your JS environment"));
}
cb(null,new Error("WASM/GO not initialized"))
}
}
const initialize = function(cb) {
if (initialized === true) {
cb(null)
}
go = new Go();
if(!wasm_gz || !wasm) {
wasm_gz = fs.readFileSync(__dirname + "/lib/main.wasm.gz")
wasm = pako.ungzip(wasm_gz)
}
if (WebAssembly) {
WebAssembly.instantiate(wasm, go.importObject).then((result) => {
go.run(result.instance);
initialized = true;
cb(null);
});
} else {
cb(new Error("WebAssembly is not supported in your JS environment"));
}
}
const exit = function() {
if(INIT) {
if(initialized) {
__AMF__terminateValidator()
go.exit(0)
INIT = false;
go = new Go();
initialized = false;
}
}
module.exports.initialize = initialize;
module.exports.validate = validateCustomProfile;
module.exports.exit = exit;
{
"name": "@aml-org/amf-custom-validator",
"version": "0.1.0-SNAPSHOT.30",
"version": "0.1.0-SNAPSHOT.31",
"description": "AMF validator backed by OPA Rego",

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

@@ -13,22 +13,24 @@ const fs = require("fs");

validator.validate(profile, data, false, (r, err) => {
if (err) {
done(err);
} else {
let report = JSON.parse(r)
assert.ok(report["conforms"] === false)
validator.validate(profile, data, false, (r,err) => {
if (err) {
done(err)
} else {
let report = JSON.parse(r)
assert.ok(report["conforms"] === false)
validator.exit();
done();
}
});
}
});
validator.initialize(() => {
validator.validate(profile, data, false, (r, err) => {
if (err) {
done(err);
} else {
let report = JSON.parse(r)
assert.ok(report["conforms"] === false)
validator.validate(profile, data, false, (r, err) => {
if (err) {
done(err)
} else {
let report = JSON.parse(r)
assert.ok(report["conforms"] === false)
validator.exit();
done();
}
});
}
});
})
});
})
})

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