@opengovsg/mockpass 2.7.7 → 2.7.11

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.
@@ -2,7 +2,7 @@ const express = require('express')
2
2
  const fs = require('fs')
3
3
  const { render } = require('mustache')
4
4
  const path = require('path')
5
- const { DOMParser } = require('xmldom')
5
+ const { DOMParser } = require('@xmldom/xmldom')
6
6
  const xpath = require('xpath')
7
7
  const moment = require('moment')
8
8
 
@@ -92,6 +92,9 @@ function config(app, { showLoginPage, idpConfig, serviceProvider }) {
92
92
  nonce,
93
93
  accessToken,
94
94
  )
95
+ // Change sub from `s=${nric},u=${uuid}`
96
+ // to `u=${uuid}` to be consistent with userinfo sub
97
+ idTokenClaims.sub = idTokenClaims.sub.split(',')[1]
95
98
 
96
99
  const signingKey = await jose.JWK.asKey(signingPem, 'pem')
97
100
  const idToken = await jose.JWS.createSign(
@@ -106,7 +109,7 @@ function config(app, { showLoginPage, idpConfig, serviceProvider }) {
106
109
  refresh_token: refreshToken,
107
110
  expires_in: 24 * 60 * 60,
108
111
  scope: 'openid',
109
- token_type: 'bearer',
112
+ token_type: 'Bearer',
110
113
  id_token: idToken,
111
114
  })
112
115
  } catch (error) {
@@ -129,13 +132,22 @@ function config(app, { showLoginPage, idpConfig, serviceProvider }) {
129
132
  alg: 'A256GCM',
130
133
  })
131
134
 
132
- const encryptedNric = await jose.JWE.createEncrypt(payloadKey)
135
+ const encryptedNric = await jose.JWE.createEncrypt(
136
+ { format: 'compact' },
137
+ payloadKey,
138
+ )
133
139
  .update(nric)
134
140
  .final()
135
- const encryptedName = await jose.JWE.createEncrypt(payloadKey)
141
+ const encryptedName = await jose.JWE.createEncrypt(
142
+ { format: 'compact' },
143
+ payloadKey,
144
+ )
136
145
  .update(name)
137
146
  .final()
138
- const encryptedDateOfBirth = await jose.JWE.createEncrypt(payloadKey)
147
+ const encryptedDateOfBirth = await jose.JWE.createEncrypt(
148
+ { format: 'compact' },
149
+ payloadKey,
150
+ )
139
151
  .update(dateOfBirth)
140
152
  .final()
141
153
  const data = {
@@ -143,11 +155,14 @@ function config(app, { showLoginPage, idpConfig, serviceProvider }) {
143
155
  'myinfo.name': encryptedName,
144
156
  'myinfo.date_of_birth': encryptedDateOfBirth,
145
157
  }
146
- const encryptionKey = await jose.JWK.asKey(serviceProvider.cert, 'pem')
158
+ const encryptionKey = await jose.JWK.asKey(serviceProvider.pubKey, 'pem')
147
159
 
148
160
  const plaintextPayloadKey = JSON.stringify(payloadKey.toJSON(true))
149
161
  console.log(plaintextPayloadKey)
150
- const encryptedPayloadKey = await jose.JWE.createEncrypt(encryptionKey)
162
+ const encryptedPayloadKey = await jose.JWE.createEncrypt(
163
+ { format: 'compact' },
164
+ encryptionKey,
165
+ )
151
166
  .update(plaintextPayloadKey)
152
167
  .final()
153
168
  res.json({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengovsg/mockpass",
3
- "version": "2.7.7",
3
+ "version": "2.7.11",
4
4
  "description": "A mock SingPass/CorpPass server for dev purposes",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -36,9 +36,10 @@
36
36
  "node": ">=8.0.0"
37
37
  },
38
38
  "dependencies": {
39
+ "@xmldom/xmldom": "^0.8.0",
39
40
  "base-64": "^1.0.0",
40
41
  "cookie-parser": "^1.4.3",
41
- "dotenv": "^10.0.0",
42
+ "dotenv": "^14.2.0",
42
43
  "expiry-map": "^1.1.0",
43
44
  "express": "^4.16.3",
44
45
  "jsonwebtoken": "^8.4.0",
@@ -49,21 +50,20 @@
49
50
  "node-jose": "^2.0.0",
50
51
  "uuid": "^8.0.0",
51
52
  "xml-crypto": "^2.1.2",
52
- "xml-encryption": "^1.2.4",
53
- "xmldom": "^0.6.0",
53
+ "xml-encryption": "^2.0.0",
54
54
  "xpath": "0.0.32"
55
55
  },
56
56
  "devDependencies": {
57
- "@commitlint/cli": "^13.1.0",
58
- "@commitlint/config-conventional": "^13.1.0",
59
- "@commitlint/travis-cli": "^13.1.0",
57
+ "@commitlint/cli": "^16.0.1",
58
+ "@commitlint/config-conventional": "^16.0.0",
59
+ "@commitlint/travis-cli": "^16.0.1",
60
60
  "commitizen": "^4.2.4",
61
61
  "cz-conventional-changelog": "^3.2.0",
62
- "eslint": "^7.25.0",
62
+ "eslint": "^8.0.0",
63
63
  "eslint-config-prettier": "^8.3.0",
64
- "eslint-plugin-prettier": "^3.4.0",
64
+ "eslint-plugin-prettier": "^4.0.0",
65
65
  "husky": "^7.0.0",
66
- "lint-staged": "^11.0.0",
66
+ "lint-staged": "^12.0.2",
67
67
  "nodemon": "^2.0.4",
68
68
  "pinst": "^2.1.6",
69
69
  "prettier": "^2.0.5"