@opengovsg/mockpass 3.1.3 → 4.0.0

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/README.md CHANGED
@@ -44,9 +44,11 @@ MyInfo:
44
44
  - http://localhost:5156/myinfo/v3/person
45
45
 
46
46
  sgID:
47
- - http://localhost:5156/sgid/v1/oauth/authorize
48
- - http://localhost:5156/sgid/v1/oauth/token
49
- - http://localhost:5156/sgid/v1/oauth/userinfo
47
+ - http://localhost:5156/v2/oauth/authorize
48
+ - http://localhost:5156/v2/oauth/token
49
+ - http://localhost:5156/v2/oauth/userinfo
50
+ - http://localhost:5156/v2/.well-known/openid-configuration - OpenID discovery endpoint
51
+ - http://localhost:5156/v2/.well-known/jwks.json - JWKS endpoint which exposes the auth provider's signing keys
50
52
 
51
53
  Provide your application with the `spcp*` certs found in `static/certs`
52
54
  and with application certs at `static/certs/{key.pem|server.crt}`
@@ -12,7 +12,9 @@ const LOGIN_TEMPLATE = fs.readFileSync(
12
12
  'utf8',
13
13
  )
14
14
 
15
- const PATH_PREFIX = '/sgid/v1/oauth'
15
+ const VERSION_PREFIX = '/v2'
16
+ const OAUTH_PREFIX = '/oauth'
17
+ const PATH_PREFIX = VERSION_PREFIX + OAUTH_PREFIX
16
18
 
17
19
  const signingPem = fs.readFileSync(
18
20
  path.resolve(__dirname, '../../static/certs/spcp-key.pem'),
@@ -77,7 +79,7 @@ function config(app, { showLoginPage, serviceProvider }) {
77
79
  `Profile ${JSON.stringify(profile)} with token scope ${scopes}`,
78
80
  )
79
81
  const accessToken = authCode
80
- const iss = `${req.protocol}://${req.get('host')}`
82
+ const iss = `${req.protocol}://${req.get('host') + VERSION_PREFIX}`
81
83
 
82
84
  const { idTokenClaims, refreshToken } = assertions.oidc.create.singPass(
83
85
  profile,
@@ -165,49 +167,52 @@ function config(app, { showLoginPage, serviceProvider }) {
165
167
  })
166
168
  })
167
169
 
168
- app.get('/.well-known/jwks.json', async (_req, res) => {
170
+ app.get(`${VERSION_PREFIX}/.well-known/jwks.json`, async (_req, res) => {
169
171
  const key = await jose.JWK.asKey(signingPem, 'pem')
170
172
  const jwk = key.toJSON()
171
173
  jwk.use = 'sig'
172
174
  res.json({ keys: [jwk] })
173
175
  })
174
176
 
175
- app.get('/.well-known/openid-configuration', async (req, res) => {
176
- const issuer = `${req.protocol}://${req.get('host')}`
177
+ app.get(
178
+ `${VERSION_PREFIX}/.well-known/openid-configuration`,
179
+ async (req, res) => {
180
+ const issuer = `${req.protocol}://${req.get('host') + VERSION_PREFIX}`
177
181
 
178
- res.json({
179
- issuer,
180
- authorization_endpoint: `${issuer}/${PATH_PREFIX}/authorize`,
181
- token_endpoint: `${issuer}/${PATH_PREFIX}/token`,
182
- userinfo_endpoint: `${issuer}/${PATH_PREFIX}/userinfo`,
183
- jwks_uri: `${issuer}/.well-known/jwks.json`,
184
- response_types_supported: ['code'],
185
- grant_types_supported: ['authorization_code'],
186
- // Note: some of these scopes are not yet officially documented
187
- // in https://docs.id.gov.sg/data-catalog
188
- // So they are not officially supported yet.
189
- scopes_supported: [
190
- 'openid',
191
- 'myinfo.nric_number',
192
- 'myinfo.name',
193
- 'myinfo.email',
194
- 'myinfo.sex',
195
- 'myinfo.race',
196
- 'myinfo.mobile_number',
197
- 'myinfo.registered_address',
198
- 'myinfo.date_of_birth',
199
- 'myinfo.passport_number',
200
- 'myinfo.passport_expiry_date',
201
- 'myinfo.nationality',
202
- 'myinfo.residentialstatus',
203
- 'myinfo.residential',
204
- 'myinfo.housingtype',
205
- 'myinfo.hdbtype',
206
- ],
207
- id_token_signing_alg_values_supported: ['RS256'],
208
- subject_types_supported: ['pairwise'],
209
- })
210
- })
182
+ res.json({
183
+ issuer,
184
+ authorization_endpoint: `${issuer}/${OAUTH_PREFIX}/authorize`,
185
+ token_endpoint: `${issuer}/${OAUTH_PREFIX}/token`,
186
+ userinfo_endpoint: `${issuer}/${OAUTH_PREFIX}/userinfo`,
187
+ jwks_uri: `${issuer}/.well-known/jwks.json`,
188
+ response_types_supported: ['code'],
189
+ grant_types_supported: ['authorization_code'],
190
+ // Note: some of these scopes are not yet officially documented
191
+ // in https://docs.id.gov.sg/data-catalog
192
+ // So they are not officially supported yet.
193
+ scopes_supported: [
194
+ 'openid',
195
+ 'myinfo.nric_number',
196
+ 'myinfo.name',
197
+ 'myinfo.email',
198
+ 'myinfo.sex',
199
+ 'myinfo.race',
200
+ 'myinfo.mobile_number',
201
+ 'myinfo.registered_address',
202
+ 'myinfo.date_of_birth',
203
+ 'myinfo.passport_number',
204
+ 'myinfo.passport_expiry_date',
205
+ 'myinfo.nationality',
206
+ 'myinfo.residentialstatus',
207
+ 'myinfo.residential',
208
+ 'myinfo.housingtype',
209
+ 'myinfo.hdbtype',
210
+ ],
211
+ id_token_signing_alg_values_supported: ['RS256'],
212
+ subject_types_supported: ['pairwise'],
213
+ })
214
+ },
215
+ )
211
216
  }
212
217
 
213
218
  const concatMyInfoRegAddr = (regadd) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengovsg/mockpass",
3
- "version": "3.1.3",
3
+ "version": "4.0.0",
4
4
  "description": "A mock SingPass/CorpPass server for dev purposes",
5
5
  "main": "index.js",
6
6
  "bin": {