Socket
Socket
Sign inDemoInstall

react-canvas-captcha

Package Overview
Dependencies
5
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.13 to 1.0.14

18

dist/index.js

@@ -34,3 +34,9 @@ "use strict";

canvas.height = canvasHeight;
var sCode = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9';
var sCode = 'A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,0,1,2,3,4,5,6,7,8,9';
if ((config === null || config === void 0 ? void 0 : config.caseType) === 'uppercase') {
sCode = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9';
}
if ((config === null || config === void 0 ? void 0 : config.caseType) === 'lowercase') {
sCode = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9';
}
var saCode = sCode.split(',');

@@ -76,3 +82,4 @@ var saCodeLen = saCode.length;

captchaConfig = _ref.captchaConfig,
setCode = _ref.setCode;
setCode = _ref.setCode,
caseType = _ref.caseType;
var canvasRef = (0, _react.useRef)();

@@ -86,3 +93,4 @@ var _useState = (0, _react.useState)(''),

boxHeight: boxHeight,
boxWidth: boxWidth
boxWidth: boxWidth,
caseType: caseType
}, captchaConfig));

@@ -98,3 +106,4 @@ setCaptchaCode(newCaptcha);

boxHeight: boxHeight,
boxWidth: boxWidth
boxWidth: boxWidth,
caseType: caseType
}, captchaConfig));

@@ -140,2 +149,3 @@ setCaptchaCode(newCaptcha);

refreshButton: false,
caseType: 'mix',
captchaConfig: {

@@ -142,0 +152,0 @@ numberOfChars: 4,

{
"name": "react-canvas-captcha",
"version": "1.0.13",
"version": "1.0.14",
"description": "Add captcha to your react projects",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -52,3 +52,4 @@ # React Canvas Captcha

refreshButton | false | Show or hide the refresh button. To show the refresh button make this "true"
caseType | mix | Use caseType to make the captcha code case sensitive or use mix. options (mix, uppercase, lowercase)
captchaConfig | { numberOfChars: 4, font: 'bold 23px Arial', textStartingX: 15, textStartingY: 5 } | Config for the box. Set the number of characters usinng prop "numberOfChars". Use "font" to set the font styling. Use "textStartingX" to set the horizontal starting point for characters inside the box. Use "textStartingY" to set the vertical starting point for characters inside the box.
setCode | | Use this function to get the new captcha code

@@ -17,3 +17,10 @@ import { memo, useEffect, useRef, useState } from "react";

canvas.height = canvasHeight;
let sCode = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9';
let sCode = 'A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,0,1,2,3,4,5,6,7,8,9';
if (config?.caseType === 'uppercase') {
sCode = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9';
}
if (config?.caseType === 'lowercase') {
sCode = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9';
}
let saCode = sCode.split(',');

@@ -63,3 +70,3 @@ let saCodeLen = saCode.length;

const Captcha = ({ boxWidth, boxHeight, refreshButton, captchaConfig, setCode }) => {
const Captcha = ({ boxWidth, boxHeight, refreshButton, captchaConfig, setCode, caseType }) => {
const canvasRef = useRef();

@@ -69,3 +76,3 @@ const [captchaCode, setCaptchaCode] = useState('');

const onChangeCaptcha = () => {
const newCaptcha = createCaptcha(canvasRef.current, { boxHeight, boxWidth, ...captchaConfig});
const newCaptcha = createCaptcha(canvasRef.current, { boxHeight, boxWidth, caseType, ...captchaConfig});
setCaptchaCode(newCaptcha);

@@ -80,3 +87,3 @@ }

useEffect(() => {
const newCaptcha = createCaptcha(canvasRef.current, { boxHeight, boxWidth, ...captchaConfig});
const newCaptcha = createCaptcha(canvasRef.current, { boxHeight, boxWidth, caseType, ...captchaConfig});
setCaptchaCode(newCaptcha);

@@ -121,2 +128,3 @@ // eslint-disable-next-line react-hooks/exhaustive-deps

refreshButton: false,
caseType: 'mix',
captchaConfig: {

@@ -123,0 +131,0 @@ numberOfChars: 4,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc