@sphereon/ssi-sdk.w3c-vc-api 0.13.1-next.3 → 0.13.1-next.32

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/src/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { GenericAuthArgs, ISingleEndpointOpts } from '@sphereon/ssi-sdk.express-support'
1
2
  import {
2
3
  IAgentContext,
3
4
  ICredentialIssuer,
@@ -9,7 +10,7 @@ import {
9
10
  IKeyManager,
10
11
  IResolver,
11
12
  } from '@veramo/core'
12
- import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange'
13
+ import { ProofFormat } from '@veramo/core/src/types/ICredentialIssuer'
13
14
 
14
15
  export type IRequiredPlugins = IDataStore &
15
16
  IDataStoreORM &
@@ -17,7 +18,81 @@ export type IRequiredPlugins = IDataStore &
17
18
  IKeyManager &
18
19
  ICredentialIssuer &
19
20
  ICredentialVerifier &
20
- IPresentationExchange &
21
21
  ICredentialPlugin &
22
22
  IResolver
23
23
  export type IRequiredContext = IAgentContext<IRequiredPlugins>
24
+
25
+ interface IVCAPISecurityOpts {}
26
+
27
+ export interface IVCAPIOpts {
28
+ endpointOpts?: IVCAPIEndpointOpts
29
+ securityOpts?: IVCAPISecurityOpts
30
+ issueCredentialOpts?: IVCAPIIssueOpts
31
+ }
32
+
33
+ export interface IVCAPIEndpointOpts {
34
+ basePath?: string
35
+ globalAuth?: GenericAuthArgs
36
+ issueCredential?: IIssueCredentialEndpointOpts
37
+ getCredentials?: ISingleEndpointOpts
38
+ getCredential?: ISingleEndpointOpts
39
+ deleteCredential?: ISingleEndpointOpts
40
+ verifyCredential?: IVerifyCredentialEndpointOpts
41
+ verifyPresentation?: ISingleEndpointOpts
42
+ }
43
+
44
+ export type vcApiFeatures = 'vc-verify' | 'vc-issue' | 'vc-persist'
45
+
46
+ export interface IVCAPIIssueOpts {
47
+ enableFeatures?: vcApiFeatures[] // Feature to enable. If not defined or empty, all features will be enabled
48
+ persistIssuedCredentials?: boolean // Whether the issuer persists issued credentials or not. Defaults to VC_PERSISTENCE feature flag being present or not
49
+
50
+ /**
51
+ * The desired format for the VerifiablePresentation to be created.
52
+ */
53
+ proofFormat: ProofFormat
54
+
55
+ /**
56
+ * Remove payload members during JWT-JSON transformation. Defaults to `true`.
57
+ * See https://www.w3.org/TR/vc-data-model/#jwt-encoding
58
+ */
59
+ removeOriginalFields?: boolean
60
+
61
+ /**
62
+ * [Optional] The ID of the key that should sign this credential.
63
+ * If this is not specified, the first matching key will be used.
64
+ */
65
+ keyRef?: string
66
+
67
+ /**
68
+ * When dealing with JSON-LD you also MUST provide the proper contexts.
69
+ * Set this to `true` ONLY if you want the `@context` URLs to be fetched in case they are not preloaded.
70
+ * The context definitions SHOULD rather be provided at startup instead of being fetched.
71
+ *
72
+ * Defaults to `false`
73
+ */
74
+ fetchRemoteContexts?: boolean
75
+ }
76
+
77
+ export interface IIssueCredentialEndpointOpts extends ISingleEndpointOpts {
78
+ issueCredentialOpts?: IVCAPIIssueOpts
79
+ persistIssuedCredentials?: boolean
80
+ }
81
+
82
+ export interface IVerifyCredentialEndpointOpts extends ISingleEndpointOpts {
83
+ fetchRemoteContexts?: boolean
84
+ }
85
+
86
+ export interface IIssueOptionsPayload {
87
+ created?: string
88
+ challenge?: string
89
+ domain?: string
90
+ credentialStatus?: {
91
+ type: string
92
+ }
93
+ }
94
+
95
+ export interface ChallengeOptsPayload {
96
+ challenge?: string
97
+ domain?: string
98
+ }
@@ -0,0 +1,89 @@
1
+ import { agentContext } from '@sphereon/ssi-sdk.core'
2
+ import { ExpressBuildResult } from '@sphereon/ssi-sdk.express-support'
3
+ import { TAgent } from '@veramo/core'
4
+
5
+ import express, { Express, Router } from 'express'
6
+ import {
7
+ deleteCredentialEndpoint,
8
+ getCredentialEndpoint,
9
+ getCredentialsEndpoint,
10
+ issueCredentialEndpoint,
11
+ verifyCredentialEndpoint,
12
+ } from './api-functions'
13
+ import { IRequiredPlugins, IVCAPIOpts } from './types'
14
+
15
+ export class VcApiServer {
16
+ get router(): express.Router {
17
+ return this._router
18
+ }
19
+
20
+ private readonly _express: Express
21
+ private readonly _agent: TAgent<IRequiredPlugins>
22
+ private readonly _opts?: IVCAPIOpts
23
+ private readonly _router: Router
24
+
25
+ constructor(args: { agent: TAgent<IRequiredPlugins>; expressArgs: ExpressBuildResult; opts?: IVCAPIOpts }) {
26
+ const { agent, opts } = args
27
+ this._agent = agent
28
+ if (opts?.endpointOpts?.globalAuth) {
29
+ copyGlobalAuthToEndpoint(opts, 'issueCredential')
30
+ copyGlobalAuthToEndpoint(opts, 'getCredential')
31
+ copyGlobalAuthToEndpoint(opts, 'getCredentials')
32
+ copyGlobalAuthToEndpoint(opts, 'deleteCredential')
33
+ copyGlobalAuthToEndpoint(opts, 'verifyCredential')
34
+ }
35
+
36
+ this._opts = opts
37
+ this._express = args.expressArgs.express
38
+ this._router = express.Router()
39
+
40
+ const context = agentContext(agent)
41
+
42
+ const features = opts?.issueCredentialOpts?.enableFeatures ?? ['vc-issue', 'vc-persist', 'vc-verify']
43
+ console.log(`VC API enabled, with features: ${JSON.stringify(features)}`)
44
+
45
+ // Credential endpoints
46
+ if (features.includes('vc-issue')) {
47
+ issueCredentialEndpoint(this.router, context, {
48
+ ...opts?.endpointOpts?.issueCredential,
49
+ issueCredentialOpts: opts?.issueCredentialOpts,
50
+ })
51
+ }
52
+ if (features.includes('vc-persist')) {
53
+ getCredentialEndpoint(this.router, context, opts?.endpointOpts?.getCredential)
54
+ getCredentialsEndpoint(this.router, context, opts?.endpointOpts?.getCredentials)
55
+ deleteCredentialEndpoint(this.router, context, opts?.endpointOpts?.deleteCredential) // not in spec.
56
+ }
57
+ if (features.includes('vc-verify')) {
58
+ verifyCredentialEndpoint(this.router, context, {
59
+ ...opts?.endpointOpts?.verifyCredential,
60
+ fetchRemoteContexts: opts?.issueCredentialOpts?.fetchRemoteContexts,
61
+ })
62
+ }
63
+ this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)
64
+ }
65
+
66
+ get agent(): TAgent<IRequiredPlugins> {
67
+ return this._agent
68
+ }
69
+
70
+ get opts(): IVCAPIOpts | undefined {
71
+ return this._opts
72
+ }
73
+
74
+ get express(): Express {
75
+ return this._express
76
+ }
77
+ }
78
+
79
+ function copyGlobalAuthToEndpoint(opts: IVCAPIOpts, key: string) {
80
+ if (opts?.endpointOpts?.globalAuth) {
81
+ // @ts-ignore
82
+ opts.endpointOpts[key] = {
83
+ // @ts-ignore
84
+ ...opts.endpointOpts[key],
85
+ // @ts-ignore
86
+ endpoint: { ...opts.endpointOpts.globalAuth, ...opts.endpointOpts[key]?.endpoint },
87
+ }
88
+ }
89
+ }
@@ -1,78 +0,0 @@
1
- import { TAgent } from '@veramo/core';
2
- import { ProofFormat } from '@veramo/core/src/types/ICredentialIssuer';
3
- import { Express } from 'express';
4
- import { IRequiredPlugins } from './types';
5
- export interface IVCAPIOpts {
6
- issueCredentialOpts?: IIssueOpts;
7
- serverOpts?: IServerOpts;
8
- }
9
- export interface IServerOpts {
10
- port?: number;
11
- cookieSigningKey?: string;
12
- hostname?: string;
13
- }
14
- export interface IIssueOpts {
15
- issueCredentialPath?: string;
16
- getCredentialsPath?: string;
17
- getCredentialPath?: string;
18
- deleteCredentialPath?: string;
19
- verifyCredentialPath?: string;
20
- verifyPresentationPath?: string;
21
- persistIssuedCredentials?: boolean;
22
- /**
23
- * The desired format for the VerifiablePresentation to be created.
24
- */
25
- proofFormat: ProofFormat;
26
- /**
27
- * Remove payload members during JWT-JSON transformation. Defaults to `true`.
28
- * See https://www.w3.org/TR/vc-data-model/#jwt-encoding
29
- */
30
- removeOriginalFields?: boolean;
31
- /**
32
- * [Optional] The ID of the key that should sign this credential.
33
- * If this is not specified, the first matching key will be used.
34
- */
35
- keyRef?: string;
36
- /**
37
- * When dealing with JSON-LD you also MUST provide the proper contexts.
38
- * Set this to `true` ONLY if you want the `@context` URLs to be fetched in case they are not preloaded.
39
- * The context definitions SHOULD rather be provided at startup instead of being fetched.
40
- *
41
- * Defaults to `false`
42
- */
43
- fetchRemoteContexts?: boolean;
44
- }
45
- export interface IIssueOptionsPayload {
46
- created?: string;
47
- challenge?: string;
48
- domain?: string;
49
- credentialStatus?: {
50
- type: string;
51
- };
52
- }
53
- export interface ChallengeOptsPayload {
54
- challenge?: string;
55
- domain?: string;
56
- }
57
- export declare class VCAPIServer {
58
- private readonly _express;
59
- private readonly _agent;
60
- private readonly _opts?;
61
- constructor(args: {
62
- agent: TAgent<IRequiredPlugins>;
63
- express?: Express;
64
- opts?: IVCAPIOpts;
65
- });
66
- get agent(): TAgent<IRequiredPlugins>;
67
- get opts(): IVCAPIOpts | undefined;
68
- get express(): Express;
69
- private setupExpress;
70
- private static sendErrorResponse;
71
- private getCredentialsEndpoint;
72
- private getCredentialEndpoint;
73
- private verifyCredentialEndpoint;
74
- private deleteCredentialEndpoint;
75
- private issueCredentialEndpoint;
76
- private getCredentialByIdOrHash;
77
- }
78
- //# sourceMappingURL=VCAPIServer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VCAPIServer.d.ts","sourceRoot":"","sources":["../src/VCAPIServer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,MAAM,EAAwB,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAKtE,OAAgB,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAA;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,MAAM,WAAW,UAAU;IACzB,mBAAmB,CAAC,EAAE,UAAU,CAAA;IAChC,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,mBAAmB,CAAC,EAAE,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AAY;IA4BpB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAMhC,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,wBAAwB;IA0BhC,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,uBAAuB;YA2BjB,uBAAuB;CA+BtC"}
@@ -1,245 +0,0 @@
1
- "use strict";
2
- // noinspection JSUnusedGlobalSymbols
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
- return new (P || (P = Promise))(function (resolve, reject) {
29
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
- step((generator = generator.apply(thisArg, _arguments || [])).next());
33
- });
34
- };
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.VCAPIServer = void 0;
40
- const body_parser_1 = __importDefault(require("body-parser"));
41
- const cookie_parser_1 = __importDefault(require("cookie-parser"));
42
- const dotenv = __importStar(require("dotenv-flow"));
43
- const express_1 = __importDefault(require("express"));
44
- const uuid_1 = require("uuid");
45
- class VCAPIServer {
46
- constructor(args) {
47
- var _a;
48
- const { agent, opts } = args;
49
- this._agent = agent;
50
- this._opts = opts;
51
- const existingExpress = !!args.express;
52
- this._express = (_a = args.express) !== null && _a !== void 0 ? _a : (0, express_1.default)();
53
- this.setupExpress(existingExpress);
54
- // Credential endpoints
55
- this.issueCredentialEndpoint();
56
- this.getCredentialEndpoint();
57
- this.getCredentialsEndpoint();
58
- this.deleteCredentialEndpoint(); // not in spec. TODO: Authz
59
- this.verifyCredentialEndpoint();
60
- }
61
- get agent() {
62
- return this._agent;
63
- }
64
- get opts() {
65
- return this._opts;
66
- }
67
- get express() {
68
- return this._express;
69
- }
70
- setupExpress(existingExpress) {
71
- var _a, _b, _c, _d, _e, _f;
72
- dotenv.config();
73
- if (!existingExpress) {
74
- const port = ((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.serverOpts) === null || _b === void 0 ? void 0 : _b.port) || process.env.PORT || 5000;
75
- const secret = ((_d = (_c = this.opts) === null || _c === void 0 ? void 0 : _c.serverOpts) === null || _d === void 0 ? void 0 : _d.cookieSigningKey) || process.env.COOKIE_SIGNING_KEY;
76
- const hostname = ((_f = (_e = this.opts) === null || _e === void 0 ? void 0 : _e.serverOpts) === null || _f === void 0 ? void 0 : _f.hostname) || '0.0.0.0';
77
- this._express.use((req, res, next) => {
78
- res.header('Access-Control-Allow-Origin', '*');
79
- // Request methods you wish to allow
80
- res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
81
- // Request headers you wish to allow
82
- res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
83
- // Set to true if you need the website to include cookies in the requests sent
84
- // to the API (e.g. in case you use sessions)
85
- res.setHeader('Access-Control-Allow-Credentials', 'true');
86
- next();
87
- });
88
- // this.express.use(cors({ credentials: true }));
89
- // this.express.use('/proxy', proxy('www.gssoogle.com'));
90
- this._express.use(body_parser_1.default.urlencoded({ extended: true }));
91
- this._express.use(body_parser_1.default.json());
92
- this._express.use((0, cookie_parser_1.default)(secret));
93
- this._express.listen(port, hostname, () => console.log(`Listening on ${hostname}, port ${port}`));
94
- }
95
- }
96
- static sendErrorResponse(response, statusCode, message) {
97
- console.log(message);
98
- response.statusCode = statusCode;
99
- response.status(statusCode).send(message);
100
- }
101
- getCredentialsEndpoint() {
102
- var _a, _b, _c;
103
- this._express.get((_c = (_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.issueCredentialOpts) === null || _b === void 0 ? void 0 : _b.getCredentialsPath) !== null && _c !== void 0 ? _c : '/credentials', (request, response) => __awaiter(this, void 0, void 0, function* () {
104
- try {
105
- const uniqueVCs = yield this.agent.dataStoreORMGetVerifiableCredentials();
106
- response.statusCode = 202;
107
- return response.send(uniqueVCs.map((uVC) => uVC.verifiableCredential));
108
- }
109
- catch (e) {
110
- console.log(e);
111
- return VCAPIServer.sendErrorResponse(response, 500, e.message);
112
- }
113
- }));
114
- }
115
- getCredentialEndpoint() {
116
- var _a, _b, _c;
117
- this._express.get((_c = (_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.issueCredentialOpts) === null || _b === void 0 ? void 0 : _b.getCredentialPath) !== null && _c !== void 0 ? _c : '/credentials/:id', (request, response) => __awaiter(this, void 0, void 0, function* () {
118
- try {
119
- const id = request.params.id;
120
- if (!id) {
121
- return VCAPIServer.sendErrorResponse(response, 400, 'no id provided');
122
- }
123
- let vcInfo = yield this.getCredentialByIdOrHash(id);
124
- if (!vcInfo.vc) {
125
- return VCAPIServer.sendErrorResponse(response, 404, `id ${id} not found`);
126
- }
127
- response.statusCode = 200;
128
- return response.send(vcInfo.vc);
129
- }
130
- catch (e) {
131
- console.log(e);
132
- return VCAPIServer.sendErrorResponse(response, 500, e.message);
133
- }
134
- }));
135
- }
136
- verifyCredentialEndpoint() {
137
- var _a, _b, _c;
138
- this._express.post((_c = (_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.issueCredentialOpts) === null || _b === void 0 ? void 0 : _b.verifyCredentialPath) !== null && _c !== void 0 ? _c : '/credentials/verify', (request, response) => __awaiter(this, void 0, void 0, function* () {
139
- var _d, _e;
140
- try {
141
- console.log(request.body);
142
- const credential = request.body.verifiableCredential;
143
- // const options: IIssueOptionsPayload = request.body.options
144
- if (!credential) {
145
- return VCAPIServer.sendErrorResponse(response, 400, 'No verifiable credential supplied');
146
- }
147
- const verifyResult = yield this.agent.verifyCredential({
148
- credential,
149
- fetchRemoteContexts: (_e = (_d = this.opts) === null || _d === void 0 ? void 0 : _d.issueCredentialOpts) === null || _e === void 0 ? void 0 : _e.fetchRemoteContexts,
150
- });
151
- response.statusCode = 200;
152
- return response.send(verifyResult);
153
- }
154
- catch (e) {
155
- console.log(e);
156
- return VCAPIServer.sendErrorResponse(response, 500, e.message);
157
- }
158
- }));
159
- }
160
- deleteCredentialEndpoint() {
161
- var _a, _b, _c;
162
- this._express.delete((_c = (_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.issueCredentialOpts) === null || _b === void 0 ? void 0 : _b.getCredentialsPath) !== null && _c !== void 0 ? _c : '/credentials/:id', (request, response) => __awaiter(this, void 0, void 0, function* () {
163
- try {
164
- const id = request.params.id;
165
- if (!id) {
166
- return VCAPIServer.sendErrorResponse(response, 400, 'no id provided');
167
- }
168
- let vcInfo = yield this.getCredentialByIdOrHash(id);
169
- if (!vcInfo.vc || !vcInfo.hash) {
170
- return VCAPIServer.sendErrorResponse(response, 404, `id ${id} not found`);
171
- }
172
- const success = this.agent.dataStoreDeleteVerifiableCredential({ hash: vcInfo.hash });
173
- if (!success) {
174
- return VCAPIServer.sendErrorResponse(response, 400, `Could not delete Verifiable Credential with id ${id}`);
175
- }
176
- response.statusCode = 200;
177
- return response.send();
178
- }
179
- catch (e) {
180
- console.log(e);
181
- return VCAPIServer.sendErrorResponse(response, 500, e.message);
182
- }
183
- }));
184
- }
185
- issueCredentialEndpoint() {
186
- var _a, _b, _c;
187
- this._express.post((_c = (_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.issueCredentialOpts) === null || _b === void 0 ? void 0 : _b.issueCredentialPath) !== null && _c !== void 0 ? _c : '/credentials/issue', (request, response) => __awaiter(this, void 0, void 0, function* () {
188
- var _d, _e, _f;
189
- try {
190
- const credential = request.body.credential;
191
- // const options: IIssueOptionsPayload = request.body.options
192
- if (!credential) {
193
- return VCAPIServer.sendErrorResponse(response, 400, 'No credential supplied');
194
- }
195
- if (!credential.id) {
196
- credential.id = `urn:uuid:${(0, uuid_1.v4)()}`;
197
- }
198
- const issueOpts = (_d = this.opts) === null || _d === void 0 ? void 0 : _d.issueCredentialOpts;
199
- const vc = yield this._agent.createVerifiableCredential({
200
- credential,
201
- save: (_e = issueOpts === null || issueOpts === void 0 ? void 0 : issueOpts.persistIssuedCredentials) !== null && _e !== void 0 ? _e : true,
202
- proofFormat: (_f = issueOpts === null || issueOpts === void 0 ? void 0 : issueOpts.proofFormat) !== null && _f !== void 0 ? _f : 'lds',
203
- fetchRemoteContexts: (issueOpts === null || issueOpts === void 0 ? void 0 : issueOpts.fetchRemoteContexts) || true,
204
- });
205
- response.statusCode = 201;
206
- return response.send({ verifiableCredential: vc });
207
- }
208
- catch (e) {
209
- console.log(e);
210
- return VCAPIServer.sendErrorResponse(response, 500, e.message);
211
- }
212
- }));
213
- }
214
- getCredentialByIdOrHash(idOrHash) {
215
- return __awaiter(this, void 0, void 0, function* () {
216
- let vc;
217
- let hash;
218
- const uniqueVCs = yield this.agent.dataStoreORMGetVerifiableCredentials({
219
- where: [
220
- {
221
- column: 'id',
222
- value: [idOrHash],
223
- op: 'Equal',
224
- },
225
- ],
226
- });
227
- if (uniqueVCs.length === 0) {
228
- hash = idOrHash;
229
- vc = yield this.agent.dataStoreGetVerifiableCredential({ hash });
230
- }
231
- else {
232
- const uniqueVC = uniqueVCs[0];
233
- hash = uniqueVC.hash;
234
- vc = uniqueVC.verifiableCredential;
235
- }
236
- return {
237
- vc,
238
- id: idOrHash,
239
- hash,
240
- };
241
- });
242
- }
243
- }
244
- exports.VCAPIServer = VCAPIServer;
245
- //# sourceMappingURL=VCAPIServer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VCAPIServer.js","sourceRoot":"","sources":["../src/VCAPIServer.ts"],"names":[],"mappings":";AAAA,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKrC,8DAAoC;AACpC,kEAAwC;AACxC,oDAAqC;AACrC,sDAA6D;AAC7D,+BAAyB;AAiEzB,MAAa,WAAW;IAKtB,YAAY,IAA+E;;QACzF,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAA;QACtC,IAAI,CAAC,QAAQ,GAAG,MAAA,IAAI,CAAC,OAAO,mCAAI,IAAA,iBAAO,GAAE,CAAA;QACzC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAA;QAElC,uBAAuB;QACvB,IAAI,CAAC,uBAAuB,EAAE,CAAA;QAC9B,IAAI,CAAC,qBAAqB,EAAE,CAAA;QAC5B,IAAI,CAAC,sBAAsB,EAAE,CAAA;QAC7B,IAAI,CAAC,wBAAwB,EAAE,CAAA,CAAC,2BAA2B;QAC3D,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACjC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;I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CAAC,CAAC,CAAC,CAAA;gBAC7B,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAA;gBACpB,EAAE,GAAG,QAAQ,CAAC,oBAAoB,CAAA;aACnC;YAED,OAAO;gBACL,EAAE;gBACF,EAAE,EAAE,QAAQ;gBACZ,IAAI;aACL,CAAA;QACH,CAAC;KAAA;CACF;AAhND,kCAgNC"}
@@ -1,30 +0,0 @@
1
- import { IAgent } from '@veramo/core';
2
- import { Request, Router } from 'express';
3
- export interface RequestWithAgent extends Request {
4
- agent?: IAgent;
5
- }
6
- /**
7
- * @public
8
- */
9
- export interface RequestWithAgentRouterOptions {
10
- /**
11
- * Optional. Pre-configured agent
12
- */
13
- agent?: IAgent;
14
- /**
15
- * Optional. Function that returns a Promise that resolves to a configured agent for specific request
16
- */
17
- getAgentForRequest?: (req: Request) => Promise<IAgent>;
18
- }
19
- /**
20
- * Creates an expressjs router that adds a Veramo agent to the request object.
21
- *
22
- * This is needed by all other routers provided by this package to be able to perform their functions.
23
- *
24
- * @param options - Initialization option
25
- * @returns Expressjs router
26
- *
27
- * @public
28
- */
29
- export declare const RequestWithAgentRouter: (options: RequestWithAgentRouterOptions) => Router;
30
- //# sourceMappingURL=request-agent-router.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-agent-router.d.ts","sourceRoot":"","sources":["../src/request-agent-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,WAAW,gBAAiB,SAAQ,OAAO;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CACvD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,YAAa,6BAA6B,KAAG,MAc/E,CAAA"}
@@ -1,41 +0,0 @@
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.RequestWithAgentRouter = void 0;
13
- const express_1 = require("express");
14
- /**
15
- * Creates an expressjs router that adds a Veramo agent to the request object.
16
- *
17
- * This is needed by all other routers provided by this package to be able to perform their functions.
18
- *
19
- * @param options - Initialization option
20
- * @returns Expressjs router
21
- *
22
- * @public
23
- */
24
- const RequestWithAgentRouter = (options) => {
25
- const router = (0, express_1.Router)();
26
- router.use((req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
27
- if (options.agent) {
28
- req.agent = options.agent;
29
- }
30
- else if (options.getAgentForRequest) {
31
- req.agent = yield options.getAgentForRequest(req);
32
- }
33
- else {
34
- throw Error('[RequestWithAgentRouter] agent or getAgentForRequest is required');
35
- }
36
- next();
37
- }));
38
- return router;
39
- };
40
- exports.RequestWithAgentRouter = RequestWithAgentRouter;
41
- //# sourceMappingURL=request-agent-router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-agent-router.js","sourceRoot":"","sources":["../src/request-agent-router.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAyC;AAqBzC;;;;;;;;;GASG;AACI,MAAM,sBAAsB,GAAG,CAAC,OAAsC,EAAU,EAAE;IACvF,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAA;IACvB,MAAM,CAAC,GAAG,CAAC,CAAO,GAAqB,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACpD,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;SAC1B;aAAM,IAAI,OAAO,CAAC,kBAAkB,EAAE;YACrC,GAAG,CAAC,KAAK,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;SAClD;aAAM;YACL,MAAM,KAAK,CAAC,kEAAkE,CAAC,CAAA;SAChF;QACD,IAAI,EAAE,CAAA;IACR,CAAC,CAAA,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAdY,QAAA,sBAAsB,0BAclC"}