Documentation
¶
Index ¶
- Variables
- func IsE164Format(phoneNumber string) bool
- func IsVerificationCode(code string) bool
- type Metadata
- type Server
- func (s *Server) CheckVerificationCode(ctx context.Context, req *phonepb.CheckVerificationCodeRequest) (*phonepb.CheckVerificationCodeResponse, error)
- func (s *Server) SendVerificationCode(ctx context.Context, req *phonepb.SendVerificationCodeRequest) (*phonepb.SendVerificationCodeResponse, error)
- func (s *Server) Unlink(ctx context.Context, req *phonepb.UnlinkRequest) (*phonepb.UnlinkResponse, error)
- type Type
- type Verifier
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidNumber is returned if the phone number is invalid ErrInvalidNumber = errors.New("phone number is invalid") // ErrRateLimited indicates that the call was rate limited ErrRateLimited = errors.New("rate limited") // ErrInvalidVerificationCode is returned when the verification does not // match what's expected in a Confirm call ErrInvalidVerificationCode = errors.New("verification code does not match") // ErrNoVerification indicates that no verification is in progress for // the provided phone number in a Confirm call. Several reasons this // can occur include a verification being expired or having reached a // maximum check threshold. ErrNoVerification = errors.New("verification not in progress") // ErrUnsupportedPhoneType indicates the provided phone number maps to // a type of phone that isn't supported. ErrUnsupportedPhoneType = errors.New("unsupported phone type") )
Functions ¶
func IsE164Format ¶
IsE164Format returns whether a string is a E.164 formatted phone number.
func IsVerificationCode ¶
IsVerificationCode returns whether a string is a 4-10 digit numberical verification code.
Types ¶
type Metadata ¶
type Metadata struct {
// The phone number associated with the set of metadata
PhoneNumber string
// The type of phone. Currently, this is always expected to be a mobile type.
Type Type
// Identifies the country and MNO
// https://www.twilio.com/docs/iot/supersim/api/network-resource#the-identifiers-property
MobileCountryCode *int
MobileNetworkCode *int
}
Metadata provides additional information regarding a phone number. Information is provided on a best-effort basis as provided by third party solutions. This can be used for antispam and fraud measures.
type Server ¶
type Server struct {
phonepb.UnimplementedPhoneVerificationServer
// contains filtered or unexported fields
}
func (*Server) CheckVerificationCode ¶
func (s *Server) CheckVerificationCode(ctx context.Context, req *phonepb.CheckVerificationCodeRequest) (*phonepb.CheckVerificationCodeResponse, error)
func (*Server) SendVerificationCode ¶
func (s *Server) SendVerificationCode(ctx context.Context, req *phonepb.SendVerificationCodeRequest) (*phonepb.SendVerificationCodeResponse, error)
func (*Server) Unlink ¶
func (s *Server) Unlink(ctx context.Context, req *phonepb.UnlinkRequest) (*phonepb.UnlinkResponse, error)
type Verifier ¶
type Verifier interface {
// SendCode sends a verification code via SMS to the provided phone number.
// If an active verification is already taking place, the existing code will
// be resent. A unique ID for the verification and phone metadata is returned on
// success.
SendCode(ctx context.Context, phoneNumber string, appHash *string) (string, *Metadata, error)
// Check verifies a SMS code sent to a phone number.
Check(ctx context.Context, phoneNumber, code string) error
// Cancel cancels an active verification. No error is returned if the
// verification doesn't exist, previously canceled or successfully
// completed.
Cancel(ctx context.Context, id string) error
// IsVerificationActive checks whether a verification is active or not
IsVerificationActive(ctx context.Context, id string) (bool, error)
// IsValid validates a phone number is real and is able to receive
// a verification code.
IsValidPhoneNumber(ctx context.Context, phoneNumber string) (bool, error)
}
Click to show internal directories.
Click to hide internal directories.