@verii/server-credentialagent 1.1.0-pre.1765354771 → 1.1.0-pre.1765441856

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verii/server-credentialagent",
3
- "version": "1.1.0-pre.1765354771",
3
+ "version": "1.1.0-pre.1765441856",
4
4
  "description": "Credential Agent application",
5
5
  "main": "src/index.js",
6
6
  "repository": "https://github.com/LFDT-Verii/core",
@@ -40,31 +40,31 @@
40
40
  "@fastify/view": "^11.0.0",
41
41
  "@spencejs/spence-factories": "^0.10.2",
42
42
  "@spencejs/spence-mongo-repos": "^0.10.2",
43
- "@verii/auth": "1.1.0-pre.1765354771",
44
- "@verii/base-contract-io": "1.1.0-pre.1765354771",
45
- "@verii/blockchain-functions": "1.1.0-pre.1765354771",
46
- "@verii/common-fetchers": "1.1.0-pre.1765354771",
47
- "@verii/common-functions": "1.1.0-pre.1765354771",
48
- "@verii/common-schemas": "1.1.0-pre.1765354771",
49
- "@verii/config": "1.1.0-pre.1765354771",
50
- "@verii/contract-permissions": "1.1.0-pre.1765354771",
51
- "@verii/crypto": "1.1.0-pre.1765354771",
52
- "@verii/csv-parser": "1.1.0-pre.1765354771",
53
- "@verii/db-kms": "1.1.0-pre.1765354771",
54
- "@verii/did-doc": "1.1.0-pre.1765354771",
55
- "@verii/fastify-plugins": "1.1.0-pre.1765354771",
56
- "@verii/http-client": "1.1.0-pre.1765354771",
57
- "@verii/jwt": "1.1.0-pre.1765354771",
58
- "@verii/metadata-registration": "1.1.0-pre.1765354771",
59
- "@verii/organizations-registry": "1.1.0-pre.1765354771",
60
- "@verii/rest-queries": "1.1.0-pre.1765354771",
61
- "@verii/server-provider": "1.1.0-pre.1765354771",
62
- "@verii/spencer-mongo-extensions": "1.1.0-pre.1765354771",
63
- "@verii/test-regexes": "1.1.0-pre.1765354771",
64
- "@verii/validation": "1.1.0-pre.1765354771",
65
- "@verii/vc-checks": "1.1.0-pre.1765354771",
66
- "@verii/verii-issuing": "1.1.0-pre.1765354771",
67
- "@verii/verii-verification": "1.1.0-pre.1765354771",
43
+ "@verii/auth": "1.1.0-pre.1765441856",
44
+ "@verii/base-contract-io": "1.1.0-pre.1765441856",
45
+ "@verii/blockchain-functions": "1.1.0-pre.1765441856",
46
+ "@verii/common-fetchers": "1.1.0-pre.1765441856",
47
+ "@verii/common-functions": "1.1.0-pre.1765441856",
48
+ "@verii/common-schemas": "1.1.0-pre.1765441856",
49
+ "@verii/config": "1.1.0-pre.1765441856",
50
+ "@verii/contract-permissions": "1.1.0-pre.1765441856",
51
+ "@verii/crypto": "1.1.0-pre.1765441856",
52
+ "@verii/csv-parser": "1.1.0-pre.1765441856",
53
+ "@verii/db-kms": "1.1.0-pre.1765441856",
54
+ "@verii/did-doc": "1.1.0-pre.1765441856",
55
+ "@verii/fastify-plugins": "1.1.0-pre.1765441856",
56
+ "@verii/http-client": "1.1.0-pre.1765441856",
57
+ "@verii/jwt": "1.1.0-pre.1765441856",
58
+ "@verii/metadata-registration": "1.1.0-pre.1765441856",
59
+ "@verii/organizations-registry": "1.1.0-pre.1765441856",
60
+ "@verii/rest-queries": "1.1.0-pre.1765441856",
61
+ "@verii/server-provider": "1.1.0-pre.1765441856",
62
+ "@verii/spencer-mongo-extensions": "1.1.0-pre.1765441856",
63
+ "@verii/test-regexes": "1.1.0-pre.1765441856",
64
+ "@verii/validation": "1.1.0-pre.1765441856",
65
+ "@verii/vc-checks": "1.1.0-pre.1765441856",
66
+ "@verii/verii-issuing": "1.1.0-pre.1765441856",
67
+ "@verii/verii-verification": "1.1.0-pre.1765441856",
68
68
  "ajv": "8.17.1",
69
69
  "canonicalize": "^2.1.0",
70
70
  "date-fns": "~4.1.0",
@@ -83,10 +83,10 @@
83
83
  },
