Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
maya-cookie-notice-vue
Advanced tools
A simple vue component to accept/reject cookies.
V3.0.0 introduces TypeScript and Vue3 support. If you need Vue 2 support, use v2.x.x.
yarn add maya-cookie-notice-vue
or
npm install --save maya-cookie-notice-vue
You'll want to extend `maya-cookie-notice-vue' and override whichever handle methods you need.
The example below grants consent for analytics storage when statistic cookies are enabled.
<script lang="ts">
import CookieNotice from 'maya-cookie-notice-vue';
export default {
extends: CookieNotice,
methods: {
handleAcceptedStatistic() {
if (typeof gtag !== 'undefined' && gtag) {
gtag('consent', 'update', {
analytics_storage: 'granted',
wait_for_update: 500,
region: ['GB'],
});
}
},
handleRejectedStatistic() {
if (typeof gtag !== 'undefined' && gtag) {
gtag('consent', 'update', {
analytics_storage: 'denied',
wait_for_update: 0,
region: ['GB'],
});
}
},
handleAcceptedPreference() {
// Preference cookies were accepted
},
handleRejectedPreference () {
// Preference cookies were rejected
},
handleAcceptedMarketing() {
// Marketing cookies were accepted
},
handleRejectedMarketing() {
// Marketing cookies were rejected
},
}
}
</script>
Then include your extended version in your app:
import App from './App.vue';
import CookieNotice from './my-vue-files/CookieNotice.vue';
const app = createApp(App);
app.component('cookie-notice', CookieNotice);
app.mount('#app');
When the user scrolls down, that will be taken as implied consent (your text in the default slot should reflect this).
The user can then choose to accept all the cookies or use the options button to filter the cookies or reject all of them.
The following will both be emited from the component and triggered as events on the body
element.
You can use the following slots to provide extra text.
<cookie-notice>
We've got cookies
</cookie-notice>
<cookie-notice>
<template v-slot:options-text>
Please select and accept your tracking preferences:
</template>
</cookie-notice>
<cookie-notice>
<template v-slot:required-cookies-description>
Cookies for basic website functionality. These can't be turned off.
</template>
<template v-slot:preference-cookies-description>
Cookies to store your preferences.
</template>
<template v-slot:statistics-cookies-description>
Cookies to track how our site is being used in order to improve our service.
</template>
<template v-slot:marketing-cookies-description>
Cookies used by us and our advertising partners to provide you with personalised advertising.
</template>
</cookie-notice>
To compile before distribution, run ./compile
. This will use vue-compile
to convert the TS to JS.
Note: this does strip out the type information so a better solution should be found.
FAQs
Vue component for accepting and rejecting cookies
We found that maya-cookie-notice-vue 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.