//nolint:revive package barcode import ( "context" "time" ) type Code struct { // Subject is the user this barcode is issued to Subject string `bson:"subject" json:"subject" xml:"subject"` // IssuedBy is used to indicate who issued this IssuedBy string `bson:"iby" json:"iby" xml:"iby"` // ClientID is used to make sure that the same client is the one exchanging the code for the actual barcode ClientID string `bson:"clientId" json:"clientId" xml:"clientId"` // Challenge is used to map the barcode key to the session Challenge string `bson:"challenge" json:"challenge" xml:"challenge"` // Used tells whether this barcode is used previously or not Used bool `bson:"used" json:"used" xml:"used"` // CreatedAt refers to the timestamp when the barcode is generated as per user request. CreatedAt time.Time `bson:"createdAt" json:"createdAt" xml:"createdAt"` // Type refers to QR or 128A. Type string `bson:"type" json:"type" xml:"type"` } type Barcode struct { // Subject is the user this barcode is issued to Subject string `bson:"subject" json:"subject" xml:"subject"` // Secret is a unique generated credential for a barcode generation request. Secret string `bson:"secret" json:"secret" xml:"secret"` // CreatedAt refers to the timestamp when the barcode is generated as per user request. CreatedAt time.Time `bson:"createdAt" json:"createdAt" xml:"createdAt"` } type BarcodeKey struct { // BarcodeKey is used to map barcode to a barcode user BarcodeKey string `bson:"barcodeKey" json:"barcodeKey" xml:"barcodeKey"` } type Storage interface { CreateBarcodeCode(ctx context.Context, code string, subject string, issuedBy string, clientID string, barcodeType string, challenge string) (err error) InvalidateBarcodeCode(ctx context.Context, code string, subject string, issuedBy string, clientID string, barcodeType string, challenge string) (err error) CreateBarcodeKey(ctx context.Context, challenge string, barcodeKey string) (err error) GetBarcodeKey(ctx context.Context, challenge string) (barcodeKey *BarcodeKey, err error) DeleteBarcodeKey(ctx context.Context, challenge string) (err error) GetBarcodeCode(ctx context.Context, code string) (barcodeCode *Code, err error) GetBarcodeUser(ctx context.Context, barCodeUser string) (string, error) CreateBarcodeUser(ctx context.Context, subject, barcodeKey string) (err error) DeleteBarcodeCode(ctx context.Context, code string) (err error) CreateBarcode(ctx context.Context, key, secret, subject string) (err error) GetBarcode(ctx context.Context, key string) (barcode *Barcode, err error) DeleteBarcode(ctx context.Context, barcode string) (err error) IsOffline() bool RunOfflineDetection() }