Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HJunyuan committed Oct 5, 2021
1 parent b8dfda6 commit dd89a6f
Show file tree
Hide file tree
Showing 37 changed files with 11,242 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: { "@typescript-eslint/explicit-module-boundary-types": "off" },
};
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
38 changes: 38 additions & 0 deletions .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI - Master

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [master]

jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14.17"
- run: npm ci
- run: npm run lint
- run: npm run type-check
- run: npm run test
release:
name: Build and Release
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: "14.17"
- run: npm ci
- run: npm run build
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/ci-pull-request-open.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI - Pull Request Open

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: ["!master"]
pull_request:
branches: [master]
types:
- labeled
- unlabeled
- synchronize
- opened
- edited
- ready_for_review
- reopened
- unlocked

jobs:
test:
runs-on: ubuntu-latest
name: Tests
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14.17"
- run: npm install
- run: npm run lint
- run: npm run type-check
- run: npm run test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
dist
secrets
node_modules
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.17
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "printWidth": 120 }
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
# Google Pay COVID Cards

A helper library for Google Pay COVID Cards.

## Getting Started

```bash
npm i @notarise-gov-sg/gpay-covid-cards
```

### 1. Import

```javascript
import GPay from "@notarise-gov-sg/gpay-covid-cards";
const gpay = GPay(private_key);
```

### 2. Prepare records

```javascript
// Patient Details
const patientDetails: PatientDetails = {
dateOfBirth: "1990-01-15",
identityAssuranceLevel: "IAL1.4",
patientId: "E7831177G",
patientIdLabel: "Passport Number",
patientName: "Tan Chen Chen",
};

// Basic Details
const basicDetails: BasicDetails = {
iss: "[email protected]",
uuid: "some_uuid",
issuerId: "issuer_id",
title: "COVID-19 Test Result Card",
qr: "https://www.verify.gov.sg/",
expiration: "2021-10-01",
patientDetails: gpay.genPatientDetails(patientDetails),
};

// Notarise PDT (Testing Record)
const testingRecord = gpay.genTestingRecord({
administrationDateTime: "27 September 2020, 2:15 pm SGT",
contactInfo: "MacRitchie Hospital, Thomson Road, Singapore 123000",
provider: "MacRitchie Medical Clinic",
reportDateTime: "28 September 2020, 2:15 pm SGT",
testCode: "94531-1",
testDescription: "SARS-CoV-2 (COVID-19) RNA panel - Respiratory specimen by NAA with probe detection",
testResultCode: "260385009",
testResultDescription: "Negative",
specimen: "Nasopharyngeal swab",
});

// Notarise Vaccination (Vaccination Record)
const vaccinationRecord = gpay.genVaccinationRecord({
code: "1234",
contactInfo: "123 Forever Rd. 12345 Infinity, CA",
description: "Q4NTL6",
doseDateTime: "2014-01-12",
doseLabel: "1st Dose",
lotNumber: "92681",
manufacturer: "Moderna",
provider: "Healthgenics",
});
```

### 3. Generate and sign the JWT payload

```javascript
const payload = gpay.genGPayCovidCard(basicDetails, [testingRecord]);
const signedPayload = gpay.signPayload(payload);
```

### 4. Get the full URL

