Code Monkey home page Code Monkey logo

captcha-canvas's People

Contributors

allcontributors[bot] avatar code-factor avatar dependabot[bot] avatar fossabot avatar ichiidev avatar ikr4-m avatar lostigeros avatar ryanhex53 avatar shashank3736 avatar stacksharebot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

captcha-canvas's Issues

letters and decoys not showing up

When using the package on my on client, it works fine. I put it on my vps however, and only the line shows, no decoys, nor the actual text you need to enter. How do I fix this?
image

Displaying undefined on 4 characters

I tried to set the characters limit to 4 but it displays those 4 characters but also says undefined at the end.

const captcha = new Captcha(100, 100);
captcha.addDecoy().drawTrace().drawCaptcha({ characters: 4 });

image

ISSUE

image
Why i can't see number on image

invalid ELF header

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.

Before:
image

After:
image

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

Text not appearing in Captcha

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..

Local (works as expected)
image

Host (Doesn't add text)
image

We're running it in docker (on host only):
image

And we have our dependencies in package:
image

The code:
image

skia-canvas module not found

<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
captcha code

canvas captcha

My VPS partition failed, and I'm reinstalling dependencies

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?

Error on captcha.text

At the constructor you define this.captcha.characters but then on this.captcha.text you use this.characters to substr so it gives me 32 characters while captcha has only 6.
image

Specified module could not be found.

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:
image
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.

"MODULE NOT FOUND' captcha-canvas

Hey @Shashank3736 ! I'm getting this error when running my project with the captcha-canvas installed:
Screenshot 2022-08-15 at 1 12 52 AM

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.

Package.json:
Screenshot 2022-08-15 at 1 12 29 AM

node_modules:
Screenshot 2022-08-15 at 1 12 43 AM

Cannot find module 'XXX/../package.json'

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.

export const version: string = require(`${__dirname}/../package.json`).version;

Is it really needed?
Thanks.

fonts

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?

Fontconfig error: Cannot load default config file

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();

And the captcha image looks like this
Verification

Could not find find "Cargo.toml". Did not copy cdylib:skia-canvas

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.

.setBackground() not working (v2.3.1)

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.

Supposed background image
image
Actual Result
image

errors in docker

Dockerfile:

`FROM node:20.9.0

WORKDIR /bots/app

COPY . .

RUN npm i && npm run build

CMD [ "node", "dist/main" ]`

Errors:

npm ERR! code 1
8.553 npm ERR! path /bots/app/node_modules/skia-canvas
8.554 npm ERR! command failed
8.554 npm ERR! command sh -c node-pre-gyp install || npm run build -- --release
8.554 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
8.554 npm ERR!
8.554 npm ERR! > [email protected] build
8.554 npm ERR! > cargo-cp-artifact -nc lib/v6/index.node -- cargo build --message-format=json-render-diagnostics --release
8.554 npm ERR! node-pre-gyp info it worked if it ends with ok
8.554 npm ERR! node-pre-gyp info using [email protected]
8.554 npm ERR! node-pre-gyp info using [email protected] | linux | arm64
8.555 npm ERR! node-pre-gyp info check checked for "/bots/app/node_modules/skia-canvas/lib/v6/index.node" (not found)
8.555 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
8.555 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
8.555 npm ERR! node-pre-gyp ERR! install error
8.555 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
8.555 npm ERR! node-pre-gyp ERR! stack at /bots/app/node_modules/@mapbox/node-pre-gyp/lib/install.js:67:15
8.555 npm ERR! node-pre-gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
8.555 npm ERR! node-pre-gyp ERR! System Linux 6.4.16-linuxkit
8.555 npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/bots/app/node_modules/.bin/node-pre-gyp" "install"
8.555 npm ERR! node-pre-gyp ERR! cwd /bots/app/node_modules/skia-canvas
8.555 npm ERR! node-pre-gyp ERR! node -v v20.9.0
8.555 npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
8.555 npm ERR! node-pre-gyp ERR! not ok
8.555 npm ERR! Error: could not find the cargo executable.
8.555 npm ERR!
8.555 npm ERR! You can find instructions for installing Rust and Cargo at:
8.555 npm ERR!
8.555 npm ERR! https://www.rust-lang.org/tools/install
8.555 npm ERR!
8.555 npm ERR!
8.555 npm ERR! Did not copy "cdylib:skia-canvas"
8.556
8.556 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-11-14T18_57_59_368Z-debug-0.log

failed to solve: process "/bin/sh -c npm i && npm run build" did not complete successfully: exit code: 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.