@sphereon/ssi-sdk.linked-vp 0.34.1-feature.SSISDK.82.linkedVP.325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/index.cjs +463 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +447 -0
- package/dist/index.d.ts +447 -0
- package/dist/index.js +442 -0
- package/dist/index.js.map +1 -0
- package/package.json +80 -0
- package/plugin.schema.json +183 -0
- package/src/__tests__/localAgent.test.ts +95 -0
- package/src/__tests__/shared/linkedVPManagerAgentLogic.ts +170 -0
- package/src/agent/LinkedVPManager.ts +221 -0
- package/src/index.ts +7 -0
- package/src/services/LinkedVPService.ts +84 -0
- package/src/types/ILinkedVPManager.ts +85 -0
- package/src/types/index.ts +1 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { IPluginMethodMap, IAgentContext, IAgentPlugin } from '@veramo/core';
|
|
2
|
+
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
3
|
+
import { ICredentialStore } from '@sphereon/ssi-sdk.credential-store';
|
|
4
|
+
import { VcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm';
|
|
5
|
+
import { IKeyManager } from '@veramo/core/src/types/IKeyManager';
|
|
6
|
+
|
|
7
|
+
var ILinkedVPManager$1 = {
|
|
8
|
+
components: {
|
|
9
|
+
schemas: {
|
|
10
|
+
GeneratePresentationArgs: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
linkedVpId: {
|
|
14
|
+
type: "string"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
required: [
|
|
18
|
+
"linkedVpId"
|
|
19
|
+
],
|
|
20
|
+
additionalProperties: false
|
|
21
|
+
},
|
|
22
|
+
LinkedVPPresentation: {
|
|
23
|
+
anyOf: [
|
|
24
|
+
{
|
|
25
|
+
type: "string"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
$ref: "#/components/schemas/Record<string,any>"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"Record<string,any>": {
|
|
33
|
+
type: "object"
|
|
34
|
+
},
|
|
35
|
+
GetServiceEntriesArgs: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
tenantId: {
|
|
39
|
+
type: "string"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
additionalProperties: false
|
|
43
|
+
},
|
|
44
|
+
LinkedVPServiceEntry: {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
id: {
|
|
48
|
+
type: "string"
|
|
49
|
+
},
|
|
50
|
+
type: {
|
|
51
|
+
type: "string",
|
|
52
|
+
"const": "LinkedVerifiablePresentation"
|
|
53
|
+
},
|
|
54
|
+
serviceEndpoint: {
|
|
55
|
+
type: "string"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
required: [
|
|
59
|
+
"id",
|
|
60
|
+
"type",
|
|
61
|
+
"serviceEndpoint"
|
|
62
|
+
],
|
|
63
|
+
additionalProperties: false
|
|
64
|
+
},
|
|
65
|
+
HasLinkedVPEntryArgs: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
linkedVpId: {
|
|
69
|
+
type: "string"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
required: [
|
|
73
|
+
"linkedVpId"
|
|
74
|
+
],
|
|
75
|
+
additionalProperties: false
|
|
76
|
+
},
|
|
77
|
+
PublishCredentialArgs: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
digitalCredentialId: {
|
|
81
|
+
type: "string"
|
|
82
|
+
},
|
|
83
|
+
linkedVpId: {
|
|
84
|
+
type: "string"
|
|
85
|
+
},
|
|
86
|
+
tenantId: {
|
|
87
|
+
type: "string"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
required: [
|
|
91
|
+
"digitalCredentialId"
|
|
92
|
+
],
|
|
93
|
+
additionalProperties: false
|
|
94
|
+
},
|
|
95
|
+
LinkedVPEntry: {
|
|
96
|
+
type: "object",
|
|
97
|
+
properties: {
|
|
98
|
+
id: {
|
|
99
|
+
type: "string"
|
|
100
|
+
},
|
|
101
|
+
linkedVpId: {
|
|
102
|
+
type: "string"
|
|
103
|
+
},
|
|
104
|
+
tenantId: {
|
|
105
|
+
type: "string"
|
|
106
|
+
},
|
|
107
|
+
linkedVpFrom: {
|
|
108
|
+
type: "string",
|
|
109
|
+
format: "date-time"
|
|
110
|
+
},
|
|
111
|
+
createdAt: {
|
|
112
|
+
type: "string",
|
|
113
|
+
format: "date-time"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
required: [
|
|
117
|
+
"id",
|
|
118
|
+
"linkedVpId",
|
|
119
|
+
"createdAt"
|
|
120
|
+
],
|
|
121
|
+
additionalProperties: false
|
|
122
|
+
},
|
|
123
|
+
UnpublishCredentialArgs: {
|
|
124
|
+
type: "object",
|
|
125
|
+
properties: {
|
|
126
|
+
linkedVpId: {
|
|
127
|
+
type: "string"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
required: [
|
|
131
|
+
"linkedVpId"
|
|
132
|
+
],
|
|
133
|
+
additionalProperties: false
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
methods: {
|
|
137
|
+
lvpGeneratePresentation: {
|
|
138
|
+
description: "Generate and return a Verifiable Presentation for a published LinkedVP This is the main endpoint handler for GET /linked-vp/",
|
|
139
|
+
"arguments": {
|
|
140
|
+
$ref: "#/components/schemas/GeneratePresentationArgs"
|
|
141
|
+
},
|
|
142
|
+
returnType: {
|
|
143
|
+
$ref: "#/components/schemas/LinkedVPPresentation"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
lvpGetServiceEntries: {
|
|
147
|
+
description: "Get LinkedVP service entries for a DID to be added to a DID Document This is useful when generating DID Documents with toDidDocument",
|
|
148
|
+
"arguments": {
|
|
149
|
+
$ref: "#/components/schemas/GetServiceEntriesArgs"
|
|
150
|
+
},
|
|
151
|
+
returnType: {
|
|
152
|
+
type: "array",
|
|
153
|
+
items: {
|
|
154
|
+
$ref: "#/components/schemas/LinkedVPServiceEntry"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
lvpHasEntry: {
|
|
159
|
+
description: "Check if a LinkedVP entry exists by linkedVpId",
|
|
160
|
+
"arguments": {
|
|
161
|
+
$ref: "#/components/schemas/HasLinkedVPEntryArgs"
|
|
162
|
+
},
|
|
163
|
+
returnType: {
|
|
164
|
+
type: "boolean"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
lvpPublishCredential: {
|
|
168
|
+
description: "Publish a credential as a LinkedVP by adding it to the holder's DID Document",
|
|
169
|
+
"arguments": {
|
|
170
|
+
$ref: "#/components/schemas/PublishCredentialArgs"
|
|
171
|
+
},
|
|
172
|
+
returnType: {
|
|
173
|
+
$ref: "#/components/schemas/LinkedVPEntry"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
lvpUnpublishCredential: {
|
|
177
|
+
description: "Unpublish a credential by removing its LinkedVP entry from the DID Document",
|
|
178
|
+
"arguments": {
|
|
179
|
+
$ref: "#/components/schemas/UnpublishCredentialArgs"
|
|
180
|
+
},
|
|
181
|
+
returnType: {
|
|
182
|
+
type: "boolean"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var plugin_schema = {
|
|
189
|
+
ILinkedVPManager: ILinkedVPManager$1
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
declare const LOGGER_NAMESPACE = "sphereon:linked-vp";
|
|
193
|
+
type LinkedVPPresentation = string | Record<string, any>;
|
|
194
|
+
interface ILinkedVPManager extends IPluginMethodMap {
|
|
195
|
+
/**
|
|
196
|
+
* Publish a credential as a LinkedVP by adding it to the holder's DID Document
|
|
197
|
+
* @param args - Publication arguments including credential ID and scope configuration
|
|
198
|
+
* @param context - Agent context
|
|
199
|
+
*/
|
|
200
|
+
lvpPublishCredential(args: PublishCredentialArgs, context: RequiredContext): Promise<LinkedVPEntry>;
|
|
201
|
+
/**
|
|
202
|
+
* Unpublish a credential by removing its LinkedVP entry from the DID Document
|
|
203
|
+
* @param args - Unpublish arguments
|
|
204
|
+
* @param context - Agent context
|
|
205
|
+
*/
|
|
206
|
+
lvpUnpublishCredential(args: UnpublishCredentialArgs, context: RequiredContext): Promise<boolean>;
|
|
207
|
+
/**
|
|
208
|
+
* Check if a LinkedVP entry exists by linkedVpId
|
|
209
|
+
* @param args - Query arguments
|
|
210
|
+
* @param context - Agent context
|
|
211
|
+
*/
|
|
212
|
+
lvpHasEntry(args: HasLinkedVPEntryArgs, context: RequiredContext): Promise<boolean>;
|
|
213
|
+
/**
|
|
214
|
+
* Get LinkedVP service entries for a DID to be added to a DID Document
|
|
215
|
+
* This is useful when generating DID Documents with toDidDocument
|
|
216
|
+
* @param args - Query arguments for the DID
|
|
217
|
+
* @param context - Agent context
|
|
218
|
+
*/
|
|
219
|
+
lvpGetServiceEntries(args: GetServiceEntriesArgs, context: RequiredContext): Promise<Array<LinkedVPServiceEntry>>;
|
|
220
|
+
/**
|
|
221
|
+
* Generate and return a Verifiable Presentation for a published LinkedVP
|
|
222
|
+
* This is the main endpoint handler for GET /linked-vp/{linkedVpId}
|
|
223
|
+
* @param args - Generation arguments
|
|
224
|
+
* @param context - Agent context
|
|
225
|
+
*/
|
|
226
|
+
lvpGeneratePresentation(args: GeneratePresentationArgs, context: RequiredContext): Promise<LinkedVPPresentation>;
|
|
227
|
+
}
|
|
228
|
+
type PublishCredentialArgs = {
|
|
229
|
+
digitalCredentialId: string;
|
|
230
|
+
linkedVpId?: string;
|
|
231
|
+
};
|
|
232
|
+
type UnpublishCredentialArgs = {
|
|
233
|
+
linkedVpId: string;
|
|
234
|
+
};
|
|
235
|
+
type HasLinkedVPEntryArgs = {
|
|
236
|
+
linkedVpId: string;
|
|
237
|
+
};
|
|
238
|
+
type GetServiceEntriesArgs = {
|
|
239
|
+
tenantId?: string;
|
|
240
|
+
};
|
|
241
|
+
type GeneratePresentationArgs = {
|
|
242
|
+
linkedVpId: string;
|
|
243
|
+
};
|
|
244
|
+
type LinkedVPEntry = {
|
|
245
|
+
id: string;
|
|
246
|
+
linkedVpId: string;
|
|
247
|
+
tenantId?: string;
|
|
248
|
+
linkedVpFrom?: Date;
|
|
249
|
+
createdAt: Date;
|
|
250
|
+
};
|
|
251
|
+
type LinkedVPServiceEntry = {
|
|
252
|
+
id: string;
|
|
253
|
+
type: 'LinkedVerifiablePresentation';
|
|
254
|
+
serviceEndpoint: string;
|
|
255
|
+
};
|
|
256
|
+
type RequiredContext = IAgentContext<IIdentifierResolution & ICredentialStore & IKeyManager & VcdmCredentialPlugin>;
|
|
257
|
+
|
|
258
|
+
declare const linkedVPManagerMethods: Array<string>;
|
|
259
|
+
/**
|
|
260
|
+
* {@inheritDoc ILinkedVPManager}
|
|
261
|
+
*/
|
|
262
|
+
declare class LinkedVPManager implements IAgentPlugin {
|
|
263
|
+
readonly schema: {
|
|
264
|
+
components: {
|
|
265
|
+
schemas: {
|
|
266
|
+
GeneratePresentationArgs: {
|
|
267
|
+
type: string;
|
|
268
|
+
properties: {
|
|
269
|
+
linkedVpId: {
|
|
270
|
+
type: string;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
required: string[];
|
|
274
|
+
additionalProperties: boolean;
|
|
275
|
+
};
|
|
276
|
+
LinkedVPPresentation: {
|
|
277
|
+
anyOf: ({
|
|
278
|
+
type: string;
|
|
279
|
+
$ref?: undefined;
|
|
280
|
+
} | {
|
|
281
|
+
$ref: string;
|
|
282
|
+
type?: undefined;
|
|
283
|
+
})[];
|
|
284
|
+
};
|
|
285
|
+
"Record<string,any>": {
|
|
286
|
+
type: string;
|
|
287
|
+
};
|
|
288
|
+
GetServiceEntriesArgs: {
|
|
289
|
+
type: string;
|
|
290
|
+
properties: {
|
|
291
|
+
tenantId: {
|
|
292
|
+
type: string;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
additionalProperties: boolean;
|
|
296
|
+
};
|
|
297
|
+
LinkedVPServiceEntry: {
|
|
298
|
+
type: string;
|
|
299
|
+
properties: {
|
|
300
|
+
id: {
|
|
301
|
+
type: string;
|
|
302
|
+
};
|
|
303
|
+
type: {
|
|
304
|
+
type: string;
|
|
305
|
+
const: string;
|
|
306
|
+
};
|
|
307
|
+
serviceEndpoint: {
|
|
308
|
+
type: string;
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
required: string[];
|
|
312
|
+
additionalProperties: boolean;
|
|
313
|
+
};
|
|
314
|
+
HasLinkedVPEntryArgs: {
|
|
315
|
+
type: string;
|
|
316
|
+
properties: {
|
|
317
|
+
linkedVpId: {
|
|
318
|
+
type: string;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
required: string[];
|
|
322
|
+
additionalProperties: boolean;
|
|
323
|
+
};
|
|
324
|
+
PublishCredentialArgs: {
|
|
325
|
+
type: string;
|
|
326
|
+
properties: {
|
|
327
|
+
digitalCredentialId: {
|
|
328
|
+
type: string;
|
|
329
|
+
};
|
|
330
|
+
linkedVpId: {
|
|
331
|
+
type: string;
|
|
332
|
+
};
|
|
333
|
+
tenantId: {
|
|
334
|
+
type: string;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
required: string[];
|
|
338
|
+
additionalProperties: boolean;
|
|
339
|
+
};
|
|
340
|
+
LinkedVPEntry: {
|
|
341
|
+
type: string;
|
|
342
|
+
properties: {
|
|
343
|
+
id: {
|
|
344
|
+
type: string;
|
|
345
|
+
};
|
|
346
|
+
linkedVpId: {
|
|
347
|
+
type: string;
|
|
348
|
+
};
|
|
349
|
+
tenantId: {
|
|
350
|
+
type: string;
|
|
351
|
+
};
|
|
352
|
+
linkedVpFrom: {
|
|
353
|
+
type: string;
|
|
354
|
+
format: string;
|
|
355
|
+
};
|
|
356
|
+
createdAt: {
|
|
357
|
+
type: string;
|
|
358
|
+
format: string;
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
required: string[];
|
|
362
|
+
additionalProperties: boolean;
|
|
363
|
+
};
|
|
364
|
+
UnpublishCredentialArgs: {
|
|
365
|
+
type: string;
|
|
366
|
+
properties: {
|
|
367
|
+
linkedVpId: {
|
|
368
|
+
type: string;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
required: string[];
|
|
372
|
+
additionalProperties: boolean;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
methods: {
|
|
376
|
+
lvpGeneratePresentation: {
|
|
377
|
+
description: string;
|
|
378
|
+
arguments: {
|
|
379
|
+
$ref: string;
|
|
380
|
+
};
|
|
381
|
+
returnType: {
|
|
382
|
+
$ref: string;
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
lvpGetServiceEntries: {
|
|
386
|
+
description: string;
|
|
387
|
+
arguments: {
|
|
388
|
+
$ref: string;
|
|
389
|
+
};
|
|
390
|
+
returnType: {
|
|
391
|
+
type: string;
|
|
392
|
+
items: {
|
|
393
|
+
$ref: string;
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
lvpHasEntry: {
|
|
398
|
+
description: string;
|
|
399
|
+
arguments: {
|
|
400
|
+
$ref: string;
|
|
401
|
+
};
|
|
402
|
+
returnType: {
|
|
403
|
+
type: string;
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
lvpPublishCredential: {
|
|
407
|
+
description: string;
|
|
408
|
+
arguments: {
|
|
409
|
+
$ref: string;
|
|
410
|
+
};
|
|
411
|
+
returnType: {
|
|
412
|
+
$ref: string;
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
lvpUnpublishCredential: {
|
|
416
|
+
description: string;
|
|
417
|
+
arguments: {
|
|
418
|
+
$ref: string;
|
|
419
|
+
};
|
|
420
|
+
returnType: {
|
|
421
|
+
type: string;
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
readonly methods: ILinkedVPManager;
|
|
428
|
+
private readonly holderDids;
|
|
429
|
+
constructor(options: {
|
|
430
|
+
holderDids: Record<string, string>;
|
|
431
|
+
});
|
|
432
|
+
private lvpPublishCredential;
|
|
433
|
+
private lvpUnpublishCredential;
|
|
434
|
+
private lvpHasEntry;
|
|
435
|
+
private lvpGetServiceEntries;
|
|
436
|
+
private lvpGeneratePresentation;
|
|
437
|
+
private getHolderDid;
|
|
438
|
+
private parseTenantFromLinkedVpId;
|
|
439
|
+
private generateLinkedVpId;
|
|
440
|
+
private ensureLinkedVpIdUnique;
|
|
441
|
+
private buildLinkedVpId;
|
|
442
|
+
private getBaseUrlFromDid;
|
|
443
|
+
private buildServiceEndpoint;
|
|
444
|
+
private credentialToServiceEntry;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export { type GeneratePresentationArgs, type GetServiceEntriesArgs, type HasLinkedVPEntryArgs, type ILinkedVPManager, LOGGER_NAMESPACE, type LinkedVPEntry, LinkedVPManager, type LinkedVPPresentation, type LinkedVPServiceEntry, type PublishCredentialArgs, type RequiredContext, type UnpublishCredentialArgs, linkedVPManagerMethods, plugin_schema as schema };
|