Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opengovsg/myinfo-gov-client

Package Overview
Dependencies
Maintainers
5
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

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.

  • 2.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
249
decreased by-3.11%
Maintainers
5
Weekly downloads
 
Created
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

Package last updated on 21 Dec 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc