-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathshare.url.controller.js
51 lines (42 loc) · 1.18 KB
/
share.url.controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const Yoti = require('yoti');
const config = require('../config');
const yotiClient = new Yoti.Client(config.CLIENT_SDK_ID, config.PEM_KEY);
const identityProfileRequirementsDescriptors = {
RTW: {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'RTW',
},
},
RTR: {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'RTR',
},
},
DBS_BASIC: {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'DBS',
objective: 'BASIC',
},
},
};
module.exports = async (req, res) => {
const { scheme } = req.query;
const identityProfileRequirementsDescriptor = identityProfileRequirementsDescriptors[scheme];
const subject = {
subject_id: 'subject_id_string',
};
const dynamicPolicy = new Yoti.DynamicPolicyBuilder()
.withIdentityProfileRequirements(identityProfileRequirementsDescriptor)
.build();
const dynamicScenario = new Yoti.DynamicScenarioBuilder()
.withCallbackEndpoint('/identity-profile-report')
.withPolicy(dynamicPolicy)
.withSubject(subject)
.build();
const shareUrlResult = await yotiClient.createShareUrl(dynamicScenario);
const shareUrl = shareUrlResult.getShareUrl();
res.json({ shareUrl });
};