@evokegroup/recaptcha
v2.0.0
Published
Helper for verifying reCAPTCHA challenges
Downloads
13
Keywords
Readme
@evokegroup/recaptcha
Utility class for verifying reCAPTCHA challenges
Class: Recaptcha
Static Methods
Recaptcha.verify(secret, response) ⇒ Promise<Recaptcha.Response>
Verifies the reCAPTCHA challenge response using the secret key
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| secret | string
| The reCAPTCHA secret key |
| response | string
| The reCAPTCHA challenge response |
Usage
const Recaptcha = require('@evokegroup/recaptcha');
Recaptcha.verify('mysecret', 'challengeResponse')
.then((response) => {
if (response.success) {
// Do something
} else {
// Invalid
}
})
.catch((ex) => {
console.log(ex);
});
Class: Recaptcha.Response
constructor(webRequestResponse)
Properties
| Property | Type | Description |
| -------- | ---- | ----------- |
| success | boolean
| Indicates if the challenge response was valid |
| result | object
| The result object returned from the reCAPTCHA API call |
| response | object
| The web request response object |
| exception | Error
| Any exception that occurred |