-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdcc.go
92 lines (80 loc) · 2.67 KB
/
dcc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package dcc
import "time"
// DCC (Digital Covid Certificate) Top Level CBOR structure
// Section 3.3.1 at https://ec.europa.eu/health/sites/default/files/ehealth/docs/digital-green-certificates_v1_en.pdf
type DCC struct {
ExpirationTime int `cbor:"4,keyasint,omitempty" json:"4"`
IssuedAt int `cbor:"6,keyasint,omitempty" json:"6"`
Issuer string `cbor:"1,keyasint,omitempty" json:"1"`
HealthCertificate HCert `cbor:"-260,keyasint,omitempty" json:"-260"`
}
type HCert struct {
DGC DCCPayload `cbor:"1,keyasint,omitempty" json:"1"`
}
type DCCPayload struct {
Nam Nam `json:"nam"`
Dob string `json:"dob"` // Date of birth in range of 1900-0-01 to 2099-12-31
V []V `json:"v"` // Vaccination group
Ver string `json:"ver"`
}
type Nam struct {
Fn string `json:"fn"` // Surname
Fnt string `json:"fnt"` // Standardised Surname
Gn string `json:"gn"` // Forename
Gnt string `json:"gnt"` // Standardised Forename
}
// DCC Payload for Vaccination group type of HCERT
type V struct {
Dn int `json:"dn"` // Number in a series of doses
Sd int `json:"sd"` // The overall number of doses
Mp string `json:"mp"` // Vaccine Product
Dt string `json:"dt"` // Date of vaccination
Tg string `json:"tg"` // Disease or agent targeted
Vp string `json:"vp"` // Vaccine or Prophylaxis
Ma string `json:"ma"` // Vaccine marketing authorisation holder or manufacturer
Co string `json:"co"` // Member state which administered the vaccine
Is string `json:"is"` // Certificate Issuer
Ci string `json:"ci"` // Unique certificate identifier
}
var (
GreenPassVersion = "1.3.0"
SNOMEDCovidCode = "840539006"
VaccineProduct = "EU/1/20/1528"
VaccineType = "1119349007" // SARS-CoV-2 mRNA vaccine
MarketingAuthorisation = "ORG-100030215" // Biontech Manufacturing GmbH
)
func generateDCCStruct(name, surname, dob, issuerCountry, issuer, vaccinationDate string, vaccinationDoses int) *DCC {
issuedAt := int(time.Now().Unix())
expiry := int(time.Now().AddDate(1, 0, 0).Unix())
NameInfo := Nam{
Fn: surname,
Fnt: surname,
Gn: name,
Gnt: name,
}
VaccinePayload := V{
Dn: vaccinationDoses,
Sd: vaccinationDoses,
Mp: VaccineProduct,
Dt: vaccinationDate,
Tg: SNOMEDCovidCode,
Vp: VaccineType,
Ma: MarketingAuthorisation,
Co: issuerCountry,
Is: issuer,
Ci: "UVCI:01:NZ:FC45E0107AAA4CFD22D1F653E3281D4F", // Fake Certificate identifier as I am unsure how to generate it
}
return &DCC{
ExpirationTime: expiry,
IssuedAt: issuedAt,
Issuer: issuerCountry,
HealthCertificate: HCert{
DGC: DCCPayload{
Nam: NameInfo,
Dob: dob,
V: []V{VaccinePayload},
Ver: GreenPassVersion,
},
},
}
}