84
84
  "devDependencies": {
85
85
  "@spencejs/spence-config": "0.10.2",
86
- "@verii/endpoints-organizations-registrar": "1.1.0-pre.1765354771",
87
- "@verii/sample-data": "1.1.0-pre.1765354771",
86
+ "@verii/endpoints-organizations-registrar": "1.1.0-pre.1765441856",
87
+ "@verii/sample-data": "1.1.0-pre.1765441856",
88
88
  "@verii/test-regexes": "0.5.0-build",
89
- "@verii/tests-helpers": "1.1.0-pre.1765354771",
89
+ "@verii/tests-helpers": "1.1.0-pre.1765441856",
90
90
  "cheerio": "1.1.2",
91
91
  "dotenv": "16.6.1",
92
92
  "eslint": "8.57.1",
@@ -107,5 +107,5 @@
107
107
  "prettier": "2.8.8",
108
108
  "qs": "6.14.0"
109
109
  },
110
- "gitHead": "95b0dfb9c8d00b85e3c0ca240ea38048505a8681"
110
+ "gitHead": "65907afa06a773fbe9c544abc54c6e7fb807a427"
111
111
  }
@@ -22,6 +22,7 @@ const {
22
22
  forEach,
23
23
  isEmpty,
24
24
  values,
25
+ identity,
25
26
  } = require('lodash/fp');
26
27
  const { nanoid } = require('nanoid');
27
28
  const fastifyView = require('@fastify/view');
@@ -81,6 +82,19 @@ const appRedirectController = async (fastify) => {
81
82
  items: { type: 'string' },
82
83
  },
83
84
  inspectorDid: { type: 'array', items: { type: 'string' } },
85
+ providers: {
86
+ type: 'array',
87
+ items: {
88
+ type: 'object',
89
+ properties: {
90
+ name: { type: 'string' },
91
+ logo: { type: 'string' },
92
+ category: { type: 'string' },
93
+ id: { type: 'string' },
94
+ },
95
+ required: ['name', 'id', 'logo', 'category'],
96
+ },
97
+ },
84
98
  },
85
99
  required: ['request_uri', 'exchange_type'],
86
100
  },
@@ -124,9 +138,13 @@ const appRedirectController = async (fastify) => {
124
138
  };
125
139
 
126
140
  const validateInspectorDid = ({ exchangeType, inspectorDid }) => {
127
- if (exchangeType === EXCHANGE_TYPE.inspect && isEmpty(inspectorDid)) {
141
+ if (
142
+ (exchangeType === EXCHANGE_TYPE.inspect ||
143
+ exchangeType === EXCHANGE_TYPE.claim) &&
144
+ isEmpty(inspectorDid)
145
+ ) {
128
146
  throw new Error.BadRequest(
129
- 'inspectorDid should be present for exchange_type = "inspect"'
147
+ `inspectorDid should be present for exchange_type = "${exchangeType}"`
130
148
  );
131
149
  }
132
150
  if (exchangeType === EXCHANGE_TYPE.issue && !isEmpty(inspectorDid)) {
@@ -143,6 +161,7 @@ const processingLinks = (context) => {
143
161
  request_uri: requestUriItems,
144
162
  inspectorDid: inspectorDidItems = [],
145
163
  vendorOriginContext: vendorOriginContextItems = [],
164
+ providers: providersItems,
146
165
  },
147
166
  } = context;
148
167
 
@@ -152,17 +171,29 @@ const processingLinks = (context) => {
152
171
  requestUri: value,
153
172
  vendorOriginContext: vendorOriginContextItems[index],
154
173
  inspectorDid: inspectorDidItems[index],
174
+ ...(providersItems ? { providers: providersItems } : {}),
155
175
  }))
156
176
  )(requestUriItems);
157
177
 
158
178
  const deeplink = createDeepLinkUrl(exchangeType, context);
159
- forEach(({ requestUri, inspectorDid, vendorOriginContext }) => {
160
- flow(
161
- appendSearchParam('request_uri', requestUri),
162
- appendSearchParam('inspectorDid', inspectorDid),
163
- appendSearchParam('vendorOriginContext', vendorOriginContext)
164
- )(deeplink);
165
- }, parsedLinks);
179
+ forEach(
180
+ ({
181
+ requestUri,
182
+ inspectorDid,
183
+ vendorOriginContext,
184
+ providers: providersItem,
185
+ }) => {
186
+ const appendParams = flow(
187
+ appendSearchParam('request_uri', requestUri),
188
+ appendSearchParam('inspectorDid', inspectorDid),
189
+ appendSearchParam('vendorOriginContext', vendorOriginContext),
190
+ providersItem ? appendSearchParam('providers', providersItem) : identity
191
+ );
192
+
193
+ appendParams(deeplink);
194
+ },
195
+ parsedLinks
196
+ );
166
197
 
167
198
  return { deeplink };
168
199
  };
@@ -17,6 +17,7 @@
17
17
  const EXCHANGE_TYPE = {
18
18
  inspect: 'inspect',
19
19
  issue: 'issue',
20
+ claim: 'claim.wizard',
20
21
  };
21
22
 
22
23
  module.exports = {
@@ -126,6 +126,18 @@ describe('app redirect controller test', () => {
126
126
  );
127
127
  });