```javascript
const fullUrl = gpay.generateFullUrl(signedPayload);
```
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }], "@babel/preset-typescript"],
};
1 change: 1 addition & 0 deletions fixtures/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TEST_IAT = 1633413015;
62 changes: 62 additions & 0 deletions fixtures/google-examples/test-multi-record.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"iss": "[email protected]",
"aud": "google",
"iat": 1620349587,
"typ": "savetogooglepay",
"origins": [],
"payload": {
"covidCardObjects": [
{
"id": "your_issuer_id.unique_object_id",
"issuerId": "your_issuer_id",
"barcode": {
"alternateText": "some_barcode_value",
"type": "qrCode",
"value": "some_barcode_value"
},
"cardColorHex": "#223CFF",
"expiration": "2021-09-09",
"logo": {
"sourceUri": {
"description": "Google Inc",
"uri": "https://www.gstatic.com/images/icons/material/system_gm/2x/healing_black_48dp.png"
}
},
"patientDetails": {
"dateOfBirth": "1881-05-19",
"identityAssuranceLevel": "IAL1.4",
"patientId": "123-456-ABC",
"patientIdLabel": "National ID",
"patientName": "John Doe"
},
"testingDetails": {
"testingRecord": [
{
"administrationDateTime": "2014-03-14 - (1)",
"contactInfo": "123 Forever Rd. 12345 Infinity, CA - (1)",
"provider": "Tests-R-Us - (1)",
"reportDateTime": "2014-01-15 - (1)",
"testCode": "LOINC 28496 - (1)",
"testDescription": "NcAid - (1)",
"testResultCode": "4321 - (1)",
"testResultDescription": "Negative - (1)",
"specimen": "CNT (Combined Nasal and Throat Swabs)"
},
{
"administrationDateTime": "2014-03-14 - (2)",
"contactInfo": "123 Forever Rd. 12345 Infinity, CA - (2)",
"provider": "Tests-R-Us - (2)",
"reportDateTime": "2014-01-15 - (2)",
"testCode": "LOINC 28496 - (2)",
"testDescription": "NcAid - (2)",
"testResultCode": "4321 - (2)",
"testResultDescription": "Negative - (2)",
"specimen": "CNT (Combined Nasal and Throat Swabs)"
}
]
},
"title": "COVID-19 Test Result Card"
}
]
}
}
51 changes: 51 additions & 0 deletions fixtures/google-examples/test-single-record.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"aud": "google",
"iat": 1620349066,
"iss": "[email protected]",
"typ": "savetogooglepay",
"origins": [],
"payload": {
"covidCardObjects": [
{
"id": "your_issuer_id.unique_object_id",
"issuerId": "your_issuer_id",
"cardColorHex": "#223CFF",
"title": "COVID-19 Test Result Card",
"barcode": {
"alternateText": "some_barcode_value",
"type": "qrCode",
"value": "some_barcode_value"
},
"expiration": "2021-09-09",
"logo": {
"sourceUri": {
"description": "Google Inc",
"uri": "https://www.gstatic.com/images/icons/material/system_gm/2x/healing_black_48dp.png"
}
},
"patientDetails": {
"dateOfBirth": "1881-05-19",
"identityAssuranceLevel": "IAL1.4",
"patientId": "123-456-ABC",
"patientIdLabel": "National ID",
"patientName": "John Doe"
},
"testingDetails": {
"testingRecord": [
{
"administrationDateTime": "2014-03-14",
"contactInfo": "123 Forever Rd., Infinity, CA 12345",
"provider": "Tests-R-Us",
"reportDateTime": "2014-01-15",
"testCode": "LOINC 28496",
"testDescription": "NcAid",
"testResultCode": "4321",
"testResultDescription": "Negative",
"specimen": "CNT (Combined Nasal and Throat Swabs)"
}
]
}
}
]
}
}
60 changes: 60 additions & 0 deletions fixtures/google-examples/vaccination-multi-record.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"iss": "[email protected]",
"aud": "google",
"iat": 1620349587,
"typ": "savetogooglepay",
"origins": [],
"payload": {
"covidCardObjects": [
{
"id": "your_issuer_id.unique_object_id",
"issuerId": "your_issuer_id",
"barcode": {
"alternateText": "some_barcode_value",
"type": "qrCode",
"value": "some_barcode_value"
},
"cardColorHex": "#223CFF",
"expiration": "2021-09-09",
"logo": {
"sourceUri": {
"description": "Google Inc",
"uri": "https://www.gstatic.com/images/icons/material/system_gm/2x/healing_black_48dp.png"
}
},
"patientDetails": {
"dateOfBirth": "1881-05-19",
"identityAssuranceLevel": "IAL1.4",
"patientId": "123-456-ABC",
"patientIdLabel": "National ID",
"patientName": "John Doe"
},
"title": "COVID-19 Test Vaccination Card",
"vaccinationDetails": {
"vaccinationRecord": [
{
"code": "1234",
"contactInfo": "123 Forever Rd. 12345 Infinity, CA",
"description": "Q4NTL6",
"doseDateTime": "2014-01-12",
"doseLabel": "1st Dose",
"lotNumber": "92681",
"manufacturer": "Moderna",
"provider": "Healthgenics"
},
{
"code": "1234",
"contactInfo": "123 Forever Rd. 12345 Infinity, CA",
"description": "Q4NTL6",
"doseDateTime": "2014-01-12",
"doseLabel": "1st Dose",
"lotNumber": "92681",
"manufacturer": "Moderna",
"provider": "Healthgenics"
}
]
}
}
]
}
}
Loading

0 comments on commit dd89a6f

Please sign in to comment.