@verii/server-credentialing-hub 2.0.0
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/LICENSE +202 -0
- package/README.md +13 -0
- package/package.json +87 -0
- package/src/assets/templates/app-redirect.hbs +22 -0
- package/src/config/config.js +118 -0
- package/src/config/index.js +19 -0
- package/src/controllers/app-redirect/controller.js +85 -0
- package/src/controllers/openid4vc/autohooks.js +22 -0
- package/src/controllers/openid4vc/oauth-controller.js +96 -0
- package/src/controllers/openid4vc/openid4vc-metadata-controller.js +66 -0
- package/src/controllers/openid4vc/openid4vci-controller.js +125 -0
- package/src/controllers/openid4vp/autohooks.js +22 -0
- package/src/controllers/openid4vp/openid4vp-controller.js +177 -0
- package/src/controllers/operator/autohooks.js +31 -0
- package/src/controllers/operator/credentials/credentials-controller.js +212 -0
- package/src/controllers/operator/credentials/schemas/credential.schema.js +46 -0
- package/src/controllers/operator/credentials/schemas/index.js +7 -0
- package/src/controllers/operator/credentials/schemas/new-credential.schema.json +23 -0
- package/src/controllers/operator/depots/depots-controller.js +154 -0
- package/src/controllers/operator/depots/schemas/depot.schema.js +34 -0
- package/src/controllers/operator/depots/schemas/index.js +24 -0
- package/src/controllers/operator/depots/schemas/new-depot.schema.json +30 -0
- package/src/controllers/operator/issue-links/issue-links-controller.js +74 -0
- package/src/controllers/operator/issuer-services/issuer-services-controller.js +200 -0
- package/src/controllers/operator/issuer-services/schemas/index.js +7 -0
- package/src/controllers/operator/issuer-services/schemas/issuer-service.schema.js +26 -0
- package/src/controllers/operator/issuer-services/schemas/new-issuer-service.schema.js +137 -0
- package/src/controllers/operator/presentation-links/presentation-links-controller.js +76 -0
- package/src/controllers/operator/presentations/presentations-controller.js +174 -0
- package/src/controllers/operator/presentations/schemas/base-presentation.schema.js +39 -0
- package/src/controllers/operator/presentations/schemas/credential-verification.schema.js +83 -0
- package/src/controllers/operator/presentations/schemas/index.js +23 -0
- package/src/controllers/operator/presentations/schemas/presentation-verification.schema.js +42 -0
- package/src/controllers/operator/presentations/schemas/presentation.schema.js +53 -0
- package/src/controllers/operator/presentations/schemas/w3c-presentation.js +52 -0
- package/src/controllers/operator/relying-party-services/relying-party-services-controller.js +202 -0
- package/src/controllers/operator/relying-party-services/schemas/index.js +7 -0
- package/src/controllers/operator/relying-party-services/schemas/new-relying-party-service.schema.js +91 -0
- package/src/controllers/operator/relying-party-services/schemas/relying-party-service.schema.js +26 -0
- package/src/controllers/operator/tenants/schemas/index.js +33 -0
- package/src/controllers/operator/tenants/schemas/jwk.schema.json +56 -0
- package/src/controllers/operator/tenants/schemas/key-metadata.schema.json +12 -0
- package/src/controllers/operator/tenants/schemas/new-key-metadata.schema.json +42 -0
- package/src/controllers/operator/tenants/schemas/new-key.schema.json +12 -0
- package/src/controllers/operator/tenants/schemas/new-tenant.schema.json +33 -0
- package/src/controllers/operator/tenants/schemas/secret-key.schema.json +33 -0
- package/src/controllers/operator/tenants/schemas/tenant.schema.json +44 -0
- package/src/controllers/operator/tenants/tenants-controller.js +165 -0
- package/src/controllers/root-controller.js +43 -0
- package/src/controllers/vn-api/schemas/index.js +25 -0
- package/src/controllers/vn-api/schemas/presentation-submission.schema.json +41 -0
- package/src/controllers/vn-api/schemas/velocity-presentation-submission.response.200.schema.json +36 -0
- package/src/controllers/vn-api/schemas/velocity-presentation-submission.schema.json +31 -0
- package/src/controllers/vn-api/vn-api-presentation-controller.js +158 -0
- package/src/controllers/vn-api/vn-issuing-controller.js +295 -0
- package/src/entities/credential-types/fetchers/fetch-credential-type-descriptors.js +36 -0
- package/src/entities/credential-types/fetchers/index.js +19 -0
- package/src/entities/credential-types/index.js +19 -0
- package/src/entities/credentials/domain/canonicalize-credentials.js +70 -0
- package/src/entities/credentials/domain/credential-errors.js +25 -0
- package/src/entities/credentials/domain/credential-format.js +21 -0
- package/src/entities/credentials/domain/index.js +22 -0
- package/src/entities/credentials/domain/validate-credential.js +74 -0
- package/src/entities/credentials/facades/anchor-verii-credentials-facade.js +45 -0
- package/src/entities/credentials/facades/build-verii-issuer.js +44 -0
- package/src/entities/credentials/facades/index.js +22 -0
- package/src/entities/credentials/facades/issue-verii-credentials-facade.js +62 -0
- package/src/entities/credentials/facades/sign-verii-credentials-facade.js +56 -0
- package/src/entities/credentials/factories/credential-factory.js +53 -0
- package/src/entities/credentials/factories/index.js +19 -0
- package/src/entities/credentials/index.js +23 -0
- package/src/entities/credentials/orchestrators/create-credentials.js +118 -0
- package/src/entities/credentials/orchestrators/index.js +19 -0
- package/src/entities/credentials/repo/finders-extension.js +94 -0
- package/src/entities/credentials/repo/index.js +19 -0
- package/src/entities/credentials/repo/repo.js +62 -0
- package/src/entities/credentials/repo/update-issued-credential.js +60 -0
- package/src/entities/depots/domain/depot-errors.js +23 -0
- package/src/entities/depots/domain/index.js +20 -0
- package/src/entities/depots/domain/validate-depot.js +38 -0
- package/src/entities/depots/factories/depot-factory.js +50 -0
- package/src/entities/depots/factories/index.js +19 -0
- package/src/entities/depots/index.js +22 -0
- package/src/entities/depots/orchestrators/create-depot.js +31 -0
- package/src/entities/depots/orchestrators/delete-depot.js +43 -0
- package/src/entities/depots/orchestrators/index.js +20 -0
- package/src/entities/depots/repo/find-depot-by-preauth-code.js +30 -0
- package/src/entities/depots/repo/find-depots-extension.js +34 -0
- package/src/entities/depots/repo/index.js +19 -0
- package/src/entities/depots/repo/refresh-preauth-code.js +30 -0
- package/src/entities/depots/repo/repo.js +61 -0
- package/src/entities/exchanges/adapters/index.js +17 -0
- package/src/entities/exchanges/adapters/sign-exchange-response.js +37 -0
- package/src/entities/exchanges/domain/authorize-exchange.js +29 -0
- package/src/entities/exchanges/domain/build-exchange-event.js +19 -0
- package/src/entities/exchanges/domain/build-presentation-request.js +174 -0
- package/src/entities/exchanges/domain/exchange-errors.js +28 -0
- package/src/entities/exchanges/domain/exchange-protocols.js +29 -0
- package/src/entities/exchanges/domain/exchange-states.js +53 -0
- package/src/entities/exchanges/domain/exchange-types.js +22 -0
- package/src/entities/exchanges/domain/generate-issuing-challenge.js +48 -0
- package/src/entities/exchanges/domain/index.js +32 -0
- package/src/entities/exchanges/domain/validate-message-settings.js +33 -0
- package/src/entities/exchanges/domain/validate-new-exchange.js +25 -0
- package/src/entities/exchanges/domain/validate-preauth.js +45 -0
- package/src/entities/exchanges/domain/validate-referenced-service.js +33 -0
- package/src/entities/exchanges/domain/verify-issuing-challenge.js +42 -0
- package/src/entities/exchanges/domain/verify-proof-of-key-possession.js +128 -0
- package/src/entities/exchanges/factories/index.js +19 -0
- package/src/entities/exchanges/factories/init-exchange-factory.js +58 -0
- package/src/entities/exchanges/hooks/exchange-error-hook.js +30 -0
- package/src/entities/exchanges/hooks/index.js +17 -0
- package/src/entities/exchanges/index.js +24 -0
- package/src/entities/exchanges/orchestrators/authenticate.js +67 -0
- package/src/entities/exchanges/orchestrators/credential-offer-request.js +70 -0
- package/src/entities/exchanges/orchestrators/get-credential-manifest.js +84 -0
- package/src/entities/exchanges/orchestrators/get-presentation-request.js +114 -0
- package/src/entities/exchanges/orchestrators/index.js +24 -0
- package/src/entities/exchanges/orchestrators/issue-credentials.js +132 -0
- package/src/entities/exchanges/orchestrators/post-presentation.js +58 -0
- package/src/entities/exchanges/repo/exchange-state-repo-extension.js +78 -0
- package/src/entities/exchanges/repo/index.js +19 -0
- package/src/entities/exchanges/repo/repo.js +52 -0
- package/src/entities/issuer-services/domain/index.js +20 -0
- package/src/entities/issuer-services/domain/issuer-services-errors.js +23 -0
- package/src/entities/issuer-services/domain/validate-issuer-service.js +23 -0
- package/src/entities/issuer-services/factories/index.js +19 -0
- package/src/entities/issuer-services/factories/issuer-service-factory.js +44 -0
- package/src/entities/issuer-services/index.js +21 -0
- package/src/entities/issuer-services/repo/find-issuer-services-extension.js +30 -0
- package/src/entities/issuer-services/repo/index.js +19 -0
- package/src/entities/issuer-services/repo/repo.js +59 -0
- package/src/entities/keys/adapters/index.js +19 -0
- package/src/entities/keys/adapters/load-primary-account.js +39 -0
- package/src/entities/keys/domain/cih-key-purposes.js +23 -0
- package/src/entities/keys/domain/get-key-with-purpose.js +22 -0
- package/src/entities/keys/domain/index.js +22 -0
- package/src/entities/keys/domain/key-errors.js +25 -0
- package/src/entities/keys/domain/normalize-tenant-key.js +33 -0
- package/src/entities/keys/domain/validate-tenant-keys.js +78 -0
- package/src/entities/keys/factories/index.js +19 -0
- package/src/entities/keys/factories/key-factory.js +61 -0
- package/src/entities/keys/index.js +22 -0
- package/src/entities/keys/plugins/index.js +17 -0
- package/src/entities/keys/plugins/kms-plugin.js +61 -0
- package/src/entities/links/domain/build-deep-link-url.js +58 -0
- package/src/entities/links/domain/build-openid4vci-credential-offer-link.js +31 -0
- package/src/entities/links/domain/build-openid4vp-authorization-request-link.js +36 -0
- package/src/entities/links/domain/build-redirect-url.js +29 -0
- package/src/entities/links/domain/build-vn-api-issuing-link.js +54 -0
- package/src/entities/links/domain/build-vn-api-presentation-link.js +49 -0
- package/src/entities/links/domain/index.js +28 -0
- package/src/entities/links/domain/is-preauth-code-auth.js +19 -0
- package/src/entities/links/domain/link-errors.js +23 -0
- package/src/entities/links/domain/validate-issue-link.js +39 -0
- package/src/entities/links/domain/validate-presentation-link.js +39 -0
- package/src/entities/links/index.js +20 -0
- package/src/entities/links/orchestrators/index.js +17 -0
- package/src/entities/links/orchestrators/refresh-links.js +139 -0
- package/src/entities/openid4vci/domain/index.js +20 -0
- package/src/entities/openid4vci/domain/openid4vci-errors.js +24 -0
- package/src/entities/openid4vci/domain/to-credential-configuration-id.js +21 -0
- package/src/entities/openid4vci/index.js +21 -0
- package/src/entities/openid4vci/orchestrators/create-access-token.js +85 -0
- package/src/entities/openid4vci/orchestrators/create-credential.js +108 -0
- package/src/entities/openid4vci/orchestrators/get-authorization-server-metadata.js +22 -0
- package/src/entities/openid4vci/orchestrators/get-credential-issuer-metadata.js +22 -0
- package/src/entities/openid4vci/orchestrators/handle-notification.js +94 -0
- package/src/entities/openid4vci/orchestrators/index.js +24 -0
- package/src/entities/openid4vci/plugins/index.js +19 -0
- package/src/entities/openid4vci/plugins/openid4vci-plugin.js +427 -0
- package/src/entities/openid4vp/domain/index.js +21 -0
- package/src/entities/openid4vp/domain/openid4vp-request-id.js +47 -0
- package/src/entities/openid4vp/domain/presentation-request-expiry.js +37 -0
- package/src/entities/openid4vp/domain/wallet-metadata.js +30 -0
- package/src/entities/openid4vp/index.js +21 -0
- package/src/entities/openid4vp/orchestrators/create-authorization-request.js +183 -0
- package/src/entities/openid4vp/orchestrators/index.js +20 -0
- package/src/entities/openid4vp/orchestrators/post-authorization-response.js +353 -0
- package/src/entities/openid4vp/plugins/index.js +19 -0
- package/src/entities/openid4vp/plugins/openid4vp-plugin.js +174 -0
- package/src/entities/presentations/domain/index.js +20 -0
- package/src/entities/presentations/domain/presentation-format.js +20 -0
- package/src/entities/presentations/domain/validate-presentation.js +178 -0
- package/src/entities/presentations/factories/index.js +19 -0
- package/src/entities/presentations/factories/presentation-factory.js +96 -0
- package/src/entities/presentations/index.js +21 -0
- package/src/entities/presentations/orchestrators/index.js +19 -0
- package/src/entities/presentations/orchestrators/verify-presentation.js +131 -0
- package/src/entities/presentations/repo/add-verification.js +31 -0
- package/src/entities/presentations/repo/finders-extension.js +50 -0
- package/src/entities/presentations/repo/index.js +19 -0
- package/src/entities/presentations/repo/repo.js +58 -0
- package/src/entities/relying-party-services/factories/index.js +19 -0
- package/src/entities/relying-party-services/factories/relying-party-service-factory.js +43 -0
- package/src/entities/relying-party-services/index.js +20 -0
- package/src/entities/relying-party-services/repo/find-relying-party-services-extension.js +30 -0
- package/src/entities/relying-party-services/repo/index.js +19 -0
- package/src/entities/relying-party-services/repo/repo.js +55 -0
- package/src/entities/service-configurations/domain/canonicalize-service-configuration.js +12 -0
- package/src/entities/service-configurations/domain/index.js +22 -0
- package/src/entities/service-configurations/domain/service-configuration-errors.js +24 -0
- package/src/entities/service-configurations/domain/validate-service-configuration.js +31 -0
- package/src/entities/service-configurations/domain/validate-update-service-configuration.js +19 -0
- package/src/entities/service-configurations/index.js +20 -0
- package/src/entities/service-configurations/orchestrators/create-service-configuration.js +34 -0
- package/src/entities/service-configurations/orchestrators/delete-service-configuration.js +41 -0
- package/src/entities/service-configurations/orchestrators/index.js +21 -0
- package/src/entities/service-configurations/orchestrators/update-service-configuration.js +40 -0
- package/src/entities/tenants/adapters/index.js +20 -0
- package/src/entities/tenants/adapters/load-tenant-did-doc.js +47 -0
- package/src/entities/tenants/adapters/load-tenant-profile.js +40 -0
- package/src/entities/tenants/domain/index.js +20 -0
- package/src/entities/tenants/domain/tenant-errors.js +29 -0
- package/src/entities/tenants/domain/validate-new-tenant.js +49 -0
- package/src/entities/tenants/factories/index.js +19 -0
- package/src/entities/tenants/factories/tenant-factory.js +41 -0
- package/src/entities/tenants/index.js +24 -0
- package/src/entities/tenants/orchestrators/create-tenant.js +116 -0
- package/src/entities/tenants/orchestrators/delete-tenant.js +45 -0
- package/src/entities/tenants/orchestrators/find-tenants.js +22 -0
- package/src/entities/tenants/orchestrators/index.js +21 -0
- package/src/entities/tenants/plugins/index.js +3 -0
- package/src/entities/tenants/plugins/tenant-loader-plugin.js +64 -0
- package/src/entities/tenants/repo/index.js +19 -0
- package/src/entities/tenants/repo/insert-tenant-extension.js +36 -0
- package/src/entities/tenants/repo/repo.js +51 -0
- package/src/entities/tokens/domains/access-token.js +74 -0
- package/src/entities/tokens/domains/index.js +19 -0
- package/src/entities/tokens/index.js +19 -0
- package/src/index.js +3 -0
- package/src/init-server.js +88 -0
- package/src/main.js +25 -0
- package/src/schemas/index.js +20 -0
- package/src/schemas/oauth-error-response.schema.js +27 -0
- package/src/standalone.js +8 -0
- package/src/start-app-server.js +27 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
const { coerceArray } = require('@verii/common-functions');
|
|
18
|
+
const {
|
|
19
|
+
createTenant,
|
|
20
|
+
deleteTenant,
|
|
21
|
+
findTenants,
|
|
22
|
+
} = require('../../../entities/tenants');
|
|
23
|
+
const {
|
|
24
|
+
jwkSchema,
|
|
25
|
+
newTenantSchema,
|
|
26
|
+
tenantSchema,
|
|
27
|
+
newKeyMetadataSchema,
|
|
28
|
+
keyMetadataSchema,
|
|
29
|
+
secretKeySchema,
|
|
30
|
+
newKeySchema,
|
|
31
|
+
} = require('./schemas');
|
|
32
|
+
|
|
33
|
+
module.exports = async (fastify) => {
|
|
34
|
+
fastify
|
|
35
|
+
.addSchema(jwkSchema)
|
|
36
|
+
.addSchema(newTenantSchema)
|
|
37
|
+
.addSchema(tenantSchema)
|
|
38
|
+
.addSchema(newKeyMetadataSchema)
|
|
39
|
+
.addSchema(keyMetadataSchema)
|
|
40
|
+
.addSchema(secretKeySchema)
|
|
41
|
+
.addSchema(newKeySchema)
|
|
42
|
+
.post(
|
|
43
|
+
'/create',
|
|
44
|
+
{
|
|
45
|
+
schema: fastify.autoSchema({
|
|
46
|
+
body: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
tenant: {
|
|
50
|
+
$ref: 'new-tenant#',
|
|
51
|
+
},
|
|
52
|
+
keys: {
|
|
53
|
+
type: 'array',
|
|
54
|
+
minItems: 1,
|
|
55
|
+
items: {
|
|
56
|
+
$ref: 'new-key#',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
required: ['tenant', 'keys'],
|
|
61
|
+
},
|
|
62
|
+
response: {
|
|
63
|
+
200: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
tenant: {
|
|
67
|
+
$ref: 'tenant#',
|
|
68
|
+
},
|
|
69
|
+
keyMetadatas: {
|
|
70
|
+
type: 'array',
|
|
71
|
+
items: {
|
|
72
|
+
$ref: 'key-metadata#',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
requestId: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
async (req) => {
|
|
84
|
+
const { tenant, keyMetadatas } = await createTenant(
|
|
85
|
+
req.body.tenant,
|
|
86
|
+
req.body.keys,
|
|
87
|
+
req,
|
|
88
|
+
);
|
|
89
|
+
return { tenant, keyMetadatas };
|
|
90
|
+
},
|
|
91
|
+
)
|
|
92
|
+
.get(
|
|
93
|
+
'/get',
|
|
94
|
+
{
|
|
95
|
+
schema: fastify.autoSchema({
|
|
96
|
+
query: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
properties: {
|
|
99
|
+
tenantId: {
|
|
100
|
+
anyOf: [
|
|
101
|
+
{ type: 'string' },
|
|
102
|
+
{
|
|
103
|
+
type: 'array',
|
|
104
|
+
items: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
response: {
|
|
113
|
+
200: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
tenants: {
|
|
117
|
+
type: 'array',
|
|
118
|
+
items: {
|
|
119
|
+
$ref: 'tenant#',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
requestId: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
},
|
|
130
|
+
async (req) => {
|
|
131
|
+
const tenants = await findTenants(
|
|
132
|
+
coerceArray(req.query?.tenantId),
|
|
133
|
+
req,
|
|
134
|
+
);
|
|
135
|
+
return { tenants };
|
|
136
|
+
},
|
|
137
|
+
)
|
|
138
|
+
.post(
|
|
139
|
+
'/delete',
|
|
140
|
+
{
|
|
141
|
+
schema: fastify.autoSchema({
|
|
142
|
+
body: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: {
|
|
145
|
+
tenantId: {
|
|
146
|
+
type: 'string',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
required: ['tenantId'],
|
|
150
|
+
},
|
|
151
|
+
response: {
|
|
152
|
+
200: {
|
|
153
|
+
type: 'object',
|
|
154
|
+
properties: {
|
|
155
|
+
requestId: {
|
|
156
|
+
type: 'string',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
}),
|
|
162
|
+
},
|
|
163
|
+
async (req) => deleteTenant(req.body.tenantId, req),
|
|
164
|
+
);
|
|
165
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const rootController = async (fastify) => {
|
|
19
|
+
fastify.get(
|
|
20
|
+
'/',
|
|
21
|
+
{
|
|
22
|
+
schema: {
|
|
23
|
+
description: 'Healthcheck and version info',
|
|
24
|
+
response: {
|
|
25
|
+
200: {
|
|
26
|
+
description: 'Successful response',
|
|
27
|
+
content: { 'text/plain': { schema: { type: 'string' } } },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
tags: ['utilities'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
async (req, reply) => {
|
|
34
|
+
reply
|
|
35
|
+
.status(200)
|
|
36
|
+
.send(
|
|
37
|
+
`Welcome to the Credentialing Hub\nHost: ${fastify.config.hostUrl}\nVersion: ${fastify.config.version}\n`,
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = rootController;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
const presentationSubmissionSchema = require('./presentation-submission.schema.json');
|
|
18
|
+
const velocityPresentationSubmissionSchema = require('./velocity-presentation-submission.schema.json');
|
|
19
|
+
const velocityPresentationSubmissionResponseSchema = require('./velocity-presentation-submission.response.200.schema.json');
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
presentationSubmissionSchema,
|
|
23
|
+
velocityPresentationSubmissionSchema,
|
|
24
|
+
velocityPresentationSubmissionResponseSchema,
|
|
25
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Presentation Submission",
|
|
4
|
+
"$id": "https://velocitycareerlabs.io/presentation-submission.schema.json",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"presentation_submission": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"id": { "type": "string" },
|
|
11
|
+
"definition_id": { "type": "string" },
|
|
12
|
+
"locale": { "type": "string" },
|
|
13
|
+
"descriptor_map": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": { "$ref": "#/definitions/descriptor" }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"required": ["descriptor_map", "definition_id"],
|
|
19
|
+
"additionalProperties": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"definitions": {
|
|
23
|
+
"descriptor": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"id": { "type": "string" },
|
|
27
|
+
"path": { "type": "string" },
|
|
28
|
+
"path_nested": {
|
|
29
|
+
"$ref": "#/definitions/descriptor"
|
|
30
|
+
},
|
|
31
|
+
"format": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"enum": ["jwt", "jwt_vc", "jwt_vp", "ldp", "ldp_vc", "ldp_vp", "JWT"]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": ["id", "path", "format"],
|
|
37
|
+
"additionalProperties": false
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": ["presentation_submission"]
|
|
41
|
+
}
|
package/src/controllers/vn-api/schemas/velocity-presentation-submission.response.200.schema.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Velocity Presentation Submission Response",
|
|
4
|
+
"$id": "https://velocitycareerlabs.io/velocity-presentation-submission-response.schema.json",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"token": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"exchange": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {
|
|
15
|
+
"id": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"type": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": [
|
|
21
|
+
"ISSUING",
|
|
22
|
+
"DISCLOSURE"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"disclosureComplete": {
|
|
26
|
+
"type": "boolean"
|
|
27
|
+
},
|
|
28
|
+
"exchangeComplete": {
|
|
29
|
+
"type": "boolean"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": ["id","type", "disclosureComplete", "exchangeComplete"]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": ["exchange"]
|
|
36
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Velocity Presentation Submission",
|
|
4
|
+
"$id": "https://velocitycareerlabs.io/velocity-presentation-submission.schema.json",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"allOf": [
|
|
7
|
+
{
|
|
8
|
+
"$ref": "https://velocitycareerlabs.io/presentation-submission.schema.json#"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"id": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"issuanceDate": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"format": "date-time"
|
|
19
|
+
},
|
|
20
|
+
"vendorOriginContext": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"required": [
|
|
27
|
+
"presentation_submission",
|
|
28
|
+
"id",
|
|
29
|
+
"issuanceDate"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
const { tenantLoaderPlugin } = require('../../entities/tenants');
|
|
18
|
+
const { kmsPlugin } = require('../../entities/keys');
|
|
19
|
+
const {
|
|
20
|
+
ExchangeTypes,
|
|
21
|
+
getPresentationRequest,
|
|
22
|
+
postPresentation,
|
|
23
|
+
signExchangeResponse,
|
|
24
|
+
exchangeErrorHook,
|
|
25
|
+
} = require('../../entities/exchanges');
|
|
26
|
+
const { generateAccessToken } = require('../../entities/tokens');
|
|
27
|
+
const {
|
|
28
|
+
presentationSubmissionSchema,
|
|
29
|
+
velocityPresentationSubmissionSchema,
|
|
30
|
+
velocityPresentationSubmissionResponseSchema,
|
|
31
|
+
} = require('./schemas');
|
|
32
|
+
|
|
33
|
+
const vnApiPresentationController = async (fastify) => {
|
|
34
|
+
fastify
|
|
35
|
+
.register(tenantLoaderPlugin, { useDID: true })
|
|
36
|
+
.register(kmsPlugin)
|
|
37
|
+
.addSchema(presentationSubmissionSchema)
|
|
38
|
+
.addSchema(velocityPresentationSubmissionSchema)
|
|
39
|
+
.addSchema(velocityPresentationSubmissionResponseSchema)
|
|
40
|
+
.get(
|
|
41
|
+
'/r/:tenantId/get-presentation-request',
|
|
42
|
+
{
|
|
43
|
+
schema: fastify.autoSchema({
|
|
44
|
+
params: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
tenantId: { type: 'string' },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
query: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
id: { type: 'string' },
|
|
54
|
+
vendorOriginContext: { type: 'string' },
|
|
55
|
+
'push_delegate.push_token': { type: 'string' },
|
|
56
|
+
'push_delegate.push_url': { type: 'string' },
|
|
57
|
+
format: { type: 'string', enum: ['json', 'jwt'], default: 'jwt' },
|
|
58
|
+
},
|
|
59
|
+
required: ['id'],
|
|
60
|
+
},
|
|
61
|
+
response: {
|
|
62
|
+
200: {
|
|
63
|
+
oneOf: [
|
|
64
|
+
{
|
|
65
|
+
presentation_request: { type: 'object' },
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
presentation_request: { type: 'string' },
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
// eslint-disable-next-line complexity
|
|
76
|
+
async (req) => {
|
|
77
|
+
const { query } = req;
|
|
78
|
+
|
|
79
|
+
const messagingSettings =
|
|
80
|
+
query.push_delegate?.push_url != null ||
|
|
81
|
+
query.push_delegate?.push_token != null
|
|
82
|
+
? {
|
|
83
|
+
webhookUrl: query.push_delegate?.push_url,
|
|
84
|
+
authToken: query.push_delegate?.push_token,
|
|
85
|
+
}
|
|
86
|
+
: undefined;
|
|
87
|
+
|
|
88
|
+
const presentationRequest = await getPresentationRequest(
|
|
89
|
+
query.id,
|
|
90
|
+
query.locale,
|
|
91
|
+
messagingSettings,
|
|
92
|
+
query.vendorOriginContext,
|
|
93
|
+
req,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
/* eslint-disable camelcase */
|
|
97
|
+
const presentation_request =
|
|
98
|
+
query.format !== 'json'
|
|
99
|
+
? await signExchangeResponse(presentationRequest, {}, req)
|
|
100
|
+
: presentationRequest;
|
|
101
|
+
|
|
102
|
+
return { presentation_request };
|
|
103
|
+
/* eslint-enable */
|
|
104
|
+
},
|
|
105
|
+
)
|
|
106
|
+
.post(
|
|
107
|
+
'/r/:tenantId/presentation',
|
|
108
|
+
{
|
|
109
|
+
schema: fastify.autoSchema({
|
|
110
|
+
body: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {
|
|
113
|
+
exchange_id: { type: 'string', description: 'exchange id value' },
|
|
114
|
+
jwt_vp: {
|
|
115
|
+
type: 'string',
|
|
116
|
+
description: 'vp encoded as a jwt signed by the holder',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
required: ['exchange_id', 'jwt_vp'],
|
|
120
|
+
},
|
|
121
|
+
response: {
|
|
122
|
+
200: {
|
|
123
|
+
$ref: 'https://velocitycareerlabs.io/velocity-presentation-submission-response.schema.json#',
|
|
124
|
+
},
|
|
125
|
+
...fastify.UnauthorizedResponse,
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
onError: async (req, reply, err) =>
|
|
129
|
+
exchangeErrorHook(req.body.exchange_id, err, req),
|
|
130
|
+
},
|
|
131
|
+
async (req) => {
|
|
132
|
+
const [relyingPartyService, exchange] = await postPresentation(
|
|
133
|
+
req.body.exchange_id,
|
|
134
|
+
req.body.jwt_vp,
|
|
135
|
+
req,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const token = await generateAccessToken(
|
|
139
|
+
relyingPartyService,
|
|
140
|
+
exchange,
|
|
141
|
+
req,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
token,
|
|
146
|
+
exchange: {
|
|
147
|
+
id: exchange._id,
|
|
148
|
+
type:
|
|
149
|
+
exchange.type === ExchangeTypes.ISSUER ? 'ISSUING' : 'DISCLOSURE',
|
|
150
|
+
disclosureComplete: true,
|
|
151
|
+
exchangeComplete: true,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
module.exports = vnApiPresentationController;
|