@opengovsg/mockpass 4.1.0 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +46 -0
- package/.husky/install.mjs +6 -0
- package/.husky/pre-commit +0 -3
- package/.husky/pre-push +0 -3
- package/Dockerfile +2 -0
- package/README.md +12 -3
- package/eslint.config.mjs +24 -0
- package/lib/express/myinfo/consent.js +1 -7
- package/lib/express/sgid.js +6 -0
- package/package.json +13 -10
- package/static/myinfo/v3.json +26 -17
- package/.github/workflows/npmpublish.yml +0 -22
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [created]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish-npm:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-node@v3
|
|
13
|
+
with:
|
|
14
|
+
node-version: 'lts/*'
|
|
15
|
+
cache: 'npm'
|
|
16
|
+
cache-dependency-path: '**/package-lock.json'
|
|
17
|
+
registry-url: https://registry.npmjs.org/
|
|
18
|
+
- run: npm ci
|
|
19
|
+
- run: npm publish --access public
|
|
20
|
+
env:
|
|
21
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
22
|
+
publish-docker:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v3
|
|
27
|
+
with:
|
|
28
|
+
node-version: 'lts/*'
|
|
29
|
+
cache: 'npm'
|
|
30
|
+
cache-dependency-path: '**/package-lock.json'
|
|
31
|
+
registry-url: https://registry.npmjs.org/
|
|
32
|
+
- name: Set up Docker Buildx
|
|
33
|
+
uses: docker/setup-buildx-action@v3
|
|
34
|
+
- name: Login to Docker Hub
|
|
35
|
+
uses: docker/login-action@v3
|
|
36
|
+
with:
|
|
37
|
+
username: ${{ secrets.DOCKER_USER }}
|
|
38
|
+
password: ${{ secrets.DOCKER_PASS }}
|
|
39
|
+
- run: echo TAGNAME=`echo ${{ github.ref_name }} | sed 's/v//'` >> ${GITHUB_ENV}
|
|
40
|
+
- name: Build and push
|
|
41
|
+
uses: docker/build-push-action@v6
|
|
42
|
+
with:
|
|
43
|
+
push: true
|
|
44
|
+
tags: |
|
|
45
|
+
opengovsg/mockpass:latest
|
|
46
|
+
opengovsg/mockpass:${{ env.TAGNAME }}
|
package/.husky/pre-commit
CHANGED
package/.husky/pre-push
CHANGED
package/Dockerfile
CHANGED
package/README.md
CHANGED
|
@@ -84,13 +84,13 @@ Configure your application (or MockPass) with certificates/keys:
|
|
|
84
84
|
MockPass accepts any value for `client_id`, `redirect_uri` and `sp_esvcId`.
|
|
85
85
|
The `client_secret` value will be checked if configured, see below.
|
|
86
86
|
|
|
87
|
-
Only the profiles (NRICs) that have entries in Mockpass'
|
|
87
|
+
Only the profiles (NRICs) that have entries in Mockpass' personas dataset will
|
|
88
88
|
succeed, using other NRICs will result in an error. See the list of personas in
|
|
89
89
|
[static/myinfo/v3.json](static/myinfo/v3.json).
|
|
90
90
|
|
|
91
91
|
| Configuration item | Explanation |
|
|
92
92
|
|---|---|
|
|
93
|
-
| Client certificate | **Overview:** When client makes any request, what certificate is used to verify the request signature, and what certificate is used to encrypt the data payload. <br> **Default:** static certificate/key `static/certs/(server.crt
|
|
93
|
+
| Client certificate | **Overview:** When client makes any request, what certificate is used to verify the request signature, and what certificate is used to encrypt the data payload. <br> **Default:** static certificate/key `static/certs/(server.crt\|key.pub)` are used. <br> **How to configure:** Set the env var `SERVICE_PROVIDER_PUB_KEY` to the path to a public key PEM file, and `SERVICE_PROVIDER_CERT_PATH` to the path to a certificate PEM file. (A certificate PEM file can also be provided to `SERVICE_PROVIDER_PUB_KEY`, despite the env var name.) |
|
|
94
94
|
| Client secret | **Overview:** When client makes a Token request, whether MockPass verifies the request signature. <br> **Default:** Disabled. <br> **How to configure:** Enable for all requests by setting the env var `SERVICE_PROVIDER_MYINFO_SECRET` to some non-blank string. Provide this value to your application as well. |
|
|
95
95
|
| Payload encryption | **Overview:** When client makes a Person or Person-Basic request, whether MockPass encrypts the data payload. When client makes a Person request, whether MockPass verifies the request signature. <br> **Default:** Disabled. <br> **How to configure:** Enable for all requests by setting the env var `ENCRYPT_MYINFO` to `true`. |
|
|
96
96
|
|
|
@@ -119,10 +119,19 @@ Configure your application (or MockPass) with certificates/keys:
|
|
|
119
119
|
|
|
120
120
|
MockPass accepts any value for `client_id`, `client_secret` and `redirect_uri`.
|
|
121
121
|
|
|
122
|
-
Only the profiles (NRICs) that have entries in Mockpass'
|
|
122
|
+
Only the profiles (NRICs) that have entries in Mockpass' personas dataset will
|
|
123
123
|
succeed, using other NRICs will result in an error. See the list of personas in
|
|
124
124
|
[static/myinfo/v3.json](static/myinfo/v3.json).
|
|
125
125
|
|
|
126
|
+
If the Public Officer Employment Details data item is requested, the
|
|
127
|
+
`pocdex.public_officer_details` scope data is sourced from the
|
|
128
|
+
`publicofficerdetails` data key (where present) on personas.
|
|
129
|
+
Most personas do not have this data key configured, and will result in a `"NA"`
|
|
130
|
+
response instead of an stringified array. As these personas are not identified
|
|
131
|
+
in the login page dropdown, please check the personas dataset linked above to
|
|
132
|
+
identify them.
|
|
133
|
+
The `pocdex.number_of_employments` scope is not supported.
|
|
134
|
+
|
|
126
135
|
| Configuration item | Explanation |
|
|
127
136
|
|---|---|
|
|
128
137
|
| Client certificate | **Overview:** When client makes any request, what certificate is used to verify the request signature, and what certificate is used to encrypt the data payload. <br> **Default:** static key `static/certs/key.pub` is used. <br> **How to configure:** Set the env var `SERVICE_PROVIDER_PUB_KEY` to the path to a public key PEM file. (A certificate PEM file can also be provided, despite the env var name.) |
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import js from "@eslint/js";
|
|
5
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const compat = new FlatCompat({
|
|
10
|
+
baseDirectory: __dirname,
|
|
11
|
+
recommendedConfig: js.configs.recommended,
|
|
12
|
+
allConfig: js.configs.all
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default [...compat.extends("eslint:recommended", "plugin:prettier/recommended"), {
|
|
16
|
+
languageOptions: {
|
|
17
|
+
globals: {
|
|
18
|
+
...globals.node,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
ecmaVersion: 2020,
|
|
22
|
+
sourceType: "commonjs",
|
|
23
|
+
},
|
|
24
|
+
}];
|
|
@@ -20,13 +20,7 @@ const CONSENT_TEMPLATE = fs.readFileSync(
|
|
|
20
20
|
const authorizations = {}
|
|
21
21
|
|
|
22
22
|
const authorize = (redirectTo) => (req, res) => {
|
|
23
|
-
const {
|
|
24
|
-
client_id, // eslint-disable-line camelcase
|
|
25
|
-
redirect_uri, // eslint-disable-line camelcase
|
|
26
|
-
attributes,
|
|
27
|
-
purpose,
|
|
28
|
-
state,
|
|
29
|
-
} = req.query
|
|
23
|
+
const { client_id, redirect_uri, attributes, purpose, state } = req.query
|
|
30
24
|
const relayStateParams = qs.stringify({
|
|
31
25
|
client_id,
|
|
32
26
|
redirect_uri,
|
package/lib/express/sgid.js
CHANGED
|
@@ -268,6 +268,10 @@ const formatVehicles = (vehicles) => {
|
|
|
268
268
|
return vehicleObjects
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
const formatJsonStringify = (value) => {
|
|
272
|
+
return value == undefined ? 'NA' : JSON.stringify(value)
|
|
273
|
+
}
|
|
274
|
+
|
|
271
275
|
const defaultUndefinedToNA = (value) => {
|
|
272
276
|
return value || 'NA'
|
|
273
277
|
}
|
|
@@ -320,6 +324,8 @@ const sgIDScopeToMyInfoField = (persona, scope) => {
|
|
|
320
324
|
return defaultUndefinedToNA(persona.marital?.desc)
|
|
321
325
|
case 'myinfo.mobile_number_with_country_code':
|
|
322
326
|
return formatMobileNumberWithPrefix(persona.mobileno)
|
|
327
|
+
case 'pocdex.public_officer_details':
|
|
328
|
+
return formatJsonStringify(persona.publicofficerdetails)
|
|
323
329
|
default:
|
|
324
330
|
return 'NA'
|
|
325
331
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengovsg/mockpass",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.3",
|
|
4
4
|
"description": "A mock SingPass/CorpPass server for dev purposes",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"cz": "git-cz",
|
|
13
13
|
"lint": "eslint lib",
|
|
14
14
|
"lint-fix": "eslint --fix lib",
|
|
15
|
-
"
|
|
15
|
+
"prepare": "node .husky/install.mjs",
|
|
16
16
|
"prepublishOnly": "pinst --disable",
|
|
17
17
|
"postpublish": "pinst --enable"
|
|
18
18
|
},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dotenv": "^16.0.0",
|
|
42
42
|
"expiry-map": "^2.0.0",
|
|
43
43
|
"express": "^4.16.3",
|
|
44
|
-
"jose": "^
|
|
44
|
+
"jose": "^5.2.3",
|
|
45
45
|
"jsonwebtoken": "^9.0.0",
|
|
46
46
|
"lodash": "^4.17.11",
|
|
47
47
|
"morgan": "^1.9.1",
|
|
@@ -50,16 +50,19 @@
|
|
|
50
50
|
"uuid": "^9.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@commitlint/cli": "^
|
|
54
|
-
"@commitlint/config-conventional": "^
|
|
55
|
-
"@commitlint/travis-cli": "^
|
|
53
|
+
"@commitlint/cli": "^19.1.0",
|
|
54
|
+
"@commitlint/config-conventional": "^19.0.3",
|
|
55
|
+
"@commitlint/travis-cli": "^19.0.3",
|
|
56
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
57
|
+
"@eslint/js": "^9.8.0",
|
|
56
58
|
"commitizen": "^4.2.4",
|
|
57
59
|
"cz-conventional-changelog": "^3.2.0",
|
|
58
|
-
"eslint": "^8.0
|
|
59
|
-
"eslint-config-prettier": "^
|
|
60
|
+
"eslint": "^9.8.0",
|
|
61
|
+
"eslint-config-prettier": "^9.1.0",
|
|
60
62
|
"eslint-plugin-prettier": "^4.0.0",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
+
"globals": "^15.9.0",
|
|
64
|
+
"husky": "^9.0.11",
|
|
65
|
+
"lint-staged": "^15.2.2",
|
|
63
66
|
"nodemon": "^3.0.1",
|
|
64
67
|
"pinst": "^3.0.0",
|
|
65
68
|
"prettier": "^2.0.5"
|
package/static/myinfo/v3.json
CHANGED
|
@@ -1203,7 +1203,16 @@
|
|
|
1203
1203
|
"source": "1",
|
|
1204
1204
|
"classification": "C",
|
|
1205
1205
|
"desc": ""
|
|
1206
|
-
}
|
|
1206
|
+
},
|
|
1207
|
+
"publicofficerdetails": [
|
|
1208
|
+
{
|
|
1209
|
+
"work_email": "lim_yong_xiang@was.gov.sg",
|
|
1210
|
+
"agency_name": "Work Allocation Singapore",
|
|
1211
|
+
"department_name": "Allocation Central",
|
|
1212
|
+
"employment_type": "Fixed Term",
|
|
1213
|
+
"employment_title": "Senior Software Engineer - LLv1 (Individual Contributor) (WAS)"
|
|
1214
|
+
}
|
|
1215
|
+
]
|
|
1207
1216
|
},
|
|
1208
1217
|
"S9912370B": {
|
|
1209
1218
|
"edulevel": {
|
|
@@ -1517,7 +1526,7 @@
|
|
|
1517
1526
|
"code": "C",
|
|
1518
1527
|
"source": "1",
|
|
1519
1528
|
"classification": "C",
|
|
1520
|
-
"desc": "
|
|
1529
|
+
"desc": "CITIZEN"
|
|
1521
1530
|
},
|
|
1522
1531
|
"cpfbalances": {
|
|
1523
1532
|
"lastupdated": "2020-04-16",
|
|
@@ -2415,7 +2424,7 @@
|
|
|
2415
2424
|
"code": "C",
|
|
2416
2425
|
"source": "1",
|
|
2417
2426
|
"classification": "C",
|
|
2418
|
-
"desc": "
|
|
2427
|
+
"desc": "CITIZEN"
|
|
2419
2428
|
},
|
|
2420
2429
|
"cpfbalances": {
|
|
2421
2430
|
"lastupdated": "2020-04-16",
|
|
@@ -7065,7 +7074,7 @@
|
|
|
7065
7074
|
"code": "C",
|
|
7066
7075
|
"source": "1",
|
|
7067
7076
|
"classification": "C",
|
|
7068
|
-
"desc": "
|
|
7077
|
+
"desc": "CITIZEN"
|
|
7069
7078
|
},
|
|
7070
7079
|
"cpfbalances": {
|
|
7071
7080
|
"lastupdated": "2020-04-16",
|
|
@@ -8214,7 +8223,7 @@
|
|
|
8214
8223
|
"code": "C",
|
|
8215
8224
|
"source": "1",
|
|
8216
8225
|
"classification": "C",
|
|
8217
|
-
"desc": "
|
|
8226
|
+
"desc": "CITIZEN"
|
|
8218
8227
|
},
|
|
8219
8228
|
"cpfbalances": {
|
|
8220
8229
|
"lastupdated": "2020-04-16",
|
|
@@ -9302,7 +9311,7 @@
|
|
|
9302
9311
|
"code": "C",
|
|
9303
9312
|
"source": "1",
|
|
9304
9313
|
"classification": "C",
|
|
9305
|
-
"desc": "
|
|
9314
|
+
"desc": "CITIZEN"
|
|
9306
9315
|
},
|
|
9307
9316
|
"cpfbalances": {
|
|
9308
9317
|
"lastupdated": "2020-04-16",
|
|
@@ -10104,7 +10113,7 @@
|
|
|
10104
10113
|
"code": "C",
|
|
10105
10114
|
"source": "1",
|
|
10106
10115
|
"classification": "C",
|
|
10107
|
-
"desc": "
|
|
10116
|
+
"desc": "CITIZEN"
|
|
10108
10117
|
},
|
|
10109
10118
|
"cpfbalances": {
|
|
10110
10119
|
"lastupdated": "2020-02-04",
|
|
@@ -12107,7 +12116,7 @@
|
|
|
12107
12116
|
"code": "C",
|
|
12108
12117
|
"source": "1",
|
|
12109
12118
|
"classification": "C",
|
|
12110
|
-
"desc": "
|
|
12119
|
+
"desc": "CITIZEN"
|
|
12111
12120
|
},
|
|
12112
12121
|
"cpfbalances": {
|
|
12113
12122
|
"lastupdated": "2020-04-16",
|
|
@@ -13817,7 +13826,7 @@
|
|
|
13817
13826
|
"code": "C",
|
|
13818
13827
|
"source": "1",
|
|
13819
13828
|
"classification": "C",
|
|
13820
|
-
"desc": "
|
|
13829
|
+
"desc": "CITIZEN"
|
|
13821
13830
|
},
|
|
13822
13831
|
"cpfbalances": {
|
|
13823
13832
|
"oa": {
|
|
@@ -14473,7 +14482,7 @@
|
|
|
14473
14482
|
"code": "C",
|
|
14474
14483
|
"source": "1",
|
|
14475
14484
|
"classification": "C",
|
|
14476
|
-
"desc": "
|
|
14485
|
+
"desc": "CITIZEN"
|
|
14477
14486
|
},
|
|
14478
14487
|
"cpfbalances": {
|
|
14479
14488
|
"lastupdated": "2020-04-16",
|
|
@@ -15150,7 +15159,7 @@
|
|
|
15150
15159
|
"code": "C",
|
|
15151
15160
|
"source": "1",
|
|
15152
15161
|
"classification": "C",
|
|
15153
|
-
"desc": "
|
|
15162
|
+
"desc": "CITIZEN"
|
|
15154
15163
|
},
|
|
15155
15164
|
"cpfbalances": {
|
|
15156
15165
|
"lastupdated": "2020-04-16",
|
|
@@ -16153,7 +16162,7 @@
|
|
|
16153
16162
|
"code": "C",
|
|
16154
16163
|
"source": "1",
|
|
16155
16164
|
"classification": "C",
|
|
16156
|
-
"desc": "
|
|
16165
|
+
"desc": "CITIZEN"
|
|
16157
16166
|
},
|
|
16158
16167
|
"cpfbalances": {
|
|
16159
16168
|
"lastupdated": "2020-04-16",
|
|
@@ -19137,7 +19146,7 @@
|
|
|
19137
19146
|
"code": "C",
|
|
19138
19147
|
"source": "1",
|
|
19139
19148
|
"classification": "C",
|
|
19140
|
-
"desc": "
|
|
19149
|
+
"desc": "CITIZEN"
|
|
19141
19150
|
},
|
|
19142
19151
|
"cpfbalances": {
|
|
19143
19152
|
"lastupdated": "2020-04-16",
|
|
@@ -24343,7 +24352,7 @@
|
|
|
24343
24352
|
"code": "C",
|
|
24344
24353
|
"source": "1",
|
|
24345
24354
|
"classification": "C",
|
|
24346
|
-
"desc": "
|
|
24355
|
+
"desc": "CITIZEN"
|
|
24347
24356
|
},
|
|
24348
24357
|
"cpfbalances": {
|
|
24349
24358
|
"lastupdated": "2020-04-16",
|
|
@@ -26126,7 +26135,7 @@
|
|
|
26126
26135
|
"code": "C",
|
|
26127
26136
|
"source": "1",
|
|
26128
26137
|
"classification": "C",
|
|
26129
|
-
"desc": "
|
|
26138
|
+
"desc": "CITIZEN"
|
|
26130
26139
|
},
|
|
26131
26140
|
"cpfbalances": {
|
|
26132
26141
|
"oa": {
|
|
@@ -26919,7 +26928,7 @@
|
|
|
26919
26928
|
"code": "C",
|
|
26920
26929
|
"source": "1",
|
|
26921
26930
|
"classification": "C",
|
|
26922
|
-
"desc": "
|
|
26931
|
+
"desc": "CITIZEN"
|
|
26923
26932
|
},
|
|
26924
26933
|
"cpfbalances": {
|
|
26925
26934
|
"lastupdated": "2020-04-16",
|
|
@@ -27960,7 +27969,7 @@
|
|
|
27960
27969
|
"code": "C",
|
|
27961
27970
|
"source": "1",
|
|
27962
27971
|
"classification": "C",
|
|
27963
|
-
"desc": "
|
|
27972
|
+
"desc": "CITIZEN"
|
|
27964
27973
|
},
|
|
27965
27974
|
"cpfbalances": {
|
|
27966
27975
|
"oa": {
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Node.js Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
publish-npm:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v2
|
|
15
|
-
- uses: actions/setup-node@v1
|
|
16
|
-
with:
|
|
17
|
-
node-version: 12
|
|
18
|
-
registry-url: https://registry.npmjs.org/
|
|
19
|
-
- run: npm ci
|
|
20
|
-
- run: npm publish --access public
|
|
21
|
-
env:
|
|
22
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|