This file is intended for developers. It provides details on the project's structure and instructions on how to work with it.
Common:
types- Declarations of interfaces and constants, used in different packages.
Client-side (browser):
-
procaptcha-bundle- Displaying captcha widgetprocaptcha-frictionless(Dynamic CAPTCHA that does client-side detection to determine whether to serve PoW/Image)procaptcha-react(image)procaptcha-pow(Proof-of-Work)
-
widget-skeleton- Widget skeleton wrapped into the web component
Server-side (node.js):
provider- API Endpoints for the captcha widgetcli- CLI wrapper for theprovider, that startsExpress
database- Mongo DB Query buildertypes-database- declaration of interfaces and types used in the Query builder
Building configs (for Vite):
dev/config/src/vite:
vite.frontend.config.tsvite.backend.config.ts
If your IDE supports biome (directly, or via plugin), you can configure it to work with the /biome.json).
dapp,dappAccount=clientId=siteKeyin the portaluser,userAccount=userId
- Installation:
npm install - Building packages:
npm run build:all - Building the bundle:
npm run build:bundle - Lint checks:
npm run lint - Lint formatting fixes:
npm run lint-fix
This step should be done only once, after the repository has been cloned, then this step should be omitted.
To set up the environment for testing, run the following commands:
cp demos/client-example-server/env.development demos/client-example-server/.env.test
cp demos/client-bundle-example/env.development demos/client-bundle-example/.env.test
cp dev/scripts/env.test .env.test
cp dev/scripts/env.test dev/scripts/.env.test
cp dev/scripts/env.test packages/cli/.env.test
cp dev/scripts/env.test packages/procaptcha-bundle/.env.test
The DB is necessary for all kind of the tests. Since the DB is docked, to start the DB service run the following:
docker compose --file ./docker/docker-compose.test.yml up -d --remove-orphans --force-recreate --always-recreate-deps
Note: After the testing is done, stop it using the down command:
docker compose --file ./docker/docker-compose.test.yml down
This command should be called once per the container lifetime, and adds the initial data, like domains, siteKeys, etc.
NODE_ENV="test" npm run setup
Launch services:
NODE_ENV=test npm run start:provider:admin
Provider:adminservice is required for theproviderunit tests.
Run all the unit tests:
npm run test
- The command will loop through all the
package/*folders, and run individual unit tests for each package.
Tip: You can also run package-related unit tests individually, by running npm run test inside the target package
folder.
Launch services:
npm run -w @prosopo/client-example-server build ; NODE_ENV=test npm run start:server
NODE_ENV=test npm run start:provider:admin
NODE_ENV="development" npm -w @prosopo/procaptcha-bundle run bundle
NODE_ENV=test npm run start:bundle
Run tests:
NODE_ENV=test npm -w @prosopo/cypress-shared run cypress:open:client-bundle-example
# demo
npm run start:bundle
# server (if you need verification)
NODE_ENV=test npm run start:provider:admin
# bundle
turbo run build --filter @prosopo/procaptcha-bundle...;
NODE_ENV=development npm -w @prosopo/procaptcha-bundle run bundle;
npm -w @prosopo/procaptcha-bundle run serve
# visit
http://localhost:9232/pow-explicit.html