
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
ng-hcaptcha
Advanced tools
ng-hcaptcha provides an easy to use component for hCaptcha.
The latest version of ng-hcaptcha
currently supports Angular v9 to v17.
# NPM
npm install --save ng-hcaptcha
# Yarn
yarn add ng-hcaptcha
You can use the tag 'next' to get the latest beta version.
import { NgHcaptchaModule } from 'ng-hcaptcha';
@NgModule({
imports: [
// Option #1
// Set the sitekey globally for every hCaptcha component
NgHcaptchaModule.forRoot({
siteKey: 'YOUR_SITEKEY',
languageCode: 'de' // optional, will default to browser language
}),
// Option #2
// This option requires you to set the [siteKey] property for every hCaptcha component
NgHcaptchaModule.forRoot()
]
})
Template:
<!-- Regular usage -->
<ng-hcaptcha (verify)="onVerify($event)"
(expired)="onExpired($event)"
(error)="onError($event)">
</ng-hcaptcha>
<!-- Usage in forms -->
<!-- The value of the form control will be the verification token -->
<form [formGroup]="formGroup" (submit)="onSubmit()">
<ng-hcaptcha formControlName="captcha"></ng-hcaptcha>
</form>
<!-- Invisible captcha -->
<button ngHcaptchaInvisibleButton
(verify)="onVerify($event)"
(expired)="onExpired($event)"
(error)="onError($event)">Click me</button>
TS:
onVerify(token: string) {
// The verification process was successful.
// You can verify the token on your server now.
}
onExpired(response: any) {
// The verification expired.
}
onError(error: any) {
// An error occured during the verification process.
}
The hCaptcha verification process can also be executed programmatically:
@Component({
selector: 'hc-programmatically',
templateUrl: './programmatically.component.html',
styleUrls: ['./programmatically.component.scss']
})
export class ProgrammaticallyComponent {
constructor(private hcaptchaService: NgHcaptchaService) { }
verify() {
this.hcaptchaService.verify().subscribe(
(result) => {
console.log('SUCCESS', result);
},
(err) => {
console.log('FAILED', err);
},
() => {
console.log('COMPLETE');
}
);
}
}
The properties below exist for all captcha components.
siteKey
Allows you to set the site key per captcha instance.
languageCode
Allows you to force a specific language. See https://docs.hcaptcha.com/languages
If you found a bug or something you don't like, feel free to open an issue. If you have any ideas for new features or improvements, feel free to contribute or open an issue :wink:
If you would like to support me for free, just create your hCaptcha account using my referral link :relaxed: https://hCaptcha.com/?r=4afcb2d42338
FAQs
hCaptcha Component for Angular
The npm package ng-hcaptcha receives a total of 2,719 weekly downloads. As such, ng-hcaptcha popularity was classified as popular.
We found that ng-hcaptcha 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.