smartid-calls
Version:
Smart-ID client module for Node.JS with proxy layer
63 lines (52 loc) • 1.7 kB
Markdown
`npm install smartid-calls`
```typescript
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.
```typescript
//...
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 `npm run test` will use automated identities to test different cases.
Smart-ID provides [test accounts](https://github.com/SK-EID/smart-id-documentation/wiki/Environment-technical-parameters#test-accounts-for-automated-testing) for automated testing.