Prompt Your LLM: Android / Kotlin

Copy the prompt below into ChatGPT, Claude, Cursor, or any AI coding assistant. It contains everything the LLM needs to generate a working Akedly Shield V1.2 integration for your Android project.


Copy This Prompt

I need to integrate Akedly Shield V1.2 OTP authentication into my Android application.

## Architecture: keep APIKey on the backend

APIKey and pipelineID are credentials. They MUST NOT be compiled into an APK or AAB — packages can be unpacked and anything inside is public.
My backend exposes three thin proxy routes that the Android app will call:
  GET  /auth/akedly/challenge
  POST /auth/akedly/send            body: { phoneNumber, powSolution, turnstileToken? }
  POST /auth/akedly/verify          body: { transactionReqID, otp }

The Kotlin code you generate must ONLY call these three routes.
Never reference APIKey or pipelineID in Kotlin. Never call api.akedly.io from the client.

## Reference backend (Node.js / Express) — drop in if I don't have one yet

import express from 'express';

const app = express();
app.use(express.json());
// Optional: only needed if you want per-end-user-IP rate limiting (drop
// this line and the x-end-user-ip header below if you don't). Makes req.ip
// the real client IP behind Cloudflare / Vercel / AWS ALB / Nginx.
app.set('trust proxy', 1);

app.get('/auth/akedly/challenge', async (_req, res) => {
  const r = await fetch(
    `https://api.akedly.io/api/v1.2/transactions/challenge` +
    `?APIKey=${process.env.AKEDLY_API_KEY}` +
    `&pipelineID=${process.env.AKEDLY_PIPELINE_ID}`
  );
  res.status(r.status).json(await r.json());
});

app.post('/auth/akedly/send', async (req, res) => {
  const { phoneNumber, powSolution, turnstileToken } = req.body;
  const r = await fetch('https://api.akedly.io/api/v1.2/transactions/send', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'x-end-user-ip': req.ip },
    body: JSON.stringify({
      APIKey: process.env.AKEDLY_API_KEY,
      pipelineID: process.env.AKEDLY_PIPELINE_ID,
      verificationAddress: { phoneNumber },
      powSolution,
      turnstileToken,
    }),
  });
  res.status(r.status).json(await r.json());
});

app.post('/auth/akedly/verify', async (req, res) => {
  const { transactionReqID, otp } = req.body;
  const r = await fetch('https://api.akedly.io/api/v1.2/transactions/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ transactionReqID, otp }),
  });
  res.status(r.status).json(await r.json());
});

## Challenge response shape (what Android receives from /auth/akedly/challenge)

{ status, data: { challenge, difficulty, challengeToken, challengeRequired, turnstile: { required, siteKey } } }

## Frontend flow

1. GET {backendUrl}/auth/akedly/challenge
2. Solve PoW on-device: `val nonce = solvePow(challenge, difficulty)` (suspend function)
   Algorithm: SHA256(challenge + ":" + nonce) must start with `difficulty` leading hex zeros.
3. If turnstile.required: `val token = AkedlyTurnstile(context).getToken(siteKey)` (on Main dispatcher)
4. POST {backendUrl}/auth/akedly/send   body: { phoneNumber, powSolution: { challengeToken, nonce }, turnstileToken? }
   Response: { status, data: { transactionReqID } }
5. POST {backendUrl}/auth/akedly/verify   body: { transactionReqID, otp: "123456" }

## SDK: akedly-shield-kotlin (GitHub-only, not on Maven Central)

Repository: https://github.com/Akedly-Org/akedly-shield-kotlin

Install via JitPack. In settings.gradle.kts add `maven { url = uri("https://jitpack.io") }` to dependencyResolutionManagement.repositories, then in the app module build.gradle.kts:
  implementation("com.github.Akedly-Org:akedly-shield-kotlin:1.0.0")

Use a release tag, `main-SNAPSHOT`, or a commit hash as the version.

Key functions:
- suspend fun solvePow(challenge: String, difficulty: Int): Int (coroutine, yields every 10k iterations)
- fun solvePowSync(challenge: String, difficulty: Int): Int (blocking, for Java interop)
- AkedlyTurnstile(context: Context, bridgeDomain: String = "turnstile.akedly.io")
  suspend fun getToken(siteKey: String): String (invisible WebView, call from Main dispatcher)

## Requirements

Please generate a complete integration with:
- Jetpack Compose screen with full OTP flow that ONLY talks to my backend
- ViewModel with coroutine-based logic
- OkHttp or Retrofit for the three backend calls
- Error handling and loading states
- Phone number input and OTP verification UI
- A top-level `const val BACKEND_URL = "https://yourapp.com"` the user can change
- Clean MVVM architecture
- No APIKey and no pipelineID anywhere in Kotlin code

Customizing the Prompt

Add any of these to the end of the prompt to tailor the output:

  • Framework: "I'm using Next.js App Router with TypeScript" or "I'm using Expo with React Navigation"
  • State management: "Use Zustand for state" or "Use Redux Toolkit"
  • Styling: "Use Tailwind CSS" or "Use styled-components" or "Use NativeWind"
  • Auth flow: "After OTP verification, create a JWT session" or "Store the session in SecureStore"
  • Error handling: "Show toast notifications for errors" or "Use react-hot-toast"

Was this page helpful?