devin

package
v7.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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

func BuildGetUserStatusRequest(sessionToken, deviceFingerprint string) []byte

BuildGetUserStatusRequest serializes a Connect-RPC GetUserStatus request protobuf.

func FormatSessionToken

func FormatSessionToken(rawToken string) string

FormatSessionToken ensures the token carries the mandatory devin-session-token$ prefix.

func GenerateDeviceFingerprint

func GenerateDeviceFingerprint(seed string) string

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. When redirectURI is empty, it generates a headless manual code URL (with cli_pkce_marker=1) matching the exact query parameter ordering of the official Devin CLI binary.

func (*DevinAuthService) CreateAuthRecord added in v7.3.1

func (s *DevinAuthService) CreateAuthRecord(ctx context.Context, token string) (*coreauth.Auth, error)

CreateAuthRecord builds the shared CLI and management OAuth credential record. Profile and quota enrichment are best-effort; the session token is permanent.

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) SetAPIBaseURL added in v7.3.3

func (s *DevinAuthService) SetAPIBaseURL(url string)

SetAPIBaseURL overrides the token exchange and profile API base URL (used in tests).

func (*DevinAuthService) SetAppBaseURL added in v7.3.3

func (s *DevinAuthService) SetAppBaseURL(url string)

SetAppBaseURL overrides the user-facing OAuth authorization base URL (used in tests).

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

type OAuthResult struct {
	Code  string
	State string
	Error string
}

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.

type PKCECodes

type PKCECodes struct {
	CodeVerifier  string
	CodeChallenge string
}

PKCECodes contains the PKCE code verifier and code challenge pair.

func GeneratePKCECodes

func GeneratePKCECodes() (*PKCECodes, error)

GeneratePKCECodes generates a random code verifier and its S256 challenge.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL