@velocitycareerlabs/server-webwallet 1.25.0-dev-build.12642c864

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.
Files changed (193) hide show
  1. package/.localdev.env +57 -0
  2. package/.standalone.env +22 -0
  3. package/LICENSE +248 -0
  4. package/README.md +11 -0
  5. package/jest.config.js +20 -0
  6. package/migrate-mongo.config.js +23 -0
  7. package/package.json +72 -0
  8. package/src/config/config.js +74 -0
  9. package/src/controllers/accounts/autohooks.js +28 -0
  10. package/src/controllers/accounts/controller.js +209 -0
  11. package/src/controllers/accounts/schemas/index.js +6 -0
  12. package/src/controllers/accounts/schemas/webwallet-accounts-request.schema.js +25 -0
  13. package/src/controllers/accounts/schemas/webwallet-accounts-response.schema.js +72 -0
  14. package/src/controllers/accounts/schemas/webwallet-accounts-update-request.schema.js +23 -0
  15. package/src/controllers/accounts/schemas/webwallet-test-personas-response.schema.js +110 -0
  16. package/src/controllers/consent/autohooks.js +14 -0
  17. package/src/controllers/consent/controller.js +91 -0
  18. package/src/controllers/consent/schemas/index.js +3 -0
  19. package/src/controllers/consent/schemas/webwallet-consent-response.schema.js +23 -0
  20. package/src/controllers/credentials/autohooks.js +36 -0
  21. package/src/controllers/credentials/controller.js +92 -0
  22. package/src/controllers/credentials/schemas/index.js +4 -0
  23. package/src/controllers/credentials/schemas/webwallet-credential-categories-response.schema.js +21 -0
  24. package/src/controllers/credentials/schemas/webwallet-credentials-response.schema.js +29 -0
  25. package/src/controllers/disclosures/autohooks.js +21 -0
  26. package/src/controllers/disclosures/controller.js +168 -0
  27. package/src/controllers/disclosures/schemas/index.js +7 -0
  28. package/src/controllers/disclosures/schemas/webwallet-accept-presentation-request-body.schema.js +28 -0
  29. package/src/controllers/disclosures/schemas/webwallet-accept-presentation-response.schema.js +16 -0
  30. package/src/controllers/disclosures/schemas/webwallet-get-disclosures-response.schema.js +18 -0
  31. package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-query.schema.js +21 -0
  32. package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-response.schema.js +16 -0
  33. package/src/controllers/feedback/autohooks.js +11 -0
  34. package/src/controllers/feedback/controller.js +48 -0
  35. package/src/controllers/issuing/common-schemas/index.js +10 -0
  36. package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-query.schema.js +27 -0
  37. package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-response.schema.js +31 -0
  38. package/src/controllers/issuing/deep-link/autohooks.js +51 -0
  39. package/src/controllers/issuing/deep-link/controller.js +192 -0
  40. package/src/controllers/issuing/deep-link/schemas/index.js +6 -0
  41. package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-accept-offers-request.schema.js +30 -0
  42. package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-accept-offers-response.schema.js +36 -0
  43. package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-offers-request.schema.js +28 -0
  44. package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-offers-response.schema.js +48 -0
  45. package/src/controllers/issuing/identity-credentials/autohooks.js +42 -0
  46. package/src/controllers/issuing/identity-credentials/controller.js +188 -0
  47. package/src/controllers/issuing/identity-credentials/schemas/index.js +6 -0
  48. package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-confirm-body.schema.js +20 -0
  49. package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-confirm-response.schema.js +37 -0
  50. package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-request-code-body.schema.js +14 -0
  51. package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-request-code-params.schema.js +19 -0
  52. package/src/controllers/linkedin/autohooks.js +16 -0
  53. package/src/controllers/linkedin/controller.js +276 -0
  54. package/src/controllers/linkedin/schemas/index.js +3 -0
  55. package/src/controllers/linkedin/schemas/webwallet-linkedin-me-response.schema.js +14 -0
  56. package/src/controllers/root/controller.js +29 -0
  57. package/src/entities/.gitkeep +0 -0
  58. package/src/entities/accounts/constants.js +5 -0
  59. package/src/entities/accounts/domains/extract-auth0-id-token-or-access-token.js +22 -0
  60. package/src/entities/accounts/domains/index.js +5 -0
  61. package/src/entities/accounts/domains/validate-account-permissions.js +36 -0
  62. package/src/entities/accounts/domains/validate-logo-size.js +25 -0
  63. package/src/entities/accounts/index.js +5 -0
  64. package/src/entities/accounts/repos/accounts.repo.js +63 -0
  65. package/src/entities/credentials/domains/index.js +3 -0
  66. package/src/entities/credentials/domains/offer-to-credential-mongo-dto.js +43 -0
  67. package/src/entities/credentials/index.js +6 -0
  68. package/src/entities/credentials/orchestrators/index.js +3 -0
  69. package/src/entities/credentials/orchestrators/load-additional-render-info.js +65 -0
  70. package/src/entities/credentials/repos/credentials.repo.js +132 -0
  71. package/src/entities/credentials/schemas/index.js +4 -0
  72. package/src/entities/credentials/schemas/webwallet-credential-response.schema.js +138 -0
  73. package/src/entities/credentials/schemas/webwallet-credentials-response.schemas.js +95 -0
  74. package/src/entities/credentials/schemas/webwallet-display-descriptor-response.schema.js +106 -0
  75. package/src/entities/disclosures/index.js +4 -0
  76. package/src/entities/disclosures/repos/disclosures.repo.js +31 -0
  77. package/src/entities/disclosures/schemas/index.js +10 -0
  78. package/src/entities/disclosures/schemas/webwallet-disclosure.schema.js +39 -0
  79. package/src/entities/disclosures/schemas/webwallet-presentation-request-field.schema.js +45 -0
  80. package/src/entities/disclosures/schemas/webwallet-presentation-request-filter.schema.js +30 -0
  81. package/src/entities/disclosures/schemas/webwallet-presentation-request-format.schema.js +36 -0
  82. package/src/entities/disclosures/schemas/webwallet-presentation-request-input-descriptors.schema.js +111 -0
  83. package/src/entities/disclosures/schemas/webwallet-presentation-request-schema.schema.js +14 -0
  84. package/src/entities/disclosures/schemas/webwallet-presentation-request-submission-requirements.schema.js +37 -0
  85. package/src/entities/disclosures/schemas/webwallet-presentation-request.schema.js +79 -0
  86. package/src/entities/index.js +6 -0
  87. package/src/entities/issuing/domain/constants.js +8 -0
  88. package/src/entities/issuing/domain/does-user-have-fresh-pending-verification.js +26 -0
  89. package/src/entities/issuing/domain/get-credentials-from-offers.js +18 -0
  90. package/src/entities/issuing/domain/index.js +5 -0
  91. package/src/entities/issuing/index.js +5 -0
  92. package/src/entities/issuing/orchestrators/build-issuing-input-credentials.js +35 -0
  93. package/src/entities/issuing/orchestrators/generate-offers-by-deep-link.js +74 -0
  94. package/src/entities/issuing/orchestrators/get-identity-issuer.js +35 -0
  95. package/src/entities/issuing/orchestrators/get-identity-offers-by-deeplink.js +74 -0
  96. package/src/entities/issuing/orchestrators/index.js +6 -0
  97. package/src/entities/issuing/schemas/index.js +9 -0
  98. package/src/entities/issuing/schemas/webwallet-credential-manifest.schema.js +198 -0
  99. package/src/errors/error-codes.js +12 -0
  100. package/src/fetchers/career-wallet/create-account-fetcher.js +7 -0
  101. package/src/fetchers/career-wallet/create-did-fetcher.js +17 -0
  102. package/src/fetchers/career-wallet/get-app-config.js +11 -0
  103. package/src/fetchers/career-wallet/get-consents.js +13 -0
  104. package/src/fetchers/career-wallet/get-credential-categories.js +7 -0
  105. package/src/fetchers/career-wallet/get-personas.js +7 -0
  106. package/src/fetchers/career-wallet/index.js +12 -0
  107. package/src/fetchers/career-wallet/post-consent.js +9 -0
  108. package/src/fetchers/career-wallet/send-feedback.js +14 -0
  109. package/src/fetchers/career-wallet/sign-fetcher.js +14 -0
  110. package/src/fetchers/career-wallet/verify-id-credential-confirm-code.js +19 -0
  111. package/src/fetchers/career-wallet/verify-id-credential-request-code.js +20 -0
  112. package/src/fetchers/index.js +4 -0
  113. package/src/fetchers/lib-api/get-credential-display-schema.js +12 -0
  114. package/src/fetchers/lib-api/index.js +3 -0
  115. package/src/fetchers/linkedin/create-linkedin-post.js +45 -0
  116. package/src/fetchers/linkedin/get-access-token.js +26 -0
  117. package/src/fetchers/linkedin/get-linkedin-user-email.js +13 -0
  118. package/src/fetchers/linkedin/get-linkedin-user-id.js +16 -0
  119. package/src/fetchers/linkedin/index.js +9 -0
  120. package/src/fetchers/linkedin/register-image-to-upload.js +30 -0
  121. package/src/fetchers/linkedin/revoke-linkedin-access.js +20 -0
  122. package/src/fetchers/linkedin/upload-image-to-linkedin.js +16 -0
  123. package/src/index.js +15 -0
  124. package/src/init-server.js +108 -0
  125. package/src/plugins/crypto-services/index.js +5 -0
  126. package/src/plugins/crypto-services/jwt-sign-service-impl.js +72 -0
  127. package/src/plugins/crypto-services/jwt-verify-service-impl.js +21 -0
  128. package/src/plugins/crypto-services/key-service-impl.js +28 -0
  129. package/src/plugins/fetch-errors-handler-plugin.js +64 -0
  130. package/src/plugins/index.js +4 -0
  131. package/src/plugins/vnf-sdk-plugin.js +53 -0
  132. package/src/standalone.js +8 -0
  133. package/test/accounts-controller.test.js +618 -0
  134. package/test/consent-controller.test.js +185 -0
  135. package/test/credentials-controller.test.js +307 -0
  136. package/test/crypro-services/jwt-sign-service-impl.test.js +83 -0
  137. package/test/crypro-services/jwt-verify-service-impl.test.js +27 -0
  138. package/test/crypro-services/key-service-impl.test.js +76 -0
  139. package/test/crypro-services/mocks/index.js +4 -0
  140. package/test/crypro-services/mocks/jwt-mock.js +15 -0
  141. package/test/crypro-services/mocks/public-jwk.js +14 -0
  142. package/test/disclosures-controller/disclosure-credentials.test.js +428 -0
  143. package/test/disclosures-controller/get-disclosures.test.js +169 -0
  144. package/test/disclosures-controller/mocks/get-credential-manifest.js +20 -0
  145. package/test/disclosures-controller/mocks/index.js +6 -0
  146. package/test/disclosures-controller/mocks/presentation-request.js +32 -0
  147. package/test/disclosures-controller/mocks/presentation-submission.js +21 -0
  148. package/test/disclosures-controller/mocks/submission-result.js +19 -0
  149. package/test/factories/accounts.js +25 -0
  150. package/test/factories/credentials.js +66 -0
  151. package/test/factories/disclosures.js +106 -0
  152. package/test/feedback-controller.test.js +125 -0
  153. package/test/fetch-errors-handler-plugin.test.js +97 -0
  154. package/test/filter-deleted-credentials-extension.test.js +82 -0
  155. package/test/helpers/.env.test +10 -0
  156. package/test/helpers/nock-consent-add.js +16 -0
  157. package/test/helpers/nock-consents-get.js +15 -0
  158. package/test/helpers/nock-feedback.js +9 -0
  159. package/test/helpers/nock-linkedin-access-token.js +9 -0
  160. package/test/helpers/nock-linkedin-email.js +15 -0
  161. package/test/helpers/nock-linkedin-image-register.js +28 -0
  162. package/test/helpers/nock-linkedin-me.js +13 -0
  163. package/test/helpers/nock-linkedin-post.js +37 -0
  164. package/test/helpers/nock-linkedin-revoke.js +9 -0
  165. package/test/helpers/nock-test-personas.js +13 -0
  166. package/test/helpers/webwallet-build-fastify.js +17 -0
  167. package/test/issuing-controller/issuing-by-deeplink-empty-offers.test.js +142 -0
  168. package/test/issuing-controller/issuing-by-deeplink-failed-offers.test.js +142 -0
  169. package/test/issuing-controller/issuing-by-deeplink.test.js +492 -0
  170. package/test/issuing-controller/issuing-identity-credentials.test.js +377 -0
  171. package/test/issuing-controller/mocks/accept-offers-response.js +90 -0
  172. package/test/issuing-controller/mocks/accepted-credentials.js +47 -0
  173. package/test/issuing-controller/mocks/credential-manifest-presentation.js +72 -0
  174. package/test/issuing-controller/mocks/credential-manifest.js +45 -0
  175. package/test/issuing-controller/mocks/identity-issuing/accept-offers.js +22 -0
  176. package/test/issuing-controller/mocks/identity-issuing/confirm-verification-code.js +5 -0
  177. package/test/issuing-controller/mocks/identity-issuing/get-app-config.js +52 -0
  178. package/test/issuing-controller/mocks/identity-issuing/get-organization.js +118 -0
  179. package/test/issuing-controller/mocks/identity-issuing/index.js +6 -0
  180. package/test/issuing-controller/mocks/index.js +6 -0
  181. package/test/issuing-controller/mocks/issuers.js +126 -0
  182. package/test/issuing-controller/mocks/offers.js +48 -0
  183. package/test/issuing-controller/mocks/schema.js +107 -0
  184. package/test/linkedin-controller.test.js +452 -0
  185. package/test/mocks/credential-categories.js +115 -0
  186. package/test/mocks/credentials.js +15 -0
  187. package/test/mocks/didjwk.js +25 -0
  188. package/test/mocks/index.js +7 -0
  189. package/test/mocks/issuers.js +88 -0
  190. package/test/mocks/jwk.js +53 -0
  191. package/test/mocks/schema.js +107 -0
  192. package/test/root.test.js +42 -0
  193. package/test/vcl-sdk-plugin.test.js +86 -0
