-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from getyoti/release-3.8.0
Release 3.8.0
- Loading branch information
Showing
76 changed files
with
2,985 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "yoti", | ||
"version": "3.7.3", | ||
"version": "3.8.0", | ||
"description": "Yoti NodeJS SDK for back-end integration", | ||
"author": "Yoti LTD <[email protected]> (https://www.yoti.com/developers)", | ||
"license": "MIT", | ||
|
@@ -9,12 +9,13 @@ | |
"url": "https://github.com/getyoti/yoti-node-sdk.git" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"lint": "node_modules/.bin/eslint *.js './src/**/*.js' './tests/**/*.spec.js' config/*.js", | ||
"unit-test": "node_modules/.bin/jest", | ||
"test": "npm run lint && npm run unit-test" | ||
"lint": "eslint *.js './src/**/*.js' './tests/**/*.spec.js' config/*.js './sandbox/**/*.js'", | ||
"unit-test": "jest", | ||
"test": "npm run lint && npm run unit-test", | ||
"coveralls": "npm run unit-test && cat ./coverage/lcov.info | coveralls" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
|
@@ -27,6 +28,7 @@ | |
"collectCoverageFrom": [ | ||
"./*.js", | ||
"./src/**/*.js", | ||
"./sandbox/**/*.js", | ||
"!**/node_modules/**", | ||
"!**/vendor/**" | ||
], | ||
|
@@ -42,6 +44,7 @@ | |
"uuid": "^3.3.2" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^3.0.7", | ||
"eslint": "^4.19.1", | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
const SandboxClient = require('./client'); | ||
const Validation = require('../src/yoti_common/validation'); | ||
const fs = require('fs'); | ||
|
||
/** | ||
* @class SandboxClientBuilder | ||
*/ | ||
class SandboxClientBuilder { | ||
/** | ||
* @param {string} appId | ||
*/ | ||
forApplication(appId) { | ||
this.appId = appId; | ||
return this; | ||
} | ||
|
||
/** | ||
* @param {string} pemString | ||
* | ||
* @returns {SandboxClientBuilder} | ||
*/ | ||
withPemString(pem) { | ||
Validation.isString(pem, 'pem'); | ||
this.pem = pem; | ||
return this; | ||
} | ||
|
||
/** | ||
* @param {string} filePath | ||
* | ||
* @returns {SandboxClientBuilder} | ||
*/ | ||
withPemFilePath(filePath) { | ||
Validation.isString(filePath, 'filePath'); | ||
return this.withPemString(fs.readFileSync(filePath, 'utf8')); | ||
} | ||
|
||
/** | ||
* @param {string} sandboxUrl | ||
* | ||
* @returns {SandboxClientBuilder} | ||
*/ | ||
withSandboxUrl(sandboxUrl) { | ||
this.sandboxUrl = sandboxUrl; | ||
return this; | ||
} | ||
|
||
/** | ||
* @returns {SandboxClient} | ||
*/ | ||
build() { | ||
return new SandboxClient(this.appId, this.pem, this.sandboxUrl); | ||
} | ||
} | ||
|
||
module.exports = SandboxClientBuilder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
const { RequestBuilder } = require('../src/request/request.builder'); | ||
const TokenResponse = require('./profile/response/token'); | ||
const { Payload } = require('../src/request/payload'); | ||
const Validation = require('../src/yoti_common/validation'); | ||
|
||
/** | ||
* @class SandboxClient | ||
*/ | ||
class SandboxClient { | ||
/** | ||
* @param {string} appId | ||
* @param {string} pem | ||
* @param {string} sandboxUrl | ||
*/ | ||
constructor(appId, pem, sandboxUrl) { | ||
Validation.isString(appId, 'appId'); | ||
this.appId = appId; | ||
this.endpoint = `/apps/${appId}/tokens`; | ||
|
||
Validation.isString(pem, 'pem'); | ||
this.pem = pem; | ||
|
||
Validation.isString(sandboxUrl, 'sandboxUrl'); | ||
this.sandboxUrl = sandboxUrl; | ||
} | ||
|
||
/** | ||
* @param {TokenRequest} tokenRequest | ||
* | ||
* @returns {Promise} | ||
*/ | ||
setupSharingProfile(tokenRequest) { | ||
const request = (new RequestBuilder()) | ||
.withBaseUrl(this.sandboxUrl) | ||
.withEndpoint(this.endpoint) | ||
.withPemString(this.pem) | ||
.withPayload(new Payload(tokenRequest)) | ||
.withPost() | ||
.build(); | ||
|
||
return new Promise((resolve, reject) => { | ||
request.execute() | ||
.then((response) => { | ||
try { | ||
return resolve(new TokenResponse(response.getParsedResponse())); | ||
} catch (err) { | ||
console.log(`Error getting response data: ${err}`); | ||
return reject(err); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.log(`Error retrieving requested data: ${err}`); | ||
return reject(err); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = SandboxClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const SandboxClientBuilder = require('./client.builder'); | ||
const SandboxAttributeBuilder = require('./profile/request/attribute/attribute.builder'); | ||
const SandboxAgeVerificationBuilder = require('./profile/request/attribute/derivation/age.verification.builder'); | ||
const SandboxAnchorBuilder = require('./profile/request/attribute/anchor.builder'); | ||
const TokenRequestBuilder = require('./profile/request/token.builder'); | ||
|
||
module.exports = { | ||
SandboxClientBuilder, | ||
SandboxAttributeBuilder, | ||
SandboxAgeVerificationBuilder, | ||
SandboxAnchorBuilder, | ||
TokenRequestBuilder, | ||
}; |
Oops, something went wrong.