Documentation
¶
Overview ¶
Package cursor implements Cursor OAuth PKCE authentication and token refresh.
Index ¶
- Constants
- func CredentialFileName(label, subHash string) string
- func DisplayLabel(label, subHash string) string
- func GeneratePKCE() (verifier, challenge string, err error)
- func GetTokenExpiry(token string) time.Time
- func ParseJWTSub(token string) string
- func SubToShortHash(sub string) string
- type AuthParams
- type TokenPair
Constants ¶
const ( CursorLoginURL = "https://cursor.com/loginDeepControl" CursorPollURL = "https://api2.cursor.sh/auth/poll" CursorRefreshURL = "https://api2.cursor.sh/auth/exchange_user_api_key" )
Variables ¶
This section is empty.
Functions ¶
func CredentialFileName ¶
CredentialFileName returns the filename used to persist Cursor credentials. Priority: explicit label > auto-generated from JWT sub hash. If both label and subHash are empty, falls back to "cursor.json".
func DisplayLabel ¶
DisplayLabel returns a human-readable label for the Cursor account.
func GeneratePKCE ¶
GeneratePKCE creates a PKCE verifier and challenge pair.
func GetTokenExpiry ¶
GetTokenExpiry extracts the JWT expiry from an access token with a 5-minute safety margin. Falls back to 1 hour from now if the token can't be parsed.
func ParseJWTSub ¶
ParseJWTSub extracts the "sub" claim from a Cursor JWT access token. Cursor JWTs contain "sub" like "auth0|user_XXXX" which uniquely identifies the account. Returns empty string if parsing fails.
func SubToShortHash ¶
SubToShortHash converts a JWT sub claim to a short hex hash for use in filenames. e.g. "auth0|user_2x..." → "a3f8b2c1"
Types ¶
type AuthParams ¶
AuthParams holds the PKCE parameters for Cursor login.
func GenerateAuthParams ¶
func GenerateAuthParams() (*AuthParams, error)
GenerateAuthParams creates the full set of auth params for Cursor login.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package proto provides protobuf encoding for Cursor's gRPC API, using dynamicpb with the embedded FileDescriptorProto from agent.proto.
|
Package proto provides protobuf encoding for Cursor's gRPC API, using dynamicpb with the embedded FileDescriptorProto from agent.proto. |