Skip to content

Commit a9390c2

Browse files
Merge pull request #116 from getyoti/release-3.8.0
Release 3.8.0
2 parents 510df5d + cbb1410 commit a9390c2

File tree

76 files changed

+2985
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2985
-183
lines changed

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,10 @@ jobs:
5555
- cd ./examples/profile
5656
- npm update
5757
- npm run lint
58-
58+
- stage: Coverage
59+
name: Coveralls
60+
if: type = pull_request OR branch = master
61+
node_js: "10"
62+
install: npm install
63+
script:
64+
- npm run coveralls

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Yoti NodeJS SDK
22

33
[![Build Status](https://travis-ci.com/getyoti/yoti-node-sdk.svg?branch=master)](https://travis-ci.com/getyoti/yoti-node-sdk)
4+
[![Coverage Status](https://coveralls.io/repos/github/getyoti/yoti-node-sdk/badge.svg?branch=master)](https://coveralls.io/github/getyoti/yoti-node-sdk?branch=master)
45

56
Welcome to the Yoti NodeJS SDK. This repo contains the tools and step by step instructions you need to quickly integrate your NodeJS back-end with Yoti so that your users can share their identity details with your application in a secure and trusted way.
67

config/protobuf.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,22 @@ const PROTO_BUFF_COMMON_API_PATH = path.resolve(`${PROTO_BUFF_PATH}/common-publi
1313
const CORE_ENCRYPTED_DATA_PROTO_BUFF_PATH = path.resolve(`${PROTO_BUFF_COMMON_API_PATH}/EncryptedData.proto`);
1414
const CORE_SIGNED_TIMESTAMP_PROTO__BUFF_PATH = path.resolve(`${PROTO_BUFF_COMMON_API_PATH}/SignedTimeStamp.proto`);
1515

16+
const PROTO_BUFF_SHARE_API_PATH = path.resolve(`${PROTO_BUFF_PATH}/share-public-api/sharepubapi_v1`);
17+
const CORE_EXTRA_DATA_PROTO_BUFF_PATH = path.resolve(`${PROTO_BUFF_SHARE_API_PATH}/ExtraData.proto`);
18+
const CORE_DATA_ENTRY_PROTO_BUFF_PATH = path.resolve(`${PROTO_BUFF_SHARE_API_PATH}/DataEntry.proto`);
19+
const CORE_THIRD_PARTY_ATTRIBUTE_PROTO_BUFF_PATH = path.resolve(`${PROTO_BUFF_SHARE_API_PATH}/ThirdPartyAttribute.proto`);
20+
const CORE_ISSUING_ATTRIBUTES_PROTO_BUFF_PATH = path.resolve(`${PROTO_BUFF_SHARE_API_PATH}/IssuingAttributes.proto`);
21+
1622
module.exports = {
1723
PROTO_BUFF_PATH,
1824
PROTO_BUFF_ATTRIBUTE_API_PATH,
1925
CORE_ATTRIBUTE_LIST_PROTO_BUFF_PATH,
2026
PROTO_BUFF_COMMON_API_PATH,
2127
CORE_ENCRYPTED_DATA_PROTO_BUFF_PATH,
2228
CORE_SIGNED_TIMESTAMP_PROTO__BUFF_PATH,
29+
PROTO_BUFF_SHARE_API_PATH,
30+
CORE_EXTRA_DATA_PROTO_BUFF_PATH,
31+
CORE_DATA_ENTRY_PROTO_BUFF_PATH,
32+
CORE_THIRD_PARTY_ATTRIBUTE_PROTO_BUFF_PATH,
33+
CORE_ISSUING_ATTRIBUTES_PROTO_BUFF_PATH,
2334
};

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ const Client = require('./src/client').YotiClient;
44
const { AmlAddress, AmlProfile } = require('./src/aml_type');
55
const { RequestBuilder } = require('./src/request/request.builder');
66
const { Payload } = require('./src/request/payload');
7+
const { YotiDate } = require('./src/data_type/date');
78

89
const {
910
DynamicScenarioBuilder,
1011
DynamicPolicyBuilder,
1112
WantedAttributeBuilder,
1213
ExtensionBuilder,
1314
LocationConstraintExtensionBuilder,
15+
ThirdPartyAttributeExtensionBuilder,
1416
TransactionalFlowExtensionBuilder,
1517
WantedAnchorBuilder,
1618
ConstraintsBuilder,
@@ -26,10 +28,12 @@ module.exports = {
2628
WantedAttributeBuilder,
2729
ExtensionBuilder,
2830
LocationConstraintExtensionBuilder,
31+
ThirdPartyAttributeExtensionBuilder,
2932
TransactionalFlowExtensionBuilder,
3033
WantedAnchorBuilder,
3134
ConstraintsBuilder,
3235
SourceConstraintBuilder,
3336
RequestBuilder,
3437
Payload,
38+
YotiDate,
3539
};

package-lock.json

Lines changed: 51 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yoti",
3-
"version": "3.7.3",
3+
"version": "3.8.0",
44
"description": "Yoti NodeJS SDK for back-end integration",
55
"author": "Yoti LTD <tech@yoti.com> (https://www.yoti.com/developers)",
66
"license": "MIT",
@@ -9,12 +9,13 @@
99
"url": "https://github.com/getyoti/yoti-node-sdk.git"
1010
},
1111
"engines": {
12-
"node": ">=8.0.0"
12+
"node": ">=6"
1313
},
1414
"scripts": {
15-
"lint": "node_modules/.bin/eslint *.js './src/**/*.js' './tests/**/*.spec.js' config/*.js",
16-
"unit-test": "node_modules/.bin/jest",
17-
"test": "npm run lint && npm run unit-test"
15+
"lint": "eslint *.js './src/**/*.js' './tests/**/*.spec.js' config/*.js './sandbox/**/*.js'",
16+
"unit-test": "jest",
17+
"test": "npm run lint && npm run unit-test",
18+
"coveralls": "npm run unit-test && cat ./coverage/lcov.info | coveralls"
1819
},
1920
"husky": {
2021
"hooks": {
@@ -27,6 +28,7 @@
2728
"collectCoverageFrom": [
2829
"./*.js",
2930
"./src/**/*.js",
31+
"./sandbox/**/*.js",
3032
"!**/node_modules/**",
3133
"!**/vendor/**"
3234
],
@@ -42,6 +44,7 @@
4244
"uuid": "^3.3.2"
4345
},
4446
"devDependencies": {
47+
"coveralls": "^3.0.7",
4548
"eslint": "^4.19.1",
4649
"eslint-config-airbnb-base": "^12.1.0",
4750
"eslint-plugin-import": "^2.18.2",

sandbox/client.builder.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
const SandboxClient = require('./client');
3+
const Validation = require('../src/yoti_common/validation');
4+
const fs = require('fs');
5+
6+
/**
7+
* @class SandboxClientBuilder
8+
*/
9+
class SandboxClientBuilder {
10+
/**
11+
* @param {string} appId
12+
*/
13+
forApplication(appId) {
14+
this.appId = appId;
15+
return this;
16+
}
17+
18+
/**
19+
* @param {string} pemString
20+
*
21+
* @returns {SandboxClientBuilder}
22+
*/
23+
withPemString(pem) {
24+
Validation.isString(pem, 'pem');
25+
this.pem = pem;
26+
return this;
27+
}
28+
29+
/**
30+
* @param {string} filePath
31+
*
32+
* @returns {SandboxClientBuilder}
33+
*/
34+
withPemFilePath(filePath) {
35+
Validation.isString(filePath, 'filePath');
36+
return this.withPemString(fs.readFileSync(filePath, 'utf8'));
37+
}
38+
39+
/**
40+
* @param {string} sandboxUrl
41+
*
42+
* @returns {SandboxClientBuilder}
43+
*/
44+
withSandboxUrl(sandboxUrl) {
45+
this.sandboxUrl = sandboxUrl;
46+
return this;
47+
}
48+
49+
/**
50+
* @returns {SandboxClient}
51+
*/
52+
build() {
53+
return new SandboxClient(this.appId, this.pem, this.sandboxUrl);
54+
}
55+
}
56+
57+
module.exports = SandboxClientBuilder;

sandbox/client.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
const { RequestBuilder } = require('../src/request/request.builder');
3+
const TokenResponse = require('./profile/response/token');
4+
const { Payload } = require('../src/request/payload');
5+
const Validation = require('../src/yoti_common/validation');
6+
7+
/**
8+
* @class SandboxClient
9+
*/
10+
class SandboxClient {
11+
/**
12+
* @param {string} appId
13+
* @param {string} pem
14+
* @param {string} sandboxUrl
15+
*/
16+
constructor(appId, pem, sandboxUrl) {
17+
Validation.isString(appId, 'appId');
18+
this.appId = appId;
19+
this.endpoint = `/apps/${appId}/tokens`;
20+
21+
Validation.isString(pem, 'pem');
22+
this.pem = pem;
23+
24+
Validation.isString(sandboxUrl, 'sandboxUrl');
25+
this.sandboxUrl = sandboxUrl;
26+
}
27+
28+
/**
29+
* @param {TokenRequest} tokenRequest
30+
*
31+
* @returns {Promise}
32+
*/
33+
setupSharingProfile(tokenRequest) {
34+
const request = (new RequestBuilder())
35+
.withBaseUrl(this.sandboxUrl)
36+
.withEndpoint(this.endpoint)
37+
.withPemString(this.pem)
38+
.withPayload(new Payload(tokenRequest))
39+
.withPost()
40+
.build();
41+
42+
return new Promise((resolve, reject) => {
43+
request.execute()
44+
.then((response) => {
45+
try {
46+
return resolve(new TokenResponse(response.getParsedResponse()));
47+
} catch (err) {
48+
console.log(`Error getting response data: ${err}`);
49+
return reject(err);
50+
}
51+
})
52+
.catch((err) => {
53+
console.log(`Error retrieving requested data: ${err}`);
54+
return reject(err);
55+
});
56+
});
57+
}
58+
}
59+
60+
module.exports = SandboxClient;

sandbox/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const SandboxClientBuilder = require('./client.builder');
2+
const SandboxAttributeBuilder = require('./profile/request/attribute/attribute.builder');
3+
const SandboxAgeVerificationBuilder = require('./profile/request/attribute/derivation/age.verification.builder');
4+
const SandboxAnchorBuilder = require('./profile/request/attribute/anchor.builder');
5+
const TokenRequestBuilder = require('./profile/request/token.builder');
6+
7+
module.exports = {
8+
SandboxClientBuilder,
9+
SandboxAttributeBuilder,
10+
SandboxAgeVerificationBuilder,
11+
SandboxAnchorBuilder,
12+
TokenRequestBuilder,
13+
};

0 commit comments

Comments
 (0)