@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,111 @@
1
+ const webWalletPresentationRequestInputDescriptorsSchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-presentation-request-input-descriptors.schema.json',
3
+ type: 'object',
4
+ properties: {
5
+ id: { type: 'string' },
6
+ name: { type: 'string' },
7
+ purpose: { type: 'string' },
8
+ metadata: { type: 'object' },
9
+ group: {
10
+ type: 'array',
11
+ items: { type: 'string' },
12
+ },
13
+ schema: {
14
+ type: 'array',
15
+ items: {
16
+ $ref: 'https://velocitycareerlabs.io/webwallet-presentation-request-schema.schema.json',
17
+ },
18
+ },
19
+ constraints: {
20
+ type: 'object',
21
+ properties: {
22
+ limit_disclosure: { type: 'boolean' },
23
+ statuses: {
24
+ type: 'object',
25
+ properties: {
26
+ active: {
27
+ type: 'object',
28
+ properties: {
29
+ directive: {
30
+ type: 'string',
31
+ enum: ['required', 'allowed', 'disallowed'],
32
+ },
33
+ },
34
+ },
35
+ suspended: {
36
+ type: 'object',
37
+ properties: {
38
+ directive: {
39
+ type: 'string',
40
+ enum: ['required', 'allowed', 'disallowed'],
41
+ },
42
+ },
43
+ },
44
+ revoked: {
45
+ type: 'object',
46
+ properties: {
47
+ directive: {
48
+ type: 'string',
49
+ enum: ['required', 'allowed', 'disallowed'],
50
+ },
51
+ },
52
+ },
53
+ },
54
+ },
55
+ fields: {
56
+ type: 'array',
57
+ items: {
58
+ $ref: 'https://velocitycareerlabs.io/webwallet-presentation-request-field.schema.json',
59
+ },
60
+ },
61
+ subject_is_issuer: {
62
+ type: 'string',
63
+ enum: ['required', 'preferred'],
64
+ },
65
+ is_holder: {
66
+ type: 'array',
67
+ items: {
68
+ type: 'object',
69
+ properties: {
70
+ field_id: {
71
+ type: 'array',
72
+ items: { type: 'string' },
73
+ },
74
+ directive: {
75
+ type: 'string',
76
+ enum: ['required', 'preferred'],
77
+ },
78
+ },
79
+ required: ['field_id', 'directive'],
80
+ additionalProperties: false,
81
+ },
82
+ },
83
+ same_subject: {
84
+ type: 'array',
85
+ items: {
86
+ type: 'object',
87
+ properties: {
88
+ field_id: {
89
+ type: 'array',
90
+ items: { type: 'string' },
91
+ },
92
+ directive: {
93
+ type: 'string',
94
+ enum: ['required', 'preferred'],
95
+ },
96
+ },
97
+ required: ['field_id', 'directive'],
98
+ additionalProperties: false,
99
+ },
100
+ },
101
+ },
102
+ additionalProperties: false,
103
+ },
104
+ },
105
+ required: ['id', 'schema'],
106
+ additionalProperties: false,
107
+ };
108
+
109
+ module.exports = {
110
+ webWalletPresentationRequestInputDescriptorsSchema,
111
+ };
@@ -0,0 +1,14 @@
1
+ const webWalletPresentationRequestSchemaSchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-presentation-request-schema.schema.json',
3
+ type: 'object',
4
+ properties: {
5
+ uri: { type: 'string' },
6
+ required: { type: 'boolean' },
7
+ },
8
+ required: ['uri'],
9
+ additionalProperties: false,
10
+ };
11
+
12
+ module.exports = {
13
+ webWalletPresentationRequestSchemaSchema,
14
+ };
@@ -0,0 +1,37 @@
1
+ const webWalletPresentationRequestSubmissionRequirementsSchema = {
2
+ $id: 'https://velocitycareerlabs.io/webwallet-presentation-request-submission-requirements.schema.json',
3
+ type: 'object',
4
+ properties: {
5
+ name: { type: 'string' },
6
+ purpose: { type: 'string' },
7
+ rule: {
8
+ type: 'string',
9
+ enum: ['all', 'pick'],
10
+ },
11
+ count: { type: 'integer', minimum: 1 },
12
+ min: { type: 'integer', minimum: 0 },
13
+ max: { type: 'integer', minimum: 0 },
14
+ from: { type: 'string' },
15
+ from_nested: {
16
+ type: 'array',
17
+ minItems: 1,
18
+ items: {
19
+ $ref: 'https://velocitycareerlabs.io/webwallet-presentation-request-submission-requirements.schema.json',
20
+ },
21
+ },
22
+ },
23
+ required: ['rule'],
24
+ oneOf: [
25
+ {
26
+ required: ['from'],
27
+ },
28
+ {
29
+ required: ['from_nested'],
30
+ },
31
+ ],
32
+ additionalProperties: false,
33
+ };
34
+
35
+ module.exports = {
36
+ webWalletPresentationRequestSubmissionRequirementsSchema,
37
+ };
@@ -0,0 +1,79 @@
1
+ const webWalletPresentationRequestSchema = {
2
+ $id: 'https://velocitycareerlabs.io/presentation-request.schema.json',
3
+ title: 'presentation-request',
4
+ description: 'the schema for presentation request to disclosure credentials',
5
+ type: 'object',
6
+ properties: {
7
+ exp: {
8
+ type: 'integer',
9
+ },
10
+ iat: {
11
+ type: 'integer',
12
+ },
13
+ iss: {
14
+ type: 'string',
15
+ },
16
+ aud: {
17
+ type: 'string',
18
+ },
19
+ nbf: {
20
+ type: 'integer',
21
+ },
22
+ presentation_definition: {
23
+ type: 'object',
24
+ properties: {
25
+ id: { type: 'string' },
26
+ name: { type: 'string' },
27
+ purpose: { type: 'string' },
28
+ locale: { type: 'string' },
29
+ format: {
30
+ $ref: 'https://velocitycareerlabs.io/webwallet-presentation-request-format.schema.json',
31
+ },
32
+ submission_requirements: {
33
+ type: 'array',
34
+ items: {
35
+ $ref: 'https://velocitycareerlabs.io/webwallet-presentation-request-submission-requirements.schema.json',
36
+ },
37
+ },
38
+ input_descriptors: {
39
+ type: 'array',
40
+ items: {
41
+ $ref: 'https://velocitycareerlabs.io/webwallet-presentation-request-input-descriptors.schema.json',
42
+ },
43
+ },
44
+ },
45
+ required: ['id', 'input_descriptors'],
46
+ additionalProperties: false,
47
+ },
48
+ metadata: {
49
+ type: 'object',
50
+ properties: {
51
+ client_name: {
52
+ type: 'string',
53
+ },
54
+ logo_uri: {
55
+ type: 'string',
56
+ format: 'uri',
57
+ },
58
+ tos_uri: {
59
+ type: 'string',
60
+ format: 'uri',
61
+ },
62
+ max_retention_period: {
63
+ type: 'string',
64
+ },
65
+ progress_uri: { type: 'string', format: 'uri' },
66
+ submit_presentation_uri: { type: 'string', format: 'uri' },
67
+ },
68
+ required: ['client_name', 'logo_uri', 'tos_uri'],
69
+ },
70
+ exchange_id: {
71
+ type: 'string',
72
+ },
73
+ },
74
+ required: ['metadata', 'exchange_id', 'presentation_definition'],
75
+ };
76
+
77
+ module.exports = {
78
+ webWalletPresentationRequestSchema,
79
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ ...require('./accounts'),
3
+ ...require('./credentials'),
4
+ ...require('./disclosures'),
5
+ ...require('./issuing'),
6
+ };
@@ -0,0 +1,8 @@
1
+ const identityClaimTypes = {
2
+ email: 'EmailV1.0',
3
+ phone: 'PhoneV1.0',
4
+ };
5
+
6
+ module.exports = {
7
+ identityClaimTypes,
8
+ };
@@ -0,0 +1,26 @@
1
+ const md5 = require('blueimp-md5');
2
+ const { get } = require('lodash/fp');
3
+
4
+ /**
5
+ * @param {import('../../../entities/accounts/repos/accounts.repo').Account} account
6
+ * @param {string} value
7
+ * @param {string} credentialType - 'email' | 'phone'
8
+ */
9
+ const doesUserHaveFreshPendingVerification = (
10
+ account,
11
+ value,
12
+ credentialType
13
+ ) => {
14
+ const { codeSentTo, codeSentAt } =
15
+ get(`verificationInfo.${credentialType}`, account) || {};
16
+
17
+ return (
18
+ codeSentTo &&
19
+ codeSentTo === md5(value) &&
20
+ new Date(codeSentAt) > new Date(new Date().getTime() - 1000 * 60 * 2)
21
+ );
22
+ };
23
+
24
+ module.exports = {
25
+ doesUserHaveFreshPendingVerification,
26
+ };
@@ -0,0 +1,18 @@
1
+ const { jwtDecode } = require('@velocitycareerlabs/jwt');
2
+ const { map } = require('lodash/fp');
3
+ const { offerToCredentialMongoDTO } = require('../../credentials');
4
+
5
+ const getCredentialsFromOffers = (auth0UserId, userDid, offers) =>
6
+ map((offer) => {
7
+ const { encodedJwt } = offer;
8
+ const decodedJwt = jwtDecode(encodedJwt);
9
+
10
+ return offerToCredentialMongoDTO(auth0UserId, userDid, {
11
+ ...decodedJwt.payload,
12
+ encodedCredential: encodedJwt,
13
+ });
14
+ })(offers);
15
+
16
+ module.exports = {
17
+ getCredentialsFromOffers,
18
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ ...require('./constants'),
3
+ ...require('./get-credentials-from-offers'),
4
+ ...require('./does-user-have-fresh-pending-verification'),
5
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ ...require('./domain'),
3
+ ...require('./orchestrators'),
4
+ ...require('./schemas'),
5
+ };
@@ -0,0 +1,35 @@
1
+ const { map, isEmpty } = require('lodash/fp');
2
+
3
+ /**
4
+ *
5
+ * @param {Array<string>} credentialIds
6
+ * @param {object} context
7
+ * @returns {Promise<Array<{id: string, inputDescriptor: string, jwtVc: string}>>}
8
+ */
9
+ const buildIssuingInputCredentials = async (
10
+ credentialIds,
11
+ { repos: { credentials: credentialsRepo }, user }
12
+ ) => {
13
+ if (isEmpty(credentialIds)) return [];
14
+
15
+ const credentials = await credentialsRepo.find({
16
+ filter: {
17
+ _id: { $in: credentialIds },
18
+ auth0UserId: user.sub,
19
+ },
20
+ });
21
+
22
+ const issuingInput = map(
23
+ (credential) => ({
24
+ inputDescriptor: credential.type[0],
25
+ jwtVc: credential.encodedCredential,
26
+ }),
27
+ credentials
28
+ );
29
+
30
+ return issuingInput;
31
+ };
32
+
33
+ module.exports = {
34
+ buildIssuingInputCredentials,
35
+ };
@@ -0,0 +1,74 @@
1
+ const {
2
+ VCLGenerateOffersDescriptor,
3
+ VCLCredentialManifest,
4
+ VCLDeepLink,
5
+ VCLVerifiedProfile,
6
+ VCLJwt,
7
+ VCLDidJwk,
8
+ VCLVerifiableCredential,
9
+ } = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
10
+
11
+ /**
12
+ * @param {object} credentialManifest
13
+ * @param {import('@velocitycareerlabs/vnf-nodejs-wallet-sdk')} issuingType
14
+ * @param {Array<string>} credentialClaimTypes
15
+ * @param {Array<{id: string, inputDescriptor: string, jwtVc: string}>} inputCredentials
16
+ * @param {import('fastify').FastifyRequest} context
17
+ * @returns {Promise<{offers: Array<any>, credentialManifest: any}>}
18
+ */
19
+ const generateOffersByDeepLink = async (
20
+ credentialManifest,
21
+ issuingType,
22
+ credentialClaimTypes,
23
+ inputCredentials,
24
+ context
25
+ ) => {
26
+ const {
27
+ vclSdk,
28
+ config: { careerWalletAdminAccessToken },
29
+ repos: { accounts },
30
+ user,
31
+ } = context;
32
+
33
+ const { didKeyMetadatum } = await accounts.findOne({
34
+ filter: { userId: user.sub },
35
+ });
36
+ const didJwk =
37
+ didKeyMetadatum &&
38
+ Array.isArray(didKeyMetadatum) &&
39
+ didKeyMetadatum.length > 0
40
+ ? VCLDidJwk.fromJSON(didKeyMetadatum[0])
41
+ : null;
42
+
43
+ const deepLink = new VCLDeepLink(credentialManifest.link);
44
+ const vclCredentialManifest = new VCLCredentialManifest(
45
+ VCLJwt.fromEncodedJwt(credentialManifest.jwt),
46
+ deepLink.vendorOriginContext,
47
+ new VCLVerifiedProfile(credentialManifest.verifiedProfile),
48
+ deepLink,
49
+ didJwk,
50
+ careerWalletAdminAccessToken
51
+ );
52
+ const vclGenerateOffersDescriptor = new VCLGenerateOffersDescriptor(
53
+ vclCredentialManifest,
54
+ credentialClaimTypes,
55
+ [],
56
+ inputCredentials.map(
57
+ (inputCredential) =>
58
+ new VCLVerifiableCredential(
59
+ inputCredential.inputDescriptor,
60
+ inputCredential.jwtVc
61
+ )
62
+ )
63
+ );
64
+ const offers = await vclSdk.generateOffers(vclGenerateOffersDescriptor);
65
+
66
+ return {
67
+ offers,
68
+ vclCredentialManifest,
69
+ };
70
+ };
71
+
72
+ module.exports = {
73
+ generateOffersByDeepLink,
74
+ };
@@ -0,0 +1,35 @@
1
+ const { isEmpty, intersection, values, find } = require('lodash/fp');
2
+ const {
3
+ VCLOrganizationsSearchDescriptor,
4
+ VCLFilter,
5
+ } = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
6
+
7
+ const { getAppConfig } = require('../../../fetchers');
8
+ const { identityClaimTypes } = require('../domain');
9
+
10
+ const getIdentityIssuerService = async (type, context) => {
11
+ const { emailVerifierDid, phoneVerifierDid } = await getAppConfig(context);
12
+
13
+ const { all: [organization] = [] } =
14
+ await context.vclSdk.searchForOrganizations(
15
+ new VCLOrganizationsSearchDescriptor(
16
+ new VCLFilter(type === 'email' ? emailVerifierDid : phoneVerifierDid)
17
+ )
18
+ );
19
+
20
+ if (!organization) {
21
+ return null;
22
+ }
23
+
24
+ const idCredentialsService = find(
25
+ ({ credentialTypes }) =>
26
+ !isEmpty(intersection(values(identityClaimTypes), credentialTypes)),
27
+ organization.serviceCredentialAgentIssuers
28
+ );
29
+
30
+ return idCredentialsService;
31
+ };
32
+
33
+ module.exports = {
34
+ getIdentityIssuerService,
35
+ };
@@ -0,0 +1,74 @@
1
+ const { values } = require('lodash/fp');
2
+ const {
3
+ VCLFinalizeOffersDescriptor,
4
+ VCLIssuingType,
5
+ VCLDeepLink,
6
+ VCLCredentialManifestDescriptorByDeepLink,
7
+ } = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
8
+ const { identityClaimTypes } = require('../domain');
9
+ const { generateOffersByDeepLink } = require('./generate-offers-by-deep-link');
10
+
11
+ const getIdentityOffersByDeepLink = async (deepLink, context) => {
12
+ const { vclSdk } = context;
13
+
14
+ const identityClaimTypesList = values(identityClaimTypes);
15
+
16
+ const credentialManifest = await vclSdk.getCredentialManifest(
17
+ new VCLCredentialManifestDescriptorByDeepLink(
18
+ new VCLDeepLink(deepLink),
19
+ VCLIssuingType.Identity,
20
+ null,
21
+ null,
22
+ null
23
+ )
24
+ );
25
+ // TODO: need to be refactored
26
+ // Transform to weired credential manifest
27
+ const weiredCredentialManifest = {
28
+ jwt: credentialManifest.jwt.encodedJwt,
29
+ vendorOriginContext: credentialManifest.vendorOriginContext,
30
+ verifiedProfile: credentialManifest.verifiedProfile.payload,
31
+ link: credentialManifest.deepLink.value,
32
+ };
33
+ const { offers, vclCredentialManifest } = await generateOffersByDeepLink(
34
+ weiredCredentialManifest,
35
+ VCLIssuingType.Identity,
36
+ identityClaimTypesList,
37
+ [],
38
+ context
39
+ );
40
+
41
+ if (!offers.all.length) {
42
+ return {
43
+ passedCredentials: [],
44
+ failedCredentials: [],
45
+ offers: [],
46
+ credentialManifest: {},
47
+ };
48
+ }
49
+
50
+ const offersPayloadArr = offers.all.map((offer) => offer.payload);
51
+ const approvedOffersIds = offersPayloadArr.map(
52
+ (offersPayload) => offersPayload.id
53
+ );
54
+
55
+ const acceptedOffers = await vclSdk.finalizeOffers(
56
+ new VCLFinalizeOffersDescriptor(
57
+ vclCredentialManifest,
58
+ offers.challenge,
59
+ approvedOffersIds,
60
+ []
61
+ ),
62
+ offers.sessionToken
63
+ );
64
+
65
+ return {
66
+ acceptedOffers,
67
+ offersPayloadArr,
68
+ credentialManifest: vclCredentialManifest,
69
+ };
70
+ };
71
+
72
+ module.exports = {
73
+ getIdentityOffersByDeepLink,
74
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ ...require('./get-identity-issuer'),
3
+ ...require('./get-identity-offers-by-deeplink'),
4
+ ...require('./build-issuing-input-credentials'),
5
+ ...require('./generate-offers-by-deep-link'),
6
+ };
@@ -0,0 +1,9 @@
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-credential-manifest.schema'),
9
+ };