@opengovsg/mockpass 4.3.2 → 4.3.4

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.
@@ -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/README.md CHANGED
@@ -90,7 +90,7 @@ succeed, using other NRICs will result in an error. See the list of personas in
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|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.) |
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
 
@@ -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
+ }];
package/lib/assertions.js CHANGED
@@ -64,6 +64,9 @@ const oidc = {
64
64
  { nric: 'F1612358R', uuid: '45669f5c-e9ac-43c6-bcd2-9c3757f1fa1c' },
65
65
  { nric: 'F1612354N', uuid: 'c38ddb2d-9e5d-45c2-bb70-8ccb54fc8320' },
66
66
  { nric: 'F1612357U', uuid: 'f904a2b1-4b61-47e2-bdad-e2d606325e20' },
67
+ { nric: 'Y4581892I', uuid: 'acf8edda-bfdf-45fc-b140-a6ec6955d857' },
68
+ { nric: 'Y7654321K', uuid: '9916f054-488e-4894-8299-412e46d89e67' },
69
+ { nric: 'Y1234567P', uuid: '0fdcc18f-840b-4b35-80ee-44094a6cc66f' },
67
70
  ...Object.keys(myinfo.v3.personas).map((nric) => ({
68
71
  nric,
69
72
  uuid: myinfo.v3.personas[nric].uuid.value,
@@ -135,8 +138,20 @@ const oidc = {
135
138
  nonce,
136
139
  accessToken = crypto.randomBytes(15).toString('hex'),
137
140
  ) => {
138
- const sub = `s=${nric},u=${uuid}`
139
-
141
+ let sub
142
+ const sfa = {
143
+ Y4581892I: { fid: 'G730Z-H5P96', coi: 'DE', RP: 'CORPPASS' },
144
+ Y7654321K: { fid: '123456789', coi: 'CN', RP: 'IRAS' },
145
+ Y1234567P: { fid: 'G730Z-H5P96', coi: 'MY', RP: 'CORPPASS' },
146
+ }
147
+ if (nric.startsWith('Y')) {
148
+ const sfaAccount = sfa[nric]
149
+ ? sfa[nric]
150
+ : { fid: 'G730Z-H5P96', coi: 'DE', RP: 'CORPPASS' }
151
+ sub = `s=${nric},fid=${sfaAccount.fid},coi=${sfaAccount.coi},u=${uuid}`
152
+ } else {
153
+ sub = `s=${nric},u=${uuid}`
154
+ }
140
155
  const accessTokenHash = hashToken(accessToken)
141
156
 
142
157
  const refreshToken = crypto.randomBytes(20).toString('hex')
@@ -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,
@@ -50,7 +50,7 @@ module.exports =
50
50
  const encryptedAndSignedPersona = await new jose.CompactEncrypt(
51
51
  Buffer.from(sign),
52
52
  )
53
- .setProtectedHeader({ alg: 'RSA-OAEP', enc: 'A128CBC-HS256' })
53
+ .setProtectedHeader({ alg: 'RSA-OAEP', enc: 'A256GCM' })
54
54
  .encrypt(publicKey)
55
55
  return encryptedAndSignedPersona
56
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengovsg/mockpass",
3
- "version": "4.3.2",
3
+ "version": "4.3.4",
4
4
  "description": "A mock SingPass/CorpPass server for dev purposes",
5
5
  "main": "app.js",
6
6
  "bin": {
@@ -53,11 +53,14 @@
53
53
  "@commitlint/cli": "^19.1.0",
54
54
  "@commitlint/config-conventional": "^19.0.3",
55
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.0",
60
+ "eslint": "^9.8.0",
59
61
  "eslint-config-prettier": "^9.1.0",
60
62
  "eslint-plugin-prettier": "^4.0.0",
63
+ "globals": "^15.9.0",
61
64
  "husky": "^9.0.11",
62
65
  "lint-staged": "^15.2.2",
63
66
  "nodemon": "^3.0.1",
@@ -1,24 +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@v4
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 'lts/*'
18
- cache: 'npm'
19
- cache-dependency-path: '**/package-lock.json'
20
- registry-url: https://registry.npmjs.org/
21
- - run: npm ci
22
- - run: npm publish --access public
23
- env:
24
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}