npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aacn.eu/use-friendly-captcha

v1.3.0

Published

FriendlyCaptcha React Implementation

Downloads

7,392

Readme

Use Friendly Captcha hook

Usage

The library has functions for both frontend and backend. Both of them work independent of each other.

Frontend

Include the useCaptchaHook() in your selected file. From there you can then query the widget and state from the hook, for you to manage and use in your form.

Please be aware that the friendly-challenge library is a necessary peer dependency since version 1.2.0

The hook expects the following properties:

siteKey: string;
endpoint?: FC_PUZZLE_EP; enum for the currently available endpoints (EU & global)
language?: keyof typeof localizations | Localization;
startMode?: "auto" | "focus" | "none";
showAttribution: boolean;

CaptchaWidget custom props When the CaptchaWidget gets rendered, you can add additional properties: props: HTMLAttributes This includes all possible html attributes. Therefor this is the entry point to add the className attribute, to add custom styling to the outer captcha container. Here can you either directly add TailwindCSS classes or define a custom class for future styling in the .css file of the project. customWidgetStyle allows up to three attributes for specific stylings that are directly applied to the components:

  • icon The icon of the widget
  • button The submit button of the widget
  • text All text elements that appear inside the widget These attributes are all optional and if used, they expect a css object like the following example:
CustomWidgetStyle = { icon: {color: "green", background: "yellow"}, text: {color: "blue"} }

Backend

backend wise this library provides a function that uses the FriendlyCaptcha verification API to check if the submitted puzzle solution is valid or not. It returns a boolean for further handling in your own code.

The function expects the following properties:

endpoint?: FC_VERIFICATION_EP; enum for the currently available endpoints (EU & global)
solution: string;
secret: string;
sitekey?: string;
httpPostFetcher: (see further down)

httpPostFetcher

The backend expects a fetcher function as parameter. This function is provided by the user and is used to send a http post request to the fc verification server. It should match the following design:

function fetcherExample(
    endpoint: string,
    requestBody: { solution: string; secret: string; siteKey: string },
    headers: { 'Content-Type': 'application/json'; 'Accept': 'application/json'; }
) => Promise<{ success: boolean; errors: any; } | null>

Examples

We provided basic examples in the /examples folder, on how to use this library in React and Nextjs. Both examples are written in TypeScript and are kept simple to focus on easy readability and presenting the utility of the function from this library. If you want to run the examples on your machine, make sure to read the respective README files, to add all requirements that are needed.