svg-captcha
Advanced tools
Comparing version 1.3.5 to 1.3.6
@@ -69,2 +69,4 @@ /** | ||
* text: captcha text | ||
* @param {ConfigObject} [options] | ||
* @return {CaptchaObj} | ||
*/ | ||
@@ -78,2 +80,4 @@ export function create(options?: ConfigObject): CaptchaObj; | ||
* this means that text is the result of the math expression | ||
* @param {ConfigObject} [options] | ||
* @return {CaptchaObj} | ||
*/ | ||
@@ -83,2 +87,3 @@ export function createMathExpr(options?: ConfigObject): CaptchaObj; | ||
* Override the default font with your own | ||
* @param {string} url | ||
*/ | ||
@@ -92,3 +97,5 @@ export function loadFont(url: string): void; | ||
* return a random string | ||
* @param {number} size | ||
* @return {string} | ||
*/ | ||
export function randomText(size): string; |
'use strict'; | ||
const assert = require('assert'); | ||
function rndPathCmd(cmd) { | ||
const r = (Math.random() * 0.2) - 0.1; | ||
switch (cmd.type) { | ||
case 'M': case 'L': | ||
cmd.x += r; | ||
cmd.y += r; | ||
break; | ||
case 'Q': case 'C': | ||
cmd.x += r; | ||
cmd.y += r; | ||
cmd.x1 += r; | ||
cmd.y1 += r; | ||
break; | ||
default: | ||
// Close path cmd | ||
break; | ||
} | ||
return cmd; | ||
} | ||
module.exports = function (text, opts) { | ||
@@ -17,2 +39,4 @@ const ch = text[0]; | ||
const path = glyph.getPath(left, top, fontSize); | ||
// Randomize path commands | ||
path.commands.forEach(rndPathCmd); | ||
@@ -19,0 +43,0 @@ const pathData = path.toPathData(); |
{ | ||
"name": "svg-captcha", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"description": "generate svg captcha in node.js or express.js", | ||
@@ -40,3 +40,3 @@ "main": "index.js", | ||
"fs-extra": "^3.0.1", | ||
"mocha": "^3.3.0", | ||
"mocha": "^3.4.2", | ||
"xo": "^0.18.2" | ||
@@ -43,0 +43,0 @@ }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
99492
14
343
0