Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
smartIdClient
✓ const smartIdClient = require('smart-id-rest')();
✗ import smartIdClient from 'smart-id-rest';
The package exports a factory function that must be invoked. ESM import is not supported natively.
init
✓ smartIdClient.init({ hostname, apiPath, relyingPartyUUID, replyingPartyName, issuers });
init must be called with an object containing all required fields before any other methods.
authenticate
✓ const result = await smartIdClient.authenticate(nationalIdentityNumber, countryCode);
Returns a promise with sessionId and sessionHash. The countryCode is the two-letter country code (e.g., 'EE').
signature
✓ const result = await smartIdClient.signature(nationalIdentityNumber, countryCode, hashBase64);
hashBase64 must be a base64-encoded SHA-256 hash of the data to sign.
statusAuth
✓ const authStatus = await smartIdClient.statusAuth(sessionId, sessionHash);
Polls the authentication session status. Returns the API response object.
statusSign
✓ const signStatus = await smartIdClient.statusSign(sessionId);
Polls the signing session status. Returns the API response object.
Configures the Smart-ID client with environment variables, authenticates a test user, and retrieves personal information from the certificate.
const smartIdClient = require('smart-id-rest')();
smartIdClient.init({
hostname: process.env.SMART_ID_HOSTNAME || 'https://sid.demo.sk.ee',
apiPath: process.env.SMART_ID_API_PATH || '/smart-id/v1',
relyingPartyUUID: process.env.SMART_ID_RELYING_PARTY_UUID || '',
replyingPartyName: process.env.SMART_ID_RELYING_PARTY_NAME || '',
issuers: [
{
C: 'EE',
O: 'AS Sertifitseerimiskeskus',
OID: 'NTREE-10747013',
CN: 'TEST of EID-SK 2015'
}
]
});
async function main() {
try {
const authResult = await smartIdClient.authenticate('30303039914', 'EE');
console.log('Session ID:', authResult.sessionId);
const status = await smartIdClient.statusAuth(authResult.sessionId, authResult.sessionHash);
const personalInfo = await smartIdClient.getCertUserData(status.cert.value);
console.log('Personal info:', personalInfo);
} catch (error) {
console.error('Error:', error);
}
}
main();
Errors
Common errors & fixes
TypeError: smartIdClient.authenticate is not a function
init() was not called or was called incorrectly.
fixEnsure smartIdClient.init(config) is called before using authenticate.
Error: Request failed with status code 400
Missing or incorrect configuration parameters (hostname, apiPath, etc.) or invalid authentication parameters.
fixCheck that env variables are set correctly and that nationalIdentityNumber and countryCode are valid.
Error: Certificate validation failed
The issuer certificate is not in the trusted list or the certificate chain is invalid.
fixVerify that the issuers array contains the correct certificate authorities for the Smart-ID environment.
Audit
Dependencies
No dependency data recorded yet.