@sphereon/ssi-sdk.oid4vci-issuer-rest-api 0.32.1-next.54 → 0.33.1-feature.vcdm2.4
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/dist/OID4VCIRestAPI.d.ts +7 -3
- package/dist/OID4VCIRestAPI.d.ts.map +1 -1
- package/dist/OID4VCIRestAPI.js +98 -70
- package/dist/OID4VCIRestAPI.js.map +1 -1
- package/dist/index.js +2 -18
- package/dist/index.js.map +1 -1
- package/dist/issuer-metadata-api-functions.d.ts +11 -0
- package/dist/issuer-metadata-api-functions.d.ts.map +1 -0
- package/dist/issuer-metadata-api-functions.js +190 -0
- package/dist/issuer-metadata-api-functions.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/package.json +22 -18
- package/src/OID4VCIRestAPI.ts +68 -32
- package/src/issuer-metadata-api-functions.ts +240 -0
- package/src/types.ts +1 -1
package/dist/OID4VCIRestAPI.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { OID4VCIServer } from '@sphereon/oid4vci-issuer-server';
|
|
|
3
3
|
import { IOID4VCIServerOpts } from '@sphereon/oid4vci-issuer-server';
|
|
4
4
|
import { ExpressSupport } from '@sphereon/ssi-express-support';
|
|
5
5
|
import { IIssuerInstanceArgs, IssuerInstance } from '@sphereon/ssi-sdk.oid4vci-issuer';
|
|
6
|
-
import { DIDDocument } from 'did-resolver';
|
|
7
6
|
import { Express } from 'express';
|
|
8
7
|
import { IRequiredContext } from './types';
|
|
9
8
|
export interface IOID4VCIRestAPIOpts extends IOID4VCIServerOpts {
|
|
@@ -15,6 +14,9 @@ export declare class OID4VCIRestAPI {
|
|
|
15
14
|
private readonly _restApi;
|
|
16
15
|
private readonly _instance;
|
|
17
16
|
private readonly _issuer;
|
|
17
|
+
private readonly _router;
|
|
18
|
+
private _baseUrl;
|
|
19
|
+
private _basePath;
|
|
18
20
|
static init(args: {
|
|
19
21
|
context: IRequiredContext;
|
|
20
22
|
issuerInstanceArgs: IIssuerInstanceArgs;
|
|
@@ -22,13 +24,15 @@ export declare class OID4VCIRestAPI {
|
|
|
22
24
|
expressSupport: ExpressSupport;
|
|
23
25
|
opts?: IOID4VCIRestAPIOpts;
|
|
24
26
|
}): Promise<OID4VCIRestAPI>;
|
|
27
|
+
private readonly OID4VCI_SWAGGER_URL;
|
|
25
28
|
private constructor();
|
|
29
|
+
private setupSwaggerUi;
|
|
26
30
|
get express(): Express;
|
|
27
31
|
get context(): IRequiredContext;
|
|
28
32
|
get opts(): IOID4VCIRestAPIOpts | undefined;
|
|
29
|
-
get restApi(): OID4VCIServer
|
|
33
|
+
get restApi(): OID4VCIServer;
|
|
30
34
|
get instance(): IssuerInstance;
|
|
31
|
-
get issuer(): VcIssuer
|
|
35
|
+
get issuer(): VcIssuer;
|
|
32
36
|
stop(): Promise<boolean>;
|
|
33
37
|
}
|
|
34
38
|
//# sourceMappingURL=OID4VCIRestAPI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OID4VCIRestAPI.d.ts","sourceRoot":"","sources":["../src/OID4VCIRestAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"OID4VCIRestAPI.d.ts","sourceRoot":"","sources":["../src/OID4VCIRestAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,EAAe,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAGL,mBAAmB,EACnB,cAAc,EAEf,MAAM,kCAAkC,CAAA;AACzC,OAAgB,E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
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { getBasePath, OID4VCIServer } from '@sphereon/oid4vci-issuer-server';
|
|
2
|
+
import { createAuthRequestUriCallback, getAccessTokenSignerCallback, createVerifyAuthResponseCallback, } from '@sphereon/ssi-sdk.oid4vci-issuer';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import swaggerUi from 'swagger-ui-express';
|
|
5
|
+
export class OID4VCIRestAPI {
|
|
6
|
+
_expressSupport;
|
|
7
|
+
_context;
|
|
8
|
+
_opts;
|
|
9
|
+
_restApi;
|
|
10
|
+
_instance;
|
|
11
|
+
_issuer;
|
|
12
|
+
_router;
|
|
13
|
+
_baseUrl;
|
|
14
|
+
_basePath;
|
|
15
|
+
static async init(args) {
|
|
16
|
+
const { issuerInstanceArgs, context } = args;
|
|
17
|
+
const opts = args.opts ?? {};
|
|
18
|
+
const expressSupport = args.expressSupport;
|
|
19
|
+
const instance = await context.agent.oid4vciGetInstance(args.issuerInstanceArgs);
|
|
20
|
+
const issuer = await instance.get({ context, credentialDataSupplier: args.credentialDataSupplier });
|
|
21
|
+
if (!opts.endpointOpts) {
|
|
22
|
+
opts.endpointOpts = {};
|
|
23
|
+
}
|
|
24
|
+
if (!opts.endpointOpts.tokenEndpointOpts) {
|
|
25
|
+
opts.endpointOpts.tokenEndpointOpts = {
|
|
26
|
+
accessTokenIssuer: instance.metadataOptions.credentialIssuer ?? issuer.issuerMetadata.credential_issuer,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (opts?.endpointOpts.tokenEndpointOpts?.tokenEndpointDisabled !== true &&
|
|
30
|
+
typeof opts?.endpointOpts.tokenEndpointOpts?.accessTokenSignerCallback !== 'function') {
|
|
31
|
+
const idOpts = instance.issuerOptions.idOpts;
|
|
32
|
+
const tokenOpts = {
|
|
33
|
+
iss: opts.endpointOpts.tokenEndpointOpts.accessTokenIssuer ?? instance.metadataOptions.credentialIssuer,
|
|
34
|
+
didOpts: instance.issuerOptions.didOpts,
|
|
35
|
+
idOpts,
|
|
36
|
+
};
|
|
37
|
+
opts.endpointOpts.tokenEndpointOpts.accessTokenSignerCallback = await getAccessTokenSignerCallback({
|
|
38
|
+
...tokenOpts,
|
|
39
|
+
}, args.context);
|
|
40
|
+
}
|
|
41
|
+
if (opts?.endpointOpts.authorizationChallengeOpts?.enabled === true) {
|
|
42
|
+
if (!instance.issuerOptions.presentationDefinitionId) {
|
|
43
|
+
throw Error(`Unable to set createAuthRequestUriCallback. No presentationDefinitionId present in issuer options`);
|
|
26
44
|
}
|
|
27
|
-
if (
|
|
28
|
-
opts.endpointOpts.
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
if (((_c = opts === null || opts === void 0 ? void 0 : opts.endpointOpts.tokenEndpointOpts) === null || _c === void 0 ? void 0 : _c.tokenEndpointDisabled) !== true &&
|
|
33
|
-
typeof ((_d = opts === null || opts === void 0 ? void 0 : opts.endpointOpts.tokenEndpointOpts) === null || _d === void 0 ? void 0 : _d.accessTokenSignerCallback) !== 'function') {
|
|
34
|
-
const idOpts = instance.issuerOptions.idOpts;
|
|
35
|
-
const tokenOpts = {
|
|
36
|
-
iss: (_e = opts.endpointOpts.tokenEndpointOpts.accessTokenIssuer) !== null && _e !== void 0 ? _e : instance.metadataOptions.credentialIssuer,
|
|
37
|
-
didOpts: instance.issuerOptions.didOpts,
|
|
38
|
-
idOpts,
|
|
39
|
-
};
|
|
40
|
-
opts.endpointOpts.tokenEndpointOpts.accessTokenSignerCallback = yield (0, ssi_sdk_oid4vci_issuer_1.getAccessTokenSignerCallback)(Object.assign({}, tokenOpts), args.context);
|
|
41
|
-
}
|
|
42
|
-
if (((_f = opts === null || opts === void 0 ? void 0 : opts.endpointOpts.authorizationChallengeOpts) === null || _f === void 0 ? void 0 : _f.enabled) === true) {
|
|
43
|
-
if (!instance.issuerOptions.presentationDefinitionId) {
|
|
44
|
-
throw Error(`Unable to set createAuthRequestUriCallback. No presentationDefinitionId present in issuer options`);
|
|
45
|
+
if (typeof opts?.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback !== 'function') {
|
|
46
|
+
if (!opts.endpointOpts.authorizationChallengeOpts?.createAuthRequestUriEndpointPath) {
|
|
47
|
+
throw Error(`Unable to set createAuthRequestUriCallback. No createAuthRequestUriEndpointPath present in options`);
|
|
45
48
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
if (typeof ((_h = opts === null || opts === void 0 ? void 0 : opts.endpointOpts.authorizationChallengeOpts) === null || _h === void 0 ? void 0 : _h.verifyAuthResponseCallback) !== 'function') {
|
|
56
|
-
if (!((_j = opts.endpointOpts.authorizationChallengeOpts) === null || _j === void 0 ? void 0 : _j.verifyAuthResponseEndpointPath)) {
|
|
57
|
-
throw Error(`Unable to set verifyAuthResponseCallback. No createAuthRequestUriEndpointPath present in options`);
|
|
58
|
-
}
|
|
59
|
-
opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseCallback = yield (0, ssi_sdk_oid4vci_issuer_1.createVerifyAuthResponseCallback)({
|
|
60
|
-
path: opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseEndpointPath,
|
|
61
|
-
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId
|
|
62
|
-
});
|
|
49
|
+
opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback = await createAuthRequestUriCallback({
|
|
50
|
+
path: opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriEndpointPath,
|
|
51
|
+
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (typeof opts?.endpointOpts.authorizationChallengeOpts?.verifyAuthResponseCallback !== 'function') {
|
|
55
|
+
if (!opts.endpointOpts.authorizationChallengeOpts?.verifyAuthResponseEndpointPath) {
|
|
56
|
+
throw Error(`Unable to set verifyAuthResponseCallback. No createAuthRequestUriEndpointPath present in options`);
|
|
63
57
|
}
|
|
58
|
+
opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseCallback = await createVerifyAuthResponseCallback({
|
|
59
|
+
path: opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseEndpointPath,
|
|
60
|
+
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId,
|
|
61
|
+
});
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
});
|
|
63
|
+
}
|
|
64
|
+
return new OID4VCIRestAPI({ context, issuerInstanceArgs, expressSupport, opts, instance, issuer });
|
|
67
65
|
}
|
|
66
|
+
OID4VCI_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VCI/0.1.1';
|
|
68
67
|
constructor(args) {
|
|
69
|
-
const { context, opts } = args;
|
|
68
|
+
const { context, opts, issuerInstanceArgs } = args;
|
|
69
|
+
this._baseUrl = new URL(opts?.baseUrl ??
|
|
70
|
+
process.env.BASE_URL ??
|
|
71
|
+
opts?.issuer?.issuerMetadata?.credential_issuer ??
|
|
72
|
+
issuerInstanceArgs.credentialIssuer ??
|
|
73
|
+
'http://localhost');
|
|
74
|
+
this._basePath = getBasePath(this._baseUrl);
|
|
70
75
|
this._context = context;
|
|
71
|
-
this._opts = opts
|
|
76
|
+
this._opts = opts ?? {};
|
|
72
77
|
this._expressSupport = args.expressSupport;
|
|
73
78
|
this._issuer = args.issuer;
|
|
74
79
|
this._instance = args.instance;
|
|
75
|
-
this._restApi = new
|
|
80
|
+
this._restApi = new OID4VCIServer(args.expressSupport, { ...opts, issuer: this._issuer });
|
|
81
|
+
// The above setups the generic OID4VCI management and wallet APIs from the OID4VCI lib.
|
|
82
|
+
// Below sets up the management of configurations
|
|
83
|
+
this._router = express.Router();
|
|
84
|
+
this.express.use(this._basePath, this._router);
|
|
85
|
+
this.setupSwaggerUi();
|
|
86
|
+
}
|
|
87
|
+
setupSwaggerUi() {
|
|
88
|
+
fetch(this.OID4VCI_SWAGGER_URL)
|
|
89
|
+
.then((res) => res.json())
|
|
90
|
+
.then((swagger) => {
|
|
91
|
+
const apiDocs = `/api-docs`;
|
|
92
|
+
console.log(`[OID4VCI] API docs available at ${this._baseUrl.toString()}${this._basePath}${apiDocs}`);
|
|
93
|
+
swagger.servers = [{ url: this._baseUrl.toString(), description: 'This server' }];
|
|
94
|
+
this.express.set('trust proxy', this.opts?.endpointOpts?.trustProxy ?? true);
|
|
95
|
+
this._router.use(apiDocs, (req, res, next) => {
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
req.swaggerDoc = swagger;
|
|
98
|
+
next();
|
|
99
|
+
}, swaggerUi.serveFiles(swagger, options), swaggerUi.setup());
|
|
100
|
+
})
|
|
101
|
+
.catch((err) => {
|
|
102
|
+
console.log(`[OID4VCI] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`);
|
|
103
|
+
});
|
|
104
|
+
const options = {
|
|
105
|
+
// customCss: '.swagger-ui .topbar { display: none }',
|
|
106
|
+
};
|
|
76
107
|
}
|
|
77
108
|
get express() {
|
|
78
109
|
return this._expressSupport.express;
|
|
@@ -92,11 +123,8 @@ class OID4VCIRestAPI {
|
|
|
92
123
|
get issuer() {
|
|
93
124
|
return this._issuer;
|
|
94
125
|
}
|
|
95
|
-
stop() {
|
|
96
|
-
return
|
|
97
|
-
return this._expressSupport.stop();
|
|
98
|
-
});
|
|
126
|
+
async stop() {
|
|
127
|
+
return this._expressSupport.stop();
|
|
99
128
|
}
|
|
100
129
|
}
|
|
101
|
-
exports.OID4VCIRestAPI = OID4VCIRestAPI;
|
|
102
130
|
//# sourceMappingURL=OID4VCIRestAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OID4VCIRestAPI.js","sourceRoot":"","sources":["../src/OID4VCIRestAPI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OID4VCIRestAPI.js","sourceRoot":"","sources":["../src/OID4VCIRestAPI.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAG5E,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAG5B,gCAAgC,GACjC,MAAM,kCAAkC,CAAA;AACzC,OAAO,OAA+C,MAAM,SAAS,CAAA;AAErE,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAI1C,MAAM,OAAO,cAAc;IACR,eAAe,CAAgB;IAC/B,QAAQ,CAAkB;IAC1B,KAAK,CAAsB;IAC3B,QAAQ,CAAe;IACvB,SAAS,CAAgB;IACzB,OAAO,CAAU;IACjB,OAAO,CAAQ;IACxB,QAAQ,CAAK;IACb,SAAS,CAAQ;IAEzB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAMjB;QACC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAA;QAC5B,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QAC1C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAChF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAA;QAEnG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACxB,C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AAI,IAAI,CAAC,CAAA;YAC5E,IAAI,CAAC,OAAO,CAAC,GAAG,CACd,OAAO,EACP,CAAC,GAAY,EAAE,GAAa,EAAE,IAAS,EAAE,EAAE;gBACzC,aAAa;gBACb,GAAG,CAAC,UAAU,GAAG,OAAO,CAAA;gBACxB,IAAI,EAAE,CAAA;YACR,CAAC,EACD,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,EACtC,SAAS,CAAC,KAAK,EAAE,CAClB,CAAA;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,+CAA+C,GAAG,2CAA2C,CAAC,CAAA;QAC5G,CAAC,CAAC,CAAA;QACJ,MAAM,OAAO,GAAG;QACd,sDAAsD;SACvD,CAAA;IACH,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAA;IACrC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAA;IACpC,CAAC;CACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/**
|
|
18
2
|
* @public
|
|
19
3
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
export * from './OID4VCIRestAPI';
|
|
5
|
+
export * from './types';
|
|
22
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { VcIssuer } from '@sphereon/oid4vci-issuer';
|
|
3
|
+
import { IGetIssueStatusEndpointOpts } from '@sphereon/oid4vci-issuer-server/lib/OID4VCIServer';
|
|
4
|
+
import { IRequiredContext } from './types';
|
|
5
|
+
import { IssuerInstance } from '@sphereon/ssi-sdk.oid4vci-issuer';
|
|
6
|
+
export declare function getCredentialConfigurationsEndpoint(router: Router, context: IRequiredContext, instance: IssuerInstance, issuer: VcIssuer, opts: IGetIssueStatusEndpointOpts): void;
|
|
7
|
+
export declare function getCredentialConfigurationByIdEndpoint(router: Router, context: IRequiredContext, instance: IssuerInstance, issuer: VcIssuer, opts: IGetIssueStatusEndpointOpts): void;
|
|
8
|
+
export declare function deleteCredentialConfigurationByIdEndpoint(router: Router, context: IRequiredContext, instance: IssuerInstance, issuer: VcIssuer, opts: IGetIssueStatusEndpointOpts): void;
|
|
9
|
+
export declare function updateCredentialConfigurationByIdEndpoint(router: Router, context: IRequiredContext, instance: IssuerInstance, issuer: VcIssuer, opts: IGetIssueStatusEndpointOpts): void;
|
|
10
|
+
export declare function newCredentialConfigurationEndpoint(router: Router, context: IRequiredContext, instance: IssuerInstance, issuer: VcIssuer, opts: IGetIssueStatusEndpointOpts): void;
|
|
11
|
+
//# sourceMappingURL=issuer-metadata-api-functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issuer-metadata-api-functions.d.ts","sourceRoot":"","sources":["../src/issuer-metadata-api-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,EAAO,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAGjE,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,2BAA2B,QAmBlC;AAED,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,2BAA2B,QA8BlC;AAED,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,2BAA2B,QA6ClC;AAED,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,2BAA2B,QAiDlC;AAED,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,2BAA2B,QAqDlC"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { checkAuth, sendErrorResponse } from '@sphereon/ssi-express-support';
|
|
2
|
+
import { LOG } from '@sphereon/oid4vci-issuer';
|
|
3
|
+
import { determinePath } from '@sphereon/oid4vci-issuer-server/lib/oid4vci-api-functions';
|
|
4
|
+
export function getCredentialConfigurationsEndpoint(router, context, instance, issuer, opts) {
|
|
5
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations', { stripBasePath: true });
|
|
6
|
+
LOG.log(`[OID4VCI] getCredentialConfigurations endpoint enabled at ${path}`);
|
|
7
|
+
if (opts?.enabled === false) {
|
|
8
|
+
console.log(`"getCredentialConfigurations" Endpoint is disabled`);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
router.get(`${path}`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
12
|
+
try {
|
|
13
|
+
const metadata = instance.issuerMetadata;
|
|
14
|
+
response.statusCode = 200;
|
|
15
|
+
return response.json({ credential_configurations_supported: metadata?.credential_configurations_supported ?? [] });
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function getCredentialConfigurationByIdEndpoint(router, context, instance, issuer, opts) {
|
|
23
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
24
|
+
stripBasePath: true,
|
|
25
|
+
});
|
|
26
|
+
LOG.log(`[OID4VCI] getCredentialConfigurations endpoint enabled at ${path}`);
|
|
27
|
+
if (opts?.enabled === false) {
|
|
28
|
+
console.log(`"getCredentialConfigurations" Endpoint is disabled`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
router.get(`${path}`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
32
|
+
try {
|
|
33
|
+
const configurationId = request.params.configurationId;
|
|
34
|
+
if (!configurationId) {
|
|
35
|
+
return sendErrorResponse(response, 400, 'Missing configurationId');
|
|
36
|
+
}
|
|
37
|
+
LOG.log(`[OID4VCI] getCredentialConfigurations endpoint called with configurationId: ${configurationId}`);
|
|
38
|
+
const metadata = instance.issuerMetadata;
|
|
39
|
+
if (!metadata?.credential_configurations_supported || !metadata?.credential_configurations_supported?.[configurationId]) {
|
|
40
|
+
return sendErrorResponse(response, 404, `Credential configuration ${configurationId} not found`);
|
|
41
|
+
}
|
|
42
|
+
const config = metadata.credential_configurations_supported[configurationId];
|
|
43
|
+
return response.json({ ...config });
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function deleteCredentialConfigurationByIdEndpoint(router, context, instance, issuer, opts) {
|
|
51
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
52
|
+
stripBasePath: true,
|
|
53
|
+
});
|
|
54
|
+
LOG.log(`[OID4VCI] deleteCredentialConfigurationById endpoint enabled at ${path}`);
|
|
55
|
+
if (opts?.enabled === false) {
|
|
56
|
+
console.log(`"deleteCredentialConfigurationById" Endpoint is disabled`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
router.delete(`${path}`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
60
|
+
try {
|
|
61
|
+
const configurationId = request.params.configurationId;
|
|
62
|
+
if (!configurationId) {
|
|
63
|
+
return sendErrorResponse(response, 400, 'Missing configurationId');
|
|
64
|
+
}
|
|
65
|
+
LOG.log(`[OID4VCI] deleteCredentialConfigurationById endpoint called with configurationId: ${configurationId}`);
|
|
66
|
+
const storeMetadata = (await context.agent.oid4vciStoreGetMetadata({
|
|
67
|
+
metadataType: 'issuer',
|
|
68
|
+
storeId: instance.metadataOptions.storeId,
|
|
69
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
70
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
71
|
+
}));
|
|
72
|
+
if (!storeMetadata?.credential_configurations_supported || !storeMetadata?.credential_configurations_supported?.[configurationId]) {
|
|
73
|
+
return sendErrorResponse(response, 404, `Credential configuration ${configurationId} not found`);
|
|
74
|
+
}
|
|
75
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata));
|
|
76
|
+
delete updateMetadata.credential_configurations_supported[configurationId];
|
|
77
|
+
await context.agent.oid4vciStorePersistMetadata({
|
|
78
|
+
metadata: updateMetadata,
|
|
79
|
+
metadataType: 'issuer',
|
|
80
|
+
storeId: instance.metadataOptions.storeId,
|
|
81
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
82
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
83
|
+
overwriteExisting: true,
|
|
84
|
+
validation: true,
|
|
85
|
+
});
|
|
86
|
+
instance.issuerMetadata = updateMetadata;
|
|
87
|
+
return response.json({});
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export function updateCredentialConfigurationByIdEndpoint(router, context, instance, issuer, opts) {
|
|
95
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
96
|
+
stripBasePath: true,
|
|
97
|
+
});
|
|
98
|
+
LOG.log(`[OID4VCI] updateCredentialConfigurationById endpoint enabled at ${path}`);
|
|
99
|
+
if (opts?.enabled === false) {
|
|
100
|
+
console.log(`"updateCredentialConfigurationById" Endpoint is disabled`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
router.put(`${path}`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
104
|
+
try {
|
|
105
|
+
const configurationId = request.params.configurationId;
|
|
106
|
+
if (!configurationId) {
|
|
107
|
+
return sendErrorResponse(response, 400, 'Missing configurationId');
|
|
108
|
+
}
|
|
109
|
+
LOG.log(`[OID4VCI] updateCredentialConfigurationById endpoint called with configurationId: ${configurationId}`);
|
|
110
|
+
const updatedCredentialConfiguration = request.body;
|
|
111
|
+
if (!updatedCredentialConfiguration || !updatedCredentialConfiguration.format) {
|
|
112
|
+
return sendErrorResponse(response, 400, 'Missing credential configuration in the body, or required format missing');
|
|
113
|
+
}
|
|
114
|
+
const storeMetadata = (await context.agent.oid4vciStoreGetMetadata({
|
|
115
|
+
metadataType: 'issuer',
|
|
116
|
+
storeId: instance.metadataOptions.storeId,
|
|
117
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
118
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
119
|
+
}));
|
|
120
|
+
if (!storeMetadata?.credential_configurations_supported || !storeMetadata?.credential_configurations_supported?.[configurationId]) {
|
|
121
|
+
return sendErrorResponse(response, 404, `Credential configuration ${configurationId} not found`);
|
|
122
|
+
}
|
|
123
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata));
|
|
124
|
+
updateMetadata.credential_configurations_supported[configurationId] = updatedCredentialConfiguration;
|
|
125
|
+
await context.agent.oid4vciStorePersistMetadata({
|
|
126
|
+
metadata: updateMetadata,
|
|
127
|
+
metadataType: 'issuer',
|
|
128
|
+
storeId: instance.metadataOptions.storeId,
|
|
129
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
130
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
131
|
+
overwriteExisting: true,
|
|
132
|
+
validation: true,
|
|
133
|
+
});
|
|
134
|
+
instance.issuerMetadata = updateMetadata;
|
|
135
|
+
return response.json({ ...updatedCredentialConfiguration });
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
export function newCredentialConfigurationEndpoint(router, context, instance, issuer, opts) {
|
|
143
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
144
|
+
stripBasePath: true,
|
|
145
|
+
});
|
|
146
|
+
LOG.log(`[OID4VCI] newCredentialConfigurationById endpoint enabled at ${path}`);
|
|
147
|
+
if (opts?.enabled === false) {
|
|
148
|
+
console.log(`"newCredentialConfigurationById" Endpoint is disabled`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
router.put(`${path}`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
152
|
+
try {
|
|
153
|
+
const configurationId = request.params.configurationId;
|
|
154
|
+
if (!configurationId) {
|
|
155
|
+
return sendErrorResponse(response, 400, 'Missing configurationId');
|
|
156
|
+
}
|
|
157
|
+
LOG.log(`[OID4VCI] newCredentialConfigurationById endpoint called with configurationId: ${configurationId}`);
|
|
158
|
+
const newCredentialConfiguration = request.body;
|
|
159
|
+
if (!newCredentialConfiguration || !newCredentialConfiguration.format) {
|
|
160
|
+
return sendErrorResponse(response, 400, 'Missing credential configuration in the body, or required format missing');
|
|
161
|
+
}
|
|
162
|
+
const storeMetadata = (await context.agent.oid4vciStoreGetMetadata({
|
|
163
|
+
metadataType: 'issuer',
|
|
164
|
+
storeId: instance.metadataOptions.storeId,
|
|
165
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
166
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
167
|
+
}));
|
|
168
|
+
if (storeMetadata?.credential_configurations_supported?.[configurationId]) {
|
|
169
|
+
return sendErrorResponse(response, 400, `Credential configuration ${configurationId} already exists, cannot create new one. Please update instead.`);
|
|
170
|
+
}
|
|
171
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata));
|
|
172
|
+
updateMetadata.credential_configurations_supported[configurationId] = newCredentialConfiguration;
|
|
173
|
+
await context.agent.oid4vciStorePersistMetadata({
|
|
174
|
+
metadata: updateMetadata,
|
|
175
|
+
metadataType: 'issuer',
|
|
176
|
+
storeId: instance.metadataOptions.storeId,
|
|
177
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
178
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
179
|
+
overwriteExisting: true,
|
|
180
|
+
validation: true,
|
|
181
|
+
});
|
|
182
|
+
instance.issuerMetadata = updateMetadata;
|
|
183
|
+
return response.json({ ...newCredentialConfiguration });
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=issuer-metadata-api-functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issuer-metadata-api-functions.js","sourceRoot":"","sources":["../src/issuer-metadata-api-functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAE,GAAG,EAAY,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2DAA2D,CAAA;AAOzF,MAAM,UAAU,mCAAmC,CACjD,MAAc,EACd,OAAyB,EACzB,QAAwB,EACxB,MAAgB,EAChB,IAAiC;IAEjC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,mDAAmD,EAAE,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AAI,CAAC,EAAE,GAAG,0BAA0B,EAAE,CAAC,CAAA;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,OAAiB,EAAE,KAAK,CAAC,CAAA;QACzE,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resoluti
|
|
|
2
2
|
import { IOID4VCIIssuer } from '@sphereon/ssi-sdk.oid4vci-issuer';
|
|
3
3
|
import { IOID4VCIStore } from '@sphereon/ssi-sdk.oid4vci-issuer-store';
|
|
4
4
|
import { IAgentContext, ICredentialIssuer, ICredentialVerifier, IDIDManager, IKeyManager, IResolver } from '@veramo/core';
|
|
5
|
-
import { IJwtService } from '@sphereon/ssi-sdk-ext.
|
|
5
|
+
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
|
|
6
6
|
export type IRequiredContext = IAgentContext<IPlugins>;
|
|
7
7
|
export type IPlugins = IDIDManager & IKeyManager & IResolver & IIdentifierResolution & IOID4VCIStore & IOID4VCIIssuer & ICredentialVerifier & ICredentialIssuer & IJwtService;
|
|
8
8
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACzH,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACzH,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;AAEtD,MAAM,MAAM,QAAQ,GAAG,WAAW,GAChC,WAAW,GACX,SAAS,GACT,qBAAqB,GACrB,aAAa,GACb,cAAc,GACd,mBAAmB,GACnB,iBAAiB,GACjB,WAAW,CAAA"}
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.oid4vci-issuer-rest-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,15 +11,16 @@
|
|
|
11
11
|
"start:dev": "ts-node __tests__/RestAPI.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@sphereon/oid4vci-common": "0.
|
|
15
|
-
"@sphereon/oid4vci-issuer": "0.
|
|
16
|
-
"@sphereon/oid4vci-issuer-server": "0.
|
|
17
|
-
"@sphereon/ssi-express-support": "0.
|
|
18
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.
|
|
19
|
-
"@sphereon/ssi-sdk.
|
|
20
|
-
"@sphereon/ssi-sdk.
|
|
21
|
-
"@sphereon/ssi-sdk.oid4vci-issuer
|
|
22
|
-
"@sphereon/ssi-
|
|
14
|
+
"@sphereon/oid4vci-common": "0.17.0",
|
|
15
|
+
"@sphereon/oid4vci-issuer": "0.17.0",
|
|
16
|
+
"@sphereon/oid4vci-issuer-server": "0.17.0",
|
|
17
|
+
"@sphereon/ssi-express-support": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
18
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.0",
|
|
19
|
+
"@sphereon/ssi-sdk-ext.jwt-service": "0.28.0",
|
|
20
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
21
|
+
"@sphereon/ssi-sdk.oid4vci-issuer": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
22
|
+
"@sphereon/ssi-sdk.oid4vci-issuer-store": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
23
|
+
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
23
24
|
"@veramo/core": "4.2.0",
|
|
24
25
|
"@veramo/credential-w3c": "4.2.0",
|
|
25
26
|
"awesome-qr": "^2.1.5-rc.0",
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"dotenv-flow": "^3.3.0",
|
|
31
32
|
"express": "^4.19.2",
|
|
32
33
|
"short-uuid": "^4.2.2",
|
|
34
|
+
"swagger-ui-express": "^5.0.1",
|
|
33
35
|
"uuid": "^9.0.1"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
@@ -37,12 +39,12 @@
|
|
|
37
39
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
38
40
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
39
41
|
"@sphereon/pex-models": "^2.3.2",
|
|
40
|
-
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.
|
|
41
|
-
"@sphereon/ssi-sdk-ext.key-manager": "0.
|
|
42
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.
|
|
43
|
-
"@sphereon/ssi-sdk-ext.kms-local": "0.
|
|
44
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
45
|
-
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.
|
|
42
|
+
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.28.0",
|
|
43
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.28.0",
|
|
44
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.28.0",
|
|
45
|
+
"@sphereon/ssi-sdk-ext.kms-local": "0.28.0",
|
|
46
|
+
"@sphereon/ssi-sdk.data-store": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
47
|
+
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
46
48
|
"@types/body-parser": "^1.19.5",
|
|
47
49
|
"@types/cookie-parser": "^1.4.7",
|
|
48
50
|
"@types/cors": "^2.8.17",
|
|
@@ -51,6 +53,7 @@
|
|
|
51
53
|
"@types/express": "^4.17.21",
|
|
52
54
|
"@types/express-http-proxy": "^1.6.6",
|
|
53
55
|
"@types/node": "^20.17.1",
|
|
56
|
+
"@types/swagger-ui-express": "^4.1.7",
|
|
54
57
|
"@types/uuid": "^9.0.8",
|
|
55
58
|
"@veramo/data-store": "4.2.0",
|
|
56
59
|
"@veramo/did-manager": "4.2.0",
|
|
@@ -62,10 +65,11 @@
|
|
|
62
65
|
"@veramo/key-manager": "4.2.0",
|
|
63
66
|
"@veramo/kms-local": "4.2.0",
|
|
64
67
|
"@veramo/utils": "4.2.0",
|
|
68
|
+
"debug": "^4.4.0",
|
|
65
69
|
"did-resolver": "^4.1.0",
|
|
66
70
|
"nock": "^13.5.4",
|
|
67
71
|
"ts-node": "^10.9.2",
|
|
68
|
-
"typeorm": "^0.3.
|
|
72
|
+
"typeorm": "^0.3.21",
|
|
69
73
|
"web-did-resolver": "^2.0.27"
|
|
70
74
|
},
|
|
71
75
|
"files": [
|
|
@@ -96,5 +100,5 @@
|
|
|
96
100
|
"Authenticator"
|
|
97
101
|
],
|
|
98
102
|
"nx": {},
|
|
99
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "9f634bdb714061141e277508c124b08d626f6036"
|
|
100
104
|
}
|
package/src/OID4VCIRestAPI.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CredentialDataSupplier, VcIssuer } from '@sphereon/oid4vci-issuer'
|
|
2
|
-
import { OID4VCIServer } from '@sphereon/oid4vci-issuer-server'
|
|
2
|
+
import { getBasePath, OID4VCIServer } from '@sphereon/oid4vci-issuer-server'
|
|
3
3
|
import { IOID4VCIServerOpts } from '@sphereon/oid4vci-issuer-server'
|
|
4
4
|
import { ExpressSupport } from '@sphereon/ssi-express-support'
|
|
5
5
|
import {
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getAccessTokenSignerCallback,
|
|
8
8
|
IIssuerInstanceArgs,
|
|
9
9
|
IssuerInstance,
|
|
10
|
-
createVerifyAuthResponseCallback
|
|
10
|
+
createVerifyAuthResponseCallback,
|
|
11
11
|
} from '@sphereon/ssi-sdk.oid4vci-issuer'
|
|
12
|
-
import {
|
|
13
|
-
import { Express } from 'express'
|
|
12
|
+
import express, { Express, Request, Response, Router } from 'express'
|
|
14
13
|
import { IRequiredContext } from './types'
|
|
14
|
+
import swaggerUi from 'swagger-ui-express'
|
|
15
15
|
|
|
16
16
|
export interface IOID4VCIRestAPIOpts extends IOID4VCIServerOpts {}
|
|
17
17
|
|
|
@@ -19,9 +19,12 @@ export class OID4VCIRestAPI {
|
|
|
19
19
|
private readonly _expressSupport: ExpressSupport
|
|
20
20
|
private readonly _context: IRequiredContext
|
|
21
21
|
private readonly _opts?: IOID4VCIRestAPIOpts
|
|
22
|
-
private readonly _restApi: OID4VCIServer
|
|
22
|
+
private readonly _restApi: OID4VCIServer
|
|
23
23
|
private readonly _instance: IssuerInstance
|
|
24
|
-
private readonly _issuer: VcIssuer
|
|
24
|
+
private readonly _issuer: VcIssuer
|
|
25
|
+
private readonly _router: Router
|
|
26
|
+
private _baseUrl: URL
|
|
27
|
+
private _basePath: string
|
|
25
28
|
|
|
26
29
|
static async init(args: {
|
|
27
30
|
context: IRequiredContext
|
|
@@ -65,60 +68,93 @@ export class OID4VCIRestAPI {
|
|
|
65
68
|
|
|
66
69
|
if (opts?.endpointOpts.authorizationChallengeOpts?.enabled === true) {
|
|
67
70
|
if (!instance.issuerOptions.presentationDefinitionId) {
|
|
68
|
-
throw Error(
|
|
69
|
-
`Unable to set createAuthRequestUriCallback. No presentationDefinitionId present in issuer options`,
|
|
70
|
-
)
|
|
71
|
+
throw Error(`Unable to set createAuthRequestUriCallback. No presentationDefinitionId present in issuer options`)
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
if (typeof opts?.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback !== 'function') {
|
|
74
75
|
if (!opts.endpointOpts.authorizationChallengeOpts?.createAuthRequestUriEndpointPath) {
|
|
75
|
-
throw Error(
|
|
76
|
-
`Unable to set createAuthRequestUriCallback. No createAuthRequestUriEndpointPath present in options`,
|
|
77
|
-
)
|
|
76
|
+
throw Error(`Unable to set createAuthRequestUriCallback. No createAuthRequestUriEndpointPath present in options`)
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback = await createAuthRequestUriCallback(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
)
|
|
79
|
+
opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback = await createAuthRequestUriCallback({
|
|
80
|
+
path: opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriEndpointPath,
|
|
81
|
+
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId,
|
|
82
|
+
})
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
if (typeof opts?.endpointOpts.authorizationChallengeOpts?.verifyAuthResponseCallback !== 'function') {
|
|
89
86
|
if (!opts.endpointOpts.authorizationChallengeOpts?.verifyAuthResponseEndpointPath) {
|
|
90
|
-
throw Error(
|
|
91
|
-
`Unable to set verifyAuthResponseCallback. No createAuthRequestUriEndpointPath present in options`,
|
|
92
|
-
)
|
|
87
|
+
throw Error(`Unable to set verifyAuthResponseCallback. No createAuthRequestUriEndpointPath present in options`)
|
|
93
88
|
}
|
|
94
89
|
|
|
95
|
-
opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseCallback = await createVerifyAuthResponseCallback(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
)
|
|
90
|
+
opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseCallback = await createVerifyAuthResponseCallback({
|
|
91
|
+
path: opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseEndpointPath,
|
|
92
|
+
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId,
|
|
93
|
+
})
|
|
101
94
|
}
|
|
102
95
|
}
|
|
103
96
|
|
|
104
97
|
return new OID4VCIRestAPI({ context, issuerInstanceArgs, expressSupport, opts, instance, issuer })
|
|
105
98
|
}
|
|
106
99
|
|
|
100
|
+
private readonly OID4VCI_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VCI/0.1.1'
|
|
101
|
+
|
|
107
102
|
private constructor(args: {
|
|
108
|
-
issuer: VcIssuer
|
|
103
|
+
issuer: VcIssuer
|
|
109
104
|
instance: IssuerInstance
|
|
110
105
|
context: IRequiredContext
|
|
111
106
|
issuerInstanceArgs: IIssuerInstanceArgs
|
|
112
107
|
expressSupport: ExpressSupport
|
|
113
108
|
opts: IOID4VCIRestAPIOpts
|
|
114
109
|
}) {
|
|
115
|
-
const { context, opts } = args
|
|
110
|
+
const { context, opts, issuerInstanceArgs } = args
|
|
111
|
+
this._baseUrl = new URL(
|
|
112
|
+
opts?.baseUrl ??
|
|
113
|
+
process.env.BASE_URL ??
|
|
114
|
+
opts?.issuer?.issuerMetadata?.credential_issuer ??
|
|
115
|
+
issuerInstanceArgs.credentialIssuer ??
|
|
116
|
+
'http://localhost',
|
|
117
|
+
)
|
|
118
|
+
this._basePath = getBasePath(this._baseUrl)
|
|
116
119
|
this._context = context
|
|
117
120
|
this._opts = opts ?? {}
|
|
118
121
|
this._expressSupport = args.expressSupport
|
|
119
122
|
this._issuer = args.issuer
|
|
120
123
|
this._instance = args.instance
|
|
121
|
-
this._restApi = new OID4VCIServer
|
|
124
|
+
this._restApi = new OID4VCIServer(args.expressSupport, { ...opts, issuer: this._issuer })
|
|
125
|
+
|
|
126
|
+
// The above setups the generic OID4VCI management and wallet APIs from the OID4VCI lib.
|
|
127
|
+
// Below sets up the management of configurations
|
|
128
|
+
this._router = express.Router()
|
|
129
|
+
this.express.use(this._basePath, this._router)
|
|
130
|
+
this.setupSwaggerUi()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private setupSwaggerUi() {
|
|
134
|
+
fetch(this.OID4VCI_SWAGGER_URL)
|
|
135
|
+
.then((res) => res.json())
|
|
136
|
+
.then((swagger) => {
|
|
137
|
+
const apiDocs = `/api-docs`
|
|
138
|
+
console.log(`[OID4VCI] API docs available at ${this._baseUrl.toString()}${this._basePath}${apiDocs}`)
|
|
139
|
+
swagger.servers = [{ url: this._baseUrl.toString(), description: 'This server' }]
|
|
140
|
+
this.express.set('trust proxy', this.opts?.endpointOpts?.trustProxy ?? true)
|
|
141
|
+
this._router.use(
|
|
142
|
+
apiDocs,
|
|
143
|
+
(req: Request, res: Response, next: any) => {
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
req.swaggerDoc = swagger
|
|
146
|
+
next()
|
|
147
|
+
},
|
|
148
|
+
swaggerUi.serveFiles(swagger, options),
|
|
149
|
+
swaggerUi.setup(),
|
|
150
|
+
)
|
|
151
|
+
})
|
|
152
|
+
.catch((err) => {
|
|
153
|
+
console.log(`[OID4VCI] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`)
|
|
154
|
+
})
|
|
155
|
+
const options = {
|
|
156
|
+
// customCss: '.swagger-ui .topbar { display: none }',
|
|
157
|
+
}
|
|
122
158
|
}
|
|
123
159
|
|
|
124
160
|
get express(): Express {
|
|
@@ -133,7 +169,7 @@ export class OID4VCIRestAPI {
|
|
|
133
169
|
return this._opts
|
|
134
170
|
}
|
|
135
171
|
|
|
136
|
-
get restApi(): OID4VCIServer
|
|
172
|
+
get restApi(): OID4VCIServer {
|
|
137
173
|
return this._restApi
|
|
138
174
|
}
|
|
139
175
|
|
|
@@ -141,7 +177,7 @@ export class OID4VCIRestAPI {
|
|
|
141
177
|
return this._instance
|
|
142
178
|
}
|
|
143
179
|
|
|
144
|
-
get issuer(): VcIssuer
|
|
180
|
+
get issuer(): VcIssuer {
|
|
145
181
|
return this._issuer
|
|
146
182
|
}
|
|
147
183
|
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { Request, Response, Router } from 'express'
|
|
2
|
+
import { checkAuth, sendErrorResponse } from '@sphereon/ssi-express-support'
|
|
3
|
+
import { LOG, VcIssuer } from '@sphereon/oid4vci-issuer'
|
|
4
|
+
import { determinePath } from '@sphereon/oid4vci-issuer-server/lib/oid4vci-api-functions'
|
|
5
|
+
import { IGetIssueStatusEndpointOpts } from '@sphereon/oid4vci-issuer-server/lib/OID4VCIServer'
|
|
6
|
+
import { IRequiredContext } from './types'
|
|
7
|
+
import { CredentialConfigurationSupportedV1_0_13 } from '@sphereon/oid4vci-common/lib/types/v1_0_13.types'
|
|
8
|
+
import { IssuerInstance } from '@sphereon/ssi-sdk.oid4vci-issuer'
|
|
9
|
+
import { IssuerMetadataV1_0_13 } from '@sphereon/oid4vci-common'
|
|
10
|
+
|
|
11
|
+
export function getCredentialConfigurationsEndpoint(
|
|
12
|
+
router: Router,
|
|
13
|
+
context: IRequiredContext,
|
|
14
|
+
instance: IssuerInstance,
|
|
15
|
+
issuer: VcIssuer,
|
|
16
|
+
opts: IGetIssueStatusEndpointOpts,
|
|
17
|
+
) {
|
|
18
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations', { stripBasePath: true })
|
|
19
|
+
LOG.log(`[OID4VCI] getCredentialConfigurations endpoint enabled at ${path}`)
|
|
20
|
+
if (opts?.enabled === false) {
|
|
21
|
+
console.log(`"getCredentialConfigurations" Endpoint is disabled`)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
router.get(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
26
|
+
try {
|
|
27
|
+
const metadata = instance.issuerMetadata as IssuerMetadataV1_0_13
|
|
28
|
+
response.statusCode = 200
|
|
29
|
+
|
|
30
|
+
return response.json({ credential_configurations_supported: metadata?.credential_configurations_supported ?? [] })
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return sendErrorResponse(response, 500, error.message as string, error)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getCredentialConfigurationByIdEndpoint(
|
|
38
|
+
router: Router,
|
|
39
|
+
context: IRequiredContext,
|
|
40
|
+
instance: IssuerInstance,
|
|
41
|
+
issuer: VcIssuer,
|
|
42
|
+
opts: IGetIssueStatusEndpointOpts,
|
|
43
|
+
) {
|
|
44
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
45
|
+
stripBasePath: true,
|
|
46
|
+
})
|
|
47
|
+
LOG.log(`[OID4VCI] getCredentialConfigurations endpoint enabled at ${path}`)
|
|
48
|
+
if (opts?.enabled === false) {
|
|
49
|
+
console.log(`"getCredentialConfigurations" Endpoint is disabled`)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
router.get(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
54
|
+
try {
|
|
55
|
+
const configurationId = request.params.configurationId
|
|
56
|
+
if (!configurationId) {
|
|
57
|
+
return sendErrorResponse(response, 400, 'Missing configurationId')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
LOG.log(`[OID4VCI] getCredentialConfigurations endpoint called with configurationId: ${configurationId}`)
|
|
61
|
+
const metadata = instance.issuerMetadata as IssuerMetadataV1_0_13
|
|
62
|
+
if (!metadata?.credential_configurations_supported || !metadata?.credential_configurations_supported?.[configurationId]) {
|
|
63
|
+
return sendErrorResponse(response, 404, `Credential configuration ${configurationId} not found`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const config = metadata.credential_configurations_supported[configurationId]
|
|
67
|
+
return response.json({ ...config })
|
|
68
|
+
} catch (error) {
|
|
69
|
+
return sendErrorResponse(response, 500, error.message as string, error)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function deleteCredentialConfigurationByIdEndpoint(
|
|
75
|
+
router: Router,
|
|
76
|
+
context: IRequiredContext,
|
|
77
|
+
instance: IssuerInstance,
|
|
78
|
+
issuer: VcIssuer,
|
|
79
|
+
opts: IGetIssueStatusEndpointOpts,
|
|
80
|
+
) {
|
|
81
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
82
|
+
stripBasePath: true,
|
|
83
|
+
})
|
|
84
|
+
LOG.log(`[OID4VCI] deleteCredentialConfigurationById endpoint enabled at ${path}`)
|
|
85
|
+
if (opts?.enabled === false) {
|
|
86
|
+
console.log(`"deleteCredentialConfigurationById" Endpoint is disabled`)
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
router.delete(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
91
|
+
try {
|
|
92
|
+
const configurationId = request.params.configurationId
|
|
93
|
+
if (!configurationId) {
|
|
94
|
+
return sendErrorResponse(response, 400, 'Missing configurationId')
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
LOG.log(`[OID4VCI] deleteCredentialConfigurationById endpoint called with configurationId: ${configurationId}`)
|
|
98
|
+
const storeMetadata = (await context.agent.oid4vciStoreGetMetadata({
|
|
99
|
+
metadataType: 'issuer',
|
|
100
|
+
storeId: instance.metadataOptions.storeId,
|
|
101
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
102
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
103
|
+
})) as IssuerMetadataV1_0_13
|
|
104
|
+
if (!storeMetadata?.credential_configurations_supported || !storeMetadata?.credential_configurations_supported?.[configurationId]) {
|
|
105
|
+
return sendErrorResponse(response, 404, `Credential configuration ${configurationId} not found`)
|
|
106
|
+
}
|
|
107
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata)) as IssuerMetadataV1_0_13
|
|
108
|
+
delete updateMetadata.credential_configurations_supported[configurationId]
|
|
109
|
+
await context.agent.oid4vciStorePersistMetadata({
|
|
110
|
+
metadata: updateMetadata,
|
|
111
|
+
metadataType: 'issuer',
|
|
112
|
+
storeId: instance.metadataOptions.storeId,
|
|
113
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
114
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
115
|
+
overwriteExisting: true,
|
|
116
|
+
validation: true,
|
|
117
|
+
})
|
|
118
|
+
instance.issuerMetadata = updateMetadata
|
|
119
|
+
return response.json({})
|
|
120
|
+
} catch (error) {
|
|
121
|
+
return sendErrorResponse(response, 500, error.message as string, error)
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function updateCredentialConfigurationByIdEndpoint(
|
|
127
|
+
router: Router,
|
|
128
|
+
context: IRequiredContext,
|
|
129
|
+
instance: IssuerInstance,
|
|
130
|
+
issuer: VcIssuer,
|
|
131
|
+
opts: IGetIssueStatusEndpointOpts,
|
|
132
|
+
) {
|
|
133
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
134
|
+
stripBasePath: true,
|
|
135
|
+
})
|
|
136
|
+
LOG.log(`[OID4VCI] updateCredentialConfigurationById endpoint enabled at ${path}`)
|
|
137
|
+
if (opts?.enabled === false) {
|
|
138
|
+
console.log(`"updateCredentialConfigurationById" Endpoint is disabled`)
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
router.put(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
143
|
+
try {
|
|
144
|
+
const configurationId = request.params.configurationId
|
|
145
|
+
if (!configurationId) {
|
|
146
|
+
return sendErrorResponse(response, 400, 'Missing configurationId')
|
|
147
|
+
}
|
|
148
|
+
LOG.log(`[OID4VCI] updateCredentialConfigurationById endpoint called with configurationId: ${configurationId}`)
|
|
149
|
+
const updatedCredentialConfiguration = request.body as CredentialConfigurationSupportedV1_0_13
|
|
150
|
+
if (!updatedCredentialConfiguration || !updatedCredentialConfiguration.format) {
|
|
151
|
+
return sendErrorResponse(response, 400, 'Missing credential configuration in the body, or required format missing')
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const storeMetadata = (await context.agent.oid4vciStoreGetMetadata({
|
|
155
|
+
metadataType: 'issuer',
|
|
156
|
+
storeId: instance.metadataOptions.storeId,
|
|
157
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
158
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
159
|
+
})) as IssuerMetadataV1_0_13
|
|
160
|
+
if (!storeMetadata?.credential_configurations_supported || !storeMetadata?.credential_configurations_supported?.[configurationId]) {
|
|
161
|
+
return sendErrorResponse(response, 404, `Credential configuration ${configurationId} not found`)
|
|
162
|
+
}
|
|
163
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata)) as IssuerMetadataV1_0_13
|
|
164
|
+
updateMetadata.credential_configurations_supported[configurationId] = updatedCredentialConfiguration
|
|
165
|
+
await context.agent.oid4vciStorePersistMetadata({
|
|
166
|
+
metadata: updateMetadata,
|
|
167
|
+
metadataType: 'issuer',
|
|
168
|
+
storeId: instance.metadataOptions.storeId,
|
|
169
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
170
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
171
|
+
overwriteExisting: true,
|
|
172
|
+
validation: true,
|
|
173
|
+
})
|
|
174
|
+
instance.issuerMetadata = updateMetadata
|
|
175
|
+
return response.json({ ...updatedCredentialConfiguration })
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return sendErrorResponse(response, 500, error.message as string, error)
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function newCredentialConfigurationEndpoint(
|
|
183
|
+
router: Router,
|
|
184
|
+
context: IRequiredContext,
|
|
185
|
+
instance: IssuerInstance,
|
|
186
|
+
issuer: VcIssuer,
|
|
187
|
+
opts: IGetIssueStatusEndpointOpts,
|
|
188
|
+
) {
|
|
189
|
+
const path = determinePath(opts.baseUrl, opts?.path ?? '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
190
|
+
stripBasePath: true,
|
|
191
|
+
})
|
|
192
|
+
LOG.log(`[OID4VCI] newCredentialConfigurationById endpoint enabled at ${path}`)
|
|
193
|
+
if (opts?.enabled === false) {
|
|
194
|
+
console.log(`"newCredentialConfigurationById" Endpoint is disabled`)
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
router.put(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
199
|
+
try {
|
|
200
|
+
const configurationId = request.params.configurationId
|
|
201
|
+
if (!configurationId) {
|
|
202
|
+
return sendErrorResponse(response, 400, 'Missing configurationId')
|
|
203
|
+
}
|
|
204
|
+
LOG.log(`[OID4VCI] newCredentialConfigurationById endpoint called with configurationId: ${configurationId}`)
|
|
205
|
+
const newCredentialConfiguration = request.body as CredentialConfigurationSupportedV1_0_13
|
|
206
|
+
if (!newCredentialConfiguration || !newCredentialConfiguration.format) {
|
|
207
|
+
return sendErrorResponse(response, 400, 'Missing credential configuration in the body, or required format missing')
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const storeMetadata = (await context.agent.oid4vciStoreGetMetadata({
|
|
211
|
+
metadataType: 'issuer',
|
|
212
|
+
storeId: instance.metadataOptions.storeId,
|
|
213
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
214
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
215
|
+
})) as IssuerMetadataV1_0_13
|
|
216
|
+
if (storeMetadata?.credential_configurations_supported?.[configurationId]) {
|
|
217
|
+
return sendErrorResponse(
|
|
218
|
+
response,
|
|
219
|
+
400,
|
|
220
|
+
`Credential configuration ${configurationId} already exists, cannot create new one. Please update instead.`,
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata)) as IssuerMetadataV1_0_13
|
|
224
|
+
updateMetadata.credential_configurations_supported[configurationId] = newCredentialConfiguration
|
|
225
|
+
await context.agent.oid4vciStorePersistMetadata({
|
|
226
|
+
metadata: updateMetadata,
|
|
227
|
+
metadataType: 'issuer',
|
|
228
|
+
storeId: instance.metadataOptions.storeId,
|
|
229
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
230
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
231
|
+
overwriteExisting: true,
|
|
232
|
+
validation: true,
|
|
233
|
+
})
|
|
234
|
+
instance.issuerMetadata = updateMetadata
|
|
235
|
+
return response.json({ ...newCredentialConfiguration })
|
|
236
|
+
} catch (error) {
|
|
237
|
+
return sendErrorResponse(response, 500, error.message as string, error)
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resoluti
|
|
|
2
2
|
import { IOID4VCIIssuer } from '@sphereon/ssi-sdk.oid4vci-issuer'
|
|
3
3
|
import { IOID4VCIStore } from '@sphereon/ssi-sdk.oid4vci-issuer-store'
|
|
4
4
|
import { IAgentContext, ICredentialIssuer, ICredentialVerifier, IDIDManager, IKeyManager, IResolver } from '@veramo/core'
|
|
5
|
-
import { IJwtService } from '@sphereon/ssi-sdk-ext.
|
|
5
|
+
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
6
6
|
|
|
7
7
|
export type IRequiredContext = IAgentContext<IPlugins>
|
|
8
8
|
|