128
128
 
129
+ it('should 400 if exchange_type is claim.wizard and inspectorDid not provided', async () => {
130
+ setupNock();
131
+ const response = await fastify.injectJson({
132
+ method: 'GET',
133
+ url: `${appRedirectUrl}?request_uri=uri&exchange_type=claim.wizard`,
134
+ });
135
+ expect(response.statusCode).toEqual(400);
136
+ expect(response.json.message).toEqual(
137
+ 'inspectorDid should be present for exchange_type = "claim.wizard"'
138
+ );
139
+ });
140
+
129
141
  it('should 400 if exchange_type is not one of allowed values', async () => {
130
142
  setupNock();
131
143
  const response = await fastify.injectJson({
@@ -187,7 +199,7 @@ describe('app redirect controller test', () => {
187
199
  expect(scriptTag.attr('nonce')).toEqual(nonceFromCspHeader);
188
200
  });
189
201
 
190
- it('should include vnf wallet selection mount point', async () => {
202
+ it('should include vnf wallet selection mount point if inspect', async () => {
191
203
  const url =
192
204
  // eslint-disable-next-line max-len
193
205
  'http%3A%2F%2Flocalhost.test%2Fapi%2Fholder%2Fv0.6%2Forg%2Fdid%3Aion%3A4131209321321323123e%2Fissue%2Fget-credential-manifest%3Fexchange_id%3D5f123eab4362bb2e%26credential_types%3DPastEmploymentPosition%26id%3DsecretId';
@@ -205,4 +217,26 @@ describe('app redirect controller test', () => {
205
217
  expect(scriptTag.attr('data-deeplink')).toEqual(deeplink);
206
218
  expect(scriptTag.attr('data-automode')).toEqual('');
207
219
  });
220
+
221
+ it('should include vnf wallet selection mount point if claim.wizard', async () => {
222
+ setupNock();
223
+ const url =
224
+ // eslint-disable-next-line max-len
225
+ 'http%3A%2F%2Flocalhost.test%2Fapi%2Fholder%2Fv0.6%2Forg%2Fdid%3Aion%3A4131209321321323123e%2Fissue%2Fget-credential-manifest%3Fexchange_id%3D5f123eab4362bb2e%26credential_types%3DPastEmploymentPosition%26id%3DsecretId';
226
+ const response = await fastify.injectJson({
227
+ method: 'GET',
228
+ // eslint-disable-next-line max-len
229
+ url: `${appRedirectUrl}?request_uri=${url}&exchange_type=claim.wizard&inspectorDid=321123providers=%5B%7B%22logo%22%3A%22https%3A//upload.wikimedia.org/wikipedia/commons/a/aa/LinkedIn_2021.svg%22%2C%22name%22%3A%22LinkedIn%22%2C%22category%22%3A%22Personal%20Records%22%2C%22id%22%3A%22a9f1063c-06b7-476a-8410-9ff6e427e637%22%7D%2C%7B%22logo%22%3A%22https%3A//logos-world.net/wp-content/uploads/2020/11/GitHub-Emblem.png%22%2C%22name%22%3A%22GitHub%22%2C%22category%22%3A%22User%20Profile%22%2C%22id%22%3A%226d3f6753-7ee6-49ee-a545-62f1b1822ae5%22%7D%5D`,
230
+ });
231
+
232
+ expect(response.statusCode).toEqual(200);
233
+ const $ = cheerio.load(response.body);
234
+
235
+ const scriptTag = $('html > body > #vnf-wallet-selection');
236
+ const deeplink =
237
+ // eslint-disable-next-line max-len
238
+ 'velocity-test://claim.wizard?request_uri=http%3A%2F%2Flocalhost.test%2Fapi%2Fholder%2Fv0.6%2Forg%2Fdid%3Aion%3A4131209321321323123e%2Fissue%2Fget-credential-manifest%3Fexchange_id%3D5f123eab4362bb2e%26credential_types%3DPastEmploymentPosition%26id%3DsecretId&inspectorDid=321123providers%3D%5B%7B%22logo%22%3A%22https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fa%2Faa%2FLinkedIn_2021.svg%22%2C%22name%22%3A%22LinkedIn%22%2C%22category%22%3A%22Personal+Records%22%2C%22id%22%3A%22a9f1063c-06b7-476a-8410-9ff6e427e637%22%7D%2C%7B%22logo%22%3A%22https%3A%2F%2Flogos-world.net%2Fwp-content%2Fuploads%2F2020%2F11%2FGitHub-Emblem.png%22%2C%22name%22%3A%22GitHub%22%2C%22category%22%3A%22User+Profile%22%2C%22id%22%3A%226d3f6753-7ee6-49ee-a545-62f1b1822ae5%22%7D%5D';
239
+ expect(scriptTag.attr('data-deeplink')).toEqual(deeplink);
240
+ expect(scriptTag.attr('data-automode')).toEqual('');
241
+ });
208
242
  });