
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.
ember-cli-cookie
Advanced tools
Wrap $.cookie in Ember goodness
To try and remove external dependencies from my Ember CLI apps with a Promise aware object wrapper.
This addon is designed to help pushing the external dependencies of cookies as far from my Ember CLI app as possible. By injecting this object where cookie access is needed, my Ember code can just deal with an Ember object. This also means that I can inject mock objects in during tests to simulate setting and getting cookies.
From within your Ember CLI application, run:
npm install --save-dev ember-cli-cookie
In an initializer, inject the cookie
object where needed:
// /initializers/test.js
export function initialize(container, application) {
application.inject('controller', 'cookie', 'cookie:main');
}
export default {
name: 'test-initializer',
after: ['cookie'],
initialize: initialize
}
Use this function to set a cookie, eg:
// /controllers/test.js
export default Ember.Controller.extend({
actions: {
testAction: function() {
var self = this;
this.cookie.setCookie('my-key', 'my-value', { expires: 7, path: '/' })
.then(function() {
self.transitionToRoute('success');
});
}
}
});
Use this function to get a cookie, eg:
// /controllers/test.js
export default Ember.Controller.extend({
actions: {
testAction: function() {
this.cookie.getCookie('my-key');
if (!token) {
this.transitionTo('login');
}
}
}
});
Use this function to remove/delete a cookie, eg:
// /controllers/test.js
export default Ember.Controller.extend({
actions: {
testAction: function() {
this.cookie.removeCookie('my-key');
}
}
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
FAQs
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.