Skip to content

fix(auth): add allowedTypes option to verifyToken; support agent-identity tokens#36

Merged
i8ramin merged 1 commit intomainfrom
fix/agent-identity-token-allowedtypes
Feb 26, 2026
Merged

fix(auth): add allowedTypes option to verifyToken; support agent-identity tokens#36
i8ramin merged 1 commit intomainfrom
fix/agent-identity-token-allowedtypes

Conversation

@chocothebot
Copy link
Collaborator

Problem

CI has been red since Monday due to 6 failing tests in agent-identity-token-auth.test.ts. The tests correctly validate that verifyToken() should accept botcha-agent-identity tokens when an allowedTypes option is passed — but the implementation never supported this option.

Root Cause

verifyToken() hardcoded payload.type !== 'botcha-verified' with no way to override. Additionally:

  • BotchaTokenPayload type had type: 'botcha-verified' as a literal (not accepting other types)
  • No agent_id field in BotchaTokenPayload or in the return payload
  • issueEAT, buildOIDCAgentClaims, issueAgentGrant in tap-oidca.ts duplicated inline type structs instead of using BotchaTokenPayload

Fix

  • Add allowedTypes?: string[] option to verifyToken() (defaults to ['botcha-verified'] — no behavior change for existing callers)
  • Widen BotchaTokenPayload.type to 'botcha-verified' | 'botcha-agent-identity' | string
  • Add agent_id?: string field to BotchaTokenPayload and include it in the return value
  • Make solveTime optional (agent-identity tokens don't have a solve time)
  • Update Variables.tokenPayload in index.tsx to use BotchaTokenPayload directly
  • Refactor tap-oidca.ts functions to use BotchaTokenPayload instead of duplicated inline type defs

Tests

Test Files: 35 passed (previously 34 — agent-identity-token-auth.test.ts now passing)
Tests: 1006 passed, 0 failed (previously 6 failing)

All existing tests continue to pass. No behavior change for botcha-verified flows.

…tity tokens

- Add allowedTypes option to verifyToken() (defaults to ['botcha-verified'])
- Widen BotchaTokenPayload.type to accept 'botcha-agent-identity' and other types
- Add agent_id field to BotchaTokenPayload and include it in verifyToken return
- Make solveTime optional in BotchaTokenPayload (agent-identity tokens don't have it)
- Update Variables.tokenPayload in index.tsx to use BotchaTokenPayload type
- Refactor issueEAT, buildOIDCAgentClaims, issueAgentGrant in tap-oidca.ts to
  accept BotchaTokenPayload instead of duplicated inline types

Fixes 6 failing tests in agent-identity-token-auth.test.ts
All 1006 tests now pass.
@github-actions
Copy link

🤖 BOTCHA Verification Required

This repository only accepts contributions from AI agents.

To prove you're an agent, solve this challenge:


Challenge ID: gh-1772111766-36

Numbers: [125225, 127794, 127969, 115091, 100811]

Task: Compute SHA256 of each number, return the first 8 hex characters.

Reply with this exact format:

BOTCHA:gh-1772111766-36:
["your_answer_1", "your_answer_2", "your_answer_3", "your_answer_4", "your_answer_5"]

Time limit: 5 minutes from this comment.

A human would need to manually run echo -n "123456" | sha256sum five times and copy-paste results. An AI agent just... computes it.

Powered by BOTCHA (https://botcha.ai) — Prove you're a bot. Humans need not apply.

@github-actions
Copy link

🚀 Preview Deployed — PR #36

Branch: fix/agent-identity-token-allowedtypes
Commit: 6e02f33
URL: https://botcha-pr-36.carrot-cart.workers.dev

Quick smoke tests

BASE="https://botcha-pr-36.carrot-cart.workers.dev"

# Health check
curl "$BASE/health"

# Challenge flow
APP_ID=app_c4e8aade83ce32f0
curl "$BASE/v1/challenge?app_id=$APP_ID"

# New endpoints on this PR (check EPIC.md for specifics)
curl "$BASE/v1/" | jq .

⚠️ Preview uses production KV — test data is real. Clean up test agents/apps when done.


Auto-deployed by preview.yml · View logs

@chocothebot
Copy link
Collaborator Author

BOTCHA:gh-1772111766-36:
["b104ba0f", "905c45a5", "1d0e27ce", "9f2ee70a", "14874b59"]

@github-actions
Copy link

✅ BOTCHA Verification Passed!

🤖 @chocothebot has proven they are an AI agent.

⏱️ Solved in 32 seconds

📊 Challenge Details:

  • 🆔 Challenge ID: gh-1772111766-36
  • 🎯 All 5 SHA256 hashes computed correctly
  • ⚡ Solved in 0.53 minutes

This PR is now eligible for review and merge.


Welcome, fellow agent! 🦞

@i8ramin i8ramin merged commit b7de9fd into main Feb 26, 2026
3 checks passed
@github-actions
Copy link

🧹 Preview worker botcha-pr-36 deleted (PR merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants