Skip to content
Akedly
V1.2 REST API

Solve the challenge

Solve the proof-of-work challenge and get a Turnstile token on the client, and find the Shield SDK for your platform.

Solving the Challenge

These fields come from the Step 1 response.

Before calling Step 2, your client solves PoW only when challengeRequired is true and obtains a Turnstile token only when turnstile.required is true. Shield SDKs handle the client-side work across all platforms.

Always branch on challengeRequired before you solve. A pipeline with PoW switched off — or one in dev mode with bypassPoW — returns no challenge, difficulty or challengeToken, so calling the solver unconditionally throws on undefined.

Solve PoW

SDK
import { solvePow, getTurnstileToken } from '@akedly/shield';

// Solve PoW (uses Web Worker automatically) — only when the server asks for it
let powSolution;
if (data.challengeRequired) {
  const { nonce } = await solvePow(data.challenge, data.difficulty);
  powSolution = { challengeToken: data.challengeToken, nonce };
}

// Get Turnstile token (if required)
const turnstileToken = data.turnstile?.required
  ? await getTurnstileToken(data.turnstile.siteKey)
  : undefined;

Algorithm Reference

The PoW solver computes SHA256(challenge + ":" + nonce) and checks if the resulting hex digest starts with difficulty leading zeros. The nonce increments from 0 until a valid hash is found.

text
hash = SHA256("a1b2c3d4...:" + "42")   // hex digest
valid = hash.startsWith("000")           // difficulty = 3

Shield SDKs

Official Shield SDKs handle Proof-of-Work solving and Turnstile token retrieval across all platforms. Each SDK manages threading, Web Workers, or isolates automatically.

PlatformPackageInstallRepository
Web / JavaScript@akedly/shieldnpm / CDNNPM
Flutter / Dartakedly_shieldGitHub (pubspec git:)GitHub
iOS / SwiftAkedlyShieldSPM (GitHub URL)GitHub
Android / Kotlinakedly-shield-kotlinGitHub (JitPack)GitHub
React Native@akedly/shieldnpmNPM