Documentation
¶
Index ¶
- Constants
- func BuildGetUserStatusRequest(sessionToken, deviceFingerprint string) []byte
- func FormatSessionToken(rawToken string) string
- func GenerateDeviceFingerprint(seed string) string
- type DevinAuthService
- func (s *DevinAuthService) BuildAuthorizationURL(redirectURI, codeChallenge, state string) string
- func (s *DevinAuthService) ExchangeCodeForToken(ctx context.Context, code, codeVerifier string) (string, error)
- func (s *DevinAuthService) FetchSelfProfile(ctx context.Context, sessionToken string) (userName, userID, orgID string, err error)
- func (s *DevinAuthService) FetchUserStatus(ctx context.Context, sessionToken, deviceSeed string) (*DevinUserStatus, error)
- func (s *DevinAuthService) SetServerBaseURL(url string)
- type DevinTokenBundle
- type DevinUserStatus
- type OAuthResult
- type OAuthServer
- type PKCECodes
Constants ¶
const ( // DefaultAppBaseURL is the user-facing web app for Devin OAuth. DefaultAppBaseURL = "https://app.devin.ai" // DefaultAPIBaseURL is the API backend for token exchange and user status. DefaultAPIBaseURL = "https://api.devin.ai" // DefaultServerURL is the upstream Codeium/Devin reasoning backend. DefaultServerURL = "https://server.codeium.com" )
const (
// DevinGetUserStatusPath is the Connect-RPC unary endpoint for seat management and quota.
DevinGetUserStatusPath = "/exa.seat_management_pb.SeatManagementService/GetUserStatus"
)
Variables ¶
This section is empty.
Functions ¶
func BuildGetUserStatusRequest ¶
BuildGetUserStatusRequest serializes a Connect-RPC GetUserStatus request protobuf.
func FormatSessionToken ¶
FormatSessionToken ensures the token carries the mandatory devin-session-token$ prefix.
func GenerateDeviceFingerprint ¶
GenerateDeviceFingerprint generates a 732-character hex device fingerprint. When seed is empty, it generates a cryptographically random 732-character hex string per request. When seed is provided, it derives a deterministic 732-character hex fingerprint.
Types ¶
type DevinAuthService ¶
type DevinAuthService struct {
// contains filtered or unexported fields
}
DevinAuthService coordinates Devin PKCE authorization and token exchange.
func NewDevinAuthService ¶
func NewDevinAuthService(client *http.Client) *DevinAuthService
NewDevinAuthService creates a new Devin authentication service instance.
func (*DevinAuthService) BuildAuthorizationURL ¶
func (s *DevinAuthService) BuildAuthorizationURL(redirectURI, codeChallenge, state string) string
BuildAuthorizationURL constructs the PKCE login URL.
func (*DevinAuthService) ExchangeCodeForToken ¶
func (s *DevinAuthService) ExchangeCodeForToken(ctx context.Context, code, codeVerifier string) (string, error)
ExchangeCodeForToken exchanges the authorization code for a session token.
func (*DevinAuthService) FetchSelfProfile ¶
func (s *DevinAuthService) FetchSelfProfile(ctx context.Context, sessionToken string) (userName, userID, orgID string, err error)
FetchSelfProfile retrieves the authenticated user's profile from api.devin.ai/v3/self.
func (*DevinAuthService) FetchUserStatus ¶
func (s *DevinAuthService) FetchUserStatus(ctx context.Context, sessionToken, deviceSeed string) (*DevinUserStatus, error)
FetchUserStatus queries Connect-RPC endpoint GetUserStatus for quota, plan, and user details.
func (*DevinAuthService) SetServerBaseURL ¶
func (s *DevinAuthService) SetServerBaseURL(url string)
SetServerBaseURL overrides the upstream reasoning/seat management base URL (used in tests).
type DevinTokenBundle ¶
type DevinTokenBundle struct {
SessionToken string `json:"session_token"`
RawToken string `json:"raw_token"`
UserName string `json:"user_name,omitempty"`
UserID string `json:"user_id,omitempty"`
OrgID string `json:"org_id,omitempty"`
BaseURL string `json:"base_url,omitempty"`
}
DevinTokenBundle holds the completed authentication result.
type DevinUserStatus ¶
type DevinUserStatus struct {
Email string `json:"email,omitempty"`
UserName string `json:"user_name,omitempty"`
UserID string `json:"user_id,omitempty"`
TeamID string `json:"team_id,omitempty"`
OrgID string `json:"org_id,omitempty"`
OrgName string `json:"org_name,omitempty"`
Plan string `json:"plan,omitempty"`
DailyQuotaRemainingPercent int64 `json:"daily_quota_remaining_percent"`
WeeklyQuotaRemainingPercent int64 `json:"weekly_quota_remaining_percent"`
DailyQuotaResetAt time.Time `json:"daily_quota_reset_at,omitempty"`
WeeklyQuotaResetAt time.Time `json:"weekly_quota_reset_at,omitempty"`
PlanStart time.Time `json:"plan_start,omitempty"`
PlanEnd time.Time `json:"plan_end,omitempty"`
}
DevinUserStatus contains plan, quota, and account metadata returned by GetUserStatus.
func ParseGetUserStatusResponse ¶
func ParseGetUserStatusResponse(data []byte) (*DevinUserStatus, error)
ParseGetUserStatusResponse decodes the binary protobuf returned by GetUserStatus.
type OAuthResult ¶
OAuthResult carries the authorization code from the browser callback.
type OAuthServer ¶
type OAuthServer struct {
// contains filtered or unexported fields
}
OAuthServer handles local loopback HTTP callbacks for Devin authentication.
func NewOAuthServer ¶
func NewOAuthServer(port int) *OAuthServer
NewOAuthServer creates a local loopback server for Devin OAuth.
func (*OAuthServer) Start ¶
func (s *OAuthServer) Start() (int, error)
Start initiates the local HTTP server. If port is 0, an available ephemeral port is chosen.
func (*OAuthServer) Stop ¶
func (s *OAuthServer) Stop(ctx context.Context) error
Stop gracefully stops the server.
func (*OAuthServer) WaitForCallback ¶
func (s *OAuthServer) WaitForCallback(timeout time.Duration) (*OAuthResult, error)
WaitForCallback waits for the browser redirect or times out.
func (*OAuthServer) WaitForCallbackWithContext ¶
func (s *OAuthServer) WaitForCallbackWithContext(ctx context.Context, timeout time.Duration) (*OAuthResult, error)
WaitForCallbackWithContext waits for the browser redirect, context cancellation, or times out.