Documentation ¶
Index ¶
- Constants
- Variables
- type ApprovalRequest
- type Authy
- func (authy *Authy) CheckPhoneVerification(countryCode int, phoneNumber string, verificationCode string, ...) (*PhoneVerificationCheck, error)
- func (authy *Authy) DoRequest(method string, path string, params url.Values) (*http.Response, error)
- func (authy *Authy) FindApprovalRequest(uuid string, params url.Values) (*ApprovalRequest, error)
- func (authy *Authy) RegisterUser(email string, countryCode int, phoneNumber string, params url.Values) (*User, error)
- func (authy *Authy) RequestPhoneCall(userID string, params url.Values) (*PhoneCallRequest, error)
- func (authy *Authy) RequestSMS(userID string, params url.Values) (*SMSRequest, error)
- func (authy *Authy) SendApprovalRequest(userID string, message string, details Details, params url.Values) (*ApprovalRequest, error)
- func (authy *Authy) StartPhoneVerification(countryCode int, phoneNumber string, via string, params url.Values) (*PhoneVerificationStart, error)
- func (authy *Authy) UserStatus(id string, params url.Values) (*UserStatus, error)
- func (authy *Authy) VerifyToken(userID string, token string, params url.Values) (*TokenVerification, error)
- func (authy *Authy) WaitForApprovalRequest(uuid string, maxDuration time.Duration, params url.Values) (OneTouchStatus, error)
- type Details
- type OneTouchStatus
- type PhoneCallRequest
- type PhoneVerificationCheck
- type PhoneVerificationStart
- type SMSRequest
- type TokenVerification
- type User
- type UserStatus
Constants ¶
const ( // SMS indicates the message will be delivered via SMS SMS = "sms" // Voice indicates the message will be delivered via phone call Voice = "call" )
Variables ¶
var ( // Logger is the default logger of this package. You can override it with your own. Logger = log.New(os.Stderr, "[authy] ", log.LstdFlags) // DefaultTransport is the default transport struct for the HTTP client DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: _Dialer.DialContext, MaxIdleConns: 128, IdleConnTimeout: 30 * time.Second, TLSHandshakeTimeout: 5 * time.Second, ExpectContinueTimeout: 3 * time.Second, } )
Functions ¶
This section is empty.
Types ¶
type ApprovalRequest ¶
type ApprovalRequest struct { HTTPResponse *http.Response Status OneTouchStatus `json:"status"` UUID string `json:"uuid"` Notified bool `json:"notified"` }
ApprovalRequest is the approval request response.
func NewApprovalRequest ¶
func NewApprovalRequest(response *http.Response) (*ApprovalRequest, error)
NewApprovalRequest returns an instance of ApprovalRequest.
func (*ApprovalRequest) Valid ¶
func (request *ApprovalRequest) Valid() bool
Valid returns true if the approval request was valid.
type Authy ¶
Authy contains credentials to connect to the Authy's API
func NewAuthyAPI ¶
NewAuthyAPI returns an instance of Authy pointing to production.
func (*Authy) CheckPhoneVerification ¶
func (authy *Authy) CheckPhoneVerification(countryCode int, phoneNumber string, verificationCode string, params url.Values) (*PhoneVerificationCheck, error)
CheckPhoneVerification checks the given verification code.
func (*Authy) DoRequest ¶
func (authy *Authy) DoRequest(method string, path string, params url.Values) (*http.Response, error)
DoRequest performs a HTTP request to the Authy API
func (*Authy) FindApprovalRequest ¶
FindApprovalRequest finds an approval request given its uuid.
func (*Authy) RegisterUser ¶
func (authy *Authy) RegisterUser(email string, countryCode int, phoneNumber string, params url.Values) (*User, error)
RegisterUser register a new user given an email and phone number.
func (*Authy) RequestPhoneCall ¶
RequestPhoneCall requests a phone call for the given user
func (*Authy) RequestSMS ¶
RequestSMS requests a SMS for the given userID
func (*Authy) SendApprovalRequest ¶
func (authy *Authy) SendApprovalRequest(userID string, message string, details Details, params url.Values) (*ApprovalRequest, error)
SendApprovalRequest sends a OneTouch's approval request to the given user.
func (*Authy) StartPhoneVerification ¶
func (authy *Authy) StartPhoneVerification(countryCode int, phoneNumber string, via string, params url.Values) (*PhoneVerificationStart, error)
StartPhoneVerification starts the phone verification process.
func (*Authy) UserStatus ¶
UserStatus returns a set of data about a user.
func (*Authy) VerifyToken ¶
func (authy *Authy) VerifyToken(userID string, token string, params url.Values) (*TokenVerification, error)
VerifyToken verifies the given token
func (*Authy) WaitForApprovalRequest ¶
func (authy *Authy) WaitForApprovalRequest(uuid string, maxDuration time.Duration, params url.Values) (OneTouchStatus, error)
WaitForApprovalRequest waits until the status of an approval request has changed or times out.
type OneTouchStatus ¶
type OneTouchStatus string
OneTouchStatus is the type of the OneTouch statuses.
var ( // OneTouchStatusApproved is the approved status of an approval request OneTouchStatusApproved OneTouchStatus = "approved" // OneTouchStatusPending is the pending status of an approval request OneTouchStatusPending OneTouchStatus = "pending" // OneTouchStatusDenied is the denied status of an approval request OneTouchStatusDenied OneTouchStatus = "denied" // OneTouchStatusExpired is the expired status of an approval request OneTouchStatusExpired OneTouchStatus = "expired" )
type PhoneCallRequest ¶
PhoneCallRequest encapsulates the response from the Authy API
func NewPhoneCallRequest ¶
func NewPhoneCallRequest(response *http.Response) (*PhoneCallRequest, error)
NewPhoneCallRequest returns an instance of a PhoneCallRequest
func (*PhoneCallRequest) Valid ¶
func (request *PhoneCallRequest) Valid() bool
Valid returns true if the request was valid.
type PhoneVerificationCheck ¶
type PhoneVerificationCheck struct { HTTPResponse *http.Response Message string `json:"message"` Success bool `json:"success"` }
PhoneVerificationCheck encapsulates the response from the Authy API when checking a phone verification.
func NewPhoneVerificationCheck ¶
func NewPhoneVerificationCheck(response *http.Response) (*PhoneVerificationCheck, error)
NewPhoneVerificationCheck receives a http request, parses the body and return an instance of PhoneVerification
type PhoneVerificationStart ¶
type PhoneVerificationStart struct { HTTPResponse *http.Response UUID string `json:"uuid"` Message string `json:"message"` Success bool `json:"success"` Carrier string `json:"carrier"` }
PhoneVerificationStart encapsulates the response from the Authy API when requesting a phone verification.
func NewPhoneVerificationStart ¶
func NewPhoneVerificationStart(response *http.Response) (*PhoneVerificationStart, error)
NewPhoneVerificationStart receives a http request, parses the body and return an instance of PhoneVerification
type SMSRequest ¶
SMSRequest encapsulates the response from the Authy API when requesting a SMS
func NewSMSRequest ¶
func NewSMSRequest(response *http.Response) (*SMSRequest, error)
NewSMSRequest returns an instance of SMSRequest
func (*SMSRequest) Valid ¶
func (request *SMSRequest) Valid() bool
Valid returns true if the SMS was sent
type TokenVerification ¶
type TokenVerification struct { HTTPResponse *http.Response Message string `json:"message"` Token string `json:"token"` Success interface{} `json:"success"` }
TokenVerification encapsulates the response from Authy API when verifying a token.
func NewTokenVerification ¶
func NewTokenVerification(response *http.Response) (*TokenVerification, error)
NewTokenVerification creates an instance of a TokenVerification
func (*TokenVerification) Valid ¶
func (verification *TokenVerification) Valid() bool
Valid returns true if the verification was valid.
type User ¶
type User struct { HTTPResponse *http.Response ID string UserData struct { ID int `json:"id"` } `json:"user"` Errors map[string]string `json:"errors"` Message string `json:"message"` }
User is an Authy User
type UserStatus ¶
type UserStatus struct { HTTPResponse *http.Response ID string StatusData struct { ID int `json:"authy_id"` Confirmed bool `json:"confirmed"` Registered bool `json:"registered"` Country int `json:"country_code"` PhoneNumber string `json:"phone_number"` Devices []string `json:"devices"` } `json:"status"` Message string `json:"message"` Success bool `json:"success"` }
UserStatus is a user with information loaded from Authy API
func NewUserStatus ¶
func NewUserStatus(httpResponse *http.Response) (*UserStatus, error)
NewUserStatus returns an instance of UserStatus