1.2.5 • Published 10 months ago

mobiil-id-rest v1.2.5

Weekly downloads
12
License
ISC
Repository
github
Last release
10 months ago

Simple Mobiil-ID rest client for node

Install

npm install mobiil-id-rest

Run tests

npm test

Usage

Configure client

const mobiilIdClient = require('mobiil-id-rest')();

mobiilIdClient.init({
    hostname: "{hostname}",
    apiPath: "{apiPath}",
    relyingPartyUUID: "{relyingPartyUUID}",
    replyingPartyName: "{replyingPartyName}",
    issuers: [{
          "C": "EE",
          "O": "AS Sertifitseerimiskeskus",
          "OID": "NTREE-10747013",
          "CN": "TEST of EID-SK 2015"
        }...]
});

Authenticate

const result = await mobiilId.authenticate(nationalIdentityNumber, phoneNumber);
const authResult = await mobiilId.statusAuth(result.sessionId, result.sessionHash);
/*
    authResult contains response from API, see https://github.com/SK-EID/MID#335-response-structure
*/
const personalInfo = await mobiilId.getCertUserData(authResult.cert);

/*
    personalInfo with structure:
    {
        firstName: subject.GivenName,
        lastName: subject.SurName,
        pid,
        country: subject.Country
    }
*/

Sign

This is basic example for signing, if the desired result is to sign a bdoc or asice container, see undersign. Example usages citizenos or rahvaalgatus

const hash = crypto.createHash('SHA256');
hash.update('Sign this text');
const finalHash = hash.digest('hex');

const resutl = await mobiilId.signature(nationalIdentityNumber, phoneNumber, Buffer.from(finalHash, 'hex').toString('base64'));
const signResult = await mobiilId.statusSign(result.sessionId);
/*
    signResult contains response from API, see https://github.com/SK-EID/MID#335-response-structure
*/

Credits

1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.0.1

4 years ago

1.0.0

4 years ago