@@ -0,0 +1,21 @@
1
+ /* eslint-disable max-len */
2
+ const {
3
+ VCLPresentationSubmission,
4
+ } = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
5
+ const { CredentialMocks } = require('../../mocks/credentials');
6
+ const { presentationRequestMock } = require('./presentation-request');
7
+
8
+ const presentationSubmissionMock = new VCLPresentationSubmission(
9
+ presentationRequestMock,
10
+ [
11
+ {
12
+ id: 'credential_id',
13
+ inputDescriptor: 'EducationDegreeGraduationV1.1',
14
+ jwtVc: CredentialMocks.JwtCredentialEmail,
15
+ },
16
+ ]
17
+ );
18
+
19
+ module.exports = {
20
+ presentationSubmissionMock,
21
+ };
@@ -0,0 +1,19 @@
1
+ /* eslint-disable max-len */
2
+ const {
3
+ VCLSubmissionResult,
4
+ VCLExchange,
5
+ VCLToken,
6
+ } = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
7
+
8
+ const submissionResultMock = new VCLSubmissionResult(
9
+ new VCLToken(
10
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
11
+ ),
12
+ new VCLExchange('65788639770790a0fdff7c8e', 'DISCLOSURE', true, true),
13
+ '6362860a-9be2-4357-a7da-599dc62136da',
14
+ '352e0967-03ad-4dd5-81d8-5d2b45b516dc'
15
+ );
16
+
17
+ module.exports = {
18
+ submissionResultMock,
19
+ };
@@ -0,0 +1,25 @@
1
+ const { register } = require('@spencejs/spence-factories');
2
+ const { accountsRepoPlugin } = require('../../src/entities');
3
+
4
+ module.exports = (app) => {
5
+ return register(
6
+ 'accounts',
7
+ accountsRepoPlugin(app)({ config: app.config }),
8
+ async (overrides) => {
9
+ return {
10
+ userId: '1234567890',
11
+ did: 'did:example:123',
12
+ profileName: 'Test Profile',
13
+ verificationInfo: {
14
+ email: {
15
+ status: 'verified',
16
+ },
17
+ phone: {
18
+ status: 'verified',
19
+ },
20
+ },
21
+ ...overrides(),
22
+ };
23
+ }
24
+ );
25
+ };
@@ -0,0 +1,66 @@
1
+ const { register } = require('@spencejs/spence-factories');
2
+ const { VelocityRevocationListType } = require('@velocitycareerlabs/vc-checks');
3
+ const { credentialsRepoPlugin } = require('../../src/entities');
4
+
5
+ module.exports = (app) => {
6
+ return register(
7
+ 'credentials',
8
+ credentialsRepoPlugin(app)({ config: app.config }),
9
+ async (overrides) => {
10
+ return {
11
+ auth0UserId: '1234567890',
12
+ did: 'did:test:1',
13
+ userDid: 'did:test:2',
14
+ type: ['OpenBadgeV2.0'],
15
+ issuer: {
16
+ id: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
17
+ },
18
+ contentHash: {
19
+ type: 'VelocityContentHash2020',
20
+ value:
21
+ 'e6111d72559b84448ee3c844d4d3dafaa63cf97091ee203c68e257fab9cf0337',
22
+ },
23
+ context: [
24
+ 'https://www.w3.org/2018/credentials/v1',
25
+ 'https://devlib.velocitynetwork.foundation/contexts/credential-extensions-2022.jsonld.json',
26
+ ],
27
+ credentialSchema: {
28
+ id: 'https://devregistrar.velocitynetwork.foundation/schemas/open-badge-v2.0.schema.json',
29
+ type: 'JsonSchemaValidator2018',
30
+ },
31
+ credentialStatus: {
32
+ // eslint-disable-next-line max-len
33
+ id: 'ethereum:0xD890F2D60B429f9e257FC0Bc58Ef2237776DD91B/getRevokedStatus?address=0xa27F300621a7474A68fd5a417D9560d24f9d9F74&listId=255664421176378&index=3270',
34
+ statusListCredential:
35
+ // eslint-disable-next-line max-len
36
+ 'ethereum:0xD890F2D60B429f9e257FC0Bc58Ef2237776DD91B/getRevokedStatus?address=0xa27F300621a7474A68fd5a417D9560d24f9d9F74&listId=255664421176378',
37
+ statusListIndex: 3270,
38
+ type: VelocityRevocationListType,
39
+ },
40
+ credentialSubject: {
41
+ '@context': ['https://www.w3.org/2018/credentials/v1'],
42
+ hasCredential: {
43
+ criteria: 'https://example.com/velocity-badge.html',
44
+ description: 'For issuing a Badge on the Velocity Network',
45
+ id: 'https://example.com/velocity-badge.json',
46
+ image:
47
+ 'https://www.velocitynetwork.foundation/wp-content/uploads/2020/02/fb.jpg',
48
+ issuer: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
49
+ name: 'Velocity Badge',
50
+ type: 'BadgeClass',
51
+ },
52
+ type: 'Badge',
53
+ },
54
+ iss: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
55
+ jti: 'did:velocity:v2:0xa27f300621a7474a68fd5a417d9560d24f9d9f74:56898051534679:2985',
56
+ linkCodeCommitment: {
57
+ type: 'VelocityCredentialLinkCodeCommitment2022',
58
+ value: 'EiBYXN+pEkLCGjtMvZGBMj6mQQeNtS6iaD6E6ZdhtC98Ng==',
59
+ },
60
+ encodedCredential: 'mockedEncodedCredential',
61
+ vnfProtocolVersion: 1,
62
+ ...overrides(),
63
+ };
64
+ }
65
+ );
66
+ };
@@ -0,0 +1,106 @@
1
+ const { register } = require('@spencejs/spence-factories');
2
+ const { disclosuresRepoPlugin } = require('../../src/entities/disclosures');
3
+
4
+ module.exports = (app) => {
5
+ return register(
6
+ 'disclosures',
7
+ disclosuresRepoPlugin(app)({ config: app.config }),
8
+ async (overrides) => {
9
+ return {
10
+ auth0UserId: '1234567890',
11
+ userDid: 'did:test-user:1',
12
+ jti: '8b67c34b-5920-4527-a86f-e9e8ac359341',
13
+ submissionId: 'a46e7063-8d2d-4e21-b9f0-66229c3fe028',
14
+ presentationDefinitionId:
15
+ '657b15a1b4de9ac4f06b63ee.6576d7de30b7cd12f669d900',
16
+ encodedJwt:
17
+ // eslint-disable-next-line max-len
18
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1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4Mn0.AKj5uBWdATTZOEyA4Qla4FhVxQTiqrNG5-NKsfHUMcQAFAAo-QKR466To2m3e4t_rEI_QJNdYZJtgKe49xUDYQ',
19
+ presentation: {
20
+ exp: 1703170082,
21
+ iat: 1702565282,
22
+ iss: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
23
+ nbf: 1702565282,
24
+ presentation_definition: {
25
+ id: '657b15a1b4de9ac4f06b63ee.6576d7de30b7cd12f669d900',
26
+ purpose: 'Job Application',
27
+ format: {
28
+ jwt_vp: {
29
+ alg: ['secp256k1'],
30
+ },
31
+ },
32
+ submission_requirements: [
33
+ {
34
+ rule: 'pick',
35
+ min: 1,
36
+ from: 'A',
37
+ },
38
+ ],
39
+ input_descriptors: [
40
+ {
41
+ id: 'AssessmentV1.1',
42
+ name: 'Assessment',
43
+ group: ['A'],
44
+ schema: [
45
+ {
46
+ uri: 'https://devlib.velocitynetwork.foundation/schemas/assessment-v1.1.schema.json',
47
+ },
48
+ ],
49
+ },
50
+ {
51
+ id: 'CertificationV1.1',
52
+ name: 'Certification',
53
+ group: ['A'],
54
+ schema: [
55
+ {
56
+ uri: 'https://devlib.velocitynetwork.foundation/schemas/certification-v1.1.schema.json',
57
+ },
58
+ ],
59
+ },
60
+ {
61
+ id: 'EducationDegreeGraduationV1.1',
62
+ name: 'Education degree graduation',
63
+ group: ['A'],
64
+ schema: [
65
+ {
66
+ uri: 'https://devlib.velocitynetwork.foundation/schemas/education-degree-graduation-v1.1.schema.json',
67
+ },
68
+ ],
69
+ },
70
+ ],
71
+ },
72
+ metadata: {
73
+ client_name: 'University of Massachusetts Amherst',
74
+ logo_uri:
75
+ 'https://upload.wikimedia.org/wikipedia/commons/4/4f/UMass_Seal_Medium_PMS_202.png',
76
+ tos_uri:
77
+ 'https://www.velocityexperiencecenter.com/terms-and-conditions-vnf',
78
+ max_retention_period: '6m',
79
+ progress_uri:
80
+ // eslint-disable-next-line max-len
81
+ 'https://devagent.velocitycareerlabs.io/api/holder/v0.6/org/did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA/get-exchange-progress',
82
+ submit_presentation_uri:
83
+ // eslint-disable-next-line max-len
84
+ 'https://devagent.velocitycareerlabs.io/api/holder/v0.6/org/did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA/inspect/submit-presentation',
85
+ },
86
+ exchange_id: '657b15a1b4de9ac4f06b63ee',
87
+ },
88
+ token:
89
+ // eslint-disable-next-line max-len
90
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJqdGkiOiI2NTdiMTVhMWI0ZGU5YWM0ZjA2YjYzZWUiLCJpc3MiOiJkaWQ6aW9uOkVpQXBNTGRNYjROUGI4c2FlOS1oWEdIUDc5VzFnaXNBcFZTRTgwVVNQRWJ0SkEiLCJhdWQiOiJkaWQ6aW9uOkVpQXBNTGRNYjROUGI4c2FlOS1oWEdIUDc5VzFnaXNBcFZTRTgwVVNQRWJ0SkEiLCJleHAiOjE3MDMxNzAwODMsInN1YiI6IjY1N2IxNWEzZTU5YTFjN2FhMjg5MmFiMSIsImlhdCI6MTcwMjU2NTI4M30.hvr5tOgiZfejREm3cIr0n30ngK7iVQUkCBNNQ4eIQinuhSCwmL9K05TC1G2jX8574kR6nKLcnTjm_eqWndt6wA',
91
+ sharedCredentials: [
92
+ '654caa98663bd9cd0b080337',
93
+ '654ca958663bd9cd0b080335',
94
+ '6548fb8a28ab164c786baacd',
95
+ '6548fb8a28ab164c786baace',
96
+ '6548d2c628ab164c786baacb',
97
+ '6548d2c628ab164c786baacc',
98
+ '6548d05828ab164c786baac8',
99
+ ],
100
+ createdAt: '2023-12-14T14:48:03.767Z',
101
+ updatedAt: '2023-12-14T14:48:03.767Z',
102
+ ...overrides(),
103
+ };
104
+ }
105
+ );
106
+ };
@@ -0,0 +1,125 @@
1
+ const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
+ const nock = require('nock');
3
+ const buildFastify = require('./helpers/webwallet-build-fastify');
4
+
5
+ const initAccountsFactory = require('./factories/accounts');
6
+ const { nockFeedback } = require('./helpers/nock-feedback');
7
+
8
+ const auth0Token =
9
+ // eslint-disable-next-line max-len
10
+ 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IktFWSJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0LyIsImF1ZCI6ImZvbyIsInNjb3BlIjoicmVhZDp1c2VycyJ9.VwIIUqx9T-AxqbfL_FyNRAeOxTwiC2JpcwtrqnEWN3DdF07ijUkF1WYy8Ahfr_p4R3KnoPbiefZnIbVANCt-lt0ej32rfil2yHhQEsvFxSOjcrx6ARmPp0YAfWlN-5Sotzkxy29jaOZMEDkmRFZg3jkdC7wosPW_S6M-olC4g3HHfylpZI8O3Jdd87Qr9wD_QtUzANwnPbl2Q-9NEyxVjAZIWg_HWK9JAAaf_2IY5VwHBvyp0oeQSEHKi4hogcM59EOc4FxdR5WH45B_PenVa6W4mHFBkH8sAXxt2Zs9s2efujkfWYfyXvgL_lN7vT-TEADlAPP2L6CpWpDISOMsQWUSgGHcN_KwRh_E7qJwahR6mv4QHY6ReEoyjkmSS3swrD1l74jNs7QLAdsMywvzCMDsHabs7DYcEMGQBdP14PJ_ucLFnkivZeBDAc6sS445ocbyrpyO40XMaMorD5khRd9ej89SxR7d_v0W6Ne2Nn4XgW3pAZzu5Rdc4JvqfzLFxkp95jxy1MTAddjWISPmNOYYyXHM9SSqSpqVECOFS0f4z2zycHRqXUcOytWrvED6VGo9x7-IVCgu8vFzj0zToIWQmsDs3UoH9RnV12z0PMwGXQzca1lT_zGwJxBF3e4zJjmcJ05OMF2JgZ2_G48O3M4Dtb0jlgWbKLd0kWlIFzQ;';
11
+
12
+ const auth0userId = '1234567890';
13
+ const usersDid = 'did:example:123';
14
+
15
+ jest.mock('@velocitycareerlabs/vnf-nodejs-wallet-sdk', () => {
16
+ const originalModule = jest.requireActual(
17
+ '@velocitycareerlabs/vnf-nodejs-wallet-sdk'
18
+ );
19
+ return {
20
+ ...originalModule,
21
+ VCLProvider: {
22
+ getInstance: jest.fn().mockReturnValue({
23
+ initialize: jest.fn().mockResolvedValue(null),
24
+ }),
25
+ },
26
+ };
27
+ });
28
+ describe('feedback-controller', () => {
29
+ let fastify;
30
+ let persistAccounts;
31
+
32
+ beforeAll(async () => {
33
+ fastify = buildFastify();
34
+ nock('https://localhost/')
35
+ .persist()
36
+ .get('/.well-known/jwks.json')
37
+ .reply(200, jwks);
38
+ await fastify.ready();
39
+ });
40
+
41
+ afterEach(async () => {
42
+ nock.cleanAll();
43
+ await mongoDb().collection('accounts').deleteMany({});
44
+ });
45
+
46
+ afterAll(async () => {
47
+ nock.restore();
48
+ await fastify.close();
49
+ });
50
+ describe('POST feedback', () => {
51
+ it('should return 204 and send a user feedback', async () => {
52
+ ({ persistAccounts } = initAccountsFactory(fastify));
53
+
54
+ await persistAccounts({
55
+ auth0userId,
56
+ usersDid,
57
+ careerWalletAccountId: 'mocked-user-id',
58
+ });
59
+
60
+ const feedback = {
61
+ feedback: 'test',
62
+ deviceOS: 'test',
63
+ errorCode: 'test_error_code',
64
+ };
65
+
66
+ const nockInstance = nock(fastify.config.careerWalletUrl);
67
+ nockFeedback(nockInstance);
68
+
69
+ const response = await fastify.inject({
70
+ method: 'POST',
71
+ url: '/feedback',
72
+ headers: {
73
+ authorization: `Bearer ${auth0Token}`,
74
+ },
75
+ body: feedback,
76
+ });
77
+
78
+ expect(response.statusCode).toBe(204);
79
+ expect(response.body).toEqual('');
80
+ });
81
+ });
82
+ });
83
+
84
+ const jwks = {
85
+ keys: [
86
+ {
87
+ alg: 'RS512',
88
+ kid: 'KEY',
89
+ x5c: ['UNUSED'],
90
+ },
91
+ {
92
+ alg: 'RS256',
93
+ kid: 'KEY',
94
+ x5c: [
95
+ `
96
+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aNBpdbDch2WBkME3UYlFIR9GgbXPMlACQlwJ
112
+ f4qT3iIZ9zjpVMP8F63TzRRr7KEYW2PGHEtVQktMPprGEfU4Sz0OIa9RRV+BLsfh
113
+ x8he2pimJEzoEaWPgyJXV1S+tLUif8A/CEkZVRZ2vADA7WMGl2ZTdbmsTjXh4bf2
114
+ A4l4Zec+jwOjUPiEk5lLJwv1KeYos9wuUczAk7ku8wRzyZbrjwgRam9VQA5qmRzJ
115
+ PegEQwJaKMRu8PPK0L4KFN4v3ma7Ux6D719nko8mZ0kA2oUs6phsFmoWQfsbRbsD
116
+ CdUGnM2fPp6V285r9w9Y6+1nVdtJpbAPFJR3SxIpfYVfx3tI6C3BR9bIMr8uCf81
117
+ G+Ebvo4qTuY6Cg/mTpPLZ4cKpwSvB6cE+xeSHvKIRYm6QUYEReRxQ3b4aUKBSNwl
118
+ FEQufVGhGzeblNC3fjP+mMtqbyC8c1zkHc6tjJYO5yesKf8bjO71by2jgSced7nN
119
+ 5JvJawfEcabgHJ1aAFLj0tlPMrViFzu6y8/A5aZLc5UMISXAZXfB4wIEdyUUXJh4
120
+ rJKE/ZCb2+W8g29N5cv2P6nhahT3mYatMiQ0U/gfaIrA0A==
121
+ `.trim(),
122
+ ],
123
+ },
124
+ ],
125
+ };
@@ -0,0 +1,97 @@
1
+ const buildFastify = require('fastify');
2
+ const nock = require('nock');
3
+ const got = require('got');
4
+ const { fetchErrorsHandlerPlugin } = require('../src/plugins');
5
+
6
+ describe('Test fetchErrorsHandlerPlugin', () => {
7
+ let fastify;
8
+
9
+ beforeEach(() => {
10
+ fastify = buildFastify({});
11
+ fastify.register(fetchErrorsHandlerPlugin);
12
+ });
13
+
14
+ it('Should return the same HTTPError as the nested fetch request', async () => {
15
+ fastify.get('/test', () =>
16
+ got.get('https://test/endpoint_that_returns_error')
17
+ );
18
+
19
+ const nockedRequest = nock('https://test')
20
+ .get('/endpoint_that_returns_error')
21
+ .reply(401, {
22
+ code: 'FST_JWT_AUTHORIZATION_TOKEN_INVALID',
23
+ error: 'Unauthorized',
24
+ message:
25
+ 'Authorization token is invalid: The token signature is invalid.',
26
+ statusCode: 401,
27
+ });
28
+
29
+ const response = await fastify.inject({
30
+ method: 'GET',
31
+ url: '/test',
32
+ });
33
+
34
+ expect(response.statusCode).toBe(401);
35
+
36
+ expect(response.json()).toEqual({
37
+ code: 'FST_JWT_AUTHORIZATION_TOKEN_INVALID',
38
+ error: 'Unauthorized',
39
+ message:
40
+ 'Authorization token is invalid: The token signature is invalid.',
41
+ statusCode: 401,
42
+ });
43
+
44
+ expect(nockedRequest.isDone()).toBe(true);
45
+ });
46
+
47
+ it('Should return correct error when nested fetch request returns fatal error', async () => {
48
+ fastify.get('/test', () =>
49
+ got.get('https://test/endpoint_that_throws_fatal_error')
50
+ );
51
+
52
+ const nockedRequest = nock('https://test')
53
+ .get('/endpoint_that_throws_fatal_error')
54
+ .replyWithError('Unknown fatal error');
55
+
56
+ const response = await fastify.inject({
57
+ method: 'GET',
58
+ url: '/test',
59
+ });
60
+
61
+ expect(response.statusCode).toBe(500);
62
+
63
+ expect(response.json()).toEqual({
64
+ code: 'ERR_GOT_REQUEST_ERROR',
65
+ error: 'Internal Server Error',
66
+ message: 'Unknown fatal error',
67
+ statusCode: 500,
68
+ });
69
+
70
+ expect(nockedRequest.isDone()).toBe(true);
71
+ });
72
+
73
+ it('Should return correct error when nested fetch request returns string error', async () => {
74
+ fastify.get('/test', () =>
75
+ got.get('https://test/endpoint_that_returns_error')
76
+ );
77
+
78
+ const nockedRequest = nock('https://test')
79
+ .get('/endpoint_that_returns_error')
80
+ .reply(400, 'Unknown error');
81
+
82
+ const response = await fastify.inject({
83
+ method: 'GET',
84
+ url: '/test',
85
+ });
86
+
87
+ expect(response.statusCode).toBe(400);
88
+
89
+ expect(response.json()).toEqual({
90
+ error: 'Bad Request',
91
+ message: 'Unknown error',
92
+ statusCode: 400,
93
+ });
94
+
95
+ expect(nockedRequest.isDone()).toBe(true);
96
+ });
97
+ });
@@ -0,0 +1,82 @@
1
+ const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
+ const webwalletBuildFastify = require('./helpers/webwallet-build-fastify');
3
+ const { credentialsRepoPlugin } = require('../src/entities');
4
+ const initCredentialsFactory = require('./factories/credentials');
5
+
6
+ jest.mock('@velocitycareerlabs/vnf-nodejs-wallet-sdk', () => {
7
+ const originalModule = jest.requireActual(
8
+ '@velocitycareerlabs/vnf-nodejs-wallet-sdk'
9
+ );
10
+
11
+ return {
12
+ ...originalModule,
13
+ VCLProvider: {
14
+ getInstance: jest.fn().mockReturnValue({
15
+ initialize: jest.fn().mockResolvedValue(null),
16
+ }),
17
+ },
18
+ };
19
+ });
20
+
21
+ describe('Test filterDeletedCredentialsExtension', () => {
22
+ let fastify;
23
+ let credentialsRepo;
24
+ let persistCredentials;
25
+
26
+ beforeAll(async () => {
27
+ fastify = webwalletBuildFastify();
28
+ await fastify.ready();
29
+
30
+ ({ persistCredentials } = initCredentialsFactory(fastify));
31
+
32
+ credentialsRepo = await credentialsRepoPlugin(fastify)({
33
+ config: fastify.config,
34
+ });
35
+ });
36
+
37
+ afterEach(async () => {
38
+ await mongoDb().collection('credentials').deleteMany({});
39
+ });
40
+
41
+ afterAll(async () => {
42
+ await fastify.close();
43
+ });
44
+
45
+ it('Credentials with deletedAt field shouldn`t be visible for find requests', async () => {
46
+ const [credential] = await Promise.all([
47
+ persistCredentials(),
48
+ persistCredentials(),
49
+ ]);
50
+
51
+ await credentialsRepo.update(credential._id, {
52
+ deletedAt: new Date(),
53
+ });
54
+
55
+ expect(await credentialsRepo.find()).toHaveLength(1);
56
+
57
+ expect(
58
+ await credentialsRepo.findOne({ filter: { _id: credential._id } })
59
+ ).toBeNull();
60
+ });
61
+
62
+ it('It should still be possible to retrieve deleted credentials if deletedAt is explicitly passed', async () => {
63
+ const [credential] = await Promise.all([
64
+ persistCredentials(),
65
+ persistCredentials(),
66
+ ]);
67
+
68
+ await credentialsRepo.update(credential._id, {
69
+ deletedAt: new Date(),
70
+ });
71
+
72
+ expect(
73
+ await credentialsRepo.find({ deletedAt: { $exists: true } })
74
+ ).toHaveLength(1);
75
+
76
+ expect(
77
+ await credentialsRepo.findOne({
78
+ filter: { _id: credential._id, deletedAt: { $exists: true } },
79
+ })
80
+ ).toBeTruthy();
81
+ });
82
+ });
@@ -0,0 +1,10 @@
1
+ HOST_URL=http://localhost.test
2
+ CAREER_WALLET_URL=http://careerwallet.localhost.test
3
+ OAUTH0_DOMAIN=https://localhost/
4
+ OAUTH0_WEBAPP_CLIENT_ID=foo
5
+ AUTH0_WEB_WALLET_AUDIENCE=foo
6
+ LIB_URL=http://lib.localhost.test
7
+ VCL_SDK_ENVIRONMENT=dev
8
+ VCL_SDK_VNF_PROTOCOL_VERSION=2.0
9
+ WEB_WALLET_BASE_URL=localhost:3000
10
+ DEEP_LINK_PROTOCOL=velocity-network-devnet://
@@ -0,0 +1,16 @@
1
+ const nockConsentAdd = (nockInstance) => {
2
+ nockInstance
3
+ .post('/api/v0.6/careerwallet/consents/add', () => true, {
4
+ 'Content-Type': 'application/json',
5
+ })
6
+ .reply(204, {
7
+ consent: {
8
+ version: '1.0',
9
+ accountId: 'mocked-user-id',
10
+ createdAt: new Date().toISOString(),
11
+ id: 'mocked-consent-id',
12
+ },
13
+ });
14
+ };
15
+
16
+ module.exports = { nockConsentAdd };
@@ -0,0 +1,15 @@
1
+ const nockConsentGetLatest = (nockInstance) => {
2
+ nockInstance
3
+ .get('/api/v0.6/careerwallet/consents/latest')
4
+ .query({ accountId: '1111' })
5
+ .reply(204, {
6
+ consent: {
7
+ id: '1',
8
+ version: '1.0',
9
+ accountId: '1111',
10
+ createdAt: new Date().toISOString(),
11
+ },
12
+ });
13
+ };
14
+
15
+ module.exports = { nockConsentGetLatest };
@@ -0,0 +1,9 @@
1
+ const nockFeedback = (nockInstance) => {
2
+ nockInstance
3
+ .post('/api/v0.6/feedback', () => true, {
4
+ 'Content-Type': ' application/json',
5
+ })
6
+ .reply(204, {});
7
+ };
8
+
9
+ module.exports = { nockFeedback };
@@ -0,0 +1,9 @@
1
+ const nockLinkedinAccess = (nockInstance, statusCode = 204) => {
2
+ nockInstance
3
+ .post('/accessToken', () => true, {
4
+ 'Content-Type': ' application/x-www-form-urlencoded',
5
+ })
6
+ .reply(statusCode, { expires_in: 5184000, access_token: 'access_token' });
7
+ };
8
+
9
+ module.exports = { nockLinkedinAccess };
@@ -0,0 +1,15 @@
1
+ const nockLinkedinEmail = (nockInstance) => {
2
+ nockInstance
3
+ .get('/emailAddress?q=members&projection=(elements*(handle~))')
4
+ .reply(200, {
5
+ elements: [
6
+ {
7
+ 'handle~': {
8
+ emailAddress: 'LINKEDIN_USER_EMAIL',
9
+ },
10
+ },
11
+ ],
12
+ });
13
+ };
14
+
15
+ module.exports = { nockLinkedinEmail };
@@ -0,0 +1,28 @@
1
+ const nockLinkedinImageRegister = (nockInstance) => {
2
+ nockInstance
3
+ .post('/assets?action=registerUpload', () => true, {
4
+ 'Content-Type': 'application/json',
5
+ 'X-Restli-Protocol-Version': '2.0.0',
6
+ Authorization: 'Bearer 12345',
7
+ })
8
+ .reply(
9
+ 200,
10
+ JSON.stringify({
11
+ value: {
12
+ uploadMechanism: {
13
+ 'com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest': {
14
+ uploadUrl:
15
+ // eslint-disable-next-line max-len
16
+ 'https://www.linkedin.com/dms-uploads/C5622AQHdBDflPp0pEg/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&sync=1&v=beta&ut=1lrKqjt4fYuqw1',
17
+ headers: {
18
+ 'media-type-family': 'STILLIMAGE',
19
+ },
20
+ },
21
+ },
22
+ asset: 'urn:li:digitalmediaAsset:C5622AQHdBDflPp0pEg',
23
+ },
24
+ })
25
+ );
26
+ };
27
+
28
+ module.exports = { nockLinkedinImageRegister };
@@ -0,0 +1,13 @@
1
+ const nockLinkedinMe = (nockInstance, statusCode = 200) => {
2
+ nockInstance
3
+ .get(
4
+ '/me?projection=(id,localizedFirstName,localizedLastName,profilePicture(displayImage~digitalmediaAsset:playableStreams))'
5
+ )
6
+ .reply(statusCode, {
7
+ id: 'LINKEDIN_USER_ID',
8
+ localizedLastName: 'LAST',
9
+ localizedFirstName: 'FIRST',
10
+ });
11
+ };
12
+
13
+ module.exports = { nockLinkedinMe };