Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
vue3-recaptcha-v2
Advanced tools
reCAPTCHA v2 for Vue3 and Nuxt3.
install the packge from yarn
:
$ yarn add vue3-recaptcha-v2
In Vue3
, add it to your main.ts file
:
import { createApp } from "vue";
import App from "./App.vue";
import { install } from "vue3-recaptcha-v2";
createApp(App)
.use(install, {
sitekey: "YOUR_SITE_KEY",
cnDomains: false, // Optional, If you use in China, set this value true
})
.mount("#app");
In Nuxt3
, add it to your plugin folder
:
The file name must contain the .client
.
// <ProjectRoot>/plugins/recaptcha.client.ts
import { install } from "vue3-recaptcha-v2";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(install, {
sitekey: "YOUR_SITE_KEY",
cnDomains: false,
});
});
If you want to add siteKey dynamically, follow this step.
IMPORTANT::: The reCAPTCHA widget is rendered once, so changes to the siteKey after rendering will not be reflected.
import { createApp } from "vue";
import App from "./App.vue";
import { install } from "vue3-recaptcha-v2";
createApp(App)
.use(install) // Do not add siteKey when initialize app
.mount("#app");
<script setup lang="ts">
import { RecaptchaV2 } from "vue3-recaptcha-v2";
</script>
<template>
<RecaptchaV2 :sitekey="YOUR_SITE_KEY" />
</template>
More detail about install options, you can check this Install Options
The components used are the same for Vue3
and Nuxt3
. Only the installation is different.
For more information, including the props to change the language(hl option)
, check Component Options
<script setup lang="ts">
import { RecaptchaV2 } from "vue3-recaptcha-v2";
const handleWidgetId = (widgetId: number) => {
console.log("Widget ID: ", widgetId);
};
const handleErrorCallback = () => {
console.log("Error callback");
};
const handleExpiredCallback = () => {
console.log("Expired callback");
};
const handleLoadCallback = (response: unknown) => {
console.log("Load callback", response);
};
</script>
<template>
<RecaptchaV2
@widget-id="handleWidgetId"
@error-callback="handleErrorCallback"
@expired-callback="handleExpiredCallback"
@load-callback="handleLoadCallback"
/>
</template>
<script setup lang="ts">
import { RecaptchaV2, useRecaptcha } from "vue3-recaptcha-v2";
const { handleExecute } = useRecaptcha();
const handleWidgetId = (widgetId: number) => {
console.log("Widget ID: ", widgetId);
handleExecute(widgetId);
};
</script>
<template>
<RecaptchaV2 @widget-id="handleWidgetId" size="invisible" />
</template>
Resets the reCAPTCHA widget.
<script setup lang="ts">
import { RecaptchaV2, useRecaptcha } from "vue3-recaptcha-v2";
const { handleReset } = useRecaptcha();
const handleWidgetId = (widgetId: number) => {
console.log("Widget ID: ", widgetId);
handleReset(widgetId);
};
</script>
<template>
<RecaptchaV2 @widget-id="handleWidgetId" />
</template>
Gets the response for the reCAPTCHA widget.
<script setup lang="ts">
import { RecaptchaV2, useRecaptcha } from "vue3-recaptcha-v2";
const { handleGetResponse } = useRecaptcha();
const handleWidgetId = (widgetId: number) => {
console.log("Widget ID: ", widgetId);
handleGetResponse(widgetId);
};
</script>
<template>
<RecaptchaV2 @widget-id="handleWidgetId" />
</template>
Options | Type | Required | Description | |
---|---|---|---|---|
sitekey | string | true | recaptcha siteKey | |
cnDomains | string | default is false . if you set true , script url is replace www.google.com with www.recaptcha.net |
Options | Type | Required | Description |
---|---|---|---|
language | string | recaptcha language, you can find code in language code | |
theme | light | dark | default is light , recaptcha theme | |
tabindex | number | default is 0 , tabindex | |
size | normal | comapact | invisible | default is normal , recaptcha widget size |
Options | Type | Required | Description |
---|---|---|---|
widget-id | (value:number)=>void | when recaptcha widget is created, return widgetId | |
error-callback | ()=>void | The name of your callback function, executed when reCAPTCHA encounters an error (usually network connectivity) and cannot continue until connectivity is restored. If you specify a function here, you are responsible for informing the user that they should retry. | |
expired-callback | ()=>void | The name of your callback function, executed when the reCAPTCHA response expires and the user needs to re-verify. | |
load-callback | (response:unknown)=>void | The name of your callback function, executed when the user submits a successful response. The g-recaptcha-response token is passed to your callback. |
FAQs
reCAPTCHA for Vue3 : CompositionAPI, Types
The npm package vue3-recaptcha-v2 receives a total of 3,351 weekly downloads. As such, vue3-recaptcha-v2 popularity was classified as popular.
We found that vue3-recaptcha-v2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.