Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
vue-cookie2
Advanced tools
A Vue.js plugin for manipulating cookies tested up to Vue v2.5.17
Install through npm
npm install vue-cookie2 --save
Include in <body>
after loading Vue and it will automatically hook into Vue
<script src="/node_modules/vue-cookie/build/vue-cookie.js'"></script>
Or do it the cool way and load it in your main.js/app.js
// Require dependencies
var Vue = require('vue');
var VueCookie = require('vue-cookie2');
// Tell Vue to use the plugin
Vue.use(VueCookie);
The plugin is available through this.$cookie
in components or Vue.cookie
Rather than implementing my own Cookie handling logic the plugin now wraps the awesome tiny-cookie package
// From some method in one of your Vue components
this.$cookie.set('test', 'Hello world!', 1);
// This will set a cookie with the name 'test' and the value 'Hello world!' that expires in one day
// To get the value of a cookie use
this.$cookie.get('test');
// To get all cookies
this.$cookie.getAll();
// To delete a cookie use
this.$cookie.remove('test');
// Flush all cookies
this.$cookie.flush();
// Setting the cookie Domain
this.$cookie.set('test', 'Random value', {expires: 1, domain: 'localhost'});
// As this cookie is set with a domain then if you wish to delete it you have to provide the domain when calling delete
this.$cookie.remove('test', {domain: 'localhost'});
// Customizing expires
var date = new Date;
date.setDate(date.getDate() + 21);
this.$cookie.set('dateObject', 'A date object', { expires: date });
this.$cookie.set('dateString', 'A parsable date string', { expires: date.toGMTString() });
this.$cookie.set('integer', 'Seven days later', { expires: 7 });
this.$cookie.set('stringSuffixY', 'One year later', { expires: '1Y' });
this.$cookie.set('stringSuffixM', 'One month later', { expires: '1M' });
this.$cookie.set('stringSuffixD', 'One day later', { expires: '1D' });
this.$cookie.set('stringSuffixh', 'One hour later', { expires: '1h' });
this.$cookie.set('stringSuffixm', 'Ten minutes later', { expires: '10m' });
this.$cookie.set('stringSuffixs', 'Thirty seconds later', { expires: '30s' });
// Raw Data
// We'll using encodeURIComponent/decodeURIComponent on set/get.
// You can set/get raw data by using setRaw/getRaw.
this.$cookie.setRaw('dateObject', 'A date object', { expires: date });
this.$cookie.getRaw('dataObject');
Thanks for using the plugin, I am happy to accept feedback/pull requests, do not forget to star if you like it!
Happy Coding! :D
This packacge uses the ´´´testemframework and
jasmine``` assertion library
# Run npm install to fetch dependencies
npm install
# Then you may run the tests from
npm run test-dev
FAQs
A Vue.js plugin for manipulating cookies
We found that vue-cookie2 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
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.