
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
object-id-mask
Advanced tools
Easy way to mask your public auto incrementing ids and still get back the object name and id
A little npm module that uses the Hashids library to mask IDs. This adds on a version and a object type id so if you just get an id you can figure out for what object type it was for and can have different versions based on salt.
To mask your id for object user:
var ObjectIdMask = require('object-id-mask')({
salt: 'this is a secret, you should set it or I use a system default'
});
var user_type_id = 1; //Could get this from the database it is up to you.
var user = {
id: 1,
email: 'test@test.com',
name: 'John';
last_name: 'Doe'
}
user.id = ObjectIdMask.encode(user.id, user_type_id);
return user;
Now if you get this object back you can decode it like this:
var user = req.body;
var user_type_id = 1; //Could get this from the database it is up to you.
user.id = ObjectIdMask.decode(user.id, user_type_id);
You can add your own versions as well as override the default version to yours:
var ObjectIdMask = require('object-id-mask')({
default_version: 'Custom 1',
versions: {
'Custom 1': {
salt: 'this is my secret',
getEncoder: function(object_name, config) {
//This needs to return an object like this
return {
encode: function(object_type_id, id) { //Takes postive integer numbers only
// returns a encrypted string
},
decode: function(encryptedString) {
// return a number (the Id)
}
};
}
}
}
});
We will use just plain numbers as we move up in versions so if you do customize it make sure you add some namespace in the version.
You can also override the default delimiter with whatever you want. Here is how you can override the delimiter:
var ObjectIdMask = require('object-id-mask')({
delimiter: ':',
salt: 'this is my secret'
});
var user_type_id = 1;
ObjectIdMask.decode(22, user_type_id);
//This returns Version:Hash isntead of Version-Hash
FAQs
Easy way to mask your public auto incrementing ids and still get back the object name and id
The npm package object-id-mask receives a total of 1 weekly downloads. As such, object-id-mask popularity was classified as not popular.
We found that object-id-mask demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.