@sphereon/ssi-sdk.oid4vci-issuer-rest-api 0.32.1-next.18 → 0.32.1-next.287
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 +61 -2
- package/dist/OID4VCIRestAPI.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 +216 -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/package.json +22 -18
- package/src/OID4VCIRestAPI.ts +92 -11
- 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,EAAE,OAAO,EAA6B,MAAM,SAAS,CAAA;AACrE,OAAO,EAAE,gBAAgB,EA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ments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.OID4VCIRestAPI = void 0;
|
|
13
16
|
const oid4vci_issuer_server_1 = require("@sphereon/oid4vci-issuer-server");
|
|
14
17
|
const ssi_sdk_oid4vci_issuer_1 = require("@sphereon/ssi-sdk.oid4vci-issuer");
|
|
18
|
+
const express_1 = __importDefault(require("express"));
|
|
19
|
+
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
15
20
|
class OID4VCIRestAPI {
|
|
16
21
|
static init(args) {
|
|
17
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
var _a, _b, _c, _d, _e;
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
19
24
|
const { issuerInstanceArgs, context } = args;
|
|
20
25
|
const opts = (_a = args.opts) !== null && _a !== void 0 ? _a : {};
|
|
21
26
|
const expressSupport = args.expressSupport;
|
|
@@ -39,17 +44,71 @@ class OID4VCIRestAPI {
|
|
|
39
44
|
};
|
|
40
45
|
opts.endpointOpts.tokenEndpointOpts.accessTokenSignerCallback = yield (0, ssi_sdk_oid4vci_issuer_1.getAccessTokenSignerCallback)(Object.assign({}, tokenOpts), args.context);
|
|
41
46
|
}
|
|
47
|
+
if (((_f = opts === null || opts === void 0 ? void 0 : opts.endpointOpts.authorizationChallengeOpts) === null || _f === void 0 ? void 0 : _f.enabled) === true) {
|
|
48
|
+
if (!instance.issuerOptions.presentationDefinitionId) {
|
|
49
|
+
throw Error(`Unable to set createAuthRequestUriCallback. No presentationDefinitionId present in issuer options`);
|
|
50
|
+
}
|
|
51
|
+
if (typeof (opts === null || opts === void 0 ? void 0 : opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback) !== 'function') {
|
|
52
|
+
if (!((_g = opts.endpointOpts.authorizationChallengeOpts) === null || _g === void 0 ? void 0 : _g.createAuthRequestUriEndpointPath)) {
|
|
53
|
+
throw Error(`Unable to set createAuthRequestUriCallback. No createAuthRequestUriEndpointPath present in options`);
|
|
54
|
+
}
|
|
55
|
+
opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback = yield (0, ssi_sdk_oid4vci_issuer_1.createAuthRequestUriCallback)({
|
|
56
|
+
path: opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriEndpointPath,
|
|
57
|
+
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (typeof ((_h = opts === null || opts === void 0 ? void 0 : opts.endpointOpts.authorizationChallengeOpts) === null || _h === void 0 ? void 0 : _h.verifyAuthResponseCallback) !== 'function') {
|
|
61
|
+
if (!((_j = opts.endpointOpts.authorizationChallengeOpts) === null || _j === void 0 ? void 0 : _j.verifyAuthResponseEndpointPath)) {
|
|
62
|
+
throw Error(`Unable to set verifyAuthResponseCallback. No createAuthRequestUriEndpointPath present in options`);
|
|
63
|
+
}
|
|
64
|
+
opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseCallback = yield (0, ssi_sdk_oid4vci_issuer_1.createVerifyAuthResponseCallback)({
|
|
65
|
+
path: opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseEndpointPath,
|
|
66
|
+
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
42
70
|
return new OID4VCIRestAPI({ context, issuerInstanceArgs, expressSupport, opts, instance, issuer });
|
|
43
71
|
});
|
|
44
72
|
}
|
|
45
73
|
constructor(args) {
|
|
46
|
-
|
|
74
|
+
var _a, _b, _c, _d, _e, _f;
|
|
75
|
+
this.OID4VCI_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VCI/0.1.1';
|
|
76
|
+
const { context, opts, issuerInstanceArgs } = args;
|
|
77
|
+
this._baseUrl = new URL((_f = (_e = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.baseUrl) !== null && _a !== void 0 ? _a : process.env.BASE_URL) !== null && _b !== void 0 ? _b : (_d = (_c = opts === null || opts === void 0 ? void 0 : opts.issuer) === null || _c === void 0 ? void 0 : _c.issuerMetadata) === null || _d === void 0 ? void 0 : _d.credential_issuer) !== null && _e !== void 0 ? _e : issuerInstanceArgs.credentialIssuer) !== null && _f !== void 0 ? _f : 'http://localhost');
|
|
78
|
+
this._basePath = (0, oid4vci_issuer_server_1.getBasePath)(this._baseUrl);
|
|
47
79
|
this._context = context;
|
|
48
80
|
this._opts = opts !== null && opts !== void 0 ? opts : {};
|
|
49
81
|
this._expressSupport = args.expressSupport;
|
|
50
82
|
this._issuer = args.issuer;
|
|
51
83
|
this._instance = args.instance;
|
|
52
84
|
this._restApi = new oid4vci_issuer_server_1.OID4VCIServer(args.expressSupport, Object.assign(Object.assign({}, opts), { issuer: this._issuer }));
|
|
85
|
+
// The above setups the generic OID4VCI management and wallet APIs from the OID4VCI lib.
|
|
86
|
+
// Below sets up the management of configurations
|
|
87
|
+
this._router = express_1.default.Router();
|
|
88
|
+
this.express.use(this._basePath, this._router);
|
|
89
|
+
this.setupSwaggerUi();
|
|
90
|
+
}
|
|
91
|
+
setupSwaggerUi() {
|
|
92
|
+
fetch(this.OID4VCI_SWAGGER_URL)
|
|
93
|
+
.then((res) => res.json())
|
|
94
|
+
.then((swagger) => {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
const apiDocs = `/api-docs`;
|
|
97
|
+
console.log(`[OID4VCI] API docs available at ${this._baseUrl.toString()}${this._basePath}${apiDocs}`);
|
|
98
|
+
swagger.servers = [{ url: this._baseUrl.toString(), description: 'This server' }];
|
|
99
|
+
this.express.set('trust proxy', (_c = (_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.endpointOpts) === null || _b === void 0 ? void 0 : _b.trustProxy) !== null && _c !== void 0 ? _c : true);
|
|
100
|
+
this._router.use(apiDocs, (req, res, next) => {
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
req.swaggerDoc = swagger;
|
|
103
|
+
next();
|
|
104
|
+
}, swagger_ui_express_1.default.serveFiles(swagger, options), swagger_ui_express_1.default.setup());
|
|
105
|
+
})
|
|
106
|
+
.catch((err) => {
|
|
107
|
+
console.log(`[OID4VCI] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`);
|
|
108
|
+
});
|
|
109
|
+
const options = {
|
|
110
|
+
// customCss: '.swagger-ui .topbar { display: none }',
|
|
111
|
+
};
|
|
53
112
|
}
|
|
54
113
|
get express() {
|
|
55
114
|
return this._expressSupport.express;
|
|
@@ -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,2EAA4E;AAG5E,6EAMyC;AACzC,sDAAqE;AAErE,4EAA0C;AAI1C,MAAa,cAAc;IAWzB,MAAM,CAAO,IAAI,CAAC,IAMjB;;;YACC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;YAC5C,MAAM,IAAI,GAAG,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAA;YAC5B,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;YAC1C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;YAChF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAA;YAEnG,IAAI,CAAC,IAAI,CAAC,YA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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;IAEK,IAAI;;YACR,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAA;QACpC,CAAC;KAAA;CACF;AAzKD,wCAyKC"}
|
|
@@ -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,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getCredentialConfigurationsEndpoint = getCredentialConfigurationsEndpoint;
|
|
13
|
+
exports.getCredentialConfigurationByIdEndpoint = getCredentialConfigurationByIdEndpoint;
|
|
14
|
+
exports.deleteCredentialConfigurationByIdEndpoint = deleteCredentialConfigurationByIdEndpoint;
|
|
15
|
+
exports.updateCredentialConfigurationByIdEndpoint = updateCredentialConfigurationByIdEndpoint;
|
|
16
|
+
exports.newCredentialConfigurationEndpoint = newCredentialConfigurationEndpoint;
|
|
17
|
+
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
18
|
+
const oid4vci_issuer_1 = require("@sphereon/oid4vci-issuer");
|
|
19
|
+
const oid4vci_api_functions_1 = require("@sphereon/oid4vci-issuer-server/lib/oid4vci-api-functions");
|
|
20
|
+
function getCredentialConfigurationsEndpoint(router, context, instance, issuer, opts) {
|
|
21
|
+
var _a;
|
|
22
|
+
const path = (0, oid4vci_api_functions_1.determinePath)(opts.baseUrl, (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/issuer-metadata/credential-configurations', { stripBasePath: true });
|
|
23
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] getCredentialConfigurations endpoint enabled at ${path}`);
|
|
24
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
25
|
+
console.log(`"getCredentialConfigurations" Endpoint is disabled`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
router.get(`${path}`, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a;
|
|
30
|
+
try {
|
|
31
|
+
const metadata = instance.issuerMetadata;
|
|
32
|
+
response.statusCode = 200;
|
|
33
|
+
return response.json({ credential_configurations_supported: (_a = metadata === null || metadata === void 0 ? void 0 : metadata.credential_configurations_supported) !== null && _a !== void 0 ? _a : [] });
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
function getCredentialConfigurationByIdEndpoint(router, context, instance, issuer, opts) {
|
|
41
|
+
var _a;
|
|
42
|
+
const path = (0, oid4vci_api_functions_1.determinePath)(opts.baseUrl, (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
43
|
+
stripBasePath: true,
|
|
44
|
+
});
|
|
45
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] getCredentialConfigurations endpoint enabled at ${path}`);
|
|
46
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
47
|
+
console.log(`"getCredentialConfigurations" Endpoint is disabled`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
router.get(`${path}`, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
var _a;
|
|
52
|
+
try {
|
|
53
|
+
const configurationId = request.params.configurationId;
|
|
54
|
+
if (!configurationId) {
|
|
55
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, 'Missing configurationId');
|
|
56
|
+
}
|
|
57
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] getCredentialConfigurations endpoint called with configurationId: ${configurationId}`);
|
|
58
|
+
const metadata = instance.issuerMetadata;
|
|
59
|
+
if (!(metadata === null || metadata === void 0 ? void 0 : metadata.credential_configurations_supported) || !((_a = metadata === null || metadata === void 0 ? void 0 : metadata.credential_configurations_supported) === null || _a === void 0 ? void 0 : _a[configurationId])) {
|
|
60
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 404, `Credential configuration ${configurationId} not found`);
|
|
61
|
+
}
|
|
62
|
+
const config = metadata.credential_configurations_supported[configurationId];
|
|
63
|
+
return response.json(Object.assign({}, config));
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
function deleteCredentialConfigurationByIdEndpoint(router, context, instance, issuer, opts) {
|
|
71
|
+
var _a;
|
|
72
|
+
const path = (0, oid4vci_api_functions_1.determinePath)(opts.baseUrl, (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
73
|
+
stripBasePath: true,
|
|
74
|
+
});
|
|
75
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] deleteCredentialConfigurationById endpoint enabled at ${path}`);
|
|
76
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
77
|
+
console.log(`"deleteCredentialConfigurationById" Endpoint is disabled`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
router.delete(`${path}`, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
var _a;
|
|
82
|
+
try {
|
|
83
|
+
const configurationId = request.params.configurationId;
|
|
84
|
+
if (!configurationId) {
|
|
85
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, 'Missing configurationId');
|
|
86
|
+
}
|
|
87
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] deleteCredentialConfigurationById endpoint called with configurationId: ${configurationId}`);
|
|
88
|
+
const storeMetadata = (yield context.agent.oid4vciStoreGetMetadata({
|
|
89
|
+
metadataType: 'issuer',
|
|
90
|
+
storeId: instance.metadataOptions.storeId,
|
|
91
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
92
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
93
|
+
}));
|
|
94
|
+
if (!(storeMetadata === null || storeMetadata === void 0 ? void 0 : storeMetadata.credential_configurations_supported) || !((_a = storeMetadata === null || storeMetadata === void 0 ? void 0 : storeMetadata.credential_configurations_supported) === null || _a === void 0 ? void 0 : _a[configurationId])) {
|
|
95
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 404, `Credential configuration ${configurationId} not found`);
|
|
96
|
+
}
|
|
97
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata));
|
|
98
|
+
delete updateMetadata.credential_configurations_supported[configurationId];
|
|
99
|
+
yield context.agent.oid4vciStorePersistMetadata({
|
|
100
|
+
metadata: updateMetadata,
|
|
101
|
+
metadataType: 'issuer',
|
|
102
|
+
storeId: instance.metadataOptions.storeId,
|
|
103
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
104
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
105
|
+
overwriteExisting: true,
|
|
106
|
+
validation: true,
|
|
107
|
+
});
|
|
108
|
+
instance.issuerMetadata = updateMetadata;
|
|
109
|
+
return response.json({});
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
function updateCredentialConfigurationByIdEndpoint(router, context, instance, issuer, opts) {
|
|
117
|
+
var _a;
|
|
118
|
+
const path = (0, oid4vci_api_functions_1.determinePath)(opts.baseUrl, (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
119
|
+
stripBasePath: true,
|
|
120
|
+
});
|
|
121
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] updateCredentialConfigurationById endpoint enabled at ${path}`);
|
|
122
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
123
|
+
console.log(`"updateCredentialConfigurationById" Endpoint is disabled`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
router.put(`${path}`, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
var _a;
|
|
128
|
+
try {
|
|
129
|
+
const configurationId = request.params.configurationId;
|
|
130
|
+
if (!configurationId) {
|
|
131
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, 'Missing configurationId');
|
|
132
|
+
}
|
|
133
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] updateCredentialConfigurationById endpoint called with configurationId: ${configurationId}`);
|
|
134
|
+
const updatedCredentialConfiguration = request.body;
|
|
135
|
+
if (!updatedCredentialConfiguration || !updatedCredentialConfiguration.format) {
|
|
136
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, 'Missing credential configuration in the body, or required format missing');
|
|
137
|
+
}
|
|
138
|
+
const storeMetadata = (yield context.agent.oid4vciStoreGetMetadata({
|
|
139
|
+
metadataType: 'issuer',
|
|
140
|
+
storeId: instance.metadataOptions.storeId,
|
|
141
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
142
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
143
|
+
}));
|
|
144
|
+
if (!(storeMetadata === null || storeMetadata === void 0 ? void 0 : storeMetadata.credential_configurations_supported) || !((_a = storeMetadata === null || storeMetadata === void 0 ? void 0 : storeMetadata.credential_configurations_supported) === null || _a === void 0 ? void 0 : _a[configurationId])) {
|
|
145
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 404, `Credential configuration ${configurationId} not found`);
|
|
146
|
+
}
|
|
147
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata));
|
|
148
|
+
updateMetadata.credential_configurations_supported[configurationId] = updatedCredentialConfiguration;
|
|
149
|
+
yield context.agent.oid4vciStorePersistMetadata({
|
|
150
|
+
metadata: updateMetadata,
|
|
151
|
+
metadataType: 'issuer',
|
|
152
|
+
storeId: instance.metadataOptions.storeId,
|
|
153
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
154
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
155
|
+
overwriteExisting: true,
|
|
156
|
+
validation: true,
|
|
157
|
+
});
|
|
158
|
+
instance.issuerMetadata = updateMetadata;
|
|
159
|
+
return response.json(Object.assign({}, updatedCredentialConfiguration));
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
163
|
+
}
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
function newCredentialConfigurationEndpoint(router, context, instance, issuer, opts) {
|
|
167
|
+
var _a;
|
|
168
|
+
const path = (0, oid4vci_api_functions_1.determinePath)(opts.baseUrl, (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/issuer-metadata/credential-configurations/:configurationId', {
|
|
169
|
+
stripBasePath: true,
|
|
170
|
+
});
|
|
171
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] newCredentialConfigurationById endpoint enabled at ${path}`);
|
|
172
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
173
|
+
console.log(`"newCredentialConfigurationById" Endpoint is disabled`);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
router.put(`${path}`, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
var _a;
|
|
178
|
+
try {
|
|
179
|
+
const configurationId = request.params.configurationId;
|
|
180
|
+
if (!configurationId) {
|
|
181
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, 'Missing configurationId');
|
|
182
|
+
}
|
|
183
|
+
oid4vci_issuer_1.LOG.log(`[OID4VCI] newCredentialConfigurationById endpoint called with configurationId: ${configurationId}`);
|
|
184
|
+
const newCredentialConfiguration = request.body;
|
|
185
|
+
if (!newCredentialConfiguration || !newCredentialConfiguration.format) {
|
|
186
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, 'Missing credential configuration in the body, or required format missing');
|
|
187
|
+
}
|
|
188
|
+
const storeMetadata = (yield context.agent.oid4vciStoreGetMetadata({
|
|
189
|
+
metadataType: 'issuer',
|
|
190
|
+
storeId: instance.metadataOptions.storeId,
|
|
191
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
192
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
193
|
+
}));
|
|
194
|
+
if ((_a = storeMetadata === null || storeMetadata === void 0 ? void 0 : storeMetadata.credential_configurations_supported) === null || _a === void 0 ? void 0 : _a[configurationId]) {
|
|
195
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, `Credential configuration ${configurationId} already exists, cannot create new one. Please update instead.`);
|
|
196
|
+
}
|
|
197
|
+
const updateMetadata = JSON.parse(JSON.stringify(storeMetadata));
|
|
198
|
+
updateMetadata.credential_configurations_supported[configurationId] = newCredentialConfiguration;
|
|
199
|
+
yield context.agent.oid4vciStorePersistMetadata({
|
|
200
|
+
metadata: updateMetadata,
|
|
201
|
+
metadataType: 'issuer',
|
|
202
|
+
storeId: instance.metadataOptions.storeId,
|
|
203
|
+
namespace: instance.metadataOptions.storeNamespace,
|
|
204
|
+
correlationId: instance.metadataOptions.credentialIssuer,
|
|
205
|
+
overwriteExisting: true,
|
|
206
|
+
validation: true,
|
|
207
|
+
});
|
|
208
|
+
instance.issuerMetadata = updateMetadata;
|
|
209
|
+
return response.json(Object.assign({}, newCredentialConfiguration));
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
213
|
+
}
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
//# 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":";;;;;;;;;;;AAUA,kFAwBC;AAED,wFAmCC;AAED,8FAkDC;AAED,8FAsDC;AAED,gFA0DC;AA9OD,uEAA4E;AAC5E,6DAAwD;AACxD,qGAAyF;AAOzF,SAAgB,mCAAmC,CACjD,MAAc,EACd,OAAyB,EACzB,QAAwB,EACxB,MAAgB,EAChB,IAAiC;;IAEjC,MAAM,IAAI,GAAG,IAAA,qCAAa,EAAC,IAAI,CAAC,OAAO,EAAE,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,mCAAI,mDAAmD,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACpI,oBAAG,CAAC,GAAG,CAAC,6DAA6D,IAAI,EAAE,CAAC,CAAA;IAC5E,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,MAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAA;QACjE,OAAM;IACR,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,IAAA,+BAAS,EAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,EAAE,CAAO,OAAgB,EAAE,QAAkB,EAAE,EAAE;;QAC9F,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,cA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AAC;gBAC9C,QAAQ,EAAE,cAAc;gBACxB,YAAY,EAAE,QAAQ;gBACtB,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,OAAO;gBACzC,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC,cAAc;gBAClD,aAAa,EAAE,QAAQ,CAAC,eAAe,CAAC,gBAAgB;gBACxD,iBAAiB,EAAE,IAAI;gBACvB,UAAU,EAAE,IAAI;aACjB,CAAC,CAAA;YACF,QAAQ,CAAC,cAAc,GAAG,cAAc,CAAA;YACxC,OAAO,QAAQ,CAAC,IAAI,mBAAM,0BAA0B,EAAG,CAAA;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAA,uCAAiB,EAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,OAAiB,EAAE,KAAK,CAAC,CAAA;QACzE,CAAC;IACH,CAAC,CAAA,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.oid4vci-issuer-rest-api",
|
|
3
|
-
"version": "0.32.1-next.
|
|
3
|
+
"version": "0.32.1-next.287+5f85ee8f",
|
|
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.32.1-next.
|
|
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.32.1-next.287+5f85ee8f",
|
|
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.32.1-next.287+5f85ee8f",
|
|
21
|
+
"@sphereon/ssi-sdk.oid4vci-issuer": "0.32.1-next.287+5f85ee8f",
|
|
22
|
+
"@sphereon/ssi-sdk.oid4vci-issuer-store": "0.32.1-next.287+5f85ee8f",
|
|
23
|
+
"@sphereon/ssi-types": "0.32.1-next.287+5f85ee8f",
|
|
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.32.1-next.
|
|
45
|
-
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.32.1-next.
|
|
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.32.1-next.287+5f85ee8f",
|
|
47
|
+
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.32.1-next.287+5f85ee8f",
|
|
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": "5f85ee8fef1e0fce3d20d150f187b00c7c70f093"
|
|
100
104
|
}
|
package/src/OID4VCIRestAPI.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
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
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import {
|
|
6
|
+
createAuthRequestUriCallback,
|
|
7
|
+
getAccessTokenSignerCallback,
|
|
8
|
+
IIssuerInstanceArgs,
|
|
9
|
+
IssuerInstance,
|
|
10
|
+
createVerifyAuthResponseCallback,
|
|
11
|
+
} from '@sphereon/ssi-sdk.oid4vci-issuer'
|
|
12
|
+
import express, { Express, Request, Response, Router } from 'express'
|
|
8
13
|
import { IRequiredContext } from './types'
|
|
14
|
+
import swaggerUi from 'swagger-ui-express'
|
|
9
15
|
|
|
10
16
|
export interface IOID4VCIRestAPIOpts extends IOID4VCIServerOpts {}
|
|
11
17
|
|
|
@@ -13,9 +19,12 @@ export class OID4VCIRestAPI {
|
|
|
13
19
|
private readonly _expressSupport: ExpressSupport
|
|
14
20
|
private readonly _context: IRequiredContext
|
|
15
21
|
private readonly _opts?: IOID4VCIRestAPIOpts
|
|
16
|
-
private readonly _restApi: OID4VCIServer
|
|
22
|
+
private readonly _restApi: OID4VCIServer
|
|
17
23
|
private readonly _instance: IssuerInstance
|
|
18
|
-
private readonly _issuer: VcIssuer
|
|
24
|
+
private readonly _issuer: VcIssuer
|
|
25
|
+
private readonly _router: Router
|
|
26
|
+
private _baseUrl: URL
|
|
27
|
+
private _basePath: string
|
|
19
28
|
|
|
20
29
|
static async init(args: {
|
|
21
30
|
context: IRequiredContext
|
|
@@ -56,24 +65,96 @@ export class OID4VCIRestAPI {
|
|
|
56
65
|
args.context,
|
|
57
66
|
)
|
|
58
67
|
}
|
|
68
|
+
|
|
69
|
+
if (opts?.endpointOpts.authorizationChallengeOpts?.enabled === true) {
|
|
70
|
+
if (!instance.issuerOptions.presentationDefinitionId) {
|
|
71
|
+
throw Error(`Unable to set createAuthRequestUriCallback. No presentationDefinitionId present in issuer options`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (typeof opts?.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback !== 'function') {
|
|
75
|
+
if (!opts.endpointOpts.authorizationChallengeOpts?.createAuthRequestUriEndpointPath) {
|
|
76
|
+
throw Error(`Unable to set createAuthRequestUriCallback. No createAuthRequestUriEndpointPath present in options`)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriCallback = await createAuthRequestUriCallback({
|
|
80
|
+
path: opts.endpointOpts.authorizationChallengeOpts.createAuthRequestUriEndpointPath,
|
|
81
|
+
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId,
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (typeof opts?.endpointOpts.authorizationChallengeOpts?.verifyAuthResponseCallback !== 'function') {
|
|
86
|
+
if (!opts.endpointOpts.authorizationChallengeOpts?.verifyAuthResponseEndpointPath) {
|
|
87
|
+
throw Error(`Unable to set verifyAuthResponseCallback. No createAuthRequestUriEndpointPath present in options`)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseCallback = await createVerifyAuthResponseCallback({
|
|
91
|
+
path: opts.endpointOpts.authorizationChallengeOpts.verifyAuthResponseEndpointPath,
|
|
92
|
+
presentationDefinitionId: instance.issuerOptions.presentationDefinitionId,
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
59
97
|
return new OID4VCIRestAPI({ context, issuerInstanceArgs, expressSupport, opts, instance, issuer })
|
|
60
98
|
}
|
|
61
99
|
|
|
100
|
+
private readonly OID4VCI_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VCI/0.1.1'
|
|
101
|
+
|
|
62
102
|
private constructor(args: {
|
|
63
|
-
issuer: VcIssuer
|
|
103
|
+
issuer: VcIssuer
|
|
64
104
|
instance: IssuerInstance
|
|
65
105
|
context: IRequiredContext
|
|
66
106
|
issuerInstanceArgs: IIssuerInstanceArgs
|
|
67
107
|
expressSupport: ExpressSupport
|
|
68
108
|
opts: IOID4VCIRestAPIOpts
|
|
69
109
|
}) {
|
|
70
|
-
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)
|
|
71
119
|
this._context = context
|
|
72
120
|
this._opts = opts ?? {}
|
|
73
121
|
this._expressSupport = args.expressSupport
|
|
74
122
|
this._issuer = args.issuer
|
|
75
123
|
this._instance = args.instance
|
|
76
|
-
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
|
+
}
|
|
77
158
|
}
|
|
78
159
|
|
|
79
160
|
get express(): Express {
|
|
@@ -88,7 +169,7 @@ export class OID4VCIRestAPI {
|
|
|
88
169
|
return this._opts
|
|
89
170
|
}
|
|
90
171
|
|
|
91
|
-
get restApi(): OID4VCIServer
|
|
172
|
+
get restApi(): OID4VCIServer {
|
|
92
173
|
return this._restApi
|
|
93
174
|
}
|
|
94
175
|
|
|
@@ -96,7 +177,7 @@ export class OID4VCIRestAPI {
|
|
|
96
177
|
return this._instance
|
|
97
178
|
}
|
|
98
179
|
|
|
99
|
-
get issuer(): VcIssuer
|
|
180
|
+
get issuer(): VcIssuer {
|
|
100
181
|
return this._issuer
|
|
101
182
|
}
|
|
102
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
|
|