@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.
- package/.localdev.env +57 -0
- package/.standalone.env +22 -0
- package/LICENSE +248 -0
- package/README.md +11 -0
- package/jest.config.js +20 -0
- package/migrate-mongo.config.js +23 -0
- package/package.json +72 -0
- package/src/config/config.js +74 -0
- package/src/controllers/accounts/autohooks.js +28 -0
- package/src/controllers/accounts/controller.js +209 -0
- package/src/controllers/accounts/schemas/index.js +6 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-request.schema.js +25 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-response.schema.js +72 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-update-request.schema.js +23 -0
- package/src/controllers/accounts/schemas/webwallet-test-personas-response.schema.js +110 -0
- package/src/controllers/consent/autohooks.js +14 -0
- package/src/controllers/consent/controller.js +91 -0
- package/src/controllers/consent/schemas/index.js +3 -0
- package/src/controllers/consent/schemas/webwallet-consent-response.schema.js +23 -0
- package/src/controllers/credentials/autohooks.js +36 -0
- package/src/controllers/credentials/controller.js +92 -0
- package/src/controllers/credentials/schemas/index.js +4 -0
- package/src/controllers/credentials/schemas/webwallet-credential-categories-response.schema.js +21 -0
- package/src/controllers/credentials/schemas/webwallet-credentials-response.schema.js +29 -0
- package/src/controllers/disclosures/autohooks.js +21 -0
- package/src/controllers/disclosures/controller.js +168 -0
- package/src/controllers/disclosures/schemas/index.js +7 -0
- package/src/controllers/disclosures/schemas/webwallet-accept-presentation-request-body.schema.js +28 -0
- package/src/controllers/disclosures/schemas/webwallet-accept-presentation-response.schema.js +16 -0
- package/src/controllers/disclosures/schemas/webwallet-get-disclosures-response.schema.js +18 -0
- package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-query.schema.js +21 -0
- package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-response.schema.js +16 -0
- package/src/controllers/feedback/autohooks.js +11 -0
- package/src/controllers/feedback/controller.js +48 -0
- package/src/controllers/issuing/common-schemas/index.js +10 -0
- package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-query.schema.js +27 -0
- package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-response.schema.js +31 -0
- package/src/controllers/issuing/deep-link/autohooks.js +51 -0
- package/src/controllers/issuing/deep-link/controller.js +192 -0
- package/src/controllers/issuing/deep-link/schemas/index.js +6 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-accept-offers-request.schema.js +30 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-accept-offers-response.schema.js +36 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-offers-request.schema.js +28 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-offers-response.schema.js +48 -0
- package/src/controllers/issuing/identity-credentials/autohooks.js +42 -0
- package/src/controllers/issuing/identity-credentials/controller.js +188 -0
- package/src/controllers/issuing/identity-credentials/schemas/index.js +6 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-confirm-body.schema.js +20 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-confirm-response.schema.js +37 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-request-code-body.schema.js +14 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-request-code-params.schema.js +19 -0
- package/src/controllers/linkedin/autohooks.js +16 -0
- package/src/controllers/linkedin/controller.js +276 -0
- package/src/controllers/linkedin/schemas/index.js +3 -0
- package/src/controllers/linkedin/schemas/webwallet-linkedin-me-response.schema.js +14 -0
- package/src/controllers/root/controller.js +29 -0
- package/src/entities/.gitkeep +0 -0
- package/src/entities/accounts/constants.js +5 -0
- package/src/entities/accounts/domains/extract-auth0-id-token-or-access-token.js +22 -0
- package/src/entities/accounts/domains/index.js +5 -0
- package/src/entities/accounts/domains/validate-account-permissions.js +36 -0
- package/src/entities/accounts/domains/validate-logo-size.js +25 -0
- package/src/entities/accounts/index.js +5 -0
- package/src/entities/accounts/repos/accounts.repo.js +63 -0
- package/src/entities/credentials/domains/index.js +3 -0
- package/src/entities/credentials/domains/offer-to-credential-mongo-dto.js +43 -0
- package/src/entities/credentials/index.js +6 -0
- package/src/entities/credentials/orchestrators/index.js +3 -0
- package/src/entities/credentials/orchestrators/load-additional-render-info.js +65 -0
- package/src/entities/credentials/repos/credentials.repo.js +132 -0
- package/src/entities/credentials/schemas/index.js +4 -0
- package/src/entities/credentials/schemas/webwallet-credential-response.schema.js +138 -0
- package/src/entities/credentials/schemas/webwallet-credentials-response.schemas.js +95 -0
- package/src/entities/credentials/schemas/webwallet-display-descriptor-response.schema.js +106 -0
- package/src/entities/disclosures/index.js +4 -0
- package/src/entities/disclosures/repos/disclosures.repo.js +31 -0
- package/src/entities/disclosures/schemas/index.js +10 -0
- package/src/entities/disclosures/schemas/webwallet-disclosure.schema.js +39 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-field.schema.js +45 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-filter.schema.js +30 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-format.schema.js +36 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-input-descriptors.schema.js +111 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-schema.schema.js +14 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-submission-requirements.schema.js +37 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request.schema.js +79 -0
- package/src/entities/index.js +6 -0
- package/src/entities/issuing/domain/constants.js +8 -0
- package/src/entities/issuing/domain/does-user-have-fresh-pending-verification.js +26 -0
- package/src/entities/issuing/domain/get-credentials-from-offers.js +18 -0
- package/src/entities/issuing/domain/index.js +5 -0
- package/src/entities/issuing/index.js +5 -0
- package/src/entities/issuing/orchestrators/build-issuing-input-credentials.js +35 -0
- package/src/entities/issuing/orchestrators/generate-offers-by-deep-link.js +74 -0
- package/src/entities/issuing/orchestrators/get-identity-issuer.js +35 -0
- package/src/entities/issuing/orchestrators/get-identity-offers-by-deeplink.js +74 -0
- package/src/entities/issuing/orchestrators/index.js +6 -0
- package/src/entities/issuing/schemas/index.js +9 -0
- package/src/entities/issuing/schemas/webwallet-credential-manifest.schema.js +198 -0
- package/src/errors/error-codes.js +12 -0
- package/src/fetchers/career-wallet/create-account-fetcher.js +7 -0
- package/src/fetchers/career-wallet/create-did-fetcher.js +17 -0
- package/src/fetchers/career-wallet/get-app-config.js +11 -0
- package/src/fetchers/career-wallet/get-consents.js +13 -0
- package/src/fetchers/career-wallet/get-credential-categories.js +7 -0
- package/src/fetchers/career-wallet/get-personas.js +7 -0
- package/src/fetchers/career-wallet/index.js +12 -0
- package/src/fetchers/career-wallet/post-consent.js +9 -0
- package/src/fetchers/career-wallet/send-feedback.js +14 -0
- package/src/fetchers/career-wallet/sign-fetcher.js +14 -0
- package/src/fetchers/career-wallet/verify-id-credential-confirm-code.js +19 -0
- package/src/fetchers/career-wallet/verify-id-credential-request-code.js +20 -0
- package/src/fetchers/index.js +4 -0
- package/src/fetchers/lib-api/get-credential-display-schema.js +12 -0
- package/src/fetchers/lib-api/index.js +3 -0
- package/src/fetchers/linkedin/create-linkedin-post.js +45 -0
- package/src/fetchers/linkedin/get-access-token.js +26 -0
- package/src/fetchers/linkedin/get-linkedin-user-email.js +13 -0
- package/src/fetchers/linkedin/get-linkedin-user-id.js +16 -0
- package/src/fetchers/linkedin/index.js +9 -0
- package/src/fetchers/linkedin/register-image-to-upload.js +30 -0
- package/src/fetchers/linkedin/revoke-linkedin-access.js +20 -0
- package/src/fetchers/linkedin/upload-image-to-linkedin.js +16 -0
- package/src/index.js +15 -0
- package/src/init-server.js +108 -0
- package/src/plugins/crypto-services/index.js +5 -0
- package/src/plugins/crypto-services/jwt-sign-service-impl.js +72 -0
- package/src/plugins/crypto-services/jwt-verify-service-impl.js +21 -0
- package/src/plugins/crypto-services/key-service-impl.js +28 -0
- package/src/plugins/fetch-errors-handler-plugin.js +64 -0
- package/src/plugins/index.js +4 -0
- package/src/plugins/vnf-sdk-plugin.js +53 -0
- package/src/standalone.js +8 -0
- package/test/accounts-controller.test.js +618 -0
- package/test/consent-controller.test.js +185 -0
- package/test/credentials-controller.test.js +307 -0
- package/test/crypro-services/jwt-sign-service-impl.test.js +83 -0
- package/test/crypro-services/jwt-verify-service-impl.test.js +27 -0
- package/test/crypro-services/key-service-impl.test.js +76 -0
- package/test/crypro-services/mocks/index.js +4 -0
- package/test/crypro-services/mocks/jwt-mock.js +15 -0
- package/test/crypro-services/mocks/public-jwk.js +14 -0
- package/test/disclosures-controller/disclosure-credentials.test.js +428 -0
- package/test/disclosures-controller/get-disclosures.test.js +169 -0
- package/test/disclosures-controller/mocks/get-credential-manifest.js +20 -0
- package/test/disclosures-controller/mocks/index.js +6 -0
- package/test/disclosures-controller/mocks/presentation-request.js +32 -0
- package/test/disclosures-controller/mocks/presentation-submission.js +21 -0
- package/test/disclosures-controller/mocks/submission-result.js +19 -0
- package/test/factories/accounts.js +25 -0
- package/test/factories/credentials.js +66 -0
- package/test/factories/disclosures.js +106 -0
- package/test/feedback-controller.test.js +125 -0
- package/test/fetch-errors-handler-plugin.test.js +97 -0
- package/test/filter-deleted-credentials-extension.test.js +82 -0
- package/test/helpers/.env.test +10 -0
- package/test/helpers/nock-consent-add.js +16 -0
- package/test/helpers/nock-consents-get.js +15 -0
- package/test/helpers/nock-feedback.js +9 -0
- package/test/helpers/nock-linkedin-access-token.js +9 -0
- package/test/helpers/nock-linkedin-email.js +15 -0
- package/test/helpers/nock-linkedin-image-register.js +28 -0
- package/test/helpers/nock-linkedin-me.js +13 -0
- package/test/helpers/nock-linkedin-post.js +37 -0
- package/test/helpers/nock-linkedin-revoke.js +9 -0
- package/test/helpers/nock-test-personas.js +13 -0
- package/test/helpers/webwallet-build-fastify.js +17 -0
- package/test/issuing-controller/issuing-by-deeplink-empty-offers.test.js +142 -0
- package/test/issuing-controller/issuing-by-deeplink-failed-offers.test.js +142 -0
- package/test/issuing-controller/issuing-by-deeplink.test.js +492 -0
- package/test/issuing-controller/issuing-identity-credentials.test.js +377 -0
- package/test/issuing-controller/mocks/accept-offers-response.js +90 -0
- package/test/issuing-controller/mocks/accepted-credentials.js +47 -0
- package/test/issuing-controller/mocks/credential-manifest-presentation.js +72 -0
- package/test/issuing-controller/mocks/credential-manifest.js +45 -0
- package/test/issuing-controller/mocks/identity-issuing/accept-offers.js +22 -0
- package/test/issuing-controller/mocks/identity-issuing/confirm-verification-code.js +5 -0
- package/test/issuing-controller/mocks/identity-issuing/get-app-config.js +52 -0
- package/test/issuing-controller/mocks/identity-issuing/get-organization.js +118 -0
- package/test/issuing-controller/mocks/identity-issuing/index.js +6 -0
- package/test/issuing-controller/mocks/index.js +6 -0
- package/test/issuing-controller/mocks/issuers.js +126 -0
- package/test/issuing-controller/mocks/offers.js +48 -0
- package/test/issuing-controller/mocks/schema.js +107 -0
- package/test/linkedin-controller.test.js +452 -0
- package/test/mocks/credential-categories.js +115 -0
- package/test/mocks/credentials.js +15 -0
- package/test/mocks/didjwk.js +25 -0
- package/test/mocks/index.js +7 -0
- package/test/mocks/issuers.js +88 -0
- package/test/mocks/jwk.js +53 -0
- package/test/mocks/schema.js +107 -0
- package/test/root.test.js +42 -0
- 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;
|
package/src/controllers/credentials/schemas/webwallet-credential-categories-response.schema.js
ADDED
|
@@ -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
|
+
};
|
package/src/controllers/disclosures/schemas/webwallet-accept-presentation-request-body.schema.js
ADDED
|
@@ -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
|
+
};
|
package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-query.schema.js
ADDED
|
@@ -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
|
+
};
|
package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-response.schema.js
ADDED
|
@@ -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
|
+
};
|
package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-query.schema.js
ADDED
|
@@ -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
|
+
};
|
package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-response.schema.js
ADDED
|
@@ -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
|
+
};
|