'use client'; import { ArrowLeftIcon, ArrowTopRightOnSquareIcon, ShieldCheckIcon, TrashIcon, } from '@heroicons/react/24/outline'; import Link from 'next/link'; import { useEffect, useState } from 'react'; interface OAuthGrant { id: string; clientId: string; clientName: string; clientLogo?: string; scopes: string[]; capabilities: UCANCapability[]; grantedAt: string; lastUsed: string; expiresAt?: string; status: 'active' | 'expired' | 'revoked'; } interface UCANCapability { action: string; resource: string; caveats?: Record; } export default function CapabilitiesPage() { const [grants, setGrants] = useState([]); const [loading, setLoading] = useState(true); const [selectedGrant, setSelectedGrant] = useState(null); const [revoking, setRevoking] = useState(null); useEffect(() => { fetchGrants(); }, []); const fetchGrants = async () => { try { // TODO: Replace with actual API call const mockGrants: OAuthGrant[] = [ { id: 'grant_1', clientId: 'example-app', clientName: 'Example Application', scopes: ['vault:read', 'vault:write', 'profile'], capabilities: [ { action: 'read', resource: 'vault:*' }, { action: 'write', resource: 'vault:*' }, { action: 'read', resource: 'profile:*' }, ], grantedAt: '2024-01-15T10:00:00Z', lastUsed: '2024-01-20T15:30:00Z', status: 'active', }, { id: 'grant_2', clientId: 'defi-wallet', clientName: 'DeFi Wallet', scopes: ['dwn:read', 'svc:register'], capabilities: [ { action: 'read', resource: 'dwn:*' }, { action: 'register', resource: 'svc:*' }, ], grantedAt: '2024-01-10T08:00:00Z', lastUsed: '2024-01-18T12:00:00Z', expiresAt: '2024-02-10T08:00:00Z', status: 'active', }, ]; setGrants(mockGrants); } catch (error) { console.error('Failed to fetch grants:', error); } finally { setLoading(false); } }; const revokeGrant = async (grantId: string) => { setRevoking(grantId); try { // TODO: Implement actual revocation API call await new Promise((resolve) => setTimeout(resolve, 1000)); setGrants((prev) => prev.map((grant) => grant.id === grantId ? { ...grant, status: 'revoked' as const } : grant ) ); if (selectedGrant?.id === grantId) { setSelectedGrant(null); } } catch (error) { console.error('Failed to revoke grant:', error); } finally { setRevoking(null); } }; const formatDate = (dateString: string) => { return new Date(dateString).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', }); }; const getStatusColor = (status: OAuthGrant['status']) => { switch (status) { case 'active': return 'bg-green-100 text-green-800'; case 'expired': return 'bg-yellow-100 text-yellow-800'; case 'revoked': return 'bg-red-100 text-red-800'; default: return 'bg-gray-100 text-gray-800'; } }; return (
{/* Header */}
Back to Home

OAuth Capabilities

Manage applications and services that have access to your account

{loading ? (
) : grants.length === 0 ? (

No Active Grants

You haven't granted any applications access to your account yet.

) : (
{/* Grants List */}
{grants.map((grant) => (
setSelectedGrant(grant)} >
{grant.clientLogo ? ( {grant.clientName} ) : (
{grant.clientName[0]}
)}

{grant.clientName}

Client ID: {grant.clientId}

{grant.scopes.map((scope) => ( {scope} ))}

Granted: {formatDate(grant.grantedAt)}

Last used: {formatDate(grant.lastUsed)}

{grant.expiresAt &&

Expires: {formatDate(grant.expiresAt)}

}
{grant.status} {grant.status === 'active' && ( )}
))}
{/* Grant Details */} {selectedGrant && (

Capability Details

UCAN Capabilities

{selectedGrant.capabilities.map((cap, index) => (
{cap.action} {cap.resource}
{cap.caveats && Object.keys(cap.caveats).length > 0 && (
Caveats: {JSON.stringify(cap.caveats)}
)}
))}

Delegation Chain

Audit Log

View all activities for this grant

)}
)}
); }