api

package
v0.0.0-...-ac4d359 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2015 License: ISC, ISC Imports: 12 Imported by: 0

README

keybase.io API package

Currently supported:

  • logging in
  • looking up users
  • adding a public key
  • deleting a public key

Todo:

  • figure out and implement triplesec
  • figure out keybase.io's custom pgp key format (>< * 1000)
  • implement all other endpoints

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPublicKey = fmt.Errorf("api: no public key for user")

Functions

func GetSalt

func GetSalt(user string) (session *sessionStart, err error)

GetSalt retrieves a salt for the named user. It returns a session start, which should only be passed to Login.

func IsAPIError

func IsAPIError(err error) bool

IsAPIError returns true if the error is from the Keybase API (and not a network / JSON / etc error).

Types

type Basics

type Basics struct {
	Username     string `json:"username"`
	Created      int    `json:"ctime"`
	Modified     int    `json:"mtime"`
	IDVersion    int    `json:"id_version"`
	TrackVersion int    `json:"track_version"`
	LastIDChange int    `json:"last_id_change"`
	Salt         string `json:"string"`
}

Basics contain basic information about the user.

type Email

type Email struct {
	Email    string `json:"email"`
	Verified int    `json:"is_verified"`
}

Users contains an email record.

type Emails

type Emails struct {
	Primary Email `json:"primary"`
}

Emails contains a list of the user's emails. Right now, only a primary email is contained in this structure.

type InvitationStats

type InvitationStats struct {
	Available int `json:"available"`
	Used      int `json:"used"`
	Power     int `json:"power"`
	Open      int `json:"open"`
}

InvitationStats contains the user's invitation stats.

type Key

type Key struct {
	KeyID       string  `json:"kid"`
	Fingerprint string  `json:"key_fingerprint"`
	KeyType     KeyType `json:"key_type"`
	Bundle      string  `json:"bundle"`
	Modified    int     `json:"mtime"`
	Created     int     `json:"ctime"`
}

A Key contains information about a public or private key.

type KeyType

type KeyType int

A KeyType is used to denote whether a key is public or private.

const (
	PublicKey  KeyType = 1
	PrivateKey KeyType = 2
)

These constants provide friendly names for the key types returned by the API.

type Profile

type Profile struct {
	Modified int    `json:"mtime"`
	FullName string `json:"full_name"`
	Location string `json:"location"`
	Bio      string `json:"bio"`
}

Profile contains the user's profile information.

type Proof

type Proof struct {
	Text        string
	SigID       string
	ProofID     string
	PayloadHash string
}

type Session

type Session struct {
	Status  *Status `json:"status"`
	GuestID string  `json:"guest_id"`
	Session string  `json:"session"`
	UID     string  `json:"uid"`
	User    User    `json:"me"`
	Token   string  `json:"csrf_token"`
}

Session contains a keybase session, with user information.

func Login

func Login(user string, password []byte, sstart *sessionStart) (session *Session, err error)

Login completes a login after a call to GetSalt. The session start value is destroyed once the function exits.

func (*Session) AddKey

func (s *Session) AddKey(pub string) (kid string, err error)

AddKey adds a new public key to the account. This will replace any existing accounts.

func (*Session) DeleteKey

func (s *Session) DeleteKey(kid string) (err error)

DeleteKey performs a simple delete "revocation" (in Keybase parlance): it will delete the key with the named key ID from the user's account.

func (*Session) GithubGetAuth

func (s *Session) GithubGetAuth(username string) (authData []byte, err error)

func (*Session) NextSequence

func (s *Session) NextSequence() (seqNum int, prev string, err error)

Retrieve the next sequence number for signatures.

func (*Session) ServicePostAuth

func (s *Session) ServicePostAuth(sig []byte, user, service string) (proof *Proof, err error)

func (*Session) SignaturePostAuth

func (s *Session) SignaturePostAuth(sig []byte) (authToken []byte, err error)

func (*Session) SignaturePostAuthData

func (s *Session) SignaturePostAuthData() (msg []byte, err error)

func (*Session) TwitterGetAuth

func (s *Session) TwitterGetAuth(username string) (authData []byte, err error)

type Status

type Status struct {
	Desc string `json:"desc"`
	Code int    `json:"code"`
	Name string `json:"name"`
}

Status contains the API call status results from keybase.io.

func (*Status) Error

func (st *Status) Error() string

func (*Status) Success

func (st *Status) Success() bool

Success returns true if the call succeeded.

type User

type User struct {
	ID          string          `json:"id"`
	Basics      Basics          `json:"basics"`
	Invitations InvitationStats `json:"invitation_stats"`
	Profile     Profile         `json:"profile"`
	Emails      Emails          `json:"emails"`
	PublicKeys  map[string]*Key `json:"public_keys"`
	PrivateKeys map[string]*Key `json:"private_keys"`
}

User contains information regarding a user.

func LookupUser

func LookupUser(user string) (u *User, err error)

LookupUser returns available user information for the named user.

Jump to

Keyboard shortcuts

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