Socket
Socket
Sign inDemoInstall

@opengovsg/myinfo-gov-client

Package Overview
Dependencies
66
Maintainers
5
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @opengovsg/myinfo-gov-client

A lightweight client to easily call the MyInfo TUO endpoint for the Singapore government. Compatible with NodeJS version >=6.


Version published
Weekly downloads
340
increased by6.92%
Maintainers
5
Created
Weekly downloads
 

Readme

Source

myinfo-gov-client

A lightweight client to easily call the MyInfo TUO endpoint for the Singapore government. Compatible with NodeJS version >=10.

Quick Start

'use strict'

const fs = require('fs')

const {
  MyInfoGovClient,
  CATEGORICAL_DATA_DICT, // Use this to look up code values
} = require('@opengovsg/myinfo-gov-client')


function main() {

    // Your application configuration
    const realm = '<Your Realm>'
    const appId = '<Your App ID>'
    const clientId = appId; // Usually the same value
    const singpassEserviceId = '<Your SingPass e-Service ID>'

    // Used for signing your request basestring with private key
    const privateKey = fs.readFileSync('./secrets/privateKey.pem')

    // MyInfo client
    const myInfo = new MyInfoGovClient({
      realm,
      appId,
      clientId,
      singpassEserviceId,
      privateKey,
      mode: 'stg', // Set to 'dev' to call dev endpoint, leave empty for prod
    });

    // API params
    const uinFin = 'S3000024B' // See list of dev/staging NRICs below
    const requestedAttributes = [
        'name',
        'marriedname',
        'hanyupinyinname',
        'aliasname',
        'hanyupinyinaliasname',
        'sex',
        'race',
        'dialect',
        'nationality',
        'dob',
        'birthcountry',
        'secondaryrace',
        'residentialstatus',
        'passportnumber',
        'passportexpirydate',
        'email',
        'mobileno',
        'regadd',
        'housingtype',
        'hdbtype',
        'mailadd',
        'billadd',
        'marital',
        'edulevel',
        'marriagecertno',
        'countryofmarriage',
        'marriagedate',
        'divorcedate',
        'childrenbirthrecords',
        'relationships',
        'edulevel',
        'gradyear',
        'schoolname',
        'occupation',
        'employment',
        'workpassstatus',
        'workpassexpirydate',
        'householdincome',
        'vehno',
    ];
    const txnNo = 1234 // an optional transaction number

    // API parameters
    var params = {uinFin, requestedAttributes, txnNo}

    // Make API call
    myInfo.getPersonBasic(params)
    .then(function(personObject) {
        console.log('Results of Person-Basic endpoint:\n', personObject)
    })
    .catch(function(error) {
        console.log('Error:\n', error)
    })
}

main()

Available Test accounts

See a list of available MyInfo test accounts here.

Contributing

We welcome contributions to code open-sourced by the Government Technology Agency of Singapore. All contributors will be asked to sign a Contributor License Agreement (CLA) in order to ensure that everybody is free to use their contributions.

Keywords

FAQs

Last updated on 15 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc