Pick a background color for your pass.
@@ -267,7 +197,7 @@ function Form() {
}/>
-
Data privacy is of special importance when processing health-related data.
@@ -281,11 +211,11 @@ function Form() {
-
Add to Wallet
-
+
@@ -297,8 +227,12 @@ function Form() {
}/>
-
+ {
+ errorMessage &&
setErrorMessage(undefined)}/>
+ }
)
}
+
+export default Form;
\ No newline at end of file
diff --git a/components/Logo.js b/components/Logo.tsx
similarity index 95%
rename from components/Logo.js
rename to components/Logo.tsx
index 76dc5a3..75fef46 100644
--- a/components/Logo.js
+++ b/components/Logo.tsx
@@ -1,8 +1,6 @@
import Link from 'next/link'
-export default Logo
-
-function Logo() {
+function Logo(): JSX.Element {
return (
@@ -23,4 +21,6 @@ function Logo() {
)
-}
\ No newline at end of file
+}
+
+export default Logo
\ No newline at end of file
diff --git a/components/Page.js b/components/Page.js
deleted file mode 100644
index 22a75bf..0000000
--- a/components/Page.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import Head from 'next/head'
-import Logo from './Logo'
-import Link from 'next/link'
-
-export default Page
-
-function Page({ content }) {
- return (
-
-
-
CovidPass
-
-
-
-
-
-
- {content}
-
-
-
-
-
- )
-}
\ No newline at end of file
diff --git a/components/Page.tsx b/components/Page.tsx
new file mode 100644
index 0000000..5f504cf
--- /dev/null
+++ b/components/Page.tsx
@@ -0,0 +1,36 @@
+import Head from 'next/head'
+import Logo from './Logo'
+import Link from 'next/link'
+
+interface PageProps {
+ content: JSX.Element
+}
+
+function Page(props: PageProps): JSX.Element {
+ return (
+
+
+
CovidPass
+
+
+
+
+
+
+ {props.content}
+
+
+
+
+
+ )
+}
+
+export default Page
\ No newline at end of file
diff --git a/next-env.d.ts b/next-env.d.ts
new file mode 100644
index 0000000..c6643fd
--- /dev/null
+++ b/next-env.d.ts
@@ -0,0 +1,3 @@
+///
+///
+///
diff --git a/package-lock.json b/package-lock.json
index 9739ded..eabc6fd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
"dependencies": {
"@zxing/browser": "^0.0.9",
"@zxing/library": "^0.18.6",
- "base45-js": "^1.0.1",
+ "base45": "^3.0.0",
"cbor-js": "^0.1.0",
"do-not-zip": "^1.0.0",
"file-saver": "^2.0.5",
@@ -22,13 +22,17 @@
"pngjs": "^6.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
+ "uuid": "^8.3.2",
"webpack": "^5.0.0",
"worker-loader": "^3.0.7"
},
"devDependencies": {
+ "@types/pako": "^1.0.1",
+ "@types/react": "^17.0.11",
"autoprefixer": "^10.0.4",
"postcss": "^8.1.10",
- "tailwindcss": "^2.1.1"
+ "tailwindcss": "^2.1.1",
+ "typescript": "^4.3.4"
}
},
"node_modules/@babel/code-frame": {
@@ -290,12 +294,41 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.4.tgz",
"integrity": "sha512-zrNj1+yqYF4WskCMOHwN+w9iuD12+dGm0rQ35HLl9/Ouuq52cEtd0CH9qMgrdNmi5ejC1/V7vKEXYubB+65DkA=="
},
+ "node_modules/@types/pako": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@types/pako/-/pako-1.0.1.tgz",
+ "integrity": "sha512-GdZbRSJ3Cv5fiwT6I0SQ3ckeN2PWNqxd26W9Z2fCK1tGrrasGy4puvNFtnddqH9UJFMQYXxEuuB7B8UK+LLwSg==",
+ "dev": true
+ },
"node_modules/@types/parse-json": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true
},
+ "node_modules/@types/prop-types": {
+ "version": "15.7.3",
+ "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
+ "integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==",
+ "dev": true
+ },
+ "node_modules/@types/react": {
+ "version": "17.0.11",
+ "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.11.tgz",
+ "integrity": "sha512-yFRQbD+whVonItSk7ZzP/L+gPTJVBkL/7shLEF+i9GC/1cV3JmUxEQz6+9ylhUpWSDuqo1N9qEvqS6vTj4USUA==",
+ "dev": true,
+ "dependencies": {
+ "@types/prop-types": "*",
+ "@types/scheduler": "*",
+ "csstype": "^3.0.2"
+ }
+ },
+ "node_modules/@types/scheduler": {
+ "version": "0.16.1",
+ "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz",
+ "integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==",
+ "dev": true
+ },
"node_modules/@webassemblyjs/ast": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz",
@@ -649,13 +682,10 @@
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
},
- "node_modules/base45-js": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/base45-js/-/base45-js-1.0.1.tgz",
- "integrity": "sha512-AQW3SAO/VVaof+gE/QoQLstyzFRIuQZOwkAX9AY/Ur+qBkNqUfsv8h77vBqsiAgCrTBNBWU+c5m5B0QgKmAT+Q==",
- "engines": {
- "node": ">= 0.6.0"
- }
+ "node_modules/base45": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/base45/-/base45-3.0.0.tgz",
+ "integrity": "sha512-SWayzDiUFaga+G3X/oL2XIDbjhdpmBGUqLU6T7zB89aNWYnEcfa36DIWW95rxn0sWAWbwrKcSyqcWw6AApYwsg=="
},
"node_modules/base64-js": {
"version": "1.5.1",
@@ -1150,6 +1180,12 @@
"postcss": "^8.2.2"
}
},
+ "node_modules/csstype": {
+ "version": "3.0.8",
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.8.tgz",
+ "integrity": "sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==",
+ "dev": true
+ },
"node_modules/data-uri-to-buffer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz",
@@ -4079,6 +4115,19 @@
"node": ">=8"
}
},
+ "node_modules/typescript": {
+ "version": "4.3.4",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.4.tgz",
+ "integrity": "sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==",
+ "dev": true,
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=4.2.0"
+ }
+ },
"node_modules/unbox-primitive": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
@@ -4169,6 +4218,14 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
+ "node_modules/uuid": {
+ "version": "8.3.2",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
+ "bin": {
+ "uuid": "dist/bin/uuid"
+ }
+ },
"node_modules/vm-browserify": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz",
@@ -4624,12 +4681,41 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.4.tgz",
"integrity": "sha512-zrNj1+yqYF4WskCMOHwN+w9iuD12+dGm0rQ35HLl9/Ouuq52cEtd0CH9qMgrdNmi5ejC1/V7vKEXYubB+65DkA=="
},
+ "@types/pako": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@types/pako/-/pako-1.0.1.tgz",
+ "integrity": "sha512-GdZbRSJ3Cv5fiwT6I0SQ3ckeN2PWNqxd26W9Z2fCK1tGrrasGy4puvNFtnddqH9UJFMQYXxEuuB7B8UK+LLwSg==",
+ "dev": true
+ },
"@types/parse-json": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true
},
+ "@types/prop-types": {
+ "version": "15.7.3",
+ "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
+ "integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==",
+ "dev": true
+ },
+ "@types/react": {
+ "version": "17.0.11",
+ "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.11.tgz",
+ "integrity": "sha512-yFRQbD+whVonItSk7ZzP/L+gPTJVBkL/7shLEF+i9GC/1cV3JmUxEQz6+9ylhUpWSDuqo1N9qEvqS6vTj4USUA==",
+ "dev": true,
+ "requires": {
+ "@types/prop-types": "*",
+ "@types/scheduler": "*",
+ "csstype": "^3.0.2"
+ }
+ },
+ "@types/scheduler": {
+ "version": "0.16.1",
+ "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz",
+ "integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==",
+ "dev": true
+ },
"@webassemblyjs/ast": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz",
@@ -4931,10 +5017,10 @@
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
},
- "base45-js": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/base45-js/-/base45-js-1.0.1.tgz",
- "integrity": "sha512-AQW3SAO/VVaof+gE/QoQLstyzFRIuQZOwkAX9AY/Ur+qBkNqUfsv8h77vBqsiAgCrTBNBWU+c5m5B0QgKmAT+Q=="
+ "base45": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/base45/-/base45-3.0.0.tgz",
+ "integrity": "sha512-SWayzDiUFaga+G3X/oL2XIDbjhdpmBGUqLU6T7zB89aNWYnEcfa36DIWW95rxn0sWAWbwrKcSyqcWw6AApYwsg=="
},
"base64-js": {
"version": "1.5.1",
@@ -5352,6 +5438,12 @@
"cssnano-preset-simple": "^2.0.0"
}
},
+ "csstype": {
+ "version": "3.0.8",
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.8.tgz",
+ "integrity": "sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==",
+ "dev": true
+ },
"data-uri-to-buffer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz",
@@ -7569,6 +7661,12 @@
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.7.1.tgz",
"integrity": "sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg=="
},
+ "typescript": {
+ "version": "4.3.4",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.4.tgz",
+ "integrity": "sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==",
+ "dev": true
+ },
"unbox-primitive": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
@@ -7646,6 +7744,11 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
+ "uuid": {
+ "version": "8.3.2",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
+ },
"vm-browserify": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz",
diff --git a/package.json b/package.json
index e805ddf..33efe74 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"dependencies": {
"@zxing/browser": "^0.0.9",
"@zxing/library": "^0.18.6",
- "base45-js": "^1.0.1",
+ "base45": "^3.0.0",
"cbor-js": "^0.1.0",
"do-not-zip": "^1.0.0",
"file-saver": "^2.0.5",
@@ -24,12 +24,16 @@
"pngjs": "^6.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
+ "uuid": "^8.3.2",
"webpack": "^5.0.0",
"worker-loader": "^3.0.7"
},
"devDependencies": {
+ "@types/pako": "^1.0.1",
+ "@types/react": "^17.0.11",
"autoprefixer": "^10.0.4",
"postcss": "^8.1.10",
- "tailwindcss": "^2.1.1"
+ "tailwindcss": "^2.1.1",
+ "typescript": "^4.3.4"
}
}
diff --git a/pages/_app.js b/pages/_app.js
deleted file mode 100644
index 9b571b6..0000000
--- a/pages/_app.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import 'tailwindcss/tailwind.css'
-
-import App from 'next/app';
-import { DefaultSeo } from 'next-seo';
-
-import SEO from '../next-seo.config';
-
-export default class MyApp extends App {
- render() {
- const { Component, pageProps } = this.props;
- return (
- <>
-
-
- >
- );
- }
-}
\ No newline at end of file
diff --git a/pages/_app.tsx b/pages/_app.tsx
new file mode 100644
index 0000000..3fc963b
--- /dev/null
+++ b/pages/_app.tsx
@@ -0,0 +1,16 @@
+import 'tailwindcss/tailwind.css'
+
+import {DefaultSeo} from 'next-seo';
+import SEO from '../next-seo.config';
+import type {AppProps} from 'next/app'
+
+function MyApp({Component, pageProps}: AppProps): JSX.Element {
+ return (
+ <>
+
+
+ >
+ )
+}
+
+export default MyApp;
\ No newline at end of file
diff --git a/pages/_document.js b/pages/_document.tsx
similarity index 79%
rename from pages/_document.js
rename to pages/_document.tsx
index ef3bbc3..c22c41d 100644
--- a/pages/_document.js
+++ b/pages/_document.tsx
@@ -1,7 +1,7 @@
import Document, {Html, Head, Main, NextScript} from 'next/document'
-class CustomDocument extends Document {
- render() {
+class MyDocument extends Document {
+ render(): JSX.Element {
return (
@@ -14,4 +14,4 @@ class CustomDocument extends Document {
}
}
-export default CustomDocument
\ No newline at end of file
+export default MyDocument;
\ No newline at end of file
diff --git a/pages/api/config.js b/pages/api/config.js
deleted file mode 100644
index 4892943..0000000
--- a/pages/api/config.js
+++ /dev/null
@@ -1,4 +0,0 @@
-export default function handler(req, res) {
- // Return the API_BASE_URL. This Endpoint allows us to access the env Variable in client javascript
- res.status(200).json({ apiBaseUrl: process.env.API_BASE_URL })
-}
\ No newline at end of file
diff --git a/pages/api/config.tsx b/pages/api/config.tsx
new file mode 100644
index 0000000..781ca38
--- /dev/null
+++ b/pages/api/config.tsx
@@ -0,0 +1,11 @@
+import type {NextApiRequest, NextApiResponse} from "next";
+
+type ConfigData = {
+ apiBaseUrl: string
+}
+
+export default function handler(req: NextApiRequest, res: NextApiResponse) {
+ // Return the API_BASE_URL. This Endpoint allows us to access the env Variable in client javascript
+ res.status(200).json({apiBaseUrl: process.env.API_BASE_URL})
+}
+
diff --git a/pages/imprint.js b/pages/imprint.js
deleted file mode 100644
index d17f7f9..0000000
--- a/pages/imprint.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import Page from '../components/Page'
-import Card from '../components/Card'
-
-export default function Imprint() {
- return(
-
- Information according to § 5 TMG
-
- Marvin Sextro
- Wilhelm-Busch-Str. 8A
- 30167 Hannover
-
- Contact
-
- marvin.sextro@gmail.com
-
- EU Dispute Resolution
-
- The European Commission provides a platform for online dispute resolution (OS): https://ec.europa.eu/consumers/odr . You can find our e-mail address in the imprint above.
-
- Consumer dispute resolution / universal arbitration board
-
- We are not willing or obliged to participate in dispute resolution proceedings before a consumer arbitration board.
-
- Liability for contents
-
- As a service provider, we are responsible for our own content on these pages in accordance with § 7 paragraph 1 TMG under the general laws. According to §§ 8 to 10 TMG, we are not obligated to monitor transmitted or stored information or to investigate circumstances that indicate illegal activity. Obligations to remove or block the use of information under the general laws remain unaffected. However, liability in this regard is only possible from the point in time at which a concrete infringement of the law becomes known. If we become aware of any such infringements, we will remove the relevant content immediately.
-
- Liability for links
-
- Our offer contains links to external websites of third parties, on whose contents we have no influence. Therefore, we cannot assume any liability for these external contents. The respective provider or operator of the sites is always responsible for the content of the linked sites. The linked pages were checked for possible legal violations at the time of linking. Illegal contents were not recognizable at the time of linking. However, a permanent control of the contents of the linked pages is not reasonable without concrete evidence of a violation of the law. If we become aware of any infringements, we will remove such links immediately.
-
- Credits
-
- With excerpts from: https://www.e-recht24.de/impressum-generator.html
- Translated with www.DeepL.com/Translator (free version)
-
-
- }/>
- }/>
- )
-}
\ No newline at end of file
diff --git a/pages/imprint.tsx b/pages/imprint.tsx
new file mode 100644
index 0000000..d5400ff
--- /dev/null
+++ b/pages/imprint.tsx
@@ -0,0 +1,62 @@
+import Page from '../components/Page'
+import Card from '../components/Card'
+
+function Imprint(): JSX.Element {
+ return (
+
+ Information according to § 5 TMG
+
+ Marvin Sextro
+ Wilhelm-Busch-Str. 8A
+ 30167 Hannover
+
+ Contact
+
+ marvin.sextro@gmail.com
+
+ EU Dispute Resolution
+
+ The European Commission provides a platform for online dispute resolution (OS): https://ec.europa.eu/consumers/odr . You can find our e-mail address in
+ the imprint above.
+
+ Consumer dispute resolution / universal arbitration board
+
+ We are not willing or obliged to participate in dispute resolution proceedings before a consumer
+ arbitration board.
+
+ Liability for contents
+
+ As a service provider, we are responsible for our own content on these pages in accordance with
+ § 7 paragraph 1 TMG under the general laws. According to §§ 8 to 10 TMG, we are not obligated to
+ monitor transmitted or stored information or to investigate circumstances that indicate illegal
+ activity. Obligations to remove or block the use of information under the general laws remain
+ unaffected. However, liability in this regard is only possible from the point in time at which a
+ concrete infringement of the law becomes known. If we become aware of any such infringements, we
+ will remove the relevant content immediately.
+
+ Liability for links
+
+ Our offer contains links to external websites of third parties, on whose contents we have no
+ influence. Therefore, we cannot assume any liability for these external contents. The respective
+ provider or operator of the sites is always responsible for the content of the linked sites. The
+ linked pages were checked for possible legal violations at the time of linking. Illegal contents
+ were not recognizable at the time of linking. However, a permanent control of the contents of
+ the linked pages is not reasonable without concrete evidence of a violation of the law. If we
+ become aware of any infringements, we will remove such links immediately.
+
+ Credits
+
+ With excerpts from: https://www.e-recht24.de/impressum-generator.html
+ Translated with www.DeepL.com/Translator (free version)
+
+
+ }/>
+ }/>
+ )
+}
+
+export default Imprint;
\ No newline at end of file
diff --git a/pages/index.js b/pages/index.js
deleted file mode 100644
index 016788a..0000000
--- a/pages/index.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import { NextSeo } from 'next-seo';
-
-import Form from '../components/Form'
-import Card from '../components/Card'
-import Page from '../components/Page'
-
-export default function Home() {
- return (
- <>
-
-
-
- Add your EU Digital Covid Vaccination Certificates to your favorite wallet app. On iOS, please use the Safari Browser.
-
- } />
-
-
-
- } />
- >
- )
-}
diff --git a/pages/index.tsx b/pages/index.tsx
new file mode 100644
index 0000000..e8afc83
--- /dev/null
+++ b/pages/index.tsx
@@ -0,0 +1,49 @@
+import {NextSeo} from 'next-seo';
+
+import Form from '../components/Form'
+import Card from '../components/Card'
+import Page from '../components/Page'
+
+function Index(): JSX.Element {
+ return (
+ <>
+
+
+
+ Add your EU Digital Covid Vaccination Certificates to your favorite wallet app. On iOS,
+ please use the Safari Browser.
+
+ }/>
+
+
+
+ }/>
+ >
+ )
+}
+
+export default Index;
diff --git a/pages/privacy.js b/pages/privacy.js
deleted file mode 100644
index 0029521..0000000
--- a/pages/privacy.js
+++ /dev/null
@@ -1,201 +0,0 @@
-import Page from '../components/Page'
-import Card from '../components/Card'
-
-export default function Privacy() {
- return(
-
-
- Our privacy policy is based on the terms used by the European legislator for the adoption of the General Data Protection Regulation (GDPR).
-
- General information
-
-
-
- The whole process of generating the pass file happens locally in your browser. For the signing step, only a hashed representation of your data is sent to the server.
-
-
- Your data is not stored beyond the active browser session and the site does not use cookies.
-
-
- No data is sent to third parties.
-
-
- We transmit your data securely over https.
-
-
- Our server is hosted in Nuremberg, Germany.
-
-
- The source code of this site is available on GitHub .
-
-
- By default, Apple Wallet passes are accessible from the lock screen. This can be changed in the settings .
-
-
- The server provider processes data to provide this site. In order to better understand what measures they take to protect your data, please also read their privacy policy and the data privacy FAQ .
-
-
-
- Contact
-
- Marvin Sextro
- Wilhelm-Busch-Str. 8A
- 30167 Hannover
- Germany
- Email: marvin.sextro@gmail.com
- Website: https://marvinsextro.de
-
- Simplified explanation of the process
-
- This process is only started after accepting this policy and clicking on the Add to Wallet button.
-
-
- First, the following steps happen locally in your browser:
-
-
-
- Recognizing and extracting the QR code data from your selected certificate
- Decoding your personal and health-related data from the QR code payload
- Assembling an incomplete pass file out of your data
- Generating a file containing hashes of the data stored in the pass file
- Sending only the file containing the hashes to our server
-
-
-
- Second, the following steps happen on our server:
-
-
-
- Receiving and checking the hashes which were generated locally
- Signing the file containing the hashes
- Sending the signature back
-
-
-
- Finally, the following steps happen locally in your browser:
-
-
-
- Assembling the signed pass file out of the incomplete file generated locally and the signature
- Saving the file on your device
-
-
- Locally processed data
-
- The following data is processed on in your browser to generate the pass file.
-
-
- Processed personal data contained in the QR code:
-
-
-
- Your first and last name
- Your date of birth
-
-
-
- For each vaccination certificate contained in the QR code, the following data is processed:
-
-
-
- Targeted disease
- Vaccine medical product
- Manufacturer/Marketing Authorization Holder
- Dose number
- Total series of doses
- Date of vaccination
- Country of vaccination
- Certificate issuer
- Unique certificate identifier (UVCI)
-
-
-
- For each test certificate contained in the QR code, the following data is processed:
-
-
-
- Targeted disease
- Test type
- NAA Test name
- RAT Test name and manufacturer
- Date/Time of Sample Collection
- Test Result
- Testing Centre
- Country of test
- Certificate Issuer
- Unique Certificate Identifier (UVCI)
-
-
-
- For each recovery certificate contained in the QR code, the following data is processed:
-
-
-
- Targeted disease
- Date of first positive NAA test result
- Country of test
- Certificate Issuer
- Certificate valid from
- Certificate valid until
- Unique Certificate Identifier (UVCI)
-
-
-
- The Digital Covid Certificate Schema contains a detailed specification of which data can be contained in the QR code.
-
- Server provider
-
- Our server provider is Hetzner Online GmbH .
- The following data may be collected and stored in the server log files:
-
-
-
- The browser types and versions used
- The operating system used by the accessing system
- The website from which an accessing system reaches our website (so-called referrers)
- The date and time of access
- The pseudonymised IP addresses
-
-
- Your rights
- In accordance with the GDPR you have the following rights:
-
-
-
- Right of access to your data: You have the right to know what data has been collected about you and how it was processed.
-
-
- Right to be forgotten: Erasure of your personal data.
-
-
- Right of rectification: You have the right to correct inaccurate data.
-
-
- Right of data portability: You have the right to transfer your data from one processing system into another.
-
-
-
- Third parties linked
-
-
- }/>
- }/>
- )
-}
\ No newline at end of file
diff --git a/pages/privacy.tsx b/pages/privacy.tsx
new file mode 100644
index 0000000..02d8930
--- /dev/null
+++ b/pages/privacy.tsx
@@ -0,0 +1,229 @@
+import Page from '../components/Page'
+import Card from '../components/Card'
+
+function Privacy(): JSX.Element {
+ return (
+
+
+ Our privacy policy is based on the terms used by the European legislator for the adoption of the
+ General Data Protection Regulation (GDPR).
+
+ General information
+
+
+
+ The whole process of generating the pass file happens locally in your browser. For the
+ signing step, only a hashed representation of your data is sent to the server.
+
+
+ Your data is not stored beyond the active browser session and the site does not use
+ cookies.
+
+
+ No data is sent to third parties.
+
+
+ We transmit your data securely over https.
+
+
+ Our server is hosted in Nuremberg, Germany.
+
+
+ The source code of this site is available on GitHub .
+
+
+ By default, Apple Wallet passes are accessible from the lock screen. This can be changed
+ in the settings .
+
+
+ The server provider processes data to provide this site. In order to better understand
+ what measures they take to protect your data, please also read their privacy
+ policy and the data privacy FAQ .
+
+
+
+ Contact
+
+ Marvin Sextro
+ Wilhelm-Busch-Str. 8A
+ 30167 Hannover
+ Germany
+ Email: marvin.sextro@gmail.com
+ Website: https://marvinsextro.de
+
+ Simplified explanation of the process
+
+ This process is only started after accepting this policy and clicking on the Add to Wallet
+ button.
+
+
+ First, the following steps happen locally in your browser:
+
+
+
+ Recognizing and extracting the QR code data from your selected certificate
+ Decoding your personal and health-related data from the QR code payload
+ Assembling an incomplete pass file out of your data
+ Generating a file containing hashes of the data stored in the pass file
+ Sending only the file containing the hashes to our server
+
+
+
+ Second, the following steps happen on our server:
+
+
+
+ Receiving and checking the hashes which were generated locally
+ Signing the file containing the hashes
+ Sending the signature back
+
+
+
+ Finally, the following steps happen locally in your browser:
+
+
+
+ Assembling the signed pass file out of the incomplete file generated locally and the
+ signature
+
+ Saving the file on your device
+
+
+ Locally processed data
+
+ The following data is processed on in your browser to generate the pass file.
+
+
+ Processed personal data contained in the QR code:
+
+
+
+ Your first and last name
+ Your date of birth
+
+
+
+ For each vaccination certificate contained in the QR code, the following data is processed:
+
+
+
+ Targeted disease
+ Vaccine medical product
+ Manufacturer/Marketing Authorization Holder
+ Dose number
+ Total series of doses
+ Date of vaccination
+ Country of vaccination
+ Certificate issuer
+ Unique certificate identifier (UVCI)
+
+
+
+ For each test certificate contained in the QR code, the following data is processed:
+
+
+
+ Targeted disease
+ Test type
+ NAA Test name
+ RAT Test name and manufacturer
+ Date/Time of Sample Collection
+ Test Result
+ Testing Centre
+ Country of test
+ Certificate Issuer
+ Unique Certificate Identifier (UVCI)
+
+
+
+ For each recovery certificate contained in the QR code, the following data is processed:
+
+
+
+ Targeted disease
+ Date of first positive NAA test result
+ Country of test
+ Certificate Issuer
+ Certificate valid from
+ Certificate valid until
+ Unique Certificate Identifier (UVCI)
+
+
+
+ The Digital
+ Covid Certificate Schema contains a detailed specification of which data can be contained in
+ the QR code.
+
+ Server provider
+
+ Our server provider is Hetzner Online
+ GmbH .
+ The following data may be collected and stored in the server log files:
+
+
+
+ The browser types and versions used
+ The operating system used by the accessing system
+ The website from which an accessing system reaches our website (so-called referrers)
+
+ The date and time of access
+ The pseudonymised IP addresses
+
+
+ Your rights
+ In accordance with the GDPR you have the following rights:
+
+
+
+ Right of access to your data: You have the right to know what data has been collected
+ about you and how it was processed.
+
+
+ Right to be forgotten: Erasure of your personal data.
+
+
+ Right of rectification: You have the right to correct inaccurate data.
+
+
+ Right of data portability: You have the right to transfer your data from one processing
+ system into another.
+
+
+
+ Third parties linked
+
+
+ }/>
+ }/>
+ )
+}
+
+export default Privacy;
\ No newline at end of file
diff --git a/src/constants.js b/src/constants.js
deleted file mode 100644
index af4c362..0000000
--- a/src/constants.js
+++ /dev/null
@@ -1,19 +0,0 @@
-exports.VALUE_SET_BASE_URL = 'https://raw.githubusercontent.com/ehn-dcc-development/ehn-dcc-valuesets/main/'
-exports.VALUE_TYPES = {
- medicalProducts: 'vaccine-medicinal-product.json',
- countryCodes: 'country-2-codes.json',
- manufacturers: 'vaccine-mah-manf.json',
-}
-exports.COLORS = {
- white: 'rgb(255, 255, 255)',
- black: 'rgb(0, 0, 0)',
- grey: 'rgb(33, 33, 33)',
- green: 'rgb(27, 94, 32)',
- indigo: 'rgb(26, 35, 126)',
- blue: 'rgb(1, 87, 155)',
- purple: 'rgb(74, 20, 140)',
- teal: 'rgb(0, 77, 64)',
-}
-exports.NAME = 'CovidPass'
-exports.PASS_IDENTIFIER = 'pass.de.marvinsextro.covidpass' // WELL KNOWN
-exports.TEAM_IDENTIFIER = 'X8Q7Q2RLTD' // WELL KNOWN
diff --git a/src/constants.ts b/src/constants.ts
new file mode 100644
index 0000000..87fc425
--- /dev/null
+++ b/src/constants.ts
@@ -0,0 +1,21 @@
+export class Constants {
+ public static NAME = 'CovidPass'
+ public static PASS_IDENTIFIER = 'pass.de.marvinsextro.covidpass'
+ public static TEAM_IDENTIFIER = 'X8Q7Q2RLTD'
+
+ public static COLORS = {
+ white: 'rgb(255, 255, 255)',
+ black: 'rgb(0, 0, 0)',
+ grey: 'rgb(33, 33, 33)',
+ green: 'rgb(27, 94, 32)',
+ indigo: 'rgb(26, 35, 126)',
+ blue: 'rgb(1, 87, 155)',
+ purple: 'rgb(74, 20, 140)',
+ teal: 'rgb(0, 77, 64)',
+ }
+
+ public static img1xBlack: Buffer = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAABU0lEQVR4AWIYaWAUiAExoB06gGggDOMwripJthAgGwBoCGYDBIDIgAFBwDAABoJjhBgEAEChBBBaAA0JyeKAqR0hmnWx3p5o8MHdvfd9Z7SHH8Dr723iCpdoYBOZtoJ9XOALYghxjj0sw1k7OEEAiekVxyjBShto4h6SUg8N5KGqhCHEshdsI3FdiCM3SNwnxA1uKxKXZm3QfJCPQ3RmYVAfW5j2YH+QfkweQ1uDviEmdNHBR8SYddxCDOC2ojeI4RlL+K2Kd8UYcFvRE8TQxyKmVdFLOAbcVnQNMeEUCzCKPQbcVnQEiRilGQNuK9qFRI1SjAG3Fa0iiDh8hgPcQWIKwG1dHsQyD+qKCCGWhCgiVZ7T7yhagw9JyQe37FTGCKI0QhlWq2GiGDNBDU6qYwyJaYw6nFbBABJhgAoyKYc2QoghRBs5ZF4BLTz+aaGAef+nHwt5/579e2c2AAAAAElFTkSuQmCC', 'base64');
+ public static img2xBlack: Buffer = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAACZ0lEQVR4Ae3TA8xcURRF4dq2ozqqbRtxUjeq7Zi127C2bXvSsLZtu/PP6ardjs577765K/li7mQnizGbzWaz2Wx50BXjMRYdkR0JXRq0xVq8g/ziDZaiGVIiYSqLybgPCdMtjEZpP1+oP45CYnQYPZDd7xeKnPMX1L+QAoULmnUhX12wVrwupHjBKnC8tFgEMcRcpIFjrYQYZhkcqQXEUM2h3haIoTZDvRsQQ92AeiGIoUJQTwxnB7ID2YHsQHYgO5B7zmMlztiBfhbCCKQAJUuOYbADIYRe+FP7TB1IfxyiUaYOpD8O0TJzB9IfpyqCZg6kP05ZPIBESL0gJAIBVENONMRJF8cJQr1nkDBdRWb8WBYEHB8HeAb1bkPCNB5E/xlJfRzgNtQ7CQnTWNB/R9IfBzgJ9TZCwnQJGcMYSX8cYCPUmw6JwCqkwt9K5cg4wHSo1x0SoZX/GUJ/HKA71KsAURhJdxygAtRLg1cKI2mP8wpp4EibIQoj6YwDbIZj9YIojKQzDtALjlUESZAYrEN2fK2u4jhJKAJH2wmJ0UOsRQBJECU74XjtIYZoD8dLi1sQj7uFtHClIRCPGwLXyox7EI+6h8xwtR4Qj+oB10uFExCPOYFU8ERVEIR4RBBV4KlGQTxiFDxXWgQgLgsgLTxZQdyBuOQOCsLTVcELiMNeoAqMqBHeQhzyFo1gVC3wCqLsFVrAyGrgMUTJY9SA0RXDMYVxjqEYfFEGzITEyUxkgO9qhEuQKF1CI/i69BiCB5AwPcAQpEfClBUDcR7yF+cxEFmR0NXDVFz5YirqwWaz2Ww2W9R9AE/cBAw+cEeMAAAAAElFTkSuQmCC', 'base64')
+ public static img1xWhite: Buffer = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAQAAABLCVATAAABUUlEQVRIx+XWP0tCURjH8cf+IBLaELSEvoIcWkRHX0AQbm4tbQ7uTi4XhIbAxfdQQ9HqkK05RINIgZtUgoOQ6A3026Sc9D73jzblb73P/XAOnPM8R2RTwyFF7rmjwMGqxC5n3PLNLDY3nLITDDnhih5O+eCSpB9inyLPeKVJgZgbk+QTv3nnWIcaBMmDDo0DQWMdCpj/A3W4oLo+9MqRiAgv60EzJmaeNB2aGr82qPK1wOzxaFRMdag/L3pjW4QMA5WBvg61ja1siYiQoakw0NahulFWI2R8WWagrkPlX4VzypGBsg5lF0prhFQGsjoUXmpn15zz5Mj0CLt1JMv3/bDcO2QC2xdjk/BqttYfrEdEhAgdT6ZDxM8ASDF0ZYak/I6jHBOVmZALMtnyjByZEfmgkzZNd4npkl5laEepGIfBpkJ09UdEnBItWpSIb+xL6gcK3j+JspcAUAAAAABJRU5ErkJggg==', 'base64')
+ public static img2xWhite: Buffer = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAQAAAD/5HvMAAACZklEQVRo3u3YsWsTYRiA8VcNCa3UIoJLoVsXt0KHKEWwYAfN4l4c3Bq6SCGIf0GkdJDSsYOLYCFChVKXLi7B0dKAEAgVSlpqpVBKsJLmcajFXHKXu/e7+3IZ7llzvPmF9458iUhSUtLAx11esMwSz7kdNyXNMzb4w1W/+cATbsSDmeQtP3Grzhvu9XdFL/mGX1/JW19h14r8srnCHivyK+oVBlxRf1bIQ9WKgqwwa47J8B4bvSNtBiphq3UTTg6bPdWDPlsFbelB+1ZB+3pQyyqopQdZLgEloAQU+h2rlPg+KKAWr7kuwjVeDQKoxULbnC9xgxwcEYrxgjo4IqzHCerm3KcZH6ibM8lxdDe1xyejzAPu8JhKGA5NPejUddAPRv69fouyMQdO9aAD10HLbVf8J2k5cKAHVVwHLTmuuSTpOVDRgzZdB9W42UXSc2BTD1r1GPWRlOO6lAEHVvWgec9hpU6EmgPzetBUj3EepMAcmNKD0jR0JAWnYfRjmq2eQztICo7Jz0QRERZ8xraRVBw6n8ugoHEufAZ/uvzHh0cqzgXjYhbbvsN/sUHZF+5sW0xjDhvNmYMy1CPn1MmIeRQiBxUkTIxwFCnn6Or4Yk7KRwrKS9hIsRsZZ9f7W1BDynoeZ3U1Q/wl3EEqRgIqSlSRcZyfzSqHety7SGMchuIcMibRRpYzY85ZZHePgzTLuRHnnFmxE7mehzb3GuTEXkxzouKcMC12Y4KdwJwdJsR+DLMWiLPGsPQrZqn1xNSs3ciepCEKHgfXYwoMSRwxyiJVB6bKIqMSb8ywwh57rDAjSUlJA99fMZuE+02zWzkAAAAASUVORK5CYII=', 'base64')
+}
diff --git a/src/decode.js b/src/decode.js
deleted file mode 100644
index fe17213..0000000
--- a/src/decode.js
+++ /dev/null
@@ -1,65 +0,0 @@
-// Taken from https://github.com/ehn-dcc-development/ehn-sign-verify-javascript-trivial/blob/main/cose_verify.js
-// and https://github.com/ehn-dcc-development/dgc-check-mobile-app/blob/2c2ebf4e9b7650ceef44f7e1fb05a57572830c5b/src/app/cose-js/sign.js
-
-const base45 = require('base45-js')
-const zlib = require('pako')
-const cbor = require('cbor-js')
-
-export function typedArrayToBufferSliced(array) {
- return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset)
-}
-
-export function typedArrayToBuffer(array) {
- var buffer = new ArrayBuffer(array.length)
-
- array.map(function(value, i) {
- buffer[i] = value
- })
- return array.buffer
-}
-
-export function toBuffer(ab) {
- var buf = Buffer.alloc(ab.byteLength)
- var view = new Uint8Array(ab)
-
- for (var i = 0; i < buf.length; ++i) {
- buf[i] = view[i]
- }
- return buf
-}
-
-export function decodeData(data) {
- data = data.toString('ASCII')
-
- if (data.startsWith('HC1')) {
- data = data.substring(3)
- if (data.startsWith(':')) {
- data = data.substring(1)
- } else {
- console.log("Warning: unsafe HC1: header - update to v0.0.4")
- }
- } else {
- console.log("Warning: no HC1: header - update to v0.0.4")
- }
-
- data = base45.decode(data)
-
- if (data[0] == 0x78) {
- data = zlib.inflate(data)
- }
-
- data = cbor.decode(typedArrayToBuffer(data))
-
- if (!Array.isArray(data)) {
- throw new Error('Expecting Array')
- }
-
- if (data.length !== 4) {
- throw new Error('Expecting Array of length 4')
- }
-
- let plaintext = data[2]
- let decoded = cbor.decode(typedArrayToBufferSliced(plaintext))
-
- return decoded
-}
\ No newline at end of file
diff --git a/src/decode.ts b/src/decode.ts
new file mode 100644
index 0000000..b5f20ca
--- /dev/null
+++ b/src/decode.ts
@@ -0,0 +1,56 @@
+// Taken from https://github.com/ehn-dcc-development/ehn-sign-verify-javascript-trivial/blob/main/cose_verify.js
+// and https://github.com/ehn-dcc-development/dgc-check-mobile-app/blob/main/src/app/cose-js/sign.js
+
+import base45 from 'base45';
+import pako from 'pako';
+import cbor from 'cbor-js';
+
+export function typedArrayToBufferSliced(array: Uint8Array): ArrayBuffer {
+ return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);
+}
+
+export function typedArrayToBuffer(array: Uint8Array): ArrayBuffer {
+ var buffer = new ArrayBuffer(array.length);
+
+ array.map(function (value, i) {
+ return buffer[i] = value;
+ })
+
+ return array.buffer;
+}
+
+export function decodeData(data: string): Object {
+
+ if (data.startsWith('HC1')) {
+ data = data.substring(3);
+
+ if (data.startsWith(':')) {
+ data = data.substring(1);
+ } else {
+ console.log("Warning: unsafe HC1: header");
+ }
+ } else {
+ console.log("Warning: no HC1: header");
+ }
+
+ var arrayBuffer: Uint8Array = base45.decode(data);
+
+ if (arrayBuffer[0] == 0x78) {
+ arrayBuffer = pako.inflate(arrayBuffer);
+ }
+
+ var payloadArray: Array = cbor.decode(typedArrayToBuffer(arrayBuffer));
+
+ if (!Array.isArray(payloadArray)) {
+ throw new Error('Expecting Array');
+ }
+
+ if (payloadArray.length !== 4) {
+ throw new Error('Expecting Array of length 4');
+ }
+
+ var plaintext: Uint8Array = payloadArray[2];
+ var decoded: Object = cbor.decode(typedArrayToBufferSliced(plaintext));
+
+ return decoded;
+}
\ No newline at end of file
diff --git a/src/img.js b/src/img.js
deleted file mode 100644
index 6eed8f5..0000000
--- a/src/img.js
+++ /dev/null
@@ -1,6 +0,0 @@
-module.exports = {
- img1xblack: new Buffer.from('iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAABU0lEQVR4AWIYaWAUiAExoB06gGggDOMwripJthAgGwBoCGYDBIDIgAFBwDAABoJjhBgEAEChBBBaAA0JyeKAqR0hmnWx3p5o8MHdvfd9Z7SHH8Dr723iCpdoYBOZtoJ9XOALYghxjj0sw1k7OEEAiekVxyjBShto4h6SUg8N5KGqhCHEshdsI3FdiCM3SNwnxA1uKxKXZm3QfJCPQ3RmYVAfW5j2YH+QfkweQ1uDviEmdNHBR8SYddxCDOC2ojeI4RlL+K2Kd8UYcFvRE8TQxyKmVdFLOAbcVnQNMeEUCzCKPQbcVnQEiRilGQNuK9qFRI1SjAG3Fa0iiDh8hgPcQWIKwG1dHsQyD+qKCCGWhCgiVZ7T7yhagw9JyQe37FTGCKI0QhlWq2GiGDNBDU6qYwyJaYw6nFbBABJhgAoyKYc2QoghRBs5ZF4BLTz+aaGAef+nHwt5/579e2c2AAAAAElFTkSuQmCC', 'base64'),
- img2xblack: new Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAACZ0lEQVR4Ae3TA8xcURRF4dq2ozqqbRtxUjeq7Zi127C2bXvSsLZtu/PP6ardjs577765K/li7mQnizGbzWaz2Wx50BXjMRYdkR0JXRq0xVq8g/ziDZaiGVIiYSqLybgPCdMtjEZpP1+oP45CYnQYPZDd7xeKnPMX1L+QAoULmnUhX12wVrwupHjBKnC8tFgEMcRcpIFjrYQYZhkcqQXEUM2h3haIoTZDvRsQQ92AeiGIoUJQTwxnB7ID2YHsQHYgO5B7zmMlztiBfhbCCKQAJUuOYbADIYRe+FP7TB1IfxyiUaYOpD8O0TJzB9IfpyqCZg6kP05ZPIBESL0gJAIBVENONMRJF8cJQr1nkDBdRWb8WBYEHB8HeAb1bkPCNB5E/xlJfRzgNtQ7CQnTWNB/R9IfBzgJ9TZCwnQJGcMYSX8cYCPUmw6JwCqkwt9K5cg4wHSo1x0SoZX/GUJ/HKA71KsAURhJdxygAtRLg1cKI2mP8wpp4EibIQoj6YwDbIZj9YIojKQzDtALjlUESZAYrEN2fK2u4jhJKAJH2wmJ0UOsRQBJECU74XjtIYZoD8dLi1sQj7uFtHClIRCPGwLXyox7EI+6h8xwtR4Qj+oB10uFExCPOYFU8ERVEIR4RBBV4KlGQTxiFDxXWgQgLgsgLTxZQdyBuOQOCsLTVcELiMNeoAqMqBHeQhzyFo1gVC3wCqLsFVrAyGrgMUTJY9SA0RXDMYVxjqEYfFEGzITEyUxkgO9qhEuQKF1CI/i69BiCB5AwPcAQpEfClBUDcR7yF+cxEFmR0NXDVFz5YirqwWaz2Ww2W9R9AE/cBAw+cEeMAAAAAElFTkSuQmCC', 'base64'),
- img1xwhite: new Buffer.from('iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAQAAABLCVATAAABUUlEQVRIx+XWP0tCURjH8cf+IBLaELSEvoIcWkRHX0AQbm4tbQ7uTi4XhIbAxfdQQ9HqkK05RINIgZtUgoOQ6A3026Sc9D73jzblb73P/XAOnPM8R2RTwyFF7rmjwMGqxC5n3PLNLDY3nLITDDnhih5O+eCSpB9inyLPeKVJgZgbk+QTv3nnWIcaBMmDDo0DQWMdCpj/A3W4oLo+9MqRiAgv60EzJmaeNB2aGr82qPK1wOzxaFRMdag/L3pjW4QMA5WBvg61ja1siYiQoakw0NahulFWI2R8WWagrkPlX4VzypGBsg5lF0prhFQGsjoUXmpn15zz5Mj0CLt1JMv3/bDcO2QC2xdjk/BqttYfrEdEhAgdT6ZDxM8ASDF0ZYak/I6jHBOVmZALMtnyjByZEfmgkzZNd4npkl5laEepGIfBpkJ09UdEnBItWpSIb+xL6gcK3j+JspcAUAAAAABJRU5ErkJggg==', 'base64'),
- img2xwhite: new Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAQAAAD/5HvMAAACZklEQVRo3u3YsWsTYRiA8VcNCa3UIoJLoVsXt0KHKEWwYAfN4l4c3Bq6SCGIf0GkdJDSsYOLYCFChVKXLi7B0dKAEAgVSlpqpVBKsJLmcajFXHKXu/e7+3IZ7llzvPmF9458iUhSUtLAx11esMwSz7kdNyXNMzb4w1W/+cATbsSDmeQtP3Grzhvu9XdFL/mGX1/JW19h14r8srnCHivyK+oVBlxRf1bIQ9WKgqwwa47J8B4bvSNtBiphq3UTTg6bPdWDPlsFbelB+1ZB+3pQyyqopQdZLgEloAQU+h2rlPg+KKAWr7kuwjVeDQKoxULbnC9xgxwcEYrxgjo4IqzHCerm3KcZH6ibM8lxdDe1xyejzAPu8JhKGA5NPejUddAPRv69fouyMQdO9aAD10HLbVf8J2k5cKAHVVwHLTmuuSTpOVDRgzZdB9W42UXSc2BTD1r1GPWRlOO6lAEHVvWgec9hpU6EmgPzetBUj3EepMAcmNKD0jR0JAWnYfRjmq2eQztICo7Jz0QRERZ8xraRVBw6n8ugoHEufAZ/uvzHh0cqzgXjYhbbvsN/sUHZF+5sW0xjDhvNmYMy1CPn1MmIeRQiBxUkTIxwFCnn6Or4Yk7KRwrKS9hIsRsZZ9f7W1BDynoeZ3U1Q/wl3EEqRgIqSlSRcZyfzSqHety7SGMchuIcMibRRpYzY85ZZHePgzTLuRHnnFmxE7mehzb3GuTEXkxzouKcMC12Y4KdwJwdJsR+DLMWiLPGsPQrZqn1xNSs3ciepCEKHgfXYwoMSRwxyiJVB6bKIqMSb8ywwh57rDAjSUlJA99fMZuE+02zWzkAAAAASUVORK5CYII=', 'base64'),
-}
diff --git a/src/pass.js b/src/pass.js
deleted file mode 100644
index df54ecf..0000000
--- a/src/pass.js
+++ /dev/null
@@ -1,185 +0,0 @@
-'use strict';
-
-const constants = require('./constants')
-const utils = require('./utils')
-
-const { Payload } = require('./payload')
-const { toBuffer } = require('do-not-zip')
-const crypto = require('crypto')
-
-exports.createPass = async function(data) {
- function getBufferHash(buffer) {
- // creating hash
- const sha = crypto.createHash('sha1');
- sha.update(buffer);
- return sha.digest('hex');
- }
-
- async function signPassWithRemote(pass, payload) {
- // From pass-js
- // https://github.com/walletpass/pass-js/blob/2b6475749582ca3ea742a91466303cb0eb01a13a/src/pass.ts
-
- // Creating new Zip file
- const zip = []
-
- // Adding required files
- // Create pass.json
- zip.push({ path: 'pass.json', data: Buffer.from(JSON.stringify(pass)) })
- const passHash = getBufferHash(Buffer.from(JSON.stringify(pass)))
-
- zip.push({ path: 'icon.png', data: payload.img1x })
- zip.push({ path: 'icon@2x.png', data: payload.img2x })
- zip.push({ path: 'logo.png', data: payload.img1x })
- zip.push({ path: 'logo@2x.png', data: payload.img2x })
-
- // adding manifest
- // Construct manifest here
- const manifestJson = JSON.stringify(
- zip.reduce(
- (res, { path, data }) => {
- res[path] = getBufferHash(data);
- return res;
- },
- {},
- ),
- );
- zip.push({ path: 'manifest.json', data: manifestJson });
-
- // Load API_BASE_URL form nextjs backend
- const configResponse = await fetch('/api/config')
- const apiBaseUrl = (await configResponse.json()).apiBaseUrl
-
- const response = await fetch(`${apiBaseUrl}/sign`, {
- method: 'POST',
- headers: {
- 'Accept': 'application/octet-stream',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- PassJsonHash: passHash,
- useBlackVersion: !payload.dark
- })
- })
-
- if (response.status !== 200) {
- return undefined
- }
-
- const manifestSignature = await response.arrayBuffer()
-
- zip.push({ path: 'signature', data: Buffer.from(manifestSignature) });
-
- // finished!
- return toBuffer(zip);
- }
-
- let valueSets
-
- try {
- valueSets = await utils.getValueSets()
- } catch {
- return undefined
- }
-
- let payload
-
- try {
- payload = new Payload(data, valueSets)
- } catch (e) {
- return undefined
- }
-
- const qrCode = {
- message: payload.raw,
- format: "PKBarcodeFormatQR",
- messageEncoding: "utf-8"
- }
-
- const pass = {
- passTypeIdentifier: constants.PASS_IDENTIFIER,
- teamIdentifier: constants.TEAM_IDENTIFIER,
- sharingProhibited: false,
- voided: false,
- formatVersion: 1,
- logoText: constants.NAME,
- organizationName: constants.NAME,
- description: constants.NAME,
- labelColor: payload.labelColor,
- foregroundColor: payload.foregroundColor,
- backgroundColor: payload.backgroundColor,
- serialNumber: payload.uvci,
- barcodes: [qrCode],
- barcode: qrCode,
- generic: {
- headerFields: [
- {
- key: "type",
- label: "Certificate Type",
- value: payload.certificateType
- }
- ],
- primaryFields: [
- {
- key: "name",
- label: "Name",
- value: payload.name
- }
- ],
- secondaryFields: [
- {
- key: "dose",
- label: "Dose",
- value: payload.dose
- },
- {
- key: "dov",
- label: "Date of Vaccination",
- value: payload.dateOfVaccination,
- textAlignment: "PKTextAlignmentRight"
- }
- ],
- auxiliaryFields: [
- {
- key: "vaccine",
- label: "Vaccine",
- value: payload.vaccineName
- },
- {
- key: "dob",
- label: "Date of Birth", value:
- payload.dateOfBirth,
- textAlignment: "PKTextAlignmentRight"
- }
- ],
- backFields: [
- {
- key: "uvci",
- label: "Unique Certificate Identifier (UVCI)",
- value: payload.uvci
- },
- {
- key: "issuer",
- label: "Certificate Issuer",
- value: payload.certificateIssuer
- },
- {
- key: "country",
- label: "Country of Vaccination",
- value: payload.countryOfVaccination
- },
- {
- key: "manufacturer",
- label: "Manufacturer",
- value: payload.manufacturer
- },
- {
- key: "disclaimer",
- label: "Disclaimer",
- value: "This certificate is only valid in combination with the ID card of the certificate holder and expires one year + 14 days after the last dose. The validity of this certificate was not checked by CovidPass."
- }
- ]
- }
- };
-
- return await signPassWithRemote(pass, payload)
-}
diff --git a/src/pass.ts b/src/pass.ts
new file mode 100644
index 0000000..5dc5847
--- /dev/null
+++ b/src/pass.ts
@@ -0,0 +1,229 @@
+import {Constants} from "./constants";
+import {Payload, PayloadBody} from "./payload";
+import {ValueSets} from "./value_sets";
+import {toBuffer as createZip} from 'do-not-zip';
+import {v4 as uuid4} from 'uuid';
+
+const crypto = require('crypto')
+
+enum QrFormat {
+ PKBarcodeFormatQR = 'PKBarcodeFormatQR',
+}
+
+enum Encoding {
+ utf8 = "utf-8",
+}
+
+interface QrCode {
+ message: string;
+ format: QrFormat;
+ messageEncoding: Encoding;
+}
+
+interface Field {
+ key: string;
+ label: string;
+ value: string;
+ textAlignment?: string;
+}
+
+interface PassStructureDictionary {
+ headerFields: Array;
+ primaryFields: Array;
+ secondaryFields: Array;
+ auxiliaryFields: Array;
+ backFields: Array;
+}
+
+interface SignData {
+ PassJsonHash: string;
+ useBlackVersion: boolean;
+}
+
+export class PassData {
+ passTypeIdentifier: string = Constants.PASS_IDENTIFIER;
+ teamIdentifier: string = Constants.TEAM_IDENTIFIER;
+ sharingProhibited: boolean = false;
+ voided: boolean = false;
+ formatVersion: number = 1;
+ logoText: string = Constants.NAME;
+ organizationName: string = Constants.NAME;
+ description: string = Constants.NAME;
+ labelColor: string;
+ foregroundColor: string;
+ backgroundColor: string;
+ serialNumber: string;
+ barcodes: Array;
+ barcode: QrCode;
+ generic: PassStructureDictionary;
+
+ // Generates a sha1 hash from a given buffer
+ private static getBufferHash(buffer: Buffer | string): string {
+ const sha = crypto.createHash('sha1');
+ sha.update(buffer);
+ return sha.digest('hex');
+ }
+
+ private static async signWithRemote(signData: SignData): Promise {
+ // Load API_BASE_URL form nextjs backend
+ const configResponse = await fetch('/api/config')
+ const apiBaseUrl = (await configResponse.json()).apiBaseUrl
+
+ const response = await fetch(`${apiBaseUrl}/sign`, {
+ method: 'POST',
+ headers: {
+ 'Accept': 'application/octet-stream',
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(signData)
+ })
+
+ if (response.status !== 200) {
+ throw Error("Error while singing Pass on server")
+ }
+
+ return await response.arrayBuffer()
+ }
+
+ static async generatePass(payloadBody: PayloadBody): Promise {
+ // Get the Value Sets from GitHub
+ const valueSets: ValueSets = await ValueSets.loadValueSets();
+
+ // Create Payload
+ const payload: Payload = new Payload(payloadBody, valueSets);
+
+ // Create QR Code Object
+ const qrCode: QrCode = {
+ message: payload.rawData,
+ format: QrFormat.PKBarcodeFormatQR,
+ messageEncoding: Encoding.utf8,
+ }
+
+ // Create pass data
+ const pass: PassData = new PassData(payload, qrCode);
+
+ // Create new zip
+ const zip = [] as { path: string; data: Buffer | string }[];
+
+ // Adding required fields
+
+ // Create pass.json
+ const passJson = JSON.stringify(pass);
+
+ // Add pass.json to zip
+ zip.push({path: 'pass.json', data: Buffer.from(passJson)});
+
+ // Add Images to zip
+ zip.push({path: 'icon.png', data: payload.img1x})
+ zip.push({path: 'icon@2x.png', data: payload.img2x})
+ zip.push({path: 'logo.png', data: payload.img1x})
+ zip.push({path: 'logo@2x.png', data: payload.img2x})
+
+ // Adding manifest
+ // Construct manifest
+ const manifestJson = JSON.stringify(
+ zip.reduce(
+ (res, {path, data}) => {
+ res[path] = PassData.getBufferHash(data);
+ return res;
+ },
+ {},
+ ),
+ );
+
+ // Add Manifest JSON to zip
+ zip.push({path: 'manifest.json', data: Buffer.from(manifestJson)});
+
+ // Create pass hash
+ const passHash = PassData.getBufferHash(Buffer.from(passJson));
+
+ // Sign hash with server
+ const manifestSignature = await PassData.signWithRemote({
+ PassJsonHash: passHash,
+ useBlackVersion: !payload.dark,
+ });
+
+ // Add signature to zip
+ zip.push({path: 'signature', data: Buffer.from(manifestSignature)});
+
+ return createZip(zip);
+ }
+
+ private constructor(payload: Payload, qrCode: QrCode) {
+ this.labelColor = payload.labelColor;
+ this.foregroundColor = payload.foregroundColor;
+ this.backgroundColor = payload.backgroundColor;
+ this.serialNumber = uuid4(); // Generate random UUID v4
+ this.barcodes = [qrCode];
+ this.barcode = qrCode;
+ this.generic = {
+ headerFields: [
+ {
+ key: "type",
+ label: "Certificate Type",
+ value: payload.certificateType
+ }
+ ],
+ primaryFields: [
+ {
+ key: "name",
+ label: "Name",
+ value: payload.name
+ }
+ ],
+ secondaryFields: [
+ {
+ key: "dose",
+ label: "Dose",
+ value: payload.dose
+ },
+ {
+ key: "dov",
+ label: "Date of Vaccination",
+ value: payload.dateOfVaccination,
+ textAlignment: "PKTextAlignmentRight"
+ }
+ ],
+ auxiliaryFields: [
+ {
+ key: "vaccine",
+ label: "Vaccine",
+ value: payload.vaccineName
+ },
+ {
+ key: "dob",
+ label: "Date of Birth",
+ value: payload.dateOfBirth,
+ textAlignment: "PKTextAlignmentRight"
+ }
+ ],
+ backFields: [
+ {
+ key: "uvci",
+ label: "Unique Certificate Identifier (UVCI)",
+ value: payload.uvci
+ },
+ {
+ key: "issuer",
+ label: "Certificate Issuer",
+ value: payload.certificateIssuer
+ },
+ {
+ key: "country",
+ label: "Country of Vaccination",
+ value: payload.countryOfVaccination
+ },
+ {
+ key: "manufacturer",
+ label: "Manufacturer",
+ value: payload.manufacturer
+ },
+ {
+ key: "disclaimer",
+ label: "Disclaimer",
+ value: "This certificate is only valid in combination with the ID card of the certificate holder and expires one year + 14 days after the last dose. The validity of this certificate was not checked by CovidPass."
+ }
+ ]
+ };
+ }
+}
diff --git a/src/payload.js b/src/payload.js
deleted file mode 100644
index 6b1921d..0000000
--- a/src/payload.js
+++ /dev/null
@@ -1,100 +0,0 @@
-const img = require('./img')
-const consts = require('./constants')
-
-exports.Payload = class {
- constructor(body, valueSets) {
-
- const color = body["color"]
- const rawData = body["raw"]
- const decoded = body["decoded"]
-
- if (!(color in consts.COLORS)) {
- throw new Error('Invalid color')
- }
-
- const dark = (color !== 'white')
-
- let backgroundColor = dark ? consts.COLORS[color] : consts.COLORS.white
- let labelColor = dark ? consts.COLORS.white : consts.COLORS.grey
- let foregroundColor = dark ? consts.COLORS.white : consts.COLORS.black
- let img1x = dark ? img.img1xwhite : img.img1xblack
- let img2x = dark ? img.img2xwhite : img.img2xblack
-
- if (typeof rawData === 'undefined') {
- throw new Error('No raw payload')
- }
-
- if (typeof decoded === 'undefined') {
- throw new Error('No decoded payload')
- }
-
- const v = decoded["-260"]["1"]["v"][0]
- if (typeof v === 'undefined') {
- throw new Error('Failed to read vaccination information')
- }
-
- const nam = decoded["-260"]["1"]["nam"]
- if (typeof nam === 'undefined') {
- throw new Error('Failed to read name')
- }
-
- const dob = decoded["-260"]["1"]["dob"]
- if (typeof dob === 'undefined') {
- throw new Error('Failed to read date of birth')
- }
-
- const firstName = nam["gn"]
- const lastName = nam["fn"]
- const name = lastName + ', ' + firstName
-
- const doseIndex = v["dn"]
- const totalDoses = v["sd"]
- const dose = doseIndex + '/' + totalDoses
-
- const dateOfVaccination = v["dt"]
- const uvci = v["ci"]
- const certificateIssuer = v["is"]
-
- const medicalProducts = valueSets.medicalProducts["valueSetValues"]
- const countryCodes = valueSets.countryCodes["valueSetValues"]
- const manufacturers = valueSets.manufacturers["valueSetValues"]
-
- const medicalProductKey = v["mp"]
- if(!(medicalProductKey in medicalProducts)) {
- throw new Error('Invalid medical product key')
- }
-
- const countryCode = v["co"]
- if(!(countryCode in countryCodes)) {
- throw new Error('Invalid country code')
- }
-
- const manufacturerKey = v["ma"]
- if(!(manufacturerKey in manufacturers)) {
- throw new Error('Invalid manufacturer')
- }
-
- this.certificateType = 'Vaccination'
-
- this.backgroundColor = backgroundColor
- this.labelColor = labelColor
- this.foregroundColor = foregroundColor
- this.img1x = img1x
- this.img2x = img2x
-
- this.raw = rawData
- this.dark = dark
-
- this.name = name
- this.dose = dose
- this.dateOfVaccination = dateOfVaccination
- this.dateOfBirth = dob
- this.uvci = uvci
- this.certificateIssuer = certificateIssuer
- this.medicalProductKey = medicalProductKey
-
- this.countryOfVaccination = countryCodes[countryCode].display
- this.vaccineName = medicalProducts[medicalProductKey].display
- this.manufacturer = manufacturers[manufacturerKey].display
- }
-}
diff --git a/src/payload.ts b/src/payload.ts
new file mode 100644
index 0000000..ba75469
--- /dev/null
+++ b/src/payload.ts
@@ -0,0 +1,101 @@
+import {ValueSets} from "./value_sets";
+import {Constants} from "./constants";
+
+export interface PayloadBody {
+ color: string;
+ rawData: string;
+ decodedData: Uint8Array;
+}
+
+export class Payload {
+ certificateType: string = 'Vaccination';
+
+ rawData: string;
+
+ backgroundColor: string;
+ labelColor: string;
+ foregroundColor: string;
+ img1x: Buffer;
+ img2x: Buffer;
+ dark: boolean;
+
+ name: string;
+ dose: string;
+ dateOfVaccination: string;
+ dateOfBirth: string;
+ uvci: string;
+ certificateIssuer: string;
+ medicalProductKey: string;
+
+ countryOfVaccination: string;
+ vaccineName: string;
+ manufacturer: string;
+
+ constructor(body: PayloadBody, valueSets: ValueSets) {
+
+ let colors = Constants.COLORS;
+
+ if (!(body.color in colors)) {
+ throw new Error('Invalid color');
+ }
+
+ const dark = body.color != 'white'
+
+
+ // Get Vaccine, Name and Date of Birth information
+ const vaccinationInformation = body.decodedData['-260']['1']['v'][0];
+ const nameInformation = body.decodedData['-260']['1']['nam'];
+ const dateOfBirthInformation = body.decodedData['-260']['1']['dob'];
+
+ if (vaccinationInformation == undefined) {
+ throw new Error('Failed to read vaccination information');
+ }
+
+ if (nameInformation == undefined) {
+ throw new Error('Failed to read name');
+ }
+
+ if (dateOfBirthInformation == undefined) {
+ throw new Error('Failed to read date of birth');
+ }
+
+ // Get Medical, country and manufacturer information
+ const medialProductKey = vaccinationInformation['mp'];
+ const countryCode = vaccinationInformation['co'];
+ const manufacturerKey = vaccinationInformation['ma'];
+
+ if (!(medialProductKey in valueSets.medicalProducts)) {
+ throw new Error('Invalid medical product key');
+ }
+ if (!(countryCode in valueSets.countryCodes)) {
+ throw new Error('Invalid country code')
+ }
+ if (!(manufacturerKey in valueSets.manufacturers)) {
+ throw new Error('Invalid manufacturer')
+ }
+
+
+ // Set Values
+ this.rawData = body.rawData;
+
+ this.backgroundColor = dark ? colors[body.color] : colors.white
+ this.labelColor = dark ? colors.white : colors.grey
+ this.foregroundColor = dark ? colors.white : colors.black
+ this.img1x = dark ? Constants.img1xWhite : Constants.img1xBlack
+ this.img2x = dark ? Constants.img2xWhite : Constants.img2xBlack
+ this.dark = dark;
+
+ this.name = `${nameInformation['fn']}, ${nameInformation['gn']}`;
+ this.dose = `${vaccinationInformation['dn']}/${vaccinationInformation['sd']}`;
+ this.dateOfVaccination = vaccinationInformation['dt'];
+ this.dateOfBirth = dateOfBirthInformation;
+ this.uvci = vaccinationInformation['ci'];
+ this.certificateIssuer = vaccinationInformation['is'];
+ this.medicalProductKey = medialProductKey; // TODO is this needed?
+
+ this.countryOfVaccination = valueSets.countryCodes[countryCode].display;
+ this.vaccineName = valueSets.medicalProducts[medialProductKey].display;
+ this.manufacturer = valueSets.manufacturers[manufacturerKey].display;
+ }
+
+}
\ No newline at end of file
diff --git a/src/process.js b/src/process.js
deleted file mode 100644
index bc640da..0000000
--- a/src/process.js
+++ /dev/null
@@ -1,57 +0,0 @@
-import {PNG} from 'pngjs'
-import * as PdfJS from 'pdfjs-dist'
-
-PdfJS.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${PdfJS.version}/pdf.worker.js`
-
-// Processes a pdf file and returns it as ImageData
-export async function processPdf(file) {
- // Array to store ImageData information
- const typedArray = new Uint8Array(file)
-
- // PDF scale, increase to read smaller QR Codes
- const pdfScale = 2;
-
- // Get the canvas and context to render PDF
- const canvas = document.getElementById('canvas')
- const ctx = canvas.getContext('2d')
-
- let loadingTask = PdfJS.getDocument(typedArray)
-
- await loadingTask.promise.then(async function (pdfDocument) {
- // Load last PDF page
- const pageNumber = pdfDocument.numPages;
-
- const pdfPage = await pdfDocument.getPage(pageNumber)
- const viewport = pdfPage.getViewport({scale: pdfScale})
-
- // Set correct canvas width / height
- canvas.width = viewport.width
- canvas.height = viewport.height
-
- // render PDF
- const renderTask = pdfPage.render({
- canvasContext: ctx,
- viewport,
- })
-
- return await renderTask.promise
- })
-
- // Return PDF Image Data
- return ctx.getImageData(0, 0, canvas.width, canvas.height)
-}
-
-// Processes a PNG File and returns it as ImageData
-export async function processPng(file) {
- return new Promise(async (resolve, reject) => {
- let png = new PNG({filterType: 4})
-
- png.parse(file, (error, data) => {
- if (error) {
- reject()
- }
-
- resolve(data)
- })
- })
-}
\ No newline at end of file
diff --git a/src/process.ts b/src/process.ts
new file mode 100644
index 0000000..ae71c71
--- /dev/null
+++ b/src/process.ts
@@ -0,0 +1,128 @@
+import {PayloadBody} from "./payload";
+import {PNG} from 'pngjs'
+import * as PdfJS from 'pdfjs-dist'
+import jsQR, {QRCode} from "jsqr";
+import {decodeData} from "./decode";
+import {Result} from "@zxing/library";
+
+PdfJS.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${PdfJS.version}/pdf.worker.js`
+
+export async function getPayloadBodyFromFile(file: File, color: string): Promise {
+ // Read file
+ const fileBuffer = await file.arrayBuffer();
+
+ let imageData: ImageData;
+
+ switch (file.type) {
+ case 'application/pdf':
+ console.log('pdf')
+ imageData = await getImageDataFromPdf(fileBuffer)
+ break
+ case 'image/png':
+ console.log('png')
+ imageData = await getImageDataFromPng(fileBuffer)
+ break
+ default:
+ throw Error('Invalid File Type')
+ }
+
+ let code: QRCode;
+
+ try {
+ code = jsQR(imageData.data, imageData.width, imageData.height, {
+ inversionAttempts: "dontInvert",
+ });
+ } catch (e) {
+ throw Error("Could not decode QR Code from File");
+ }
+
+ if (code == undefined) {
+ throw Error("Could not find QR Code in provided File")
+ }
+
+ // Get raw data
+ let rawData = code.data;
+
+ // Decode Data
+ let decodedData;
+
+ try {
+ decodedData = decodeData(rawData);
+ } catch (e) {
+ throw Error("Invalid QR Code")
+ }
+
+ return {
+ rawData: rawData,
+ decodedData: decodedData,
+ color: color,
+ }
+}
+
+export async function getPayloadBodyFromQR(qrCodeResult: Result, color: string): Promise {
+
+ // Get raw data
+ let rawData = qrCodeResult.getText();
+
+ // Decode Data
+ let decodedData;
+
+ try {
+ decodedData = decodeData(rawData);
+ } catch (e) {
+ throw Error("Invalid QR Code")
+ }
+
+ return {
+ rawData: rawData,
+ decodedData: decodedData,
+ color: color,
+ }
+}
+
+async function getImageDataFromPng(fileBuffer: ArrayBuffer): Promise {
+ return new Promise(async (resolve, reject) => {
+ let png = new PNG({filterType: 4})
+
+ png.parse(fileBuffer, (error, data) => {
+ if (error) {
+ reject();
+ }
+
+ resolve(data);
+ })
+ })
+}
+
+async function getImageDataFromPdf(fileBuffer: ArrayBuffer): Promise {
+ const typedArray = new Uint8Array(fileBuffer);
+ const pdfScale = 2;
+
+ const canvas = document.getElementById('canvas');
+ const canvasContext = canvas.getContext('2d');
+
+ let loadingTask = PdfJS.getDocument(typedArray);
+
+ await loadingTask.promise.then(async function (pdfDocument) {
+ // Load last PDF page
+ const pageNumber = pdfDocument.numPages;
+
+ const pdfPage = await pdfDocument.getPage(pageNumber)
+ const viewport = pdfPage.getViewport({scale: pdfScale})
+
+ // Set correct canvas width / height
+ canvas.width = viewport.width
+ canvas.height = viewport.height
+
+ // render PDF
+ const renderTask = pdfPage.render({
+ canvasContext: canvasContext,
+ viewport,
+ })
+
+ return await renderTask.promise
+ });
+
+ // Return PDF Image Data
+ return canvasContext.getImageData(0, 0, canvas.width, canvas.height)
+}
\ No newline at end of file
diff --git a/src/utils.js b/src/utils.js
deleted file mode 100644
index a08e30f..0000000
--- a/src/utils.js
+++ /dev/null
@@ -1,16 +0,0 @@
-const { VALUE_TYPES, VALUE_SET_BASE_URL } = require("./constants")
-const fetch = require("node-fetch")
-
-exports.getValueSets = async function() {
- async function getJSONFromURL(url) {
- return await (await fetch(url)).json()
- }
-
- let valueSets = {}
-
- for (const [key, value] of Object.entries(VALUE_TYPES)) {
- valueSets[key] = await getJSONFromURL(VALUE_SET_BASE_URL + value)
- }
-
- return valueSets
-}
diff --git a/src/value_sets.ts b/src/value_sets.ts
new file mode 100644
index 0000000..d1a3ac0
--- /dev/null
+++ b/src/value_sets.ts
@@ -0,0 +1,34 @@
+interface ValueTypes {
+ medicalProducts: string;
+ countryCodes: string;
+ manufacturers: string;
+}
+
+export class ValueSets {
+ private static VALUE_SET_BASE_URL: string = 'https://raw.githubusercontent.com/ehn-dcc-development/ehn-dcc-valuesets/main/';
+ private static VALUE_TYPES: ValueTypes = {
+ medicalProducts: 'vaccine-medicinal-product.json',
+ countryCodes: 'country-2-codes.json',
+ manufacturers: 'vaccine-mah-manf.json',
+ }
+
+ medicalProducts: object;
+ countryCodes: object;
+ manufacturers: object;
+
+
+ private constructor(medicalProducts: object, countryCodes: object, manufacturers: object) {
+ this.medicalProducts = medicalProducts;
+ this.countryCodes = countryCodes;
+ this.manufacturers = manufacturers;
+ }
+
+ public static async loadValueSets(): Promise {
+ // Load all Value Sets from GitHub
+ let medicalProducts = await (await fetch(ValueSets.VALUE_SET_BASE_URL + ValueSets.VALUE_TYPES.medicalProducts)).json();
+ let countryCodes = await (await fetch(ValueSets.VALUE_SET_BASE_URL + ValueSets.VALUE_TYPES.countryCodes)).json();
+ let manufacturers = await (await fetch(ValueSets.VALUE_SET_BASE_URL + ValueSets.VALUE_TYPES.manufacturers)).json();
+
+ return new ValueSets(medicalProducts['valueSetValues'], countryCodes['valueSetValues'], manufacturers['valueSetValues']);
+ }
+}
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..35d51ea
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,29 @@
+{
+ "compilerOptions": {
+ "target": "es5",
+ "lib": [
+ "dom",
+ "dom.iterable",
+ "esnext"
+ ],
+ "allowJs": true,
+ "skipLibCheck": true,
+ "strict": false,
+ "forceConsistentCasingInFileNames": true,
+ "noEmit": true,
+ "esModuleInterop": true,
+ "module": "esnext",
+ "moduleResolution": "node",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "jsx": "preserve"
+ },
+ "include": [
+ "next-env.d.ts",
+ "**/*.ts",
+ "**/*.tsx"
+ ],
+ "exclude": [
+ "node_modules"
+ ]
+}