@bitsocial/spam-blocker-challenge
v0.1.19
Published
Bitsocial SpamBlocker challenge implementation for PKC
Downloads
2,595
Readme
@bitsocial/spam-blocker-challenge
A Bitsocial challenge plugin that protects communities from spam by evaluating publication risk scores and optionally presenting an interactive challenge to users.
Using SpamBlocker In Your Community
Community owners add the spam blocker challenge to their community settings. When enabled, user-generated publications return a consent-gated iframe URL. The Bitsocial SpamBlocker server evaluates the publication only after the user opens that iframe. Low-risk publications complete immediately after evaluation, high-risk publications are rejected, and medium-risk publications continue into an interactive iframe challenge. Community-level actions (commentEdit, commentModeration, and communityEdit) are accepted locally because they do not require spam detection.
First install the challenge on the Bitsocial server:
bitsocial challenge install @bitsocial/spam-blocker-challengeThen set it on your community with one command:
bitsocial community edit your-community.bso '--settings.challenges[0].name' @bitsocial/spam-blocker-challengeThat uses the hosted Bitsocial SpamBlocker server and the default thresholds. This is the strongly recommended configuration because the centralized service can correlate cross-community abuse and signer clusters over time.
The hosted service normally allows up to three signer public keys on a confirmed user-origin IP during its rolling window, accommodating users who cannot yet sync a Bitsocial signer across devices. Excessive account switching, rapid signer churn, ban evasion, or interactions between linked signers can trigger stronger verification or a temporary IP-level rejection. This policy is enforced by the hosted server, not by the public challenge package itself.
To customize thresholds or IP-based rejection rules, pass options in the same command:
bitsocial community edit your-community.bso \
'--settings.challenges[0].name' @bitsocial/spam-blocker-challenge \
'--settings.challenges[0].options.autoAcceptThreshold' '0.2' \
'--settings.challenges[0].options.autoRejectThreshold' '0.8' \
'--settings.challenges[0].options.countryBlacklist' 'RU,CN,KP' \
'--settings.challenges[0].options.blockVpn' 'true' \
'--settings.challenges[0].options.blockTor' 'true'All option values should be strings.
Configuration
You can also open your community settings interactively:
bitsocial community editThen add or edit the challenges array in your community settings to include the spam blocker challenge with your desired options.
Options
| Option | Default | Description |
| --------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------ |
| serverUrl | https://spamblocker.bitsocial.net/api/v1 | URL of a compatible spam blocker service; the official hosted service is recommended |
| autoAcceptThreshold | 0.2 | Complete verification after iframe evaluation when risk is below this value |
| autoRejectThreshold | 0.8 | Reject after iframe evaluation when risk is above this value |
| countryBlacklist | (empty) | Comma-separated ISO 3166-1 alpha-2 country codes to block (e.g. RU,CN,KP) |
| maxIpRisk | 1.0 | Reject if IP risk score exceeds this threshold (estimation only) |
| blockVpn | false | Restrict VPN IPs, including iCloud Private Relay; a sign-in unlocks them (estimation only) |
| blockProxy | false | Restrict proxy IPs; a sign-in unlocks them (estimation only) |
| blockTor | false | Reject publications from Tor exit nodes (estimation only) |
| blockDatacenter | false | Restrict datacenter IPs; a sign-in unlocks them (estimation only) |
How It Works
- When a user publishes a post, reply, or vote to a community, the challenge signs the publication locally and returns a lazy iframe URL.
getChallenge()does not call/evaluate. - The Bitsocial client asks the user before opening the spam blocker iframe.
- After the user opens the iframe, the iframe sends the signed payload to
/evaluate. This is the first spam blocker server evaluation request for the publication. - The server returns a risk score between 0 and 1:
- Below
autoAcceptThreshold: Verification completes immediately. - Above
autoRejectThreshold: Verification fails immediately. - Between thresholds: The iframe presents OAuth and/or CAPTCHA verification.
- Below
- After challenge verification, the server's
/challenge/verifyendpoint confirms whether the user passed. The community-signed VPN, proxy, Tor, and datacenter policies are already enforced before verification; the challenge also applies configured IP policies to successful verification responses. A connection policy requiresconnectionTypesandipClassificationComplete: true; unavailable classification fails closed. The VPN, proxy and datacenter policies do not apply when the response carries aconnectionExemption:"established_account"for an account with passed challenges on at least 3 separate days from unrestricted connections, or"sign_in"for an author who signed in on the hosted challenge page, after which a ban in the community also applies to that sign-in. Services setestablishedAccount: truefor either exemption, which is what challenge versions up to 0.1.14 read; this version accepts both fields. Tor policy always applies. Rejections give abuse as the reason ("Posting through a VPN has been blocked in this community due to abuse.") and mention the exemption only when the response carriesestablishedAccount: false, which older services omit. AprivateRelay: trueresponse names iCloud Private Relay in the rejection. Upgrade the service before deploying a policy-enabled challenge. - Community-level actions (
commentEdit,commentModeration, andcommunityEdit) are accepted without calling/evaluate. - The challenge publishes
<serverUrl>/precheckwith enabledblockTor,blockVpn,blockProxy, andblockDatacenterquery parameters as its publicchallengeso clients can run the spam blocker before uploading a file. A client that completed that pre-check sends itsprecheck-<uuid>session id as this challenge's answer inchallengeRequest.challengeAnswers;getChallenge()then redeems it with/evaluateserver-to-server and answers without a second iframe when the session is already decided. If redemption is still pending or fails, the usual lazy iframe is returned. See the repository README's pre-check pass section for the client flow.
License
@bitsocial/spam-blocker-challenge is licensed under GPL-3.0-or-later. See LICENSE.
