shashank3736 / captcha-canvas Goto Github PK
View Code? Open in Web Editor NEWA captcha generator by using skia-canvas.
Home Page: https://captcha-canvas.js.org
License: Apache License 2.0
A captcha generator by using skia-canvas.
Home Page: https://captcha-canvas.js.org
License: Apache License 2.0
Captcha dosen't appears.
https://media.discordapp.net/attachments/883652933579866132/901548736625401876/file.jpg
Hello. I am having a problem using the skia-canvas, and I tried to do the captcha setup on my local host pc, which worked fine, but after trying to set my bot up on a oracle linux server, it gave me new errors. I have no clue why, but it gave me the error: https://sourceb.in/OyEm3YVZkb
I fixed this by reinstalling node_modules, and doing npm install skia-canvas (I also did some other funky commands to fix a error, something to do with libfontconfig). When that was fixed, it worked. I could get my captcha, but all the text had now been made smaller. The letters and numbers before on my local host was normal. A good size that was easy to read, but on the host, it was micro, and hard to see what they were.
I am not so used to GitHub, so I may not see any given message. So if you are able to help with the issue, please do try and contact me on discord: WoW#4929
I'm having some issues making the text appear in the captcha, running it on my local machine works fine, but running it on our host(railway.app) it doesn't add the text to the image.
We have tried a few different solutions from previous questions, but none of them seemed to solve our issues..
We're running it in docker (on host only):
<bot_path>\node_modules\captcha-canvas\node_modules\skia-canvas\lib\v6\index.node
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1210:18)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (<bot_path>\node_modules\captcha-canvas\node_modules\skia-canvas\lib\index.js:23:29)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
code: 'ERR_DLOPEN_FAILED'
i've already installed the module but the npm didnt found the dependecy. Its a version error or im doing something wrong?
pd: is the same code that is in the documentation, I've tried to put captcha.async = true to test if this fixed but nope
internal/modules/cjs/loader.js:1057
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: libfontconfig.so.1: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/manxy/API/node_modules/skia-canvas/lib/index.js:23:29)
How do I go about fixing this?
im confusing why the captcha image not showing words heres the image
https://cdn.discordapp.com/attachments/888833092041715774/919229224085254164/Screen_Shot_2021-12-11_at_9.08.32_PM.png
const captchacode = crypto.randomBytes(32).toString("hex").substr(0, 4);
const captcha = new CaptchaGenerator()
.setCaptcha({text: captchacode, size: 60, color: '#e600ff'})
.setTrace({color: '#e600ff', size: 6});
const buffer = await captcha.generate();
At node v16.9.0 I tried to install captcha-canvas like in the docs (https://www.npmjs.com/package/captcha-canvas) and after downloading captcha-canvas it keeps returning following Error:
I can't tell if it's the node version or my computer. I tried uninstalling node_modules & deleting package-lock.json and redownloading everything but I couldnt find any solution yet.
Hey @Shashank3736 ! I'm getting this error when running my project with the captcha-canvas installed:
It looks like the script file is missing inside the node_modules. I have tried to remove and install several times but doesn't get any different results.
I try to bundle with webpack and show this error:
uncaught Error Error: Cannot find module 'XXX/../package.json'
at webpackEmptyContext (XXX\main.js:71350:10)
at eval (repl:1:26)
It seen webpack don't bundle directory.
captcha-canvas/ts-script/index.ts
Line 7 in 1f95ac7
feature request: setCaptcha support to pass SetCaptchaOption array, for now, only can pass one SetCaptchaOption
for example, I want generate a captcha: "abcd"๏ผ and "ab" is red, "cd" is green
im confusing why the captcha image not showing words heres the image
https://cdn.discordapp.com/attachments/888833092041715774/919229224085254164/Screen_Shot_2021-12-11_at_9.08.32_PM.png
Im kinda confused in the Fonts, what am I supposed to enter in? I just tried like "Arial" but it did not change anything!\
What am I supposed to enter in?
I am getting this warning message everytime I turn on my discord.js bot. Any ideas?
I don't really know how i got this error for some reason. It doesn't showed up before. The only thing i did was updating my node modules(without changing the version). I'm using the latest version. Anyways heres the code that i use:
const captchacode = randomBytes(32).toString("hex").substr(0, 6);
const { CaptchaGenerator } = require('captcha-canvas');
const captcha = new CaptchaGenerator()
.setDimension(150, 450)
.setCaptcha({text: captchacode, size: 60, color: message.guild.me.displayHexColor})
.setDecoy({opacity: 0.5})
.setTrace({color: message.guild.me.displayHexColor});
const buffer = captcha.generateSync();
When I tried to install this package using the command:
npm i captcha-canvas
it displays me this error:
ubuntu@skyndalex:~/SkyndalexPrivate$ npm i captcha-canvas
npm WARN deprecated crypto@1.0.1: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN deprecated event-to-promise@0.7.0: Use promise-toolbox/fromEvent instead
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request-promise@4.2.6: request-promise has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated json2csv@4.5.1: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm ERR! code 101
npm ERR! path /home/ubuntu/SkyndalexPrivate/node_modules/skia-canvas
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install || npm run build -- --release
npm ERR! response status 403 Forbidden on https://skia-canvas.s3.us-east-1.amazonaws.com/v1.0.1/linux-arm64-napi-v6-glibc.tar.gz
npm ERR!
npm ERR! > skia-canvas@1.0.1 build
npm ERR! > cargo-cp-artifact -nc lib/v6/index.node -- cargo build --message-format=json-render-diagnostics --release
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.10
npm ERR! node-pre-gyp info using node@19.3.0 | linux | arm64
npm ERR! node-pre-gyp info check checked for "/home/ubuntu/SkyndalexPrivate/node_modules/skia-canvas/lib/v6/index.node" (not found)
npm ERR! node-pre-gyp http GET https://skia-canvas.s3.us-east-1.amazonaws.com/v1.0.1/linux-arm64-napi-v6-glibc.tar.gz
npm ERR! node-pre-gyp ERR! install response status 403 Forbidden on https://skia-canvas.s3.us-east-1.amazonaws.com/v1.0.1/linux-arm64-napi-v6-glibc.tar.gz
npm ERR! node-pre-gyp ERR! install error
npm ERR! node-pre-gyp ERR! stack Error: response status 403 Forbidden on https://skia-canvas.s3.us-east-1.amazonaws.com/v1.0.1/linux-arm64-napi-v6-glibc.tar.gz
npm ERR! node-pre-gyp ERR! stack at /home/ubuntu/SkyndalexPrivate/node_modules/@mapbox/node-pre-gyp/lib/install.js:67:15
npm ERR! node-pre-gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR! node-pre-gyp ERR! System Linux 5.15.0-1029-oracle
npm ERR! node-pre-gyp ERR! command "/usr/bin/node" "/home/ubuntu/SkyndalexPrivate/node_modules/.bin/node-pre-gyp" "install"
npm ERR! node-pre-gyp ERR! cwd /home/ubuntu/SkyndalexPrivate/node_modules/skia-canvas
npm ERR! node-pre-gyp ERR! node -v v19.3.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.10
npm ERR! node-pre-gyp ERR! not ok
npm ERR! error: could not find `Cargo.toml` in `/home/ubuntu/SkyndalexPrivate/node_modules/skia-canvas` or any parent directory
npm ERR! Did not copy "cdylib:skia-canvas"
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2023-02-18T20_47_27_728Z-debug-0.log
ubuntu@skyndalex:~/SkyndalexPrivate$ ^C
I installed rust and checked all other things to make sure they were implemented correctly. Here is what the cargo command alone gives me:
ubuntu@skyndalex:~/SkyndalexPrivate$ cargo
Rust's package manager
Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
Options:
-V, --version Print version info and exit
--list List installed commands
--explain <CODE> Run `rustc --explain CODE`
-v, --verbose... Use verbose output (-vv very verbose/build.rs output)
-q, --quiet Do not print cargo log messages
--color <WHEN> Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
--offline Run without accessing the network
--config <KEY=VALUE> Override a configuration value
-Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help Print help information
Some common cargo commands are (see all commands with --list):
build, b Compile the current package
check, c Analyze the current package and report errors, but don't build object files
clean Remove the target directory
doc, d Build this package's and its dependencies' documentation
new Create a new cargo package
init Create a new cargo package in an existing directory
add Add dependencies to a manifest file
remove Remove dependencies from a manifest file
run, r Run a binary or example of the local package
test, t Run the tests
bench Run the benchmarks
update Update dependencies listed in Cargo.lock
search Search registry for crates
publish Package and upload this package to the registry
install Install a Rust binary. Default location is $HOME/.cargo/bin
uninstall Uninstall a Rust binary
See 'cargo help <command>' for more information on a specific command.
ubuntu@skyndalex:~/SkyndalexPrivate$ ^C
I also tried using sudo, however, it does not work.
Provide support for GIF captcha which is harder to detect.
hello iam using Replit and iam getting this error any idea how i can fix it
there is not Letters on the photo
Preview https://imgur.com/Pedn0gd
const randomString = require('random-base64-string')
const filename = randomString(10);
const { CaptchaGenerator } = require("captcha-canvas");
const { writeFileSync } = require('fs');
const captcha = new CaptchaGenerator()
.setDimension(150, 450)
.setCaptcha({size: 60, color: "#bd7a21"})
.setBackground("./cdn/media/bsd-bg.jpg") //this image path is valid
.setDecoy({opacity: 0.5})
.setTrace({color: "#bd7a21"});
const buffer = captcha.generateSync();
writeFileSync(`./captcha/${filename}.png`, buffer);
res.json({text: captcha.text, image: `https://eca-beta.astrookai.repl.co/captcha/${filename}.png`});
//ex: returns {"text":"DEEDDE","image":"https://eca-beta.astrookai.repl.co/captcha/rh5OF1CHuX.png"}
The code above generates a captcha image, the problem is that the .setBackground()
doesn't add the image below as the background, is there a reason why this is happening? No errors are logged to the console when the code is executed.
Lines 224 to 228 in 2090fcd
TODO
comment in 2090fcd when #11 was merged. cc @Shashank3736.Dockerfile:
`FROM node:20.9.0
WORKDIR /bots/app
COPY . .
RUN npm i && npm run build
CMD [ "node", "dist/main" ]`
Errors:
cargo
executable.failed to solve: process "/bin/sh -c npm i && npm run build" did not complete successfully: exit code: 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.