@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,92 @@
1
+ const newError = require('http-errors');
2
+ const { loadAdditionalRenderInfo } = require('../../entities');
3
+ const { getCredentialCategories } = require('../../fetchers');
4
+
5
+ const credentialsController = async (fastify) => {
6
+ fastify.get(
7
+ '/',
8
+ {
9
+ preValidation: fastify.verifyAccessToken(),
10
+ schema: fastify.autoSchema({
11
+ tags: ['webwallet'],
12
+ response: {
13
+ 200: {
14
+ $ref: 'https://velocitycareerlabs.io/webwallet-credentials-response.schema.json',
15
+ },
16
+ },
17
+ }),
18
+ },
19
+ async (req) => {
20
+ const { repos } = req;
21
+
22
+ const credentials = await repos.credentials.find({
23
+ filter: { auth0UserId: req.user.sub },
24
+ });
25
+
26
+ const additionalRenderInfo = await loadAdditionalRenderInfo(
27
+ credentials,
28
+ req
29
+ );
30
+
31
+ return { credentials, ...additionalRenderInfo };
32
+ }
33
+ );
34
+
35
+ fastify.delete(
36
+ '/:credentialId',
37
+ {
38
+ preValidation: fastify.verifyAccessToken(),
39
+ schema: fastify.autoSchema({
40
+ params: {
41
+ type: 'object',
42
+ properties: {
43
+ credentialId: { type: 'string' },
44
+ },
45
+ },
46
+ response: {
47
+ 204: { type: 'null' },
48
+ },
49
+ }),
50
+ },
51
+ async (
52
+ { repos: { credentials: credentialsRepo }, params, user },
53
+ reply
54
+ ) => {
55
+ const credential = await credentialsRepo.findOne({
56
+ filter: { _id: params.credentialId, auth0UserId: user.sub },
57
+ });
58
+
59
+ if (!credential) {
60
+ throw newError.NotFound(`Credential ${params.credentialId} not found`);
61
+ }
62
+
63
+ await credentialsRepo.update(params.credentialId, {
64
+ deletedAt: new Date(),
65
+ });
66
+
67
+ reply.code(204);
68
+ }
69
+ );
70
+
71
+ fastify.get(
72
+ '/categories',
73
+ {
74
+ preValidation: fastify.verifyAccessToken(),
75
+ schema: fastify.autoSchema({
76
+ tags: ['webwallet'],
77
+ response: {
78
+ 200: {
79
+ $ref: 'https://velocitycareerlabs.io/webwallet-credential-categories-response.schema.json',
80
+ },
81
+ },
82
+ }),
83
+ },
84
+ async (req) => {
85
+ const credentialCategories = await getCredentialCategories(req);
86
+
87
+ return credentialCategories;
88
+ }
89
+ );
90
+ };
91
+
92
+ module.exports = credentialsController;
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ ...require('./webwallet-credentials-response.schema'),
3
+ ...require('./webwallet-credential-categories-response.schema'),
4
+ };
@@ -0,0 +1,21 @@
1
+ const webWalletCredentialCategoriesResponseSchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-credential-categories-response.schema.json',
3
+ title: 'webwallet-credential-categories-response',
4
+ description:
5
+ 'the body of response for webwallet get credential categories endpoint',
6
+ type: 'array',
7
+ items: {
8
+ type: 'object',
9
+ properties: {
10
+ title: { type: 'string' },
11
+ icon: { type: 'string' },
12
+ color: { type: 'string' },
13
+ types: { type: 'array', items: { type: 'string' } },
14
+ iconSize: { type: 'integer' },
15
+ isIdentity: { type: 'boolean' },
16
+ },
17
+ required: ['title', 'icon', 'color', 'types', 'iconSize'],
18
+ },
19
+ };
20
+
21
+ module.exports = { webWalletCredentialCategoriesResponseSchema };
@@ -0,0 +1,29 @@
1
+ const webWalletCredentialsResponseSchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-credentials-response.schema.json',
3
+ title: 'webwallet-credentials-response',
4
+ description: 'the body of response for webwallet get credentials endpoint',
5
+ type: 'object',
6
+ properties: {
7
+ credentials: {
8
+ type: 'array',
9
+ items: {
10
+ $ref: 'https://velocitycareerlabs.io/webwallet-credential-response.schema.json',
11
+ },
12
+ },
13
+ issuers: {
14
+ type: 'object',
15
+ additionalProperties: {
16
+ $ref: 'organization-profile',
17
+ },
18
+ },
19
+ displayDescriptors: {
20
+ type: 'object',
21
+ additionalProperties: {
22
+ $ref: 'https://velocitycareerlabs.io/webwallet-display-descriptor-response.schema.json',
23
+ },
24
+ },
25
+ },
26
+ required: ['credentials'],
27
+ };
28
+
29
+ module.exports = { webWalletCredentialsResponseSchema };
@@ -0,0 +1,21 @@
1
+ const { values, forEach } = require('lodash/fp');
2
+ const { oauthPlugin } = require('@velocitycareerlabs/auth');
3
+
4
+ const controllerSchemas = require('./schemas');
5
+ const disclosureSchemas = require('../../entities/disclosures/schemas');
6
+
7
+ module.exports = async (fastify) => {
8
+ forEach(
9
+ (schema) => fastify.addSchema(schema),
10
+ [...values(disclosureSchemas), ...values(controllerSchemas)]
11
+ );
12
+
13
+ fastify
14
+ .autoSchemaPreset({
15
+ tags: ['webwallet'],
16
+ })
17
+ .register(oauthPlugin, {
18
+ domain: fastify.config.auth0Domain,
19
+ audience: [fastify.config.auth0WebWalletAudience],
20
+ });
21
+ };
@@ -0,0 +1,168 @@
1
+ const { jwtDecode } = require('@velocitycareerlabs/jwt');
2
+ const {
3
+ VCLPresentationSubmission,
4
+ VCLDeepLink,
5
+ VCLPresentationRequestDescriptor,
6
+ VCLDidJwk,
7
+ } = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
8
+ const { getAppConfig } = require('../../fetchers/career-wallet/get-app-config');
9
+
10
+ /**
11
+ * @param {import('fastify').FastifyInstance} fastify
12
+ */
13
+ const disclosureController = async (fastify) => {
14
+ fastify.get(
15
+ '/get-presentation-request',
16
+ {
17
+ preValidation: fastify.verifyAccessToken(),
18
+ schema: fastify.autoSchema({
19
+ tags: ['webwallet'],
20
+ querystring: {
21
+ $ref: 'https://velocitycareerlabs.io/webwallet-get-presentation-request-query.schema.json',
22
+ },
23
+ response: {
24
+ 200: {
25
+ $ref: 'https://velocitycareerlabs.io/webwallet-get-presentation-request-response.schema.json',
26
+ },
27
+ '4xx': { $ref: 'error#' },
28
+ },
29
+ }),
30
+ },
31
+ async (req) => {
32
+ const presentationRequest = await req.vclSdk.getPresentationRequest(
33
+ new VCLPresentationRequestDescriptor(new VCLDeepLink(req.query.link))
34
+ );
35
+
36
+ const { payload: presentation } = jwtDecode(
37
+ presentationRequest.jwt.encodedJwt
38
+ );
39
+
40
+ return { presentation };
41
+ }
42
+ );
43
+
44
+ fastify.get(
45
+ '/get-public-share-link',
46
+ {
47
+ preValidation: fastify.verifyAccessToken(),
48
+ schema: fastify.autoSchema({
49
+ tags: ['webwallet'],
50
+ response: {
51
+ 200: {
52
+ type: 'object',
53
+ properties: {
54
+ link: { type: 'string' },
55
+ template: { type: 'string' },
56
+ },
57
+ },
58
+ '4xx': { $ref: 'error#' },
59
+ },
60
+ }),
61
+ },
62
+ async (req) => {
63
+ const {
64
+ verificationServiceDeepLink: link,
65
+ verificationServicePresentationLinkTemplate: template,
66
+ } = await getAppConfig(req);
67
+
68
+ return { link, template };
69
+ }
70
+ );
71
+
72
+ fastify.post(
73
+ '/accept-presentation-request',
74
+ {
75
+ preValidation: fastify.verifyAccessToken(),
76
+ schema: fastify.autoSchema({
77
+ tags: ['webwallet'],
78
+ body: {
79
+ $ref: 'https://velocitycareerlabs.io/webwallet-accept-presentation-request-body.schema.json',
80
+ },
81
+ response: {
82
+ 200: {
83
+ $ref: 'https://velocitycareerlabs.io/webwallet-accept-presentation-response.schema.json',
84
+ },
85
+ '4xx': { $ref: 'error#' },
86
+ },
87
+ }),
88
+ },
89
+ async ({
90
+ body,
91
+ vclSdk,
92
+ repos,
93
+ user,
94
+ repos: { accounts },
95
+ config: { careerWalletAdminAccessToken },
96
+ }) => {
97
+ const { didKeyMetadatum } = await accounts.findOne({
98
+ filter: { userId: user.sub },
99
+ });
100
+ const didJwk =
101
+ didKeyMetadatum &&
102
+ Array.isArray(didKeyMetadatum) &&
103
+ didKeyMetadatum.length > 0
104
+ ? VCLDidJwk.fromJSON(didKeyMetadatum[0])
105
+ : null;
106
+
107
+ const presentationRequest = await vclSdk.getPresentationRequest(
108
+ new VCLPresentationRequestDescriptor(
109
+ new VCLDeepLink(body.link),
110
+ null,
111
+ didJwk,
112
+ careerWalletAdminAccessToken
113
+ )
114
+ );
115
+
116
+ const { payload: presentation } = jwtDecode(
117
+ presentationRequest.jwt.encodedJwt
118
+ );
119
+
120
+ const submissionResult = await vclSdk.submitPresentation(
121
+ new VCLPresentationSubmission(presentationRequest, body.credentials)
122
+ );
123
+
124
+ const { did: userDid } = await repos.accounts.findOne({
125
+ filter: { userId: user.sub },
126
+ });
127
+
128
+ const disclosure = await repos.disclosures.insert({
129
+ auth0UserId: user.sub,
130
+ userDid,
131
+ presentation,
132
+ encodedJwt: presentationRequest.jwt.encodedJwt,
133
+ jti: submissionResult.jti,
134
+ submissionId: submissionResult.submissionId,
135
+ presentationDefinitionId: presentation.presentation_definition.id,
136
+ token: submissionResult.sessionToken.value,
137
+ sharedCredentials: body.credentials.map(({ id }) => id),
138
+ type: body.type,
139
+ });
140
+
141
+ return { disclosure };
142
+ }
143
+ );
144
+
145
+ fastify.get(
146
+ '',
147
+ {
148
+ preValidation: fastify.verifyAccessToken(),
149
+ schema: fastify.autoSchema({
150
+ tags: ['webwallet'],
151
+ response: {
152
+ 200: {
153
+ $ref: 'https://velocitycareerlabs.io/webwallet-get-disclosures-response.schema.json',
154
+ },
155
+ },
156
+ }),
157
+ },
158
+ async ({ repos, user }) => {
159
+ const disclosures = await repos.disclosures.find({
160
+ filter: { auth0UserId: user.sub },
161
+ });
162
+
163
+ return { disclosures };
164
+ }
165
+ );
166
+ };
167
+
168
+ module.exports = disclosureController;
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ ...require('./webwallet-get-presentation-request-query.schema'),
3
+ ...require('./webwallet-get-presentation-request-response.schema'),
4
+ ...require('./webwallet-accept-presentation-request-body.schema'),
5
+ ...require('./webwallet-accept-presentation-response.schema'),
6
+ ...require('./webwallet-get-disclosures-response.schema'),
7
+ };
@@ -0,0 +1,28 @@
1
+ const webWalletAcceptPresentationRequestBodySchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-accept-presentation-request-body.schema.json',
3
+ title: 'webwallet-accept-presentation-request',
4
+ description: 'the request schema for webwallet accept presentation request',
5
+ type: 'object',
6
+ properties: {
7
+ link: { type: 'string' },
8
+ credentials: {
9
+ type: 'array',
10
+ items: {
11
+ type: 'object',
12
+ properties: {
13
+ id: { type: 'string' },
14
+ inputDescriptor: { type: 'string' },
15
+ jwtVc: { type: 'string' },
16
+ },
17
+ required: ['inputDescriptor', 'jwtVc', 'id'],
18
+ },
19
+ minItems: 1,
20
+ },
21
+ type: { type: 'string', enum: ['public', 'linkedin'] },
22
+ },
23
+ required: ['link', 'credentials'],
24
+ };
25
+
26
+ module.exports = {
27
+ webWalletAcceptPresentationRequestBodySchema,
28
+ };
@@ -0,0 +1,16 @@
1
+ const webWalletAcceptPresentationResponseSchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-accept-presentation-response.schema.json',
3
+ title: 'webwallet-accept-presentation-response',
4
+ description: 'the response schema for webwallet accept presentation request',
5
+ type: 'object',
6
+ properties: {
7
+ disclosure: {
8
+ $ref: 'https://velocitycareerlabs.io/webwallet-disclosure.schema.json',
9
+ },
10
+ },
11
+ required: ['disclosure'],
12
+ };
13
+
14
+ module.exports = {
15
+ webWalletAcceptPresentationResponseSchema,
16
+ };
@@ -0,0 +1,18 @@
1
+ const webWalletGetDisclosuresResponseSchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-get-disclosures-response.schema.json',
3
+ title: 'webwallet-get-disclosures-response',
4
+ description: 'the response schema for webwallet get disclosures request',
5
+ type: 'object',
6
+ properties: {
7
+ disclosures: {
8
+ type: 'array',
9
+ items: {
10
+ $ref: 'https://velocitycareerlabs.io/webwallet-disclosure.schema.json',
11
+ },
12
+ },
13
+ },
14
+ };
15
+
16
+ module.exports = {
17
+ webWalletGetDisclosuresResponseSchema,
18
+ };
@@ -0,0 +1,21 @@
1
+ const config = require('../../../config/config');
2
+
3
+ const webWalletGetPresentationRequestQuerySchema = {
4
+ $id: 'https://velocitycareerlabs.io/webwallet-get-presentation-request-query.schema.json',
5
+ title: 'webwallet-get-presentation-request-query',
6
+ description: 'the request schema for webwallet get presentation request',
7
+ type: 'object',
8
+ properties: {
9
+ link: {
10
+ type: 'string',
11
+ format: 'uri',
12
+ pattern: `${config.deepLinkProtocol.replace('//', '')}\\/\\/inspect.*`,
13
+ },
14
+ public_share: { type: 'boolean' },
15
+ },
16
+ oneOf: [{ required: ['link'] }, { required: ['public_share'] }],
17
+ };
18
+
19
+ module.exports = {
20
+ webWalletGetPresentationRequestQuerySchema,
21
+ };
@@ -0,0 +1,16 @@
1
+ const webWalletGetPresentationRequestResponseSchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-get-presentation-request-response.schema.json',
3
+ title: 'webwallet-get-presentation-request-response',
4
+ description: 'the response schema for webwallet get presentation request',
5
+ type: 'object',
6
+ properties: {
7
+ presentation: {
8
+ $ref: 'https://velocitycareerlabs.io/presentation-request.schema.json',
9
+ },
10
+ },
11
+ required: ['presentation'],
12
+ };
13
+
14
+ module.exports = {
15
+ webWalletGetPresentationRequestResponseSchema,
16
+ };
@@ -0,0 +1,11 @@
1
+ const { oauthPlugin } = require('@velocitycareerlabs/auth');
2
+ const multipart = require('@fastify/multipart');
3
+
4
+ module.exports = async (fastify) => {
5
+ fastify
6
+ .register(multipart, { attachFieldsToBody: 'keyValues' })
7
+ .register(oauthPlugin, {
8
+ domain: fastify.config.auth0Domain,
9
+ audience: [fastify.config.auth0WebWalletAudience],
10
+ });
11
+ };
@@ -0,0 +1,48 @@
1
+ const { sendFeedback } = require('../../fetchers/career-wallet');
2
+
3
+ const feedbackController = async (fastify) => {
4
+ fastify.post(
5
+ '/',
6
+ {
7
+ preValidation: fastify.verifyAccessToken(),
8
+ schema: fastify.autoSchema({
9
+ tags: ['webwallet'],
10
+ body: {
11
+ type: 'object',
12
+ properties: {
13
+ feedback: { type: 'string' },
14
+ errorCode: { type: 'string' },
15
+ deviceOS: { type: 'string' },
16
+ },
17
+ required: ['feedback', 'deviceOS', 'errorCode'],
18
+ },
19
+ response: {
20
+ '4xx': { $ref: 'error#' },
21
+ },
22
+ }),
23
+ },
24
+ async (req, reply) => {
25
+ const {
26
+ repos: { accounts },
27
+ user,
28
+ ip,
29
+ } = req;
30
+ const { careerWalletAccountId } = await accounts.findOne({
31
+ filter: { userId: user.sub },
32
+ });
33
+ const payload = {
34
+ accountId: careerWalletAccountId,
35
+ appVersion: '',
36
+ deviceManufacturer: '',
37
+ deviceModel: '',
38
+ ip,
39
+ ...req.body,
40
+ };
41
+ await sendFeedback(payload, req);
42
+ reply.status(204);
43
+ return {};
44
+ }
45
+ );
46
+ };
47
+
48
+ module.exports = feedbackController;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Created by Michael Avoyan on 31/07/2024.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ module.exports = {
8
+ ...require('./webwallet-get-credential-manifest-query.schema'),
9
+ ...require('./webwallet-get-credential-manifest-response.schema'),
10
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Created by Michael Avoyan on 31/07/2024.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ const config = require('../../../config/config');
8
+
9
+ const webWalletGetCredentialManifestQuerySchema = {
10
+ $id: 'https://velocitycareerlabs.io/webwallet-get-credential-manifest-query.schema.json',
11
+ title: 'webwallet-get-credential-manifest-query',
12
+ description: 'the request schema for webwallet get credential manifest',
13
+ type: 'object',
14
+ properties: {
15
+ link: {
16
+ type: 'string',
17
+ format: 'uri',
18
+ pattern: `${config.deepLinkProtocol.replace('//', '')}\\/\\/issue.*`,
19
+ },
20
+ public_share: { type: 'boolean' },
21
+ },
22
+ oneOf: [{ required: ['link'] }, { required: ['public_share'] }],
23
+ };
24
+
25
+ module.exports = {
26
+ webWalletGetCredentialManifestQuerySchema,
27
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Created by Michael Avoyan on 31/07/2024.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ const webWalletGetCredentialManifestResponseSchema = {
8
+ $id: 'https://velocitycareerlabs.io/webwallet-get-credential-manifest-response.schema.json',
9
+ title: 'webwallet-get-credential-manifest-response',
10
+ description: 'the response for credential manifest',
11
+ type: 'object',
12
+ properties: {
13
+ credentialManifest: {
14
+ type: 'object',
15
+ properties: {
16
+ presentation: {
17
+ $ref: 'https://velocitycareerlabs.io/credential-manifest.schema.json',
18
+ },
19
+ jwt: { type: 'string' },
20
+ link: { type: 'string' },
21
+ },
22
+ required: ['jwt', 'presentation'],
23
+ additionalProperties: true,
24
+ },
25
+ },
26
+ required: ['credentialManifest'],
27
+ };
28
+
29
+ module.exports = {
30
+ webWalletGetCredentialManifestResponseSchema,
31
+ };
@@ -0,0 +1,51 @@
1
+ const { oauthPlugin } = require('@velocitycareerlabs/auth');
2
+
3
+ const {
4
+ newOfferRelatedResourceSchema,
5
+ holderOfferSchema,
6
+ organizationProfileBaseSchema,
7
+ organizationProfileSchema,
8
+ addressSchema,
9
+ locationSchema,
10
+ } = require('@velocitycareerlabs/common-schemas');
11
+ const {
12
+ webWalletDeepLinkOffersRequestSchema,
13
+ webWalletDeepLinkOffersResponseSchema,
14
+ webWalletDeepLinkAcceptOffersRequestSchema,
15
+ webWalletDeepLinkAcceptOffersResponseSchema,
16
+ } = require('./schemas');
17
+ const {
18
+ webWalletCredentialResponseSchema,
19
+ webWalletDisplayDescriptorResponseSchema,
20
+ webWalletCredentialManifestSchema,
21
+ } = require('../../../entities');
22
+ const {
23
+ webWalletGetCredentialManifestQuerySchema,
24
+ webWalletGetCredentialManifestResponseSchema,
25
+ } = require('../common-schemas');
26
+
27
+ module.exports = async (fastify) => {
28
+ fastify
29
+ .addSchema(newOfferRelatedResourceSchema)
30
+ .addSchema(holderOfferSchema)
31
+ .addSchema(webWalletCredentialManifestSchema)
32
+ .addSchema(webWalletGetCredentialManifestQuerySchema)
33
+ .addSchema(webWalletGetCredentialManifestResponseSchema)
34
+ .addSchema(webWalletDeepLinkAcceptOffersRequestSchema)
35
+ .addSchema(webWalletDeepLinkAcceptOffersResponseSchema)
36
+ .addSchema(webWalletDeepLinkOffersRequestSchema)
37
+ .addSchema(webWalletDeepLinkOffersResponseSchema)
38
+ .addSchema(addressSchema)
39
+ .addSchema(locationSchema)
40
+ .addSchema(organizationProfileBaseSchema)
41
+ .addSchema(organizationProfileSchema)
42
+ .addSchema(webWalletCredentialResponseSchema)
43
+ .addSchema(webWalletDisplayDescriptorResponseSchema)
44
+ .autoSchemaPreset({
45
+ tags: ['webwallet'],
46
+ })
47
+ .register(oauthPlugin, {
48
+ domain: fastify.config.auth0Domain,
49
+ audience: [fastify.config.auth0WebWalletAudience],
50
+ });
51
+ };