
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.
cocktail-trait-advisable
Advanced tools
A CocktailJS Trait Extension to add AOP methods to the host class
A Trait to add AOP advices into Classes/Objects.
The methods around
, after
and before
are available on host classes or objects.
npm install cocktail --save
npm install cocktail-trait-advisable --save
None.
Define a class with advisable trait:
MyClass.js
var cocktail = require('cocktail'),
advisable = require('cocktail-trait-advisable');
cocktail.mix({
'@exports': module,
'@as' : 'class',
'@traits' : [advisable],
aMethod: function () {
console.log('a method is called!');
}
});
And then use it on your index.js
index.js
var MyClass = require('./MyClass');
var obj = new MyClass();
function afterFn() { console.log('this will be called after!'); }
// #1 attach the after advice
obj.after('aMethod', afterFn);
// #2 call the adviced method
obj.aMethod();
On #1 we attached the advice for after calling aMethod
method in our obj
. Then when #2 is executed the console output will show:
node index.js
a method is called
this will be called after!
The following methods will be publicly available on the host class:
after( methodName, adviceFunction, [scope] )
: Adds the adviceFunction to be called after the method.
before( methodName, adviceFunction, [scope] )
: Adds the adviceFunction to be called before the method.
around( methodName, adviceFunction, [scope] )
: Adds the adviceFunction to be called around the method.
FAQs
A CocktailJS Trait Extension to add AOP methods to the host class
We found that cocktail-trait-advisable 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.