Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateKey = errors.New("key is already registered")
var ErrHashIDClaimed = errors.New("HashID claimed")
ErrHashIDClaimed is returned when the client tries to get a new code for a HashID that has already used the code
var ErrInvalidKeyFormat = errors.New("argument had wrong size")
var ErrInvalidOneTimeCode = errors.New("argument had wrong size")
var ErrKeyConsumed = errors.New("keypair has uploaded maximum number of diagnosis keys")
var ErrNoRecordWritten = errors.New("we tried to write a transaction but no record was written")
ErrNoRecordWritten indicates that, though we should have been able to write a transaction to the DB, for some reason no record was created. This must be a bug with our query logic, because it should never happen.
var ErrTooManyKeys = errors.New("key limit for keypair exceeded")
ErrTooManyKeys is returned when the client tries to insert one or more keys past their limit, assigned on keypair creation. The entire batch is rejected.
Functions ¶
func MigrateDatabase ¶
MigrateDatabase creates the database and migrates it into the correct state.
func SetupLookup ¶
func SetupLookup(lookup keyclaim.Authenticator)
SetupLookup Setup the originator lookup used to map events to bearerTokens
Types ¶
type Conn ¶
type Conn interface { // Return keys that were SUBMITTED to the Diagnosis Server during the specified // UTC date. // // Only returns keys that correspond to a Key for a date // less than 14 days ago. FetchKeysForHours(string, uint32, uint32, int32) ([]*pb.TemporaryExposureKey, error) StoreKeys(*[32]byte, []*pb.TemporaryExposureKey, context.Context) error NewKeyClaim(context.Context, string, string, string) (string, error) ClaimKey(string, []byte, context.Context) ([]byte, error) PrivForPub([]byte) ([]byte, error) CheckClaimKeyBan(string) (triesRemaining int, banDuration time.Duration, err error) ClaimKeySuccess(string) error ClaimKeyFailure(string) (triesRemaining int, banDuration time.Duration, err error) DeleteOldDiagnosisKeys() (int64, error) DeleteOldEncryptionKeys() (int64, error) DeleteOldFailedClaimKeyAttempts() (int64, error) CountClaimedOneTimeCodes() (int64, error) CountDiagnosisKeys() (int64, error) CountUnclaimedOneTimeCodes() (int64, error) CountEncryptionKeys() (int64, error) CountEvents() (int64, error) CountFailedKeyClaimAttempts() (int64, error) CountTekUploadCount() (int64, error) CountUnclaimedEncryptionKeysByOriginator() ([]CountByOriginator, error) CountExhaustedEncryptionKeysByOriginator() ([]CountByOriginator, error) CountExpiredClaimedEncryptionKeysByOriginator() ([]CountByOriginator, error) CountExpiredClaimedEncryptionKeysWithNoUploadsByOriginator() ([]CountByOriginator, error) SaveEvent(event Event) error GetServerEvents(startDate string) ([]Events, error) GetTEKUploads(startDate string) ([]Uploads, error) ClearDiagnosisKeys(context.Context) error Close() error }
Conn mediates all access to a MySQL/CloudSQL connection. It exposes a method for each query we support. The one exception is database creation/migrations, which are handled separately.
type CountByOriginator ¶
CountByOriginator Just a count of a thing by the Originator (Bearer Token) Originator The originator (Bearer Token) of this thing we are counting Count The number of times this thing happened
type DeviceType ¶
type DeviceType string
DeviceType the type of the device the event was generated by
const ( Android DeviceType = "Android" IOS DeviceType = "iOS" Server DeviceType = "Server" )
Android events generated by Server IOS events generated by iPhones Server events generated by Server
func (DeviceType) IsValid ¶
func (dt DeviceType) IsValid() error
IsValid validates the Device Type against a list of allowed strings
type Event ¶
type Event struct { Identifier EventType DeviceType DeviceType Date time.Time Count int Originator string }
Event the event that we are to log Identifier The EventType of the event DeviceType the DeviceType of the event Date The date the event was generated on Count The number of times the event occurred Originator The bearerToken that the event belongs to
type EventType ¶
type EventType string
EventType the type of the event that happened
const ( OTKClaimed EventType = "OTKClaimed" OTKUnclaimed EventType = "OTKUnclaimed" OTKGenerated EventType = "OTKGenerated" OTKExpired EventType = "OTKExpired" OTKExhausted EventType = "OTKExhausted" OTKExpiredNoUploads EventType = "OTKExpiredNoUploads" OTKRegenerated EventType = "OTKRegenerated" )
OTKClaimed One Time Key Claimed OTKGenerated One Time Key Generated OTKRegenerated One Time Key Regenerated OTKExpired One Time Key Expired OTKExpiredNoUploads One Time Key Expired with no TEK uploads (not exclusive but subset) OTKExhausted One Time Key exhausted all it's TEKs
type Events ¶
type Events struct { Source string `json:"source"` Date string `json:"date"` Count int64 `json:"count"` Identifier string `json:"identifier"` }
Events the aggregate of events identified in Identifier by Source Source the bearer token that generated these events Date the date the events occurs Count the number of times this event occurred Identifier the event that occurred
type Uploads ¶
type Uploads struct { Source string `json:"source"` Date string `json:"date"` Count int64 `json:"count"` FirstUpload bool `json:"first_upload"` }
Uploads the aggregate of uploads identified in orignator by Source Source the bearer token that generated these uploads Date the date the upload occurs Count the number of keys uploaded FirstUpload if this was the first upload by a user