Skip to content

Commit

Permalink
Merge pull request #28 from DSorlov/dev
Browse files Browse the repository at this point in the history
Dev to prod 1.1.2
  • Loading branch information
DSorlov authored Oct 23, 2024
2 parents b0f09ee + 992a41e commit b13a152
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 76 deletions.
26 changes: 25 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
The format is based on [Keep a Changelog][keep-a-changelog]
<!-- and this project adheres to [Semantic Versioning][semantic-versioning]. -->

## [1.1.2] (2024-10-23)

### Added
- Added extras.phoneNumber to denote primary phone (Freja)
- Added photoHash (Freja)

### Fixed
- Fixed broken photo attribute (Freja)

## [1.1.1] (2024-07-16)

### Added
- Freja eID Added userConfirmationMethod

### Fixed
- Freja eID orgID getAll function API change implemented
- Freja eID orgID getAll RP-id was broken
- Freja eID Fixed when no extra attributes are present in response

## [1.1.0] (2024-02-25)

### Removed
Expand Down Expand Up @@ -151,7 +170,12 @@ 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
[1.0.1]: https://github.com/DSorlov/eid-provider/releases/tag/v1.0.0
[1.1.2]: https://github.com/DSorlov/eid-provider/releases/tag/v1.1.2
[1.1.1]: https://github.com/DSorlov/eid-provider/releases/tag/v1.1.1
[1.1.0]: https://github.com/DSorlov/eid-provider/releases/tag/v1.1.0
[1.0.3]: https://github.com/DSorlov/eid-provider/releases/tag/v1.0.3
[1.0.2]: https://github.com/DSorlov/eid-provider/releases/tag/v1.0.2
[1.0.1]: https://github.com/DSorlov/eid-provider/releases/tag/v1.0.1
[1.0.0]: https://github.com/DSorlov/eid-provider/releases/tag/v1.0.0
[0.2.1]: https://github.com/DSorlov/eid-provider/releases/tag/v0.2.1
[0.2.0]: https://github.com/DSorlov/eid-provider/releases/tag/v0.2.0
Expand Down
88 changes: 49 additions & 39 deletions clients/frejaeid/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FrejaEID extends BaseClient {

this.clientInfo = {
name: "FrejaEID",
version: "20240225",
version: "20241023",
author: "Daniel Sörlöv <[email protected]>",
url: "https://github.com/DSorlov/eid-provider",
methods: ['auth','sign']
Expand Down Expand Up @@ -148,46 +148,54 @@ class FrejaEID extends BaseClient {
jwtToken: result.json.details
};

if (decoded.requestedAttributes.age) extras.age = decoded.requestedAttributes.age;
if (decoded.requestedAttributes.photoFileInfo) extras.photo = decoded.requestedAttributes.photoFileInfo.fileHash;
if (decoded.requestedAttributes.dateOfBirth) extras.dateOfBirth = decoded.requestedAttributes.dateOfBirth;
if (decoded.requestedAttributes.emailAddress) extras.primaryEmail = decoded.requestedAttributes.emailAddress;
if (decoded.requestedAttributes.addresses) extras.addresses = decoded.requestedAttributes.addresses;
if (decoded.requestedAttributes.customIdentifier) extras.customIdentifier = decoded.requestedAttributes.customIdentifier;
if (decoded.requestedAttributes.relyingPartyUserId) extras.relyingPartyUserId = decoded.requestedAttributes.relyingPartyUserId;
if (decoded.requestedAttributes.registrationLevel) extras.registrationLevel = decoded.requestedAttributes.registrationLevel;

if (decoded.requestedAttributes.allEmailAddresses) {
extras.emailAddresses = [];
decoded.requestedAttributes.allEmailAddresses.forEach((emailObject)=>{
extras.emailAddresses.push(emailObject.emailAddress);
})
}
if (decoded.requestedAttributes.allPhoneNumbers) {
extras.phoneNumbers = [];
decoded.requestedAttributes.allPhoneNumbers.forEach((phoneObject)=>{
extras.phoneNumbers.push(phoneObject.phoneNumber);
})
}

if (decoded.requestedAttributes.ssn) {
extras.ssnNumber = decoded.requestedAttributes.ssn.ssn;
extras.ssnCountry = decoded.requestedAttributes.ssn.country;
if (result.json.requestedAttributes.photo) {
extras.photo = result.json.requestedAttributes.photo
}

if (decoded.requestedAttributes.document) {
extras.documentType = decoded.requestedAttributes.document.type;
extras.documentCountry = decoded.requestedAttributes.document.country;
extras.documentNumber = decoded.requestedAttributes.document.serialNumber;
extras.documentExpiration = decoded.requestedAttributes.document.expirationDate;
}

if (decoded.requestedAttributes.basicUserInfo) {
firstname = decoded.requestedAttributes.basicUserInfo ? decoded.requestedAttributes.basicUserInfo.name : '',
lastname = decoded.requestedAttributes.basicUserInfo ? decoded.requestedAttributes.basicUserInfo.surname : '',
fullname = decoded.requestedAttributes.basicUserInfo ? decoded.requestedAttributes.basicUserInfo.name+' '+decoded.requestedAttributes.basicUserInfo.surname : ''
}
if (decoded.requestedAttributes) {
if (decoded.requestedAttributes.age) extras.age = decoded.requestedAttributes.age;
if (decoded.requestedAttributes.photoFileInfo) extras.photoHash = decoded.requestedAttributes.photoFileInfo.fileHash;
if (decoded.requestedAttributes.dateOfBirth) extras.dateOfBirth = decoded.requestedAttributes.dateOfBirth;
if (decoded.requestedAttributes.emailAddress) extras.primaryEmail = decoded.requestedAttributes.emailAddress;
if (decoded.requestedAttributes.addresses) extras.addresses = decoded.requestedAttributes.addresses;
if (decoded.requestedAttributes.customIdentifier) extras.customIdentifier = decoded.requestedAttributes.customIdentifier;
if (decoded.requestedAttributes.relyingPartyUserId) extras.relyingPartyUserId = decoded.requestedAttributes.relyingPartyUserId;
if (decoded.requestedAttributes.registrationLevel) extras.registrationLevel = decoded.requestedAttributes.registrationLevel;

if (decoded.requestedAttributes.allEmailAddresses) {
extras.emailAddresses = [];
decoded.requestedAttributes.allEmailAddresses.forEach((emailObject)=>{
extras.emailAddresses.push(emailObject.emailAddress);
})
}
if (decoded.requestedAttributes.allPhoneNumbers) {
extras.phoneNumbers = [];
decoded.requestedAttributes.allPhoneNumbers.forEach((phoneObject)=>{
extras.phoneNumbers.push(phoneObject.phoneNumber);
})
if (extras.phoneNumbers.lenght>0) {
extras.phoneNumber = extras.phoneNumber[0]
}
}

if (decoded.requestedAttributes.ssn) {
extras.ssnNumber = decoded.requestedAttributes.ssn.ssn;
extras.ssnCountry = decoded.requestedAttributes.ssn.country;
}

if (decoded.requestedAttributes.document) {
extras.documentType = decoded.requestedAttributes.document.type;
extras.documentCountry = decoded.requestedAttributes.document.country;
extras.documentNumber = decoded.requestedAttributes.document.serialNumber;
extras.documentExpiration = decoded.requestedAttributes.document.expirationDate;
}

if (decoded.requestedAttributes.basicUserInfo) {
firstname = decoded.requestedAttributes.basicUserInfo ? decoded.requestedAttributes.basicUserInfo.name : '',
lastname = decoded.requestedAttributes.basicUserInfo ? decoded.requestedAttributes.basicUserInfo.surname : '',
fullname = decoded.requestedAttributes.basicUserInfo ? decoded.requestedAttributes.basicUserInfo.name+' '+decoded.requestedAttributes.basicUserInfo.surname : ''
}
}

return this._createCompletionMessage(id,firstname,lastname,fullname,extras);

Expand Down Expand Up @@ -267,7 +275,7 @@ class FrejaEID extends BaseClient {
}

async getOrgIdList() {
var result = await this._httpRequest(`${this.settings.endpoint}/organisation/management/orgId/1.0/users/getAll`,{},this.relyingPartyId.slice(1));
var result = await this._httpRequest(`${this.settings.endpoint}/organisation/management/orgId/1.0/users/getAll`,{method: 'POST'},this.relyingPartyId);

if (result.statusCode===599) {
return this._createErrorMessage('internal_error',result.statusMessage);
Expand Down Expand Up @@ -337,6 +345,7 @@ class FrejaEID extends BaseClient {
postData = "initSignRequest="+Buffer.from(JSON.stringify({
attributesToReturn: this.settings.attribute_list,
minRegistrationLevel: this.settings.minimumLevel,
userConfirmationMethod: this.settings.userConfirmationMethod,
userInfoType: infoType.userInfoType,
userInfo: infoType.userInfo,
signatureType: 'SIMPLE',
Expand All @@ -349,6 +358,7 @@ class FrejaEID extends BaseClient {
postData = "initAuthRequest="+Buffer.from(JSON.stringify({
attributesToReturn: this.settings.attribute_list,
minRegistrationLevel: this.settings.minimumLevel,
userConfirmationMethod: this.settings.userConfirmationMethod,
userInfoType: infoType.userInfoType,
userInfo: infoType.userInfo
})).toString('base64');
Expand Down
2 changes: 2 additions & 0 deletions clients/frejaeid/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ var config = {
},
// The minimum level to accept
minimumLevel: 'EXTENDED',
// Level to confirm user identity, DEFAULT or DEFAULT_AND_FACE
userConfirmationMethod: 'DEFAULT',
// Default country when calling identification with just an SSN
default_country: 'SE',
// The UserInfo field
Expand Down
2 changes: 2 additions & 0 deletions clients/frejaeid/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = function(options) {
'wSYLdhe93ToPR2X1UrNXxOg1juI': fs.readFileSync(path.join(__dirname,'/cert','prod_wSYLdhe93ToPR2X1UrNXxOg1juI.jwt'))
},
minimumLevel: 'EXTENDED',
userConfirmationMethod: 'DEFAULT',
default_country: 'SE',
id_type: 'SSN',
attribute_list: ['EMAIL_ADDRESS','RELYING_PARTY_USER_ID','BASIC_USER_INFO','SSN','ADDRESSES','DATE_OF_BIRTH','ALL_EMAIL_ADDRESSES'],
Expand All @@ -30,6 +31,7 @@ module.exports = function(options) {
'DiZbzBfysUm6-IwI-GtienEsbjc': fs.readFileSync(path.join(__dirname,'/cert','test_DiZbzBfysUm6-IwI-GtienEsbjc.jwt'))
},
minimumLevel: 'EXTENDED',
userConfirmationMethod: 'DEFAULT',
password: 'test',
default_country: 'SE',
id_type: 'SSN',
Expand Down
64 changes: 30 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eid",
"version": "1.1.0",
"version": "1.1.2",
"description": "Module for simple integration to electronic identities",
"bundleDependencies": false,
"deprecated": false,
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![NPM version](https://img.shields.io/npm/v/eid.svg?style=flat)
![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)
![version](https://img.shields.io/badge/version-1.1.0-green.svg)
![version](https://img.shields.io/badge/version-1.1.2-green.svg)
![maintained](https://img.shields.io/maintenance/yes/2024.svg)
[![maintainer](https://img.shields.io/badge/maintainer-dsorlov-blue.svg)](https://github.com/DSorlov)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://img.shields.io/github/license/DSorlov/eid)
Expand Down

0 comments on commit b13a152

Please sign in to comment.