smartid-calls

Smart-ID client module for Node.JS with proxy layer

Usage no npm install needed!

<script type="module">
  import smartidCalls from 'https://cdn.skypack.dev/smartid-calls';
</script>

README

Typescript Smart-ID comunication layer for Node.js

Install

npm install smartid-calls

Usage

import SmartID from 'smartid-calls';

config = {
  algorithm: 'SHA256',
  host: 'https://sid.demo.sk.ee/smart-id-rp/v1',
  requestParams: {
    relyingPartyUUID: '00000000-0000-0000-0000-000000000000',
    relyingPartyName: 'DEMO',
    certificateLevel: 'QUALIFIED'
  }
}
smartauth = new SmartID(config);

const persNr = '010101-10006';
const country = 'LV';

// Initiate the authentication session
const resp = await smartauth.authenticate(country, persNr, 'Testing');
const sessionId = resp.sessionId;
const authHash = resp.authHash;

// Get the session
const sess = await smartauth.getSession(sessionId);

// Verify that it has been properly signed
const verification = await smartauth.verifyRequest(sessionId, sess.all, authHash);

Additionally Proxy server credentials can be supplied, to route traffic through specific IP address, which is whitelisted on SmartID side.

//...
config = {
  algorithm: 'SHA256',
  host: 'https://sid.demo.sk.ee/smart-id-rp/v1',
  requestParams: {
    relyingPartyUUID: '00000000-0000-0000-0000-000000000000',
    relyingPartyName: 'DEMO',
    certificateLevel: 'QUALIFIED'
  },
  proxy: {
    host: 'example.hostname.com',
    port: 8080,
    username: 'proxu-username',
    password: 'your-password',
  },
}
smartauth = new SmartID(config);
//...

Running tests

Running npm run test will use automated identities to test different cases. Smart-ID provides test accounts for automated testing.