...
1
2 package barcode
3
4 import (
5 "context"
6 "time"
7 )
8
9 type Code struct {
10
11 Subject string `bson:"subject" json:"subject" xml:"subject"`
12
13 IssuedBy string `bson:"iby" json:"iby" xml:"iby"`
14
15 ClientID string `bson:"clientId" json:"clientId" xml:"clientId"`
16
17 Challenge string `bson:"challenge" json:"challenge" xml:"challenge"`
18
19 Used bool `bson:"used" json:"used" xml:"used"`
20
21 CreatedAt time.Time `bson:"createdAt" json:"createdAt" xml:"createdAt"`
22
23 Type string `bson:"type" json:"type" xml:"type"`
24 }
25
26 type Barcode struct {
27
28 Subject string `bson:"subject" json:"subject" xml:"subject"`
29
30 Secret string `bson:"secret" json:"secret" xml:"secret"`
31
32 CreatedAt time.Time `bson:"createdAt" json:"createdAt" xml:"createdAt"`
33 }
34
35 type BarcodeKey struct {
36
37 BarcodeKey string `bson:"barcodeKey" json:"barcodeKey" xml:"barcodeKey"`
38 }
39
40 type Storage interface {
41 CreateBarcodeCode(ctx context.Context, code string, subject string, issuedBy string, clientID string, barcodeType string, challenge string) (err error)
42 InvalidateBarcodeCode(ctx context.Context, code string, subject string, issuedBy string, clientID string, barcodeType string, challenge string) (err error)
43 CreateBarcodeKey(ctx context.Context, challenge string, barcodeKey string) (err error)
44 GetBarcodeKey(ctx context.Context, challenge string) (barcodeKey *BarcodeKey, err error)
45 DeleteBarcodeKey(ctx context.Context, challenge string) (err error)
46 GetBarcodeCode(ctx context.Context, code string) (barcodeCode *Code, err error)
47 GetBarcodeUser(ctx context.Context, barCodeUser string) (string, error)
48 CreateBarcodeUser(ctx context.Context, subject, barcodeKey string) (err error)
49 DeleteBarcodeCode(ctx context.Context, code string) (err error)
50 CreateBarcode(ctx context.Context, key, secret, subject string) (err error)
51 GetBarcode(ctx context.Context, key string) (barcode *Barcode, err error)
52 DeleteBarcode(ctx context.Context, barcode string) (err error)
53 IsOffline() bool
54 RunOfflineDetection()
55 }
56
View as plain text