{"id":19809665,"url":"https://github.com/sventiigi/eudcckit","last_synced_at":"2025-08-17T10:04:13.388Z","repository":{"id":45484474,"uuid":"383510877","full_name":"SvenTiigi/EUDCCKit","owner":"SvenTiigi","description":"EU Digital COVID Certificate Kit for the Apple Platform  (unofficial)","archived":false,"fork":false,"pushed_at":"2022-11-02T15:32:53.000Z","size":464,"stargazers_count":29,"open_issues_count":1,"forks_count":10,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-13T15:00:33.316Z","etag":null,"topics":["covid-19","covid-certificate","eu-digital-covid-19-certificate","swift"],"latest_commit_sha":null,"homepage":"https://sventiigi.github.io/EUDCCKit/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SvenTiigi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-06T15:11:57.000Z","updated_at":"2025-01-19T13:31:36.000Z","dependencies_parsed_at":"2022-07-18T23:18:03.807Z","dependency_job_id":null,"html_url":"https://github.com/SvenTiigi/EUDCCKit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/SvenTiigi/EUDCCKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SvenTiigi%2FEUDCCKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SvenTiigi%2FEUDCCKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SvenTiigi%2FEUDCCKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SvenTiigi%2FEUDCCKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SvenTiigi","download_url":"https://codeload.github.com/SvenTiigi/EUDCCKit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SvenTiigi%2FEUDCCKit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270831798,"owners_count":24653414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["covid-19","covid-certificate","eu-digital-covid-19-certificate","swift"],"created_at":"2024-11-12T09:17:46.061Z","updated_at":"2025-08-17T10:04:13.363Z","avatar_url":"https://github.com/SvenTiigi.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr/\u003e\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/SvenTiigi/EUDCCKit/gh-pages/readme-assets/logo.png\" width=\"30%\" alt=\"logo\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eEU Digital COVID Certificate Kit\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    A Swift Package to decode, verify and validate EU Digital COVID Certificates\u003cbr/\u003efor iOS, tvOS, watchOS and macOS\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://developer.apple.com/swift/\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/Swift-5.4-orange.svg?style=flat\" alt=\"Swift 5.4\"\u003e\n   \u003c/a\u003e\n    \u003ca href=\"https://sventiigi.github.io/EUDCCKit\"\u003e\n      \u003cimg src=\"https://github.com/SvenTiigi/EUDCCKit/blob/gh-pages/badge.svg\" alt=\"Documentation\"\u003e\n   \u003c/a\u003e\n   \u003ca href=\"https://twitter.com/SvenTiigi/\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/Twitter-@SvenTiigi-blue.svg?style=flat\" alt=\"Twitter\"\u003e\n   \u003c/a\u003e\n\u003c/p\u003e\n\n## Disclaimer\n\n\u003e The EUDCCKit is not an offical implementation of the EU Digital COVID Certificate\n\n## Features\n\n- [x] Easily decode an EU Digital COVID Certificate 🧾\n- [x] Verify cryptographic signature 🔐\n- [x] Certificate validation ✅\n\n## Installation\n\n### Swift Package Manager\n\nTo integrate using Apple's [Swift Package Manager](https://swift.org/package-manager/), add the following as a dependency to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/SvenTiigi/EUDCCKit.git\", from: \"0.0.1\")\n]\n```\n\nOr navigate to your Xcode project then select `Swift Packages`, click the “+” icon and search for `EUDCCKit`.\n\n## Usage\n\nThe `EUDCCKit` Swift Package is made of four distinct libraries to decode, verify and validate an EU Digital COVID Certificate.\n\n### EUDCC\n\nThe `EUDCC` library contains the model definition of the EU Digital COVID Certificate\n\n```swift\nimport EUDCC\n\n// The EU Digital COVID Certificate model\nlet eudcc: EUDCC\n\n// Access content of EUDCC\nswitch eudcc.content {\ncase .vaccination(let vaccination):\n    print(\"Vaccination\", vaccination)\ncase .test(let test):\n    print(\"Test\", test)\ncase .recovery(let recovery):\n    print(\"Recovery\", recovery)\n}\n```\n\n\u003e Head over to the [advanced section](https://github.com/SvenTiigi/EUDCCKit#eudcc-1) to learn more.\n\n### EUDDCDecoder\n\nThe `EUDCCDecoder` library provides an `EUDCCDecoder` object which is capabale of decoding a Base-45 string reperesentation of the EU Digital COVID Certificate which is mostly embedded in a QR-Code.\n\n```swift\nimport EUDCCDecoder\n\n// Initialize an EUDCCDecoder\nlet decoder = EUDCCDecoder()\n\n// The Base-45 encoded EU Digital COVID Certificate from a QR-Code\nlet qrCodeContent = \"HC1:...\"\n\n// Decode EUDCC from QR-Code\nlet decodingResult = decoder.decode(from: qrCodeContent)\n\n// Switch on decoding result\nswitch decodingResult {\ncase .success(let eudcc):\n    // Successfully decoded Digital COVID Certificate\n    print(\"EU Digital COVID Certificate\", eudcc)\ncase .failure(let decodingError):\n    // Decoding failed with error\n    print(\"Failed to decode EUDCC\", decodingError)\n}\n```\n\n\u003e Head over to the [advanced section](https://github.com/SvenTiigi/EUDCCKit#euddcdecoder-1) to learn more.\n\n### EUDCCVerifier\n\nThe `EUDCCVerifier` library provides an `EUDCCVerifier` object which can be used to verify the cryptographic signature of the EU Digital COVID Certificate.\n\n```swift\nimport EUDCCVerifier\n\n// Initialize an EUDDCCVerifier\nlet verifier = EUDCCVerifier(\n    trustService: EUCentralEUDCCTrustService()\n)\n\n// Verify EU Digital COVID Certificate\nverifier.verify(eudcc: eudcc) { verificationResult in\n    // Switch on verification result\n    switch verificationResult {\n    case .success(let trustCertificate):\n        print(\"Cryptographically valid\", trustCertificate)\n    case .invald:\n        print(\"Invalid EUDCC\")\n    case .failure(let error):\n        print(\"Error occured during verification\", error)\n    }\n}\n```\n\n\u003e Head over to the [advanced section](https://github.com/SvenTiigi/EUDCCKit#eudccverifier-1) to learn more.\n\n### EUDCCValidator\n\nThe `EUDCCValidator` library provides an `EUDCCValidator` object which can be used to validate the EU Digital COVID Certifiate based on given rules.\n\n```swift\nimport EUDCCValidator\n\n// Initialize an EUDCCValidator\nlet validator = EUDCCValidator()\n\n// Validate EU Digital COVID Certificate\nlet validationResult = validator.validate(\n    eudcc: eudcc,\n    rule: .isFullyImmunized() \u0026\u0026 !.isVaccinationExpired()\n)\n\n// Switch on validation result\nswitch validationResult {\ncase .success:\n    // Successfully validated EU Digital COVID Certificate\n    print(\"Successfully validated\")\ncase .failure(let validationError):\n    // Validation failure\n    print(\"Validation failed\", validationError)\n}\n```\n\n\u003e Head over to the [advanced section](https://github.com/SvenTiigi/EUDCCKit#eudccvalidator-1) to learn more.\n\n## Advanced\n\n### EUDCC\n\n#### Content\n\nBeside the `content` property of an `EUDCC` you can make use of the following convenience properties to check if the `EUDCC` contains a vaccination, test or recovery object.\n\n```swift\nimport EUDCC\n\n// Vaccination\nlet vaccination: EUDCC.Vaccination? = eudcc.vaccination\n\n// Test\nlet test: EUDCC.Test? = eudcc.test\n\n// Recovery\nlet recovery: EUDCC.Recovery? = eudcc.recovery\n```\n\n#### Well-Known-Value\n\nEach of the following objects are exposing a `WellKnownValue` enumeration which can be used to retrieve more detailed information about a certain value:\n\n- `EUDCC.DiseaseAgentTargeted`\n- `EUDCC.Test.TestResult`\n- `EUDCC.Test.TestType`\n- `EUDCC.Vaccination.VaccineMarketingAuthorizationHolder`\n- `EUDCC.Vaccination.VaccineMedicinalProduct`\n- `EUDCC.Vaccination.VaccineOrProphylaxis`\n\n```swift\nimport EUDCC\n\nlet vaccineMedicinalProduct: EUDCC.Vaccination.VaccineMedicinalProduct\n\n// Switch on WellKnownValue of VaccineMedicinalProduct\nswitch vaccineMedicinalProduct.wellKnownValue {\n    case .covid19VaccineModerna:\n        break\n    case .vaxzevria:\n        break\n    default:\n        break\n}\n```\n\n#### Encoding\n\nThe `EUDCC` contains two properties `cryptographicSignature` and `base45Representation` which are convenience objects that are not an offical part of the EU Digital COVID Certificate JSON Schema. \n\nIf you wish to skip those properties when encoding an `EUDCC` you can set the following `userInfo` configuration to a `JSONEncoder`.\n\n```swift\nimport EUDCC\n\nlet encoder = JSONEncoder()\n\nencoder.userInfo = [\n    // Skip encoding CryptographicSignature\n    EUDCC.EncoderUserInfoKeys.skipCryptographicSignature: true,\n    // Skip encoding Base-45 representation\n    EUDCC.EncoderUserInfoKeys.skipBase45Representation: true,\n]\n\nlet jsonData = try encoder.encode(eudcc)\n```\n\n### EUDDCDecoder\n\n#### Decoding\n\nThe `EUDCCDecoder` supports decoding a Base-45 encoded `String` and `Data` object.\n\n```swift\nimport EUDCCDecoder\n\nlet eudccDecoder = EUDCCDecoder()\n\n// Decode from Base-45 encoded String\nlet eudccBase45EncodedString: String\nlet stringDecodingResult = eudccDecoder.decode(\n    from: eudccBase45EncodedString\n)\n\n// Decode from Base-45 encoded Data\nlet eudccBase45EncodedData: Data\nlet dataDecodingResult = eudccDecoder.decode(\n    from: eudccBase45EncodedData\n)\n```\n\n#### Convenience decoding\n\nBy importing the `EUDCCDecoder` library the `EUDCC` object will be extended with a static `decode` function.\n\n```swift\nimport EUDCCDecoder\n\nlet decodingResult = EUDCC.decode(from: \"HC1:...\")\n```\n\n### EUDCCVerifier\n\n#### EUDCCTrustService\n\nIn order to verify an `EUDCC` the `EUDCCVerifier` needs to be instantiated with an instance of an `EUDCCTrustService` which is used to retrieve the trust certificates.\n\n```swift\nimport EUDCC\nimport EUDCCVerifier\n\nstruct SpecificEUDCCTrustService: EUDCCTrustService {\n    \n    /// Retrieve EUDCC TrustCertificates\n    /// - Parameter completion: The completion closure\n    func getTrustCertificates(\n        completion: @escaping (Result\u003c[EUDCC.TrustCertificate], Error\u003e) -\u003e Void\n    ) {\n        // TODO: Retrieve TrustCertificates and invoke completion handler\n    }\n    \n}\n\nlet eudccVerifier = EUDCCVerifier(\n    trustService: SpecificEUDCCTrustService()\n)\n```\n\nThe `EUDCCKit` comes along with two pre defined `EUDCCTrustService` implementations:\n\n- `EUCentralEUDCCTrustService`\n- `RobertKochInstituteEUDCCTrustService`\n\nIf you wish to retrieve certificates from multiple `EUDCCTrustService` implementation you can make use of the `GroupableEUDCCTrustService`:\n\n```swift\nlet trustService = GroupableEUDCCTrustService(\n    trustServices: [\n        EUCentralEUDCCTrustService(),\n        RobertKochInstituteEUDCCTrustService()\n    ]\n)\n\ntrustService.getTrustCertificates { certificates in\n    // ...\n}\n```\n\n#### Convenience verification\n\nBy importing the `EUDCCVerifier` library the `EUDCC` object will be extended with a `verify` function.\n\n```swift\nimport EUDCC\nimport EUDCCVerifier\n\nlet eudcc: EUDCC\n\neudcc.verify(\n    using: EUDCCVerifier(\n        trustService: EUCentralEUDCCTrustService()\n    )\n) { verificationResult in\n    switch verificationResult {\n    case .success(let trustCertificate):\n        break\n    case .invald:\n        break\n    case .failure(let error):\n        break\n    }\n}\n```\n\n### EUDCCValidator\n\n#### ValidationRule\n\nAn `EUDCC` can be validated by using an `EUDCCValidator` and a given `EUDCC.ValidationRule`. An `EUDCC.ValidationRule` can be initialized with a simple closure wich takes in an `EUDCC` and returns a `Bool` whether the validation succeed or failed.\n\n```swift\nimport EUDCC\nimport EUDCCValidator\n\n// Simple EUDCC ValidationRule instantiation\nlet validationRule = EUDCC.ValidationRule { eudcc in\n    // Process EUDCC and return Bool result\n}\n\n// EUDCC ValidationRule with Tag in order to uniquely identify a ValidationRule\nlet isVaccinationComplete = EUDCC.ValidationRule(\n    tag: \"is-vaccination-complete\"\n) { eudcc in\n    eudcc.vaccination?.doseNumber == eudcc.vaccination?.totalSeriesOfDoses\n}\n```\n\nThe `EUDCCKit` comes along with many pre defined `EUDCC.ValidationRule` like the following ones.\n\n```swift\nimport EUDCC\nimport EUDCCValidator\n\nlet eudcc: EUDCC\nlet validator = EUDCCValidator()\n\n// Is fully immunized\nvalidator.validate(\n    eudcc: eudcc, \n    rule: .isFullyImmunized(minimumDaysPast: 15)\n)\n\n// Is tested positive\nvalidator.validate(\n    eudcc: eudcc, \n    rule: .isTestedPositive\n)\n```\n\n#### Logical/Conditional operators\n\nIn order to create more complex rules each `EUDCC.ValidationRule` can be chained together by applying standard operators.\n\n```swift\nimport EUDCC\nimport EUDCCValidator\n\nlet defaultValidationRule: EUDCC.ValidationRule = .if(\n    .isVaccination,\n    then: .isFullyImmunized() \u0026\u0026 .isWellKnownVaccineMedicinalProduct \u0026\u0026 !.isVaccinationExpired(),\n    else: .if(\n        .isTest,\n        then: .isTestedNegative \u0026\u0026 .isTestValid(),\n        else: .if(\n            .isRecovery,\n            then: .isRecoveryValid,\n            else: .constant(false)\n        )\n    )\n)\n```\n\n#### Convenience validation\n\nBy importing the `EUDCCValidator` library the `EUDCC` object will be extended with a `validate` function.\n\n```swift\nimport EUDCC\nimport EUDCCValidator\n\nlet eudcc: EUDCC\n\nlet validationRule = eudcc.validate(\n    rule: .isWellKnownVaccineMedicinalProduct\n)\n```\n\n## License\n\n```\nEUDCCKit\nCopyright (c) 2021 Sven Tiigi sven.tiigi@gmail.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsventiigi%2Feudcckit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsventiigi%2Feudcckit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsventiigi%2Feudcckit/lists"}