Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
object-unpacker
Advanced tools
This program takes a JSON object and convertes it to a new JSON object using a mapping specification, also written as JSON.
There are some examples of how to use the mapper in the test
directory, and a simple example follows:
// Import the Schema Mapper type
import { createObjectUnpacker } from './ObjectUnpacker';
// Create the schema mapper
const mapper = createObjectUnpacker();
// This is the data to be transformed
const data = {
"x": [
{
"a": [
"testa",
"testb"
],
"au": "%system.metadata.author"
}
]
};
// This is the transformation specification
const mapperData = {
"x": {
"rewriteKey": "expanded"
},
"a": {
"rewriteKey": "another",
"assignKeys": [
"s",
"t",
"u"
],
"rewriteValue": {
"first": "%s",
"second": "%t",
"third": "%u",
"fourth": "%/subs.system.metadata.name"
}
},
"au": {
"rewriteKey": "author"
}
};
// Entries in this object can be referenced by the `data` or the `mapperData`.
// E.g. `%system.metadata.name` and '%system.metadata.author'
const refs = {
system: {
metadata: {
name: 'The System Name',
author: 'A. Programmer',
},
},
};
// Apply the mapping to the data to get an `expanded` object
const expanded: object = mapper.convert(refs, data, mapperData);
// Pretty-print the resulting JSON.
console.log(JSON.stringify(expanded, null, 2));
npm install
scratch.ts
in the src
directory.tsc
commandnode dist/scratch.js
tsc && node dist/scratch.js
The output should look like this:
{
"expanded": [
{
"another": {
"first": "testa",
"second": "testb",
"fourth": "The System Name"
},
"author": "A. Programmer"
}
]
}
npm install
npm install -g webpack
webpack
command in the project root directory.test/index.html
file using a web browser (Only tested using Brave browser)Execute
FAQs
A JSON to JSON mapper in TypeScript
We found that object-unpacker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.