| 1 | using System.Text.Json.Serialization; |
| 2 | |
| 3 | namespace AgentForge.Contracts; |
| 4 | |
| 5 | public sealed record BeginDeviceLoginRequest(string? ClientName = null, string? Scopes = null); |
| 6 | |
| 7 | public sealed record DeviceAuthorizationResponse( |
| 8 | string DeviceCode, |
| 9 | string UserCode, |
| 10 | int ExpiresIn, |
| 11 | int Interval); |
| 12 | |
| 13 | public sealed record PollDeviceTokenRequest(string DeviceCode); |
| 14 | |
| 15 | public sealed record DeviceTokenPollResponse( |
| 16 | string? AccessToken, |
| 17 | string? TokenType, |
| 18 | string? Error, |
| 19 | string? TokenName) |
| 20 | { |
| 21 | public static DeviceTokenPollResponse Pending() => |
| 22 | new(null, null, "authorization_pending", null); |
| 23 | |
| 24 | public static DeviceTokenPollResponse Success(string token, string tokenName) => |
| 25 | new(token, "Bearer", null, tokenName); |
| 26 | |
| 27 | public static DeviceTokenPollResponse Expired() => |
| 28 | new(null, null, "expired_token", null); |
| 29 | |
| 30 | public static DeviceTokenPollResponse Denied() => |
| 31 | new(null, null, "access_denied", null); |
| 32 | |
| 33 | public static DeviceTokenPollResponse NotFound() => |
| 34 | new(null, null, "invalid_grant", null); |
| 35 | } |
| 36 | |
| 37 | public sealed record ApproveDeviceLoginRequest(string UserCode); |
| 38 | |
| 39 | public sealed record DeviceApprovalResponse(string TokenName, string Scopes); |
| 40 | |
| 41 | public sealed record ForgeAuthProviderItem(string Id, string DisplayName); |
| 42 | |
| 43 | public sealed record OAuthTokenExchangeRequest( |
| 44 | [property: JsonPropertyName("grant_type")] string GrantType, |
| 45 | [property: JsonPropertyName("code")] string? Code, |
| 46 | [property: JsonPropertyName("state")] string? State, |
| 47 | [property: JsonPropertyName("code_verifier")] string? CodeVerifier, |
| 48 | [property: JsonPropertyName("redirect_uri")] string? RedirectUri); |
| 49 | |
| 50 | public sealed record OAuthTokenIssueResponse( |
| 51 | string AccessToken, |
| 52 | string TokenName, |
| 53 | string Scopes); |
| 54 | |