@velocitycareerlabs/server-webwallet 1.25.0-dev-build.1f73bb0fe → 1.25.0-dev-build.187d88673

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/.localdev.env CHANGED
@@ -17,6 +17,7 @@ AWS_ACCESS_KEY_ID=EMPTY
17
17
  AWS_REGION=us-east-1
18
18
  AWS_ENDPOINT=http://host.docker.internal:4566
19
19
  REGISTRAR_URL=http://localhost:3002
20
+ VERIFICATION_SERVICE_ACTION_BASE_URL=http://localhost:3005
20
21
  LIB_URL=http://lib.localhost.test
21
22
  HOST_URL=http://localhost:3010
22
23
  YOTI_CLIENT_SDK_ID=024e10dd-fc2a-4352-b13e-ad5e3853d14a
package/.standalone.env CHANGED
@@ -4,6 +4,7 @@ MONGO_URI=mongodb://localhost:27017/webwallet-dev
4
4
  AWS_ENDPOINT=http://localhost:4566
5
5
  REGISTRAR_URL=http://localhost:3002
6
6
  LIB_URL=http://lib.localhost.test
7
+ VERIFICATION_SERVICE_ACTION_BASE_URL=https://devapi.verifymycreds.com/holder-api/org/did:web:devregistrar.velocitynetwork.foundation:d:rv0pybdkpp.example.com
7
8
  HOST_URL=http://localhost:3010
8
9
  AGENT_URL=http://localhost:3004
9
10
  SENTRY_DSN=https://883a3bd7c4254d7890fe0f34bd07726c@o460076.ingest.sentry.io/6234089
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/server-webwallet",
3
- "version": "1.25.0-dev-build.1f73bb0fe",
3
+ "version": "1.25.0-dev-build.187d88673",
4
4
  "description": "Web Wallet application",
5
5
  "repository": "https://github.com/velocitycareerlabs/packages",
6
6
  "engines": {
@@ -28,17 +28,17 @@
28
28
  "@fastify/autoload": "5.10.0",
29
29
  "@fastify/multipart": "~8.3.1",
30
30
  "@spencejs/spence-mongo-repos": "^0.10.2",
31
- "@velocitycareerlabs/auth": "1.25.0-dev-build.1f73bb0fe",
32
- "@velocitycareerlabs/common-functions": "1.25.0-dev-build.1f73bb0fe",
33
- "@velocitycareerlabs/common-schemas": "1.25.0-dev-build.1f73bb0fe",
34
- "@velocitycareerlabs/config": "1.25.0-dev-build.1f73bb0fe",
35
- "@velocitycareerlabs/fastify-plugins": "1.25.0-dev-build.1f73bb0fe",
36
- "@velocitycareerlabs/jwt": "1.25.0-dev-build.1f73bb0fe",
37
- "@velocitycareerlabs/migrations": "1.25.0-dev-build.1f73bb0fe",
38
- "@velocitycareerlabs/request": "1.25.0-dev-build.1f73bb0fe",
39
- "@velocitycareerlabs/server-provider": "1.25.0-dev-build.1f73bb0fe",
40
- "@velocitycareerlabs/vc-checks": "1.25.0-dev-build.1f73bb0fe",
41
- "@velocitycareerlabs/vnf-nodejs-wallet-sdk": "1.25.0-dev-build.1f73bb0fe",
31
+ "@velocitycareerlabs/auth": "1.25.0-dev-build.187d88673",
32
+ "@velocitycareerlabs/common-functions": "1.25.0-dev-build.187d88673",
33
+ "@velocitycareerlabs/common-schemas": "1.25.0-dev-build.187d88673",
34
+ "@velocitycareerlabs/config": "1.25.0-dev-build.187d88673",
35
+ "@velocitycareerlabs/fastify-plugins": "1.25.0-dev-build.187d88673",
36
+ "@velocitycareerlabs/jwt": "1.25.0-dev-build.187d88673",
37
+ "@velocitycareerlabs/migrations": "1.25.0-dev-build.187d88673",
38
+ "@velocitycareerlabs/request": "1.25.0-dev-build.187d88673",
39
+ "@velocitycareerlabs/server-provider": "1.25.0-dev-build.187d88673",
40
+ "@velocitycareerlabs/vc-checks": "1.25.0-dev-build.187d88673",
41
+ "@velocitycareerlabs/vnf-nodejs-wallet-sdk": "1.25.0-dev-build.187d88673",
42
42
  "blueimp-md5": "2.19.0",
43
43
  "env-var": "^7.0.0",
44
44
  "fastify": "4.29.0",
@@ -51,8 +51,8 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@spencejs/spence-factories": "0.10.2",
54
- "@velocitycareerlabs/crypto": "1.25.0-dev-build.1f73bb0fe",
55
- "@velocitycareerlabs/tests-helpers": "1.25.0-dev-build.1f73bb0fe",
54
+ "@velocitycareerlabs/crypto": "1.25.0-dev-build.187d88673",
55
+ "@velocitycareerlabs/tests-helpers": "1.25.0-dev-build.187d88673",
56
56
  "dotenv": "16.4.7",
57
57
  "eslint": "8.57.1",
58
58
  "eslint-config-airbnb-base": "14.2.1",
@@ -68,5 +68,5 @@
68
68
  "nodemon": "3.1.9",
69
69
  "prettier": "2.8.8"
70
70
  },
