Skip to content

Commit

Permalink
Merge pull request #10 from DSorlov/dev
Browse files Browse the repository at this point in the history
0.1.7
  • Loading branch information
DSorlov committed Sep 2, 2020
2 parents 982fa98 + 0871762 commit 9d0efcf
Show file tree
Hide file tree
Showing 13 changed files with 349 additions and 11 deletions.
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog][keep-a-changelog]
## [Unreleased]
- Nothing right now

## [0.1.7] (2020-09-02)

### Added
- Added IDKollen API provider (idkbankid)

### Fixed
- Added error handling on internal errors when following requests, should create more stable library (all modules).
- Verified API and updated settings for Funktionstjänster (CGI) Freja eID module (ftfrejaeid)

## [0.1.5] (2020-09-01)

### Fixed
Expand Down Expand Up @@ -63,6 +72,7 @@ The format is based on [Keep a Changelog][keep-a-changelog]

[keep-a-changelog]: http://keepachangelog.com/en/1.0.0/
[Unreleased]: https://github.com/DSorlov/eid-provider/compare/master...dev
[0.1.7]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.7
[0.1.5]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.5
[0.1.4]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.4
[0.1.3]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.3
Expand Down
37 changes: 37 additions & 0 deletions docs/idkbankid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## BankID (bankid)

### Description
This module lets you communicate and use the IDKollen V2 API.

To use IDKollen API (both test and production) you will need to contact
IDKollen to obtain a key. See (https://idkollen.se/)[https://idkollen.se/]

Due to the API beeing a call-back API a postback endpoint is created
for each request using https://webhook.site/ and a temporary endpoint,
the endpoint deletes once there response is received. You do not need
Webhook Premium, but if you are using it you can make sure your urls
and data are deleted as appropiate and that no limts are imposed.

### Inputs and outputs

**Alternative inputs**

Also accepts objects with `ssn` (Social Security Number) property.

**Extra fields on completion**
* `autostart_token` the token used for autostart
* `autostart_url` code for invoking authorization

### Default Configuration
>**Default production configuration (settings.production)**
```
endpoint: 'https://api.idkollen.se/v2',
key: '',
webhookkey: ''
```
>**Default testing configuration (settings.testing)**
```
endpoint: 'https://stgapi.idkollen.se/v2',
key: '',
webhookkey: ''
```
4 changes: 4 additions & 0 deletions modules/bankid.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ async function followRequest(self,initresp, initcallback=undefined, statuscallba
// Retreive current status
const [error, pollresp] = await to(pollStatus(initresp.id,self));

if (error) {
return {status: 'error', code: 'system_error', description: 'Internal module error', details: error.message}
}

// Check if we we have a definite answer
if (pollresp.status==='completed'||pollresp.status==='error') { return pollresp; }

Expand Down
4 changes: 4 additions & 0 deletions modules/frejaeid.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ async function followRequest(self, pollMethod, initresp, initcallback=undefined,

const [error, pollresp] = pollMethod=='auth' ? await to(self.pollAuthStatus(initresp.id,self)) : await to(self.pollSignStatus(initresp.id,self))

if (error) {
return {status: 'error', code: 'system_error', description: 'Internal module error', details: error.message}
}

// Check if we we have a definite answer
if (pollresp.status==='completed'||pollresp.status==='error') { return pollresp; }

Expand Down
4 changes: 4 additions & 0 deletions modules/frejaorgid.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ async function followRequest(self, pollMethod, initresp, initcallback=undefined,
if (pollMethod=='sign') [error, pollresp] = await to(self.pollSignStatus(initresp.id,self));
if (pollMethod=='add') [error, pollresp] = await to(self.pollAddOrgIdStatus(initresp.id,self));

if (error) {
return {status: 'error', code: 'system_error', description: 'Internal module error', details: error.message}
}

// Check if we we have a definite answer
if (pollresp.status==='completed'||pollresp.status==='error'||pollresp.status==='created') { return pollresp; }

Expand Down
4 changes: 4 additions & 0 deletions modules/ftbankid.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ async function followRequest(self,initresp, initcallback=undefined, statuscallba
// Retreive current status
const [error, pollresp] = await to(pollStatus(initresp.id,self));

if (error) {
return {status: 'error', code: 'system_error', description: 'Internal module error', details: error.message}
}

// Check if we we have a definite answer
if (pollresp.status==='completed'||pollresp.status==='error') { return pollresp; }

Expand Down
13 changes: 8 additions & 5 deletions modules/ftfrejaeid.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ function createClient(self,uri,method,options) {

async function pollStatus(id,self=this) {

if (id.length!=73) {
if (id.length!=102) {
return {status: 'error', code: 'request_id_invalid', description: 'The supplied request cannot be found'};
}

var orderRef = id.substring(37,73);
var orderRef = id.substring(37,102);
var transactionId = id.substring(0,36);

var [error,result] = await to(createClient(self,'GrpServicePortType/CollectRequest', 'Collect', {
Expand Down Expand Up @@ -138,11 +138,10 @@ async function pollStatus(id,self=this) {
ssn: result.userInfo.subjectIdentifier,
firstname: result.userInfo.givenName,
surname: result.userInfo.sn,
fullname: result.userInfo.displayName
fullname: result.userInfo.givenName + ' ' + result.userInfo.sn
},
extra: {
signature: result.validationInfo.signature,
ocspResponse: result.validationInfo.ocspResponse}
signature: result.validationInfo.signature}
};
default:
return {status: 'error', code: 'api_error', description: 'A communications error occured', details: result.data};
Expand Down Expand Up @@ -183,6 +182,10 @@ async function followRequest(self,initresp, initcallback=undefined, statuscallba
// Retreive current status
const [error, pollresp] = await to(pollStatus(initresp.id,self));

if (error) {
return {status: 'error', code: 'system_error', description: 'Internal module error', details: error.message}
}

// Check if we we have a definite answer
if (pollresp.status==='completed'||pollresp.status==='error') { return pollresp; }

Expand Down
4 changes: 4 additions & 0 deletions modules/gbankid.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ async function followRequest(self,initresp, initcallback=undefined, statuscallba
// Retreive current status
const [error, pollresp] = await to(self.pollAuthStatus(initresp.id));

if (error) {
return {status: 'error', code: 'system_error', description: 'Internal module error', details: error.message}
}

// Check if we we have a definite answer
if (pollresp.status==='completed'||pollresp.status==='error') { return pollresp; }

Expand Down
4 changes: 4 additions & 0 deletions modules/gfrejaeid.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ async function followRequest(self, initresp, initcallback=undefined, statuscallb
// Retreive current status
const [error, pollresp] = await to(pollStatus(initresp.id,self));

if (error) {
return {status: 'error', code: 'system_error', description: 'Internal module error', details: error.message}
}

// Check if we we have a definite answer
if (pollresp.status==='completed'||pollresp.status==='error') { return pollresp; }

Expand Down
4 changes: 4 additions & 0 deletions modules/ghsaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ async function followRequest(self,initresp, initcallback=undefined, statuscallba
// Retreive current status
const [error, pollresp] = await to(self.pollAuthStatus(initresp.id));

if (error) {
return {status: 'error', code: 'system_error', description: 'Internal module error', details: error.message}
}

// Check if we we have a definite answer
if (pollresp.status==='completed'||pollresp.status==='error') { return pollresp; }

Expand Down
Loading

0 comments on commit 9d0efcf

Please sign in to comment.