Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Add 'packages/captcha-validator/' from commit 'e1299735f3bcc3f2896dd3fd1df3b7ff9ed888ef'

Blue Mouse2029150d3ead
diff --cc packages/captcha-validator/.github/funding.yml
index 000000000,000000000..f7cbd9642
new file mode 100644
--- /dev/null
+++ b/packages/captcha-validator/.github/funding.yml
@@@ -1,0 -1,0 +1,2 @@@
++github: swetrix
++ko_fi: andriir
diff --cc packages/captcha-validator/.gitignore
index 000000000,000000000..8b77da101
new file mode 100644
--- /dev/null
+++ b/packages/captcha-validator/.gitignore
@@@ -1,0 -1,0 +1,109 @@@
++# Logs
++logs
++*.log
++npm-debug.log*
++yarn-debug.log*
++yarn-error.log*
++lerna-debug.log*
++
++# Diagnostic reports (https://nodejs.org/api/report.html)
++report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
++
++# Runtime data
++pids
++*.pid
++*.seed
++*.pid.lock
++
++# Directory for instrumented libs generated by jscoverage/JSCover
++lib-cov
++
++# Coverage directory used by tools like istanbul
++coverage
++*.lcov
++
++# nyc test coverage
++.nyc_output
++
++# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
++.grunt
++
++# Bower dependency directory (https://bower.io/)
++bower_components
++
++# node-waf configuration
++.lock-wscript
++
++# Compiled binary addons (https://nodejs.org/api/addons.html)
++build/Release
++
++# Dependency directories
++node_modules/
++jspm_packages/
++
++# TypeScript v1 declaration files
++typings/
++
++# TypeScript cache
++*.tsbuildinfo
++
++# Optional npm cache directory
++.npm
++
++# Optional eslint cache
++.eslintcache
++
++# Microbundle cache
++.rpt2_cache/
++.rts2_cache_cjs/
++.rts2_cache_es/
++.rts2_cache_umd/
++
++# Optional REPL history
++.node_repl_history
++
++# Output of 'npm pack'
++*.tgz
++
++# Yarn Integrity file
++.yarn-integrity
++
++# dotenv environment variables file
++.env
++.env.test
++
++# parcel-bundler cache (https://parceljs.org/)
++.cache
++
++# Next.js build output
++.next
++
++# Nuxt.js build / generate output
++.nuxt
++# dist
++
++# Gatsby files
++.cache/
++# Comment in the public line in if your project uses Gatsby and *not* Next.js
++# https://nextjs.org/blog/next-9-1#public-directory-support
++# public
++
++# vuepress build output
++.vuepress/dist
++
++# Serverless directories
++.serverless/
++
++# FuseBox cache
++.fusebox/
++
++# DynamoDB Local files
++.dynamodb/
++
++# TernJS port file
++.tern-port
++package-lock.json
++
++.DS_Store
++pnpm-lock.yaml
++dist
diff --cc packages/captcha-validator/LICENSE
index 000000000,000000000..a28eb52ad
new file mode 100644
--- /dev/null
+++ b/packages/captcha-validator/LICENSE
@@@ -1,0 -1,0 +1,21 @@@
++MIT License
++
++Copyright (c) 2023 Andrii Romasiun
++
++Permission is hereby granted, free of charge, to any person obtaining a copy
++of this software and associated documentation files (the "Software"), to deal
++in the Software without restriction, including without limitation the rights
++to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++copies of the Software, and to permit persons to whom the Software is
++furnished to do so, subject to the following conditions:
++
++The above copyright notice and this permission notice shall be included in all
++copies or substantial portions of the Software.
++
++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++SOFTWARE.
diff --cc packages/captcha-validator/README.md
index 000000000,000000000..38ceebb56
new file mode 100644
--- /dev/null
+++ b/packages/captcha-validator/README.md
@@@ -1,0 -1,0 +1,42 @@@
++<img src="https://swetrix.com/assets/logo_blue.png" alt="" height="80" />
++
++# Swetrix CAPTCHA validator
++This is a wrapper for the Swetrix CAPTCHA server-side validation API.\
++It is used to validate the user's response to the CAPTCHA.\
++Read more about server-side validation at https://docs.swetrix.com/captcha/server-side-validation
++
++# Installation
++```bash
++npm install @swetrix/captcha-validator
++```
++
++# Usage
++You can use this package in your Node.js (or NestJS, ExpressJS, etc.) project to validate the user's response to the CAPTCHA.\
++The package exports a single function `validateToken` which takes arguments listed below and returns a Promise.
++
++| Argument | Type | Description | Required |
++| --- | --- | --- | --- |
++| token | string | The token returned by the CAPTCHA widget. | YES |
++| secretKey | string | Your CAPTCHA project secret key. | YES |
++| apiURL | string | The API URL to use (default: https://api.swetrix.com/captcha), this one may be used in case you're selfhosting the API. | NO |
++
++Here's an example of how to use the package in your project:
++```js
++const { validateToken } = require('@swetrix/captcha-validator')
++// or
++import { validateToken } from '@swetrix/captcha-validator'
++
++// somewhere inside the controller of your form where the CAPTCHA is used
++validateToken(
++ 'CAPTCHA_TOKEN',
++ 'YOUR_SECRET_KEY',
++).then((result) => {
++ const [status, data] = result
++ // status is a boolean, true if the token is valid, false otherwise
++ // data is an error message if status is false
++ console.log(status, data)
++})
++```
++
++# License
++This library is licenced under the MIT License - see the [LICENSE](LICENSE) file for details.
diff --cc packages/captcha-validator/package.json
index 000000000,35e1f374f..35e1f374f
mode 000000,100644..100644
--- a/packages/captcha-validator/package.json
+++ b/packages/captcha-validator/package.json
diff --cc packages/captcha-validator/rollup.config.js
index 000000000,0bd5fd267..0bd5fd267
mode 000000,100644..100644
--- a/packages/captcha-validator/rollup.config.js
+++ b/packages/captcha-validator/rollup.config.js
diff --cc packages/captcha-validator/src/index.ts
index 000000000,13f2daea1..13f2daea1
mode 000000,100644..100644
--- a/packages/captcha-validator/src/index.ts
+++ b/packages/captcha-validator/src/index.ts
diff --cc packages/captcha-validator/src/utils.ts
index 000000000,46ec0e89a..46ec0e89a
mode 000000,100644..100644
--- a/packages/captcha-validator/src/utils.ts
+++ b/packages/captcha-validator/src/utils.ts
diff --cc packages/captcha-validator/tsconfig.esnext.json
index 000000000,901fb91ab..901fb91ab
mode 000000,100644..100644
--- a/packages/captcha-validator/tsconfig.esnext.json
+++ b/packages/captcha-validator/tsconfig.esnext.json
diff --cc packages/captcha-validator/tsconfig.json
index 000000000,3fe10f8db..3fe10f8db
mode 000000,100644..100644
--- a/packages/captcha-validator/tsconfig.json
+++ b/packages/captcha-validator/tsconfig.json