Standalone captcha canvas challenge extracted from pkc-js, packaged with independent dependencies.
This captcha can be brute-forced easily and should not be used to protect a real community.
@pkcprotocol/pkc-jsis a dev dependency used only for TypeScript types. It is not required at runtime.
- Node.js
>=22 - ESM-only environment
Community owners add the captcha-canvas challenge to their community settings. When enabled, every publication (post, reply, vote) requires the author to solve a captcha. The challenge is published as @bitsocial/captcha-canvas-challenge on npm.
If your RPC server is already running, first install the challenge on the server:
bitsocial challenge install @bitsocial/captcha-canvas-challengeThen from your RPC client, connect and set the challenge on your community by name — no npm install or challenge registration needed on the client side:
import PKC from "@pkcprotocol/pkc-js";
const pkc = await PKC({
pkcRpcClientsOptions: ["ws://localhost:9138"]
});
const community = await pkc.createCommunity({ address: "your-community-address.bso" });
await community.edit({
settings: {
challenges: [
{
name: "captcha-canvas-v3",
options: {
characters: "6",
width: "300",
height: "100",
colors: "#32cf7e"
}
}
]
}
});Install the challenge package:
npm install @bitsocial/captcha-canvas-challengeRegister the challenge and configure your community:
import PKC from '@pkcprotocol/pkc-js'
import { captchaCanvasChallenge } from '@bitsocial/captcha-canvas-challenge'
// Register the challenge so it can be referenced by name
PKC.challenges['captcha-canvas-v3'] = captchaCanvasChallenge
const pkc = await PKC({ /* your pkc options */ })
const community = await pkc.createCommunity({ address: 'your-community.bso' })
await community.edit({
settings: {
challenges: [{
name: 'captcha-canvas-v3',
options: {
characters: '6',
width: '300',
height: '100',
colors: '#32cf7e',
}
}]
}
})All option values must be strings (pkc-js challenge convention).
| Option | Default | Description |
|---|---|---|
characters |
"6" |
Amount of characters of the captcha |
height |
"100" |
Height of the captcha in pixels |
width |
"300" |
Width of the captcha in pixels |
colors |
"#32cf7e" |
Colors of the captcha text as hex comma separated values |
Install the challenge package:
bitsocial challenge install @bitsocial/captcha-canvas-challengeEdit your community to use the challenge:
bitsocial community edit your-community.bso \
'--settings.challenges[0].name' captcha-canvas-v3 \
'--settings.challenges[0].options.characters' '6' \
'--settings.challenges[0].options.width' '300' \
'--settings.challenges[0].options.height' '100' \
'--settings.challenges[0].options.colors' '#32cf7e'See the bitsocial-cli documentation for full CLI reference.
npm run typecheck
npm run build
npm test