verifiedsms

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2022 License: MIT Imports: 10 Imported by: 0

README

verifiedsms

This is a go library for interacting with the Google Verified SMS service. You'll need to already be signed up as a Verified SMS Partner to use this library.

Example:

package main

import "github.com/monzo/verifiedsms"

partner := verified_sms.VerifiedSMSPartner{
    ServiceAccountJSONFile: "foobar",
}

agent := verified_sms.VerifiedSMSAgent{
	ID: "barbaz",
	PrivateKey: ...,
}

wasMessageVerified, err := partner.MarkSMSAsVerified(context.Background(), "+447700900461", agent, "hello!")

Documentation

Index

Constants

View Source
const (
	ApiGetPublicKeysUrl = "https://verifiedsms.googleapis.com/v1/enabledUserKeys:batchGet"
	ApiSubmitHashesUrl  = "https://verifiedsms.googleapis.com/v1/messages:batchCreate"
	ContentTypeHeader   = "application/json"
	UserAgentHeader     = "monzo/verifiedsms"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// The ID of the Verified SMS agent to use
	ID string

	// The private key of the Verified SMS agent to use
	PrivateKey *ecdsa.PrivateKey
}

type Partner

type Partner struct {
	// The JSON keys for a service account that will make requests to create messages and enable user keys as the
	// Verified SMS partner
	ServiceAccountJSONFile string
}

func (Partner) GetPhoneNumberPublicKeys

func (partner Partner) GetPhoneNumberPublicKeys(ctx context.Context, phoneNumber string) ([]string, error)

GetPhoneNumberPublicKeys gets the public keys for a given phone number from the Verified SMS service and returns them as a slice of strings

func (Partner) MarkSMSAsVerified

func (partner Partner) MarkSMSAsVerified(ctx context.Context, phoneNumber string, agent *Agent, smsMessage string) (bool, error)

MarkSMSAsVerified marks a given SMS as verified for a given end users phone number agent is a VerifiedSMSAgent that the message will appear to be sent from smsMessage is the content of the message to be verified Returns a boolean to indicate whether the SMS was verified, this will be false if there were no errors but the users' device just doesn't support Verified SMS An error will be returned if we couldn't mark the SMS as Verified and we aren't sure whether the user is on Verified SMS

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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