71
- "gitHead": "ff01736586ad75645f8a3efe1bed102866b116d1"
71
+ "gitHead": "1d2d8df9d97a371200284e189b8cd3592fd4ee0d"
72
72
  }
@@ -47,6 +47,10 @@ module.exports = {
47
47
  .required()
48
48
  .asEnum(Object.values(VCLXVnfProtocolVersion)),
49
49
  libUrl: env.get('LIB_URL').required().asString(),
50
+ verificationServiceActionBaseUrl: env
51
+ .get('VERIFICATION_SERVICE_ACTION_BASE_URL')
52
+ .required()
53
+ .asString(),
50
54
  deepLinkProtocol: env.get('DEEP_LINK_PROTOCOL').required().asString(),
51
55
  vclVerificationVersion: env
52
56
  .get('VCL_VERIFICATION_VERSION')
@@ -1,3 +1,4 @@
1
+ const newError = require('http-errors');
1
2
  const { jwtDecode } = require('@velocitycareerlabs/jwt');
2
3
  const {
3
4
  VCLPresentationSubmission,
@@ -6,6 +7,9 @@ const {
6
7
  VCLDidJwk,
7
8
  } = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
8
9
  const { getAppConfig } = require('../../fetchers/career-wallet/get-app-config');
10
+ const {
11
+ removeCredentials,
12
+ } = require('../../fetchers/credverify/remove-credentials');
9
13
 
10
14
  /**
11
15
  * @param {import('fastify').FastifyInstance} fastify
@@ -163,6 +167,52 @@ const disclosureController = async (fastify) => {
163
167
  return { disclosures };
164
168
  }
165
169
  );
170
+
171
+ fastify.delete(
172
+ '/:disclosureId',
173
+ {
174
+ preValidation: fastify.verifyAccessToken(),
175
+ schema: fastify.autoSchema({
176
+ params: {
177
+ type: 'object',
178
+ properties: {
179
+ disclosureId: { type: 'string' },
180
+ },
181
+ },
182
+ response: {
183
+ 204: { type: 'null' },
184
+ },
185
+ }),
186
+ },
187
+ async (req, reply) => {
188
+ const {
189
+ repos: { disclosures: disclosuresRepo },
190
+ params,
191
+ user,
192
+ } = req;
193
+ const disclosure = await disclosuresRepo.findOne({
194
+ filter: { _id: params.disclosureId, auth0UserId: user.sub },
195
+ });
196
+
197
+ if (!disclosure) {
198
+ throw newError.NotFound(`Disclosure ${params.credentialId} not found`);
199
+ }
200
+
201
+ await removeCredentials(
202
+ {
203
+ presentationId: disclosure.jti,
204
+ exchangeId: disclosure.presentation.exchange_id,
205
+ },
206
+ req
207
+ );
208
+
209
+ await disclosuresRepo.update(params.disclosureId, {
210
+ deletedAt: new Date(),
211
+ });
212
+
213
+ reply.code(204);
214
+ }
215
+ );
166
216
  };
167
217
 
168
218
  module.exports = disclosureController;
@@ -23,9 +23,22 @@ module.exports = (app, _, next = () => {}) => {
23
23
  type: 1,
24
24
  createdAt: 1,
25
25
  updatedAt: 1,
26
+ deletedAt: 1,
26
27
  },
27
- extensions: [autoboxIdsExtension],
28
+ extensions: [autoboxIdsExtension, filterDeletedDisclosuresExtension],
28
29
  },
29
30
  app
30
31
  );
31
32
  };
33
+
34
+ const filterDeletedDisclosuresExtension = (parent) => {
35
+ return {
36
+ prepFilter: (filter) => {
37
+ return parent.prepFilter({
38
+ ...filter,
39
+ deletedAt: filter.deletedAt ?? { $exists: false },
40
+ });
41
+ },
42
+ extensions: parent.extensions.concat(['filterDeletedDisclosuresExtension']),
43
+ };
44
+ };
@@ -0,0 +1,17 @@
1
+ const removeCredentials = (
2
+ payload,
3
+ { verificationServiceActionFetch, config }
4
+ ) => {
5
+ return verificationServiceActionFetch
6
+ .post('remove-credentials', {
7
+ json: payload,
8
+ headers: {
9
+ Authorization: `Bearer ${config.careerWalletAdminAccessToken}`,
10
+ },
11
+ })
12
+ .json();
13
+ };
14
+
15
+ module.exports = {
16
+ removeCredentials,
17
+ };
@@ -60,6 +60,18 @@ const initServer = (server) => {
60
60
  .addHook('preValidation', async (req) => {
61
61
  req.libFetch = server.baseLibFetch(req);
62
62
  })
63
+ .decorate(
64
+ 'baseVerificationServiceActionFetch',
65
+ initRequest({
66
+ ...pick(['nodeEnv', 'requestTimeout', 'traceIdHeader'], server.config),
67
+ prefixUrl: server.config.verificationServiceActionBaseUrl,
68
+ })
69
+ )
70
+ .decorateRequest('verificationServiceActionFetch', null)
71
+ .addHook('preValidation', async (req) => {
72
+ req.verificationServiceActionFetch =
73
+ server.baseVerificationServiceActionFetch(req);
74
+ })
63
75
  .decorate(
64
76
  'baseCareerWalletFetch',
65
77
  initRequest({
@@ -1,6 +1,9 @@
1
1
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
2
  const { omit } = require('lodash/fp');
3
3
  const nock = require('nock');
4
+ const { mongoify } = require('@velocitycareerlabs/tests-helpers');
5
+ const { ObjectId } = require('mongodb');
6
+ const { nockRemoveCredentials } = require('../helpers/nock-remove-credentials');
4
7
 
5
8
  const buildFastify = require('../helpers/webwallet-build-fastify');
6
9
  const initDisclosuresFactory = require('../factories/disclosures');
@@ -24,9 +27,9 @@ jest.mock('@velocitycareerlabs/vnf-nodejs-wallet-sdk', () => {
24
27
  };
25
28
  });
26
29
 
27
- describe('Test Disclosures controller, get disclosures list', () => {
30
+ let persistDisclosures;
31
+ describe('Test Disclosures controller, get disclosures list, delete disclosure', () => {
28
32
  let fastify;
29
- let persistDisclosures;
30
33
 
31
34
  beforeAll(async () => {
32
35
  fastify = buildFastify();
@@ -123,6 +126,46 @@ describe('Test Disclosures controller, get disclosures list', () => {
123
126
  expect(response.statusCode).toBe(401);
124
127
  });
125
128
  });
129
+
130
+ describe('DELETE /disclosures/:disclosureId - delete disclosure by id', () => {
131
+ it('should delete disclosure by id', async () => {
132
+ ({ persistDisclosures } = initDisclosuresFactory(fastify));
133
+ const disclosure = await persistDisclosures();
134
+ // eslint-disable-next-line no-console
135
+ console.log(disclosure);
136
+
137
+ const nockInstance = nock(
138
+ fastify.config.verificationServiceActionBaseUrl
139
+ );
140
+ nockRemoveCredentials(nockInstance);
141
+
142
+ const response = await fastify.injectJson({
143
+ method: 'DELETE',
144
+ url: `/disclosures/${disclosure._id}`,
145
+ headers: {
146
+ authorization: `Bearer ${auth0Token}`,
147
+ },
148
+ });
149
+
150
+ expect(response.statusCode).toBe(204);
151
+
152
+ expect(
153
+ await mongoDb()
154
+ .collection('disclosures')
155
+ .findOne({
156
+ _id: new ObjectId(disclosure._id),
157
+ })
158
+ ).toEqual(
159
+ mongoify({
160
+ ...disclosure,
161
+ presentation: expect.any(Object),
162
+ sharedCredentials: expect.any(Array),
163
+ updatedAt: expect.any(Date),
164
+ deletedAt: expect.any(Date),
165
+ })
166
+ );
167
+ });
168
+ });
126
169
  });
127
170
 
128
171
  const jwks = {
@@ -4,6 +4,7 @@ OAUTH0_DOMAIN=https://localhost/
4
4
  OAUTH0_WEBAPP_CLIENT_ID=foo
5
5
  AUTH0_WEB_WALLET_AUDIENCE=foo
6
6
  LIB_URL=http://lib.localhost.test
7
+ VERIFICATION_SERVICE_ACTION_BASE_URL=http://credverify.localhost.tes
7
8
  VCL_SDK_ENVIRONMENT=dev
8
9
  VCL_SDK_VNF_PROTOCOL_VERSION=2.0
9
10
  WEB_WALLET_BASE_URL=localhost:3000
@@ -0,0 +1,7 @@
1
+ const nockRemoveCredentials = (nockInstance) => {
2
+ nockInstance.post('/remove-credentials').reply(204, {});
3
+ };
4
+
5
+ module.exports = {
6
+ nockRemoveCredentials,
7
+ };