From a9e6eea443ed15ebba580e9b2ac758516dedee59 Mon Sep 17 00:00:00 2001 From: Lee Chiang Fong Date: Mon, 20 May 2024 16:33:03 +0800 Subject: [PATCH] feat: sgID support for pocdex.public_officer_details --- README.md | 13 +++++++++++-- lib/express/sgid.js | 6 ++++++ static/myinfo/v3.json | 11 ++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de8472d..b254bbc 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Configure your application (or MockPass) with certificates/keys: MockPass accepts any value for `client_id`, `redirect_uri` and `sp_esvcId`. The `client_secret` value will be checked if configured, see below. -Only the profiles (NRICs) that have entries in Mockpass' static dataset will +Only the profiles (NRICs) that have entries in Mockpass' personas dataset will succeed, using other NRICs will result in an error. See the list of personas in [static/myinfo/v3.json](static/myinfo/v3.json). @@ -119,10 +119,19 @@ Configure your application (or MockPass) with certificates/keys: MockPass accepts any value for `client_id`, `client_secret` and `redirect_uri`. -Only the profiles (NRICs) that have entries in Mockpass' static dataset will +Only the profiles (NRICs) that have entries in Mockpass' personas dataset will succeed, using other NRICs will result in an error. See the list of personas in [static/myinfo/v3.json](static/myinfo/v3.json). +If the Public Officer Employment Details data item is requested, the +`pocdex.public_officer_details` scope data is sourced from the +`publicofficerdetails` data key (where present) on personas. +Most personas do not have this data key configured, and will result in a `"NA"` +response instead of an stringified array. As these personas are not identified +in the login page dropdown, please check the personas dataset linked above to +identify them. +The `pocdex.number_of_employments` scope is not supported. + | Configuration item | Explanation | |---|---| | 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.
**Default:** static key `static/certs/key.pub` is used.
**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.) | diff --git a/lib/express/sgid.js b/lib/express/sgid.js index 96e8c09..1e8c6ba 100644 --- a/lib/express/sgid.js +++ b/lib/express/sgid.js @@ -268,6 +268,10 @@ const formatVehicles = (vehicles) => { return vehicleObjects } +const formatJsonStringify = (value) => { + return value == undefined ? 'NA' : JSON.stringify(value) +} + const defaultUndefinedToNA = (value) => { return value || 'NA' } @@ -320,6 +324,8 @@ const sgIDScopeToMyInfoField = (persona, scope) => { return defaultUndefinedToNA(persona.marital?.desc) case 'myinfo.mobile_number_with_country_code': return formatMobileNumberWithPrefix(persona.mobileno) + case 'pocdex.public_officer_details': + return formatJsonStringify(persona.publicofficerdetails) default: return 'NA' } diff --git a/static/myinfo/v3.json b/static/myinfo/v3.json index c145412..a89fd2a 100644 --- a/static/myinfo/v3.json +++ b/static/myinfo/v3.json @@ -1203,7 +1203,16 @@ "source": "1", "classification": "C", "desc": "" - } + }, + "publicofficerdetails": [ + { + "work_email": "lim_yong_xiang@was.gov.sg", + "agency_name": "Work Allocation Singapore", + "department_name": "Allocation Central", + "employment_type": "Fixed Term", + "employment_title": "Senior Software Engineer - LLv1 (Individual Contributor) (WAS)" + } + ] }, "S9912370B": { "edulevel": {