@velocitycareerlabs/server-webwallet 1.26.0-dev-build.1f5f235dd → 1.26.0-dev-build.1a6aed3a4

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": "@velocitycareerlabs/server-webwallet",
3
- "version": "1.26.0-dev-build.1f5f235dd",
3
+ "version": "1.26.0-dev-build.1a6aed3a4",
4
4
  "description": "Web Wallet application",
5
5
  "repository": "https://github.com/velocitycareerlabs/packages",
6
6
  "engines": {
@@ -8,7 +8,8 @@
8
8
  },
9
9
  "main": "src/index.js",
10
10
  "scripts": {
11
- "test": "jest --config ./jest.config.js --runInBand --coverage",
11
+ "test": "cross-env NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout 'test/**/*.test.js'",
12
+ "test:ci": "NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage --test-coverage-include='src/**' --test-reporter=spec --test-reporter=junit --test-reporter-destination=stdout --test-reporter-destination=test-results.junit.xml --test-reporter=lcov --test-reporter-destination=lcov.info 'test/**/*.test.js'",
12
13
  "up": "npm run start:debug",
13
14
  "start": "node src/index.js",
14
15
  "start:dev": "nodemon src/standalone.js",
@@ -33,17 +34,17 @@
33
34
  "@fastify/swagger": "^9.0.0",
34
35
  "@fastify/swagger-ui": "^5.0.0",
35
36
  "@spencejs/spence-mongo-repos": "^0.10.2",
36
- "@velocitycareerlabs/migrations": "1.26.0-dev-build.1f5f235dd",
37
- "@verii/auth": "1.0.0-pre.1757279740",
38
- "@verii/common-functions": "1.0.0-pre.1757279740",
39
- "@verii/common-schemas": "1.0.0-pre.1757279740",
40
- "@verii/config": "1.0.0-pre.1757279740",
41
- "@verii/fastify-plugins": "1.0.0-pre.1757279740",
42
- "@verii/jwt": "1.0.0-pre.1757279740",
43
- "@verii/request": "1.0.0-pre.1757279740",
44
- "@verii/server-provider": "1.0.0-pre.1757279740",
45
- "@verii/vc-checks": "1.0.0-pre.1757279740",
46
- "@verii/vnf-nodejs-wallet-sdk": "1.0.0-pre.1757279740",
37
+ "@velocitycareerlabs/migrations": "1.26.0-dev-build.1a6aed3a4",
38
+ "@verii/auth": "1.0.0-pre.1757456926",
39
+ "@verii/common-functions": "1.0.0-pre.1757456926",
40
+ "@verii/common-schemas": "1.0.0-pre.1757456926",
41
+ "@verii/config": "1.0.0-pre.1757456926",
42
+ "@verii/fastify-plugins": "1.0.0-pre.1757456926",
43
+ "@verii/jwt": "1.0.0-pre.1757456926",
44
+ "@verii/request": "1.0.0-pre.1757456926",
45
+ "@verii/server-provider": "1.0.0-pre.1757456926",
46
+ "@verii/vc-checks": "1.0.0-pre.1757456926",
47
+ "@verii/vnf-nodejs-wallet-sdk": "1.0.0-pre.1757456926",
47
48
  "blueimp-md5": "2.19.0",
48
49
  "env-var": "^7.0.0",
49
50
  "fastify": "^5.0.0",
@@ -56,8 +57,8 @@
56
57
  },
57
58
  "devDependencies": {
58
59
  "@spencejs/spence-factories": "0.10.2",
59
- "@verii/crypto": "1.0.0-pre.1757279740",
60
- "@verii/tests-helpers": "1.0.0-pre.1757279740",
60
+ "@verii/crypto": "1.0.0-pre.1757456926",
61
+ "@verii/tests-helpers": "1.0.0-pre.1757456926",
61
62
  "dotenv": "16.6.1",
62
63
  "eslint": "8.57.1",
63
64
  "eslint-config-airbnb-base": "14.2.1",
@@ -68,10 +69,10 @@
68
69
  "eslint-plugin-prefer-arrow-functions": "3.6.2",
69
70
  "eslint-plugin-prettier": "4.2.5",
70
71
  "eslint-watch": "7.0.0",
71
- "jest": "29.7.0",
72
+ "expect": "29.7.0",
72
73
  "nock": "14.0.9",
73
74
  "nodemon": "3.1.10",
74
75
  "prettier": "2.8.8"
75
76
  },
76
- "gitHead": "8150ae28eac5fe570bea11453ae545c9f3dd74e5"
77
+ "gitHead": "ff57e717f15ed96719d3d3473902497913ee1cf5"
77
78
  }
@@ -1,26 +1,35 @@
1
+ const {
2
+ after,
3
+ afterEach,
4
+ before,
5
+ beforeEach,
6
+ describe,
7
+ it,
8
+ mock,
9
+ } = require('node:test');
10
+
11
+ const { expect } = require('expect');
12
+
1
13
  const usersDid = 'did:example:123';
2
- const mockGenerateDidJwk = jest.fn().mockResolvedValue(
3
- new Promise((resolve) => {
4
- resolve({
5
- did: usersDid,
6
- publicJwk: {},
7
- kid: '',
8
- keyId: '',
9
- });
14
+ const mockGenerateDidJwk = mock.fn(() =>
15
+ Promise.resolve({
16
+ did: usersDid,
17
+ publicJwk: {},
18
+ kid: '',
19
+ keyId: '',
10
20
  })
11
21
  );
12
22
 
13
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
14
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
15
- return {
16
- ...originalModule,
23
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
24
+ namedExports: {
25
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
17
26
  VCLProvider: {
18
- getInstance: jest.fn().mockReturnValue({
19
- initialize: jest.fn().mockResolvedValue(null),
27
+ getInstance: mock.fn(() => ({
28
+ initialize: mock.fn(() => Promise.resolve(null)),
20
29
  generateDidJwk: mockGenerateDidJwk,
21
- }),
30
+ })),
22
31
  },
23
- };
32
+ },
24
33
  });
25
34
 
26
35
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
@@ -46,7 +55,7 @@ const auth0userId = '1234567890';
46
55
  describe('Test accounts controller', () => {
47
56
  let fastify;
48
57
 
49
- beforeAll(async () => {
58
+ before(async () => {
50
59
  fastify = buildFastify();
51
60
  nock('https://localhost/').get('/.well-known/jwks.json').reply(200, jwks);
52
61
  await fastify.ready();
@@ -55,16 +64,17 @@ describe('Test accounts controller', () => {
55
64
  beforeEach(async () => {
56
65
  await mongoDb().collection('accounts').deleteMany({});
57
66
  await mongoDb().collection('credentials').deleteMany({});
58
- jest.clearAllMocks();
67
+ mockGenerateDidJwk.mock.resetCalls();
59
68
  });
60
69
 
61
70
  afterEach(async () => {
62
71
  nock.cleanAll();
63
72
  });
64
73
 
65
- afterAll(async () => {
74
+ after(async () => {
66
75
  nock.restore();
67
76
  await fastify.close();
77
+ mock.reset();
68
78
  });
69
79
 
70
80
  describe('POST /accounts - create or retrieve account', () => {
@@ -99,13 +109,11 @@ describe('Test accounts controller', () => {
99
109
  },
100
110
  });
101
111
  expect(accountsNock.isDone()).toBe(true);
102
- expect(mockGenerateDidJwk.mock.calls).toEqual([
103
- [
104
- {
105
- signatureAlgorithm: 'P-256',
106
- remoteCryptoServicesToken: 'fooAccessToken',
107
- },
108
- ],
112
+ expect(mockGenerateDidJwk.mock.calls[0].arguments).toEqual([
113
+ {
114
+ signatureAlgorithm: 'P-256',
115
+ remoteCryptoServicesToken: 'fooAccessToken',
116
+ },
109
117
  ]);
110
118
  const dbCredentials = await mongoDb()
111
119
  .collection('credentials')
@@ -142,13 +150,11 @@ describe('Test accounts controller', () => {
142
150
  expect(firstResponse.json).toEqual(secondResponse.json);
143
151
 
144
152
  expect(accountsNock.isDone()).toBe(true);
145
- expect(mockGenerateDidJwk.mock.calls).toEqual([
146
- [
147
- {
148
- signatureAlgorithm: 'P-256',
149
- remoteCryptoServicesToken: 'fooAccessToken',
150
- },
151
- ],
153
+ expect(mockGenerateDidJwk.mock.calls[0].arguments).toEqual([
154
+ {
155
+ signatureAlgorithm: 'P-256',
156
+ remoteCryptoServicesToken: 'fooAccessToken',
157
+ },
152
158
  ]);
153
159
  });
154
160
 
@@ -180,13 +186,11 @@ describe('Test accounts controller', () => {
180
186
  expect(firstResponse.json).toEqual(secondResponse.json);
181
187
 
182
188
  expect(accountsNock.isDone()).toBe(true);
183
- expect(mockGenerateDidJwk.mock.calls).toEqual([
184
- [
185
- {
186
- signatureAlgorithm: 'P-256',
187
- remoteCryptoServicesToken: 'fooAccessToken',
188
- },
189
- ],
189
+ expect(mockGenerateDidJwk.mock.calls[0].arguments).toEqual([
190
+ {
191
+ signatureAlgorithm: 'P-256',
192
+ remoteCryptoServicesToken: 'fooAccessToken',
193
+ },
190
194
  ]);
191
195
  });
192
196
 
@@ -1,3 +1,17 @@
1
+ const { after, afterEach, before, describe, it, mock } = require('node:test');
2
+ const { expect } = require('expect');
3
+
4
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
5
+ namedExports: {
6
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
7
+ VCLProvider: {
8
+ getInstance: mock.fn(() => ({
9
+ initialize: mock.fn(() => Promise.resolve(null)),
10
+ })),
11
+ },
12
+ },
13
+ });
14
+
1
15
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
16
  const nock = require('nock');
3
17
  // const newError = require('http-errors');
@@ -15,23 +29,11 @@ const auth0Token =
15
29
  const auth0userId = '1234567890';
16
30
  const usersDid = 'did:example:123';
17
31
 
18
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
19
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
20
- return {
21
- ...originalModule,
22
- VCLProvider: {
23
- getInstance: jest.fn().mockReturnValue({
24
- initialize: jest.fn().mockResolvedValue(null),
25
- }),
26
- },
27
- };
28
- });
29
-
30
32
  describe('consent-controller', () => {
31
33
  let fastify;
32
34
  let persistAccounts;
33
35
 
34
- beforeAll(async () => {
36
+ before(async () => {
35
37
  fastify = buildFastify();
36
38
  nock('https://localhost/')
37
39
  .persist()
@@ -45,10 +47,12 @@ describe('consent-controller', () => {
45
47
  await mongoDb().collection('accounts').deleteMany({});
46
48
  });
47
49
 
48
- afterAll(async () => {
50
+ after(async () => {
49
51
  nock.restore();
50
52
  await fastify.close();
53
+ mock.reset();
51
54
  });
55
+
52
56
  describe('consent', () => {
53
57
  it('should return 200 and create a consent', async () => {
54
58
  ({ persistAccounts } = initAccountsFactory(fastify));
@@ -1,14 +1,40 @@
1
+ const {
2
+ after,
3
+ afterEach,
4
+ before,
5
+ beforeEach,
6
+ describe,
7
+ it,
8
+ mock,
9
+ } = require('node:test');
10
+
11
+ const { expect } = require('expect');
12
+
13
+ const searchForOrganizations = mock.fn(() => Promise.resolve(mockIssuers));
14
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
15
+ namedExports: {
16
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
17
+ VCLProvider: {
18
+ getInstance: mock.fn(() => ({
19
+ initialize: mock.fn(() => Promise.resolve(null)),
20
+ searchForOrganizations,
21
+ credentialTypes: mockCredentialTypes,
22
+ })),
23
+ },
24
+ },
25
+ });
26
+
1
27
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
28
  const { omit } = require('lodash/fp');
3
29
  const nock = require('nock');
4
30
  const {
5
31
  VCLOrganizationsSearchDescriptor,
6
32
  VCLFilter,
7
- VCLProvider,
8
33
  } = require('@verii/vnf-nodejs-wallet-sdk');
9
34
 
10
35
  const { ObjectId } = require('mongodb');
11
36
  const { errorResponseMatcher, mongoify } = require('@verii/tests-helpers');
37
+ const { mockIssuers, mockCredentialTypes } = require('./mocks');
12
38
  const buildFastify = require('./helpers/webwallet-build-fastify');
13
39
  const {
14
40
  mockDisplayDescriptor,
@@ -21,28 +47,11 @@ const auth0Token =
21
47
  // eslint-disable-next-line max-len
22
48
  'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IktFWSJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0LyIsImF1ZCI6ImZvbyIsInNjb3BlIjoicmVhZDp1c2VycyJ9.VwIIUqx9T-AxqbfL_FyNRAeOxTwiC2JpcwtrqnEWN3DdF07ijUkF1WYy8Ahfr_p4R3KnoPbiefZnIbVANCt-lt0ej32rfil2yHhQEsvFxSOjcrx6ARmPp0YAfWlN-5Sotzkxy29jaOZMEDkmRFZg3jkdC7wosPW_S6M-olC4g3HHfylpZI8O3Jdd87Qr9wD_QtUzANwnPbl2Q-9NEyxVjAZIWg_HWK9JAAaf_2IY5VwHBvyp0oeQSEHKi4hogcM59EOc4FxdR5WH45B_PenVa6W4mHFBkH8sAXxt2Zs9s2efujkfWYfyXvgL_lN7vT-TEADlAPP2L6CpWpDISOMsQWUSgGHcN_KwRh_E7qJwahR6mv4QHY6ReEoyjkmSS3swrD1l74jNs7QLAdsMywvzCMDsHabs7DYcEMGQBdP14PJ_ucLFnkivZeBDAc6sS445ocbyrpyO40XMaMorD5khRd9ej89SxR7d_v0W6Ne2Nn4XgW3pAZzu5Rdc4JvqfzLFxkp95jxy1MTAddjWISPmNOYYyXHM9SSqSpqVECOFS0f4z2zycHRqXUcOytWrvED6VGo9x7-IVCgu8vFzj0zToIWQmsDs3UoH9RnV12z0PMwGXQzca1lT_zGwJxBF3e4zJjmcJ05OMF2JgZ2_G48O3M4Dtb0jlgWbKLd0kWlIFzQ;';
23
49
 
24
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
25
- const { mockIssuers, mockCredentialTypes } = require('./mocks');
26
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
27
- return {
28
- ...originalModule,
29
- VCLProvider: {
30
- getInstance: jest.fn().mockReturnValue({
31
- initialize: jest.fn().mockResolvedValue(null),
32
- searchForOrganizations: jest.fn().mockResolvedValue(mockIssuers),
33
- credentialTypes: mockCredentialTypes,
34
- }),
35
- },
36
- };
37
- });
38
-
39
- const vclSdk = VCLProvider.getInstance();
40
-
41
50
  describe('Test credentials controller', () => {
42
51
  let fastify;
43
52
  let persistCredentials;
44
53
 
45
- beforeAll(async () => {
54
+ before(async () => {
46
55
  fastify = buildFastify();
47
56
  nock('https://localhost/').get('/.well-known/jwks.json').reply(200, jwks);
48
57
 
@@ -58,9 +67,10 @@ describe('Test credentials controller', () => {
58
67
  nock.cleanAll();
59
68
  });
60
69
 
61
- afterAll(async () => {
70
+ after(async () => {
62
71
  nock.restore();
63
72
  await fastify.close();
73
+ mock.reset();
64
74
  });
65
75
 
66
76
  describe('GET /credentials - get list of credentials for current user', () => {
@@ -87,13 +97,12 @@ describe('Test credentials controller', () => {
87
97
 
88
98
  expect(response.statusCode).toBe(200);
89
99
 
90
- expect(vclSdk.searchForOrganizations).toHaveBeenCalledTimes(1);
91
- expect(vclSdk.searchForOrganizations).toHaveBeenCalledWith(
100
+ expect(searchForOrganizations.mock.callCount()).toEqual(1);
101
+ expect(searchForOrganizations.mock.calls[0].arguments).toEqual([
92
102
  new VCLOrganizationsSearchDescriptor(
93
103
  new VCLFilter(currentUserCredential.issuer.id)
94
- )
95
- );
96
- // expect(global.fetch.mock.calls).toHaveLength(1);
104
+ ),
105
+ ]);
97
106
 
98
107
  expect(response.json).toEqual({
99
108
  credentials: [
@@ -136,8 +145,6 @@ describe('Test credentials controller', () => {
136
145
  expect(response.json.message).toBe(
137
146
  'Failed to fetch descriptor from http://lib.localhost.test/display-descriptors/open-badge-v2.0.descriptor.json'
138
147
  );
139
-
140
- // expect(global.fetch.mock.calls).toHaveLength(1);
141
148
  });
142
149
 
143
150
  it('should return empty array of credentials if there are no items in DB for user Id', async () => {
@@ -1,3 +1,17 @@
1
+ const { after, afterEach, before, describe, it, mock } = require('node:test');
2
+ const { expect } = require('expect');
3
+
4
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
5
+ namedExports: {
6
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
7
+ VCLProvider: {
8
+ getInstance: mock.fn(() => ({
9
+ initialize: mock.fn(() => Promise.resolve(null)),
10
+ })),
11
+ },
12
+ },
13
+ });
14
+
1
15
  const nock = require('nock');
2
16
  const { VCLJwtDescriptor } = require('@verii/vnf-nodejs-wallet-sdk');
3
17
  const buildFastify = require('../helpers/webwallet-build-fastify');
@@ -11,27 +25,14 @@ const {
11
25
  } = require('../../src/plugins/crypto-services/jwt-sign-service-impl');
12
26
  const { DidJwkMocks } = require('../mocks/didjwk');
13
27
 
14
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
15
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
16
- return {
17
- ...originalModule,
18
- VCLProvider: {
19
- getInstance: jest.fn().mockReturnValue({
20
- initialize: jest.fn().mockResolvedValue(null),
21
- }),
22
- },
23
- };
24
- });
25
-
26
28
  describe('sign service implementation test', () => {
27
29
  let subject;
28
30
 
29
31
  let fastify;
30
32
 
31
- beforeAll(async () => {
33
+ before(async () => {
32
34
  fastify = buildFastify();
33
35
  await fastify.ready();
34
-
35
36
  subject = JwtSignServiceImpl(fastify);
36
37
  });
37
38
 
@@ -72,8 +73,9 @@ describe('sign service implementation test', () => {
72
73
  nock.cleanAll();
73
74
  });
74
75
 
75
- afterAll(async () => {
76
+ after(async () => {
76
77
  nock.restore();
77
78
  await fastify.close();
79
+ mock.reset();
78
80
  });
79
81
  });
@@ -1,3 +1,7 @@
1
+ const { before, describe, it } = require('node:test');
2
+
3
+ const { expect } = require('expect');
4
+
1
5
  const {
2
6
  JwtVerifyServiceImpl,
3
7
  } = require('../../src/plugins/crypto-services/jwt-verify-service-impl');
@@ -7,7 +11,7 @@ const { DidJwkMocks } = require('../mocks/didjwk');
7
11
  describe('sign service implementation test', () => {
8
12
  let subject;
9
13
 
10
- beforeAll(async () => {
14
+ before(async () => {
11
15
  subject = JwtVerifyServiceImpl();
12
16
  });
13
17
 
@@ -1,3 +1,17 @@
1
+ const { after, afterEach, before, describe, it, mock } = require('node:test');
2
+ const { expect } = require('expect');
3
+
4
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
5
+ namedExports: {
6
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
7
+ VCLProvider: {
8
+ getInstance: mock.fn(() => ({
9
+ initialize: mock.fn(() => Promise.resolve(null)),
10
+ })),
11
+ },
12
+ },
13
+ });
14
+
1
15
  const {
2
16
  VCLDidJwkDescriptor,
3
17
  VCLSignatureAlgorithm,
@@ -9,24 +23,12 @@ const {
9
23
  const { DidJwkMocks } = require('../mocks/didjwk');
10
24
  const buildFastify = require('../helpers/webwallet-build-fastify');
11
25
 
12
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
13
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
14
- return {
15
- ...originalModule,
16
- VCLProvider: {
17
- getInstance: jest.fn().mockReturnValue({
18
- initialize: jest.fn().mockResolvedValue(null),
19
- }),
20
- },
21
- };
22
- });
23
-
24
26
  describe('key service implementation test', () => {
25
27
  let subject;
26
28
 
27
29
  let fastify;
28
30
 
29
- beforeAll(async () => {
31
+ before(async () => {
30
32
  fastify = buildFastify();
31
33
  await fastify.ready();
32
34
 
@@ -67,8 +69,9 @@ describe('key service implementation test', () => {
67
69
  nock.cleanAll();
68
70
  });
69
71
 
70
- afterAll(async () => {
72
+ after(async () => {
71
73
  nock.restore();
72
74
  await fastify.close();
75
+ mock.reset();
73
76
  });
74
77
  });