@twin.org/identity-service 0.0.2-next.9 → 0.0.3-next.1

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.
Files changed (40) hide show
  1. package/dist/es/identityProfileRoutes.js +389 -0
  2. package/dist/es/identityProfileRoutes.js.map +1 -0
  3. package/dist/es/identityProfileService.js +165 -0
  4. package/dist/es/identityProfileService.js.map +1 -0
  5. package/dist/es/identityResolverRoutes.js +87 -0
  6. package/dist/es/identityResolverRoutes.js.map +1 -0
  7. package/dist/es/identityResolverService.js +98 -0
  8. package/dist/es/identityResolverService.js.map +1 -0
  9. package/dist/es/identityRoutes.js +946 -0
  10. package/dist/es/identityRoutes.js.map +1 -0
  11. package/dist/es/identityService.js +391 -0
  12. package/dist/es/identityService.js.map +1 -0
  13. package/dist/es/index.js +15 -0
  14. package/dist/es/index.js.map +1 -0
  15. package/dist/es/models/IIdentityProfileServiceConstructorOptions.js +2 -0
  16. package/dist/es/models/IIdentityProfileServiceConstructorOptions.js.map +1 -0
  17. package/dist/es/models/IIdentityResolverServiceConfig.js +4 -0
  18. package/dist/es/models/IIdentityResolverServiceConfig.js.map +1 -0
  19. package/dist/es/models/IIdentityResolverServiceConstructorOptions.js +2 -0
  20. package/dist/es/models/IIdentityResolverServiceConstructorOptions.js.map +1 -0
  21. package/dist/es/models/IIdentityServiceConfig.js +4 -0
  22. package/dist/es/models/IIdentityServiceConfig.js.map +1 -0
  23. package/dist/es/models/IIdentityServiceConstructorOptions.js +2 -0
  24. package/dist/es/models/IIdentityServiceConstructorOptions.js.map +1 -0
  25. package/dist/es/restEntryPoints.js +24 -0
  26. package/dist/es/restEntryPoints.js.map +1 -0
  27. package/dist/types/identityProfileService.d.ts +6 -1
  28. package/dist/types/identityResolverService.d.ts +6 -1
  29. package/dist/types/identityService.d.ts +6 -1
  30. package/dist/types/index.d.ts +12 -12
  31. package/dist/types/models/IIdentityResolverServiceConstructorOptions.d.ts +1 -1
  32. package/dist/types/models/IIdentityServiceConstructorOptions.d.ts +1 -1
  33. package/docs/changelog.md +50 -0
  34. package/docs/open-api/spec.json +161 -1335
  35. package/docs/reference/classes/IdentityProfileService.md +18 -0
  36. package/docs/reference/classes/IdentityResolverService.md +18 -0
  37. package/docs/reference/classes/IdentityService.md +22 -4
  38. package/package.json +7 -8
  39. package/dist/cjs/index.cjs +0 -2071
  40. package/dist/esm/index.mjs +0 -2039
@@ -0,0 +1,946 @@
1
+ import { ContextIdHelper, ContextIdKeys, ContextIdStore } from "@twin.org/context";
2
+ import { Coerce, ComponentFactory, Guards } from "@twin.org/core";
3
+ import { DocumentHelper } from "@twin.org/identity-models";
4
+ import { DidContexts } from "@twin.org/standards-w3c-did";
5
+ import { HttpStatusCode } from "@twin.org/web";
6
+ /**
7
+ * The source used when communicating about these routes.
8
+ */
9
+ const ROUTES_SOURCE = "identityRoutes";
10
+ /**
11
+ * The tag to associate with the routes.
12
+ */
13
+ export const tagsIdentity = [
14
+ {
15
+ name: "Identity",
16
+ description: "Service to provide all features related to digital identity."
17
+ }
18
+ ];
19
+ /**
20
+ * The REST routes for identity.
21
+ * @param baseRouteName Prefix to prepend to the paths.
22
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
23
+ * @returns The generated routes.
24
+ */
25
+ export function generateRestRoutesIdentity(baseRouteName, componentName) {
26
+ const identityCreateRoute = {
27
+ operationId: "identityCreate",
28
+ summary: "Create an identity",
29
+ tag: tagsIdentity[0].name,
30
+ method: "POST",
31
+ path: `${baseRouteName}/`,
32
+ handler: async (httpRequestContext, request) => identityCreate(httpRequestContext, componentName, request),
33
+ requestType: {
34
+ type: "IIdentityCreateRequest",
35
+ examples: [
36
+ {
37
+ id: "identityCreateRequestExample",
38
+ request: {}
39
+ }
40
+ ]
41
+ },
42
+ responseType: [
43
+ {
44
+ type: "IIdentityCreateResponse",
45
+ examples: [
46
+ {
47
+ id: "identityCreateResponseExample",
48
+ response: {
49
+ body: {
50
+ "@context": DidContexts.Context,
51
+ id: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a",
52
+ service: [
53
+ {
54
+ id: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a#revocation",
55
+ type: "RevocationBitmap2022",
56
+ serviceEndpoint: "data:application/octet-stream;base64,eJyzMmAAAwABr"
57
+ }
58
+ ]
59
+ }
60
+ }
61
+ }
62
+ ]
63
+ }
64
+ ]
65
+ };
66
+ const identityRemoveRoute = {
67
+ operationId: "identityRemove",
68
+ summary: "Remove an identity",
69
+ tag: tagsIdentity[0].name,
70
+ method: "DELETE",
71
+ path: `${baseRouteName}/:identity`,
72
+ handler: async (httpRequestContext, request) => identityRemove(httpRequestContext, componentName, request),
73
+ requestType: {
74
+ type: "IIdentityRemoveRequest",
75
+ examples: [
76
+ {
77
+ id: "identityRemoveRequestExample",
78
+ request: {
79
+ pathParams: {
80
+ identity: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a"
81
+ }
82
+ }
83
+ }
84
+ ]
85
+ },
86
+ responseType: [
87
+ {
88
+ type: "INoContentResponse"
89
+ }
90
+ ]
91
+ };
92
+ const identityVerificationMethodCreateRoute = {
93
+ operationId: "identityVerificationMethodCreate",
94
+ summary: "Create an identity verification method",
95
+ tag: tagsIdentity[0].name,
96
+ method: "POST",
97
+ path: `${baseRouteName}/:identity/verification-method`,
98
+ handler: async (httpRequestContext, request) => identityVerificationMethodCreate(httpRequestContext, componentName, request),
99
+ requestType: {
100
+ type: "IIdentityVerificationMethodCreateRequest",
101
+ examples: [
102
+ {
103
+ id: "identityVerificationMethodCreateRequestExample",
104
+ request: {
105
+ pathParams: {
106
+ identity: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a"
107
+ },
108
+ body: {
109
+ verificationMethodType: "assertionMethod",
110
+ verificationMethodId: "my-assertion"
111
+ }
112
+ }
113
+ }
114
+ ]
115
+ },
116
+ responseType: [
117
+ {
118
+ type: "IIdentityVerificationMethodCreateResponse",
119
+ examples: [
120
+ {
121
+ id: "identityVerificationMethodCreateResponseExample",
122
+ response: {
123
+ body: {
124
+ id: "did:iota:tst:0x70ce5abe69e7c56dd69684dd6da65812b9758b03a0081331ca560b34d73d5ff0#my-assertion",
125
+ controller: "did:iota:tst:0x70ce5abe69e7c56dd69684dd6da65812b9758b03a0081331ca560b34d73d5ff0",
126
+ type: "JsonWebKey2020",
127
+ publicKeyJwk: {
128
+ kty: "OKP",
129
+ alg: "EdDSA",
130
+ kid: "f_fj3rGsZFSYvnS_xv5MgyIBlExq-lgDciu0YQ--S3s",
131
+ crv: "Ed25519",
132
+ x: "SFm32z7y9C17olpaTeocG25WV2CNTUl5MhM679Z4bok"
133
+ }
134
+ }
135
+ }
136
+ }
137
+ ]
138
+ }
139
+ ]
140
+ };
141
+ const identityVerificationMethodRemoveRoute = {
142
+ operationId: "identityVerificationMethodRemove",
143
+ summary: "Remove an identity verification method",
144
+ tag: tagsIdentity[0].name,
145
+ method: "DELETE",
146
+ path: `${baseRouteName}/:identity/verification-method/:verificationMethodId`,
147
+ handler: async (httpRequestContext, request) => identityVerificationMethodRemove(httpRequestContext, componentName, request),
148
+ requestType: {
149
+ type: "IIdentityVerificationMethodRemoveRequest",
150
+ examples: [
151
+ {
152
+ id: "identityVerificationMethodRemoveRequestExample",
153
+ request: {
154
+ pathParams: {
155
+ identity: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a",
156
+ verificationMethodId: "my-assertion"
157
+ }
158
+ }
159
+ }
160
+ ]
161
+ },
162
+ responseType: [
163
+ {
164
+ type: "INoContentResponse",
165
+ examples: [
166
+ {
167
+ id: "identityVerificationMethodCreateResponseExample",
168
+ response: {
169
+ statusCode: HttpStatusCode.noContent
170
+ }
171
+ }
172
+ ]
173
+ }
174
+ ]
175
+ };
176
+ const identityServiceCreateRoute = {
177
+ operationId: "identityServiceCreate",
178
+ summary: "Create an identity service",
179
+ tag: tagsIdentity[0].name,
180
+ method: "POST",
181
+ path: `${baseRouteName}/:identity/service`,
182
+ handler: async (httpRequestContext, request) => identityServiceCreate(httpRequestContext, componentName, request),
183
+ requestType: {
184
+ type: "IIdentityServiceCreateRequest",
185
+ examples: [
186
+ {
187
+ id: "identityServiceCreateRequestExample",
188
+ request: {
189
+ pathParams: {
190
+ identity: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a"
191
+ },
192
+ body: {
193
+ serviceId: "did:example:123#linked-domain",
194
+ type: "LinkedDomains",
195
+ endpoint: "https://bar.example.com"
196
+ }
197
+ }
198
+ }
199
+ ]
200
+ },
201
+ responseType: [
202
+ {
203
+ type: "IIdentityServiceCreateResponse",
204
+ examples: [
205
+ {
206
+ id: "identityServiceCreateResponseExample",
207
+ response: {
208
+ body: {
209
+ id: "did:example:123#linked-domain",
210
+ type: "LinkedDomains",
211
+ serviceEndpoint: "https://bar.example.com"
212
+ }
213
+ }
214
+ }
215
+ ]
216
+ }
217
+ ]
218
+ };
219
+ const identityServiceRemoveRoute = {
220
+ operationId: "identityServiceRemove",
221
+ summary: "Remove an identity service",
222
+ tag: tagsIdentity[0].name,
223
+ method: "DELETE",
224
+ path: `${baseRouteName}/:identity/service/:serviceId`,
225
+ handler: async (httpRequestContext, request) => identityServiceRemove(httpRequestContext, componentName, request),
226
+ requestType: {
227
+ type: "IIdentityServiceRemoveRequest",
228
+ examples: [
229
+ {
230
+ id: "identityServiceRemoveRequestExample",
231
+ request: {
232
+ pathParams: {
233
+ identity: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a",
234
+ serviceId: "did:example:123#linked-domain"
235
+ }
236
+ }
237
+ }
238
+ ]
239
+ },
240
+ responseType: [
241
+ {
242
+ type: "INoContentResponse",
243
+ examples: [
244
+ {
245
+ id: "identityServiceCreateResponseExample",
246
+ response: {
247
+ statusCode: HttpStatusCode.noContent
248
+ }
249
+ }
250
+ ]
251
+ }
252
+ ]
253
+ };
254
+ const identityVerifiableCredentialCreateRoute = {
255
+ operationId: "identityVerifiableCredentialCreate",
256
+ summary: "Create an identity verifiable credential",
257
+ tag: tagsIdentity[0].name,
258
+ method: "POST",
259
+ path: `${baseRouteName}/:identity/verifiable-credential/:verificationMethodId`,
260
+ handler: async (httpRequestContext, request) => identityVerifiableCredentialCreate(httpRequestContext, componentName, request),
261
+ requestType: {
262
+ type: "IIdentityVerifiableCredentialCreateRequest",
263
+ examples: [
264
+ {
265
+ id: "identityVerifiableCredentialCreateRequestExample",
266
+ request: {
267
+ pathParams: {
268
+ identity: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
269
+ verificationMethodId: "my-assertion"
270
+ },
271
+ body: {
272
+ credentialId: "https://example.com/credentials/3732",
273
+ subject: {
274
+ "@context": "https://schema.org",
275
+ "@type": "Person",
276
+ id: "did:entity-storage:0x4757993355b921a8229bd780f30921b6a0216a72e6c3f37a09d13b8426a17def",
277
+ name: "Jane Doe"
278
+ },
279
+ revocationIndex: 5
280
+ }
281
+ }
282
+ }
283
+ ]
284
+ },
285
+ responseType: [
286
+ {
287
+ type: "IIdentityVerifiableCredentialCreateResponse",
288
+ examples: [
289
+ {
290
+ id: "identityVerifiableCredentialCreateResponseExample",
291
+ response: {
292
+ body: {
293
+ verifiableCredential: {
294
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
295
+ id: "https://example.com/credentials/3732",
296
+ type: ["VerifiableCredential", "Person"],
297
+ credentialSubject: {
298
+ id: "did:entity-storage:0x4757993355b921a8229bd780f30921b6a0216a72e6c3f37a09d13b8426a17def",
299
+ name: "Jane Doe"
300
+ },
301
+ issuer: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
302
+ issuanceDate: "2025-01-24T09:21:51.500Z",
303
+ credentialStatus: {
304
+ id: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a#revocation",
305
+ type: "BitstringStatusList",
306
+ revocationBitmapIndex: "5"
307
+ }
308
+ },
309
+ jwt: "eyJraWQiOi...D1Z3AQ"
310
+ }
311
+ }
312
+ }
313
+ ]
314
+ }
315
+ ]
316
+ };
317
+ const identityVerifiableCredentialVerifyRoute = {
318
+ operationId: "identityVerifiableCredentialVerify",
319
+ summary: "Verify an identity verifiable credential",
320
+ tag: tagsIdentity[0].name,
321
+ method: "GET",
322
+ path: `${baseRouteName}/verifiable-credential/verify`,
323
+ handler: async (httpRequestContext, request) => identityVerifiableCredentialVerify(httpRequestContext, componentName, request),
324
+ requestType: {
325
+ type: "IIdentityVerifiableCredentialVerifyRequest",
326
+ examples: [
327
+ {
328
+ id: "identityVerifiableCredentialVerifyRequestExample",
329
+ request: {
330
+ query: {
331
+ jwt: "eyJraWQiOi...D1Z3AQ"
332
+ }
333
+ }
334
+ }
335
+ ]
336
+ },
337
+ responseType: [
338
+ {
339
+ type: "IIdentityVerifiableCredentialVerifyResponse",
340
+ examples: [
341
+ {
342
+ id: "identityVerifiableCredentialVerifyResponseExample",
343
+ response: {
344
+ body: {
345
+ revoked: false,
346
+ verifiableCredential: {
347
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
348
+ id: "https://example.com/credentials/3732",
349
+ type: ["VerifiableCredential", "Person"],
350
+ credentialSubject: {
351
+ id: "did:entity-storage:0x4757993355b921a8229bd780f30921b6a0216a72e6c3f37a09d13b8426a17def",
352
+ name: "Jane Doe"
353
+ },
354
+ issuer: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
355
+ issuanceDate: "2025-01-24T09:21:51.500Z",
356
+ credentialStatus: {
357
+ id: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a#revocation",
358
+ type: "BitstringStatusList",
359
+ revocationBitmapIndex: "5"
360
+ }
361
+ }
362
+ }
363
+ }
364
+ }
365
+ ]
366
+ }
367
+ ],
368
+ skipAuth: true
369
+ };
370
+ const identityVerifiableCredentialRevokeRoute = {
371
+ operationId: "identityVerifiableCredentialRevoke",
372
+ summary: "Revoke an identity verifiable credential",
373
+ tag: tagsIdentity[0].name,
374
+ method: "GET",
375
+ path: `${baseRouteName}/:identity/verifiable-credential/revoke/:revocationIndex`,
376
+ handler: async (httpRequestContext, request) => identityVerifiableCredentialRevoke(httpRequestContext, componentName, request),
377
+ requestType: {
378
+ type: "IIdentityVerifiableCredentialRevokeRequest",
379
+ examples: [
380
+ {
381
+ id: "identityVerifiableCredentialRevokeRequestExample",
382
+ request: {
383
+ pathParams: {
384
+ identity: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
385
+ revocationIndex: 5
386
+ }
387
+ }
388
+ }
389
+ ]
390
+ },
391
+ responseType: [
392
+ {
393
+ type: "INoContentResponse",
394
+ examples: [
395
+ {
396
+ id: "identityServiceRevokeResponseExample",
397
+ response: {
398
+ statusCode: HttpStatusCode.noContent
399
+ }
400
+ }
401
+ ]
402
+ }
403
+ ]
404
+ };
405
+ const identityVerifiableCredentialUnrevokeRoute = {
406
+ operationId: "identityVerifiableCredentialUnrevoke",
407
+ summary: "Unrevoke an identity verifiable credential",
408
+ tag: tagsIdentity[0].name,
409
+ method: "GET",
410
+ path: `${baseRouteName}/:identity/verifiable-credential/unrevoke/:revocationIndex`,
411
+ handler: async (httpRequestContext, request) => identityVerifiableCredentialUnrevoke(httpRequestContext, componentName, request),
412
+ requestType: {
413
+ type: "IIdentityVerifiableCredentialUnrevokeRequest",
414
+ examples: [
415
+ {
416
+ id: "identityVerifiableCredentialUnrevokeRequestExample",
417
+ request: {
418
+ pathParams: {
419
+ identity: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
420
+ revocationIndex: 5
421
+ }
422
+ }
423
+ }
424
+ ]
425
+ },
426
+ responseType: [
427
+ {
428
+ type: "INoContentResponse",
429
+ examples: [
430
+ {
431
+ id: "identityServiceUnrevokeResponseExample",
432
+ response: {
433
+ statusCode: HttpStatusCode.noContent
434
+ }
435
+ }
436
+ ]
437
+ }
438
+ ]
439
+ };
440
+ const identityVerifiablePresentationCreateRoute = {
441
+ operationId: "identityVerifiablePresentationCreate",
442
+ summary: "Create an identity verifiable presentation",
443
+ tag: tagsIdentity[0].name,
444
+ method: "POST",
445
+ path: `${baseRouteName}/:identity/verifiable-presentation/:verificationMethodId`,
446
+ handler: async (httpRequestContext, request) => identityVerifiablePresentationCreate(httpRequestContext, componentName, request),
447
+ requestType: {
448
+ type: "IIdentityVerifiablePresentationCreateRequest",
449
+ examples: [
450
+ {
451
+ id: "identityVerifiablePresentationCreateRequestExample",
452
+ request: {
453
+ pathParams: {
454
+ identity: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
455
+ verificationMethodId: "my-assertion"
456
+ },
457
+ body: {
458
+ presentationId: "https://example.com/presentation/3732",
459
+ verifiableCredentials: ["eyJraWQiOi...D1Z3AQ"]
460
+ }
461
+ }
462
+ }
463
+ ]
464
+ },
465
+ responseType: [
466
+ {
467
+ type: "IIdentityVerifiablePresentationCreateResponse",
468
+ examples: [
469
+ {
470
+ id: "IIdentityVerifiablePresentationCreateResponseExample",
471
+ response: {
472
+ body: {
473
+ verifiablePresentation: {
474
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
475
+ id: "presentationId",
476
+ type: ["VerifiablePresentation", "Person"],
477
+ verifiableCredential: ["eyJraWQiOi...D1Z3AQ"],
478
+ holder: "did:entity-storage:0xcea318e06e89f3fb4048160770effd84d0cfa5801fee13dfa6f9413a00429cec"
479
+ },
480
+ jwt: "eyJraWQiOi...D1Z3AQ"
481
+ }
482
+ }
483
+ }
484
+ ]
485
+ }
486
+ ]
487
+ };
488
+ const identityVerifiablePresentationVerifyRoute = {
489
+ operationId: "identityVerifiablePresentationVerify",
490
+ summary: "Verify an identity verifiable presentation",
491
+ tag: tagsIdentity[0].name,
492
+ method: "GET",
493
+ path: `${baseRouteName}/verifiable-presentation/verify`,
494
+ handler: async (httpRequestContext, request) => identityVerifiablePresentationVerify(httpRequestContext, componentName, request),
495
+ requestType: {
496
+ type: "IIdentityVerifiablePresentationVerifyRequest",
497
+ examples: [
498
+ {
499
+ id: "identityVerifiablePresentationVerifyRequestExample",
500
+ request: {
501
+ query: {
502
+ jwt: "eyJraWQiOi...D1Z3AQ"
503
+ }
504
+ }
505
+ }
506
+ ]
507
+ },
508
+ responseType: [
509
+ {
510
+ type: "IIdentityVerifiablePresentationVerifyResponse",
511
+ examples: [
512
+ {
513
+ id: "identityVerifiablePresentationVerifyResponseExample",
514
+ response: {
515
+ body: {
516
+ revoked: false,
517
+ verifiablePresentation: {
518
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
519
+ id: "presentationId",
520
+ type: ["VerifiablePresentation", "Person"],
521
+ verifiableCredential: ["eyJraWQiOi...D1Z3AQ"],
522
+ holder: "did:entity-storage:0xcea318e06e89f3fb4048160770effd84d0cfa5801fee13dfa6f9413a00429cec"
523
+ }
524
+ }
525
+ }
526
+ }
527
+ ]
528
+ }
529
+ ],
530
+ skipAuth: true
531
+ };
532
+ const identityProofCreateRoute = {
533
+ operationId: "identityProofCreate",
534
+ summary: "Create an identity proof",
535
+ tag: tagsIdentity[0].name,
536
+ method: "POST",
537
+ path: `${baseRouteName}/:identity/proof/:verificationMethodId`,
538
+ handler: async (httpRequestContext, request) => identityProofCreate(httpRequestContext, componentName, request),
539
+ requestType: {
540
+ type: "IIdentityProofCreateRequest",
541
+ examples: [
542
+ {
543
+ id: "identityProofCreateRequestExample",
544
+ request: {
545
+ pathParams: {
546
+ identity: "did:entity-storage:0xda2df3ebc91ee0d5229d6532ffd0f4426952a94f34988b0ca906694dfd366a6a",
547
+ verificationMethodId: "my-verification-id"
548
+ },
549
+ body: {
550
+ proofType: "DataIntegrityProof",
551
+ document: {
552
+ "@context": [
553
+ "https://www.w3.org/2018/credentials/v1",
554
+ "https://www.w3.org/2018/credentials/examples/v1"
555
+ ],
556
+ id: "urn:uuid:58172aac-d8ba-11ed-83dd-0b3aef56cc33",
557
+ type: ["VerifiableCredential", "AlumniCredential"],
558
+ name: "Alumni Credential",
559
+ description: "A minimum viable example of an Alumni Credential.",
560
+ issuer: "https://vc.example/issuers/5678",
561
+ validFrom: "2023-01-01T00:00:00Z",
562
+ credentialSubject: {
563
+ id: "did:example:abcdefgh",
564
+ alumniOf: "The School of Examples"
565
+ }
566
+ }
567
+ }
568
+ }
569
+ }
570
+ ]
571
+ },
572
+ responseType: [
573
+ {
574
+ type: "IIdentityProofCreateResponse",
575
+ examples: [
576
+ {
577
+ id: "identityProofCreateResponseExample",
578
+ response: {
579
+ body: {
580
+ "@context": [
581
+ "https://www.w3.org/ns/credentials/v2",
582
+ "https://www.w3.org/ns/credentials/examples/v2"
583
+ ],
584
+ type: "DataIntegrityProof",
585
+ cryptosuite: "eddsa-jcs-2022",
586
+ created: "2024-01-31T16:00:45.490Z",
587
+ verificationMethod: "did:entity-storage:0x0101010101010101010101010101010101010101010101010101010101010101#my-verification-id",
588
+ proofPurpose: "assertionMethod",
589
+ proofValue: "z2zGoejwpX6HH2T11BZaniEVZrqRKDpwbQSvPcL7eL9M7hV5P9zQQZxs85n6qyDzkkXCL8aFUWfwQD5bxVGqDK1fa"
590
+ }
591
+ }
592
+ }
593
+ ]
594
+ }
595
+ ]
596
+ };
597
+ const identityProofVerifyRoute = {
598
+ operationId: "identityProofVerify",
599
+ summary: "Verify an identity proof",
600
+ tag: tagsIdentity[0].name,
601
+ method: "POST",
602
+ path: `${baseRouteName}/proof/verify`,
603
+ handler: async (httpRequestContext, request) => identityProofVerify(httpRequestContext, componentName, request),
604
+ requestType: {
605
+ type: "IIdentityProofVerifyRequest",
606
+ examples: [
607
+ {
608
+ id: "identityProofVerifyRequestExample",
609
+ request: {
610
+ body: {
611
+ document: {
612
+ "@context": [
613
+ "https://www.w3.org/2018/credentials/v1",
614
+ "https://www.w3.org/2018/credentials/examples/v1"
615
+ ],
616
+ id: "urn:uuid:58172aac-d8ba-11ed-83dd-0b3aef56cc33",
617
+ type: ["VerifiableCredential", "AlumniCredential"],
618
+ name: "Alumni Credential",
619
+ description: "A minimum viable example of an Alumni Credential.",
620
+ issuer: "https://vc.example/issuers/5678",
621
+ validFrom: "2023-01-01T00:00:00Z",
622
+ credentialSubject: {
623
+ id: "did:example:abcdefgh",
624
+ alumniOf: "The School of Examples"
625
+ }
626
+ },
627
+ proof: {
628
+ "@context": "https://www.w3.org/ns/credentials/v2",
629
+ type: "DataIntegrityProof",
630
+ cryptosuite: "eddsa-jcs-2022",
631
+ created: "2025-01-24T11:32:13.106Z",
632
+ verificationMethod: "did:entity-storage:0xda2df3ebc91ee0d5229d6532ffd0f4426952a94f34988b0ca906694dfd366a6a#my-verification-id",
633
+ proofPurpose: "assertionMethod",
634
+ proofValue: "2fVLgANruCBoRPBCJavi54mZtkQdyMz6T2N4XVyB96asawiriKrVWoktcSQ7dMGrBTiemBBDpcLE2HfiTBCGuBmq"
635
+ }
636
+ }
637
+ }
638
+ }
639
+ ]
640
+ },
641
+ responseType: [
642
+ {
643
+ type: "IIdentityProofVerifyResponse",
644
+ examples: [
645
+ {
646
+ id: "identityProofVerifyResponseExample",
647
+ response: {
648
+ body: {
649
+ verified: true
650
+ }
651
+ }
652
+ }
653
+ ]
654
+ }
655
+ ],
656
+ skipAuth: true
657
+ };
658
+ return [
659
+ identityCreateRoute,
660
+ identityRemoveRoute,
661
+ identityVerificationMethodCreateRoute,
662
+ identityVerificationMethodRemoveRoute,
663
+ identityServiceCreateRoute,
664
+ identityServiceRemoveRoute,
665
+ identityVerifiableCredentialCreateRoute,
666
+ identityVerifiableCredentialVerifyRoute,
667
+ identityVerifiableCredentialRevokeRoute,
668
+ identityVerifiableCredentialUnrevokeRoute,
669
+ identityVerifiablePresentationCreateRoute,
670
+ identityVerifiablePresentationVerifyRoute,
671
+ identityProofCreateRoute,
672
+ identityProofVerifyRoute
673
+ ];
674
+ }
675
+ /**
676
+ * Create an identity.
677
+ * @param httpRequestContext The request context for the API.
678
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
679
+ * @param request The request.
680
+ * @returns The response object with additional http response properties.
681
+ */
682
+ export async function identityCreate(httpRequestContext, componentName, request) {
683
+ Guards.object(ROUTES_SOURCE, "request", request);
684
+ const contextIds = await ContextIdStore.getContextIds();
685
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
686
+ const component = ComponentFactory.get(componentName);
687
+ const result = await component.identityCreate(request.body?.namespace, contextIds[ContextIdKeys.Organization]);
688
+ return {
689
+ body: result
690
+ };
691
+ }
692
+ /**
693
+ * Remove an identity.
694
+ * @param httpRequestContext The request context for the API.
695
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
696
+ * @param request The request.
697
+ * @returns The response object with additional http response properties.
698
+ */
699
+ export async function identityRemove(httpRequestContext, componentName, request) {
700
+ Guards.object(ROUTES_SOURCE, "request", request);
701
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
702
+ const contextIds = await ContextIdStore.getContextIds();
703
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
704
+ const component = ComponentFactory.get(componentName);
705
+ await component.identityRemove(request.pathParams.identity, contextIds[ContextIdKeys.Organization]);
706
+ return {
707
+ statusCode: HttpStatusCode.noContent
708
+ };
709
+ }
710
+ /**
711
+ * Create an identity verification method.
712
+ * @param httpRequestContext The request context for the API.
713
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
714
+ * @param request The request.
715
+ * @returns The response object with additional http response properties.
716
+ */
717
+ export async function identityVerificationMethodCreate(httpRequestContext, componentName, request) {
718
+ Guards.object(ROUTES_SOURCE, "request", request);
719
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
720
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
721
+ const contextIds = await ContextIdStore.getContextIds();
722
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
723
+ const component = ComponentFactory.get(componentName);
724
+ const result = await component.verificationMethodCreate(request.pathParams.identity, request.body.verificationMethodType, request.body.verificationMethodId, contextIds[ContextIdKeys.Organization]);
725
+ return {
726
+ body: result
727
+ };
728
+ }
729
+ /**
730
+ * Remove an identity verification method.
731
+ * @param httpRequestContext The request context for the API.
732
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
733
+ * @param request The request.
734
+ * @returns The response object with additional http response properties.
735
+ */
736
+ export async function identityVerificationMethodRemove(httpRequestContext, componentName, request) {
737
+ Guards.object(ROUTES_SOURCE, "request", request);
738
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
739
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
740
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.verificationMethodId", request.pathParams.verificationMethodId);
741
+ const contextIds = await ContextIdStore.getContextIds();
742
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
743
+ const component = ComponentFactory.get(componentName);
744
+ await component.verificationMethodRemove(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), contextIds[ContextIdKeys.Organization]);
745
+ return {
746
+ statusCode: HttpStatusCode.noContent
747
+ };
748
+ }
749
+ /**
750
+ * Create an identity service.
751
+ * @param httpRequestContext The request context for the API.
752
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
753
+ * @param request The request.
754
+ * @returns The response object with additional http response properties.
755
+ */
756
+ export async function identityServiceCreate(httpRequestContext, componentName, request) {
757
+ Guards.object(ROUTES_SOURCE, "request", request);
758
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
759
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
760
+ const contextIds = await ContextIdStore.getContextIds();
761
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
762
+ const component = ComponentFactory.get(componentName);
763
+ const result = await component.serviceCreate(request.pathParams.identity, request.body.serviceId, request.body.type, request.body.endpoint, contextIds[ContextIdKeys.Organization]);
764
+ return {
765
+ body: result
766
+ };
767
+ }
768
+ /**
769
+ * Remove an identity service.
770
+ * @param httpRequestContext The request context for the API.
771
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
772
+ * @param request The request.
773
+ * @returns The response object with additional http response properties.
774
+ */
775
+ export async function identityServiceRemove(httpRequestContext, componentName, request) {
776
+ Guards.object(ROUTES_SOURCE, "request", request);
777
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
778
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
779
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.serviceId", request.pathParams.serviceId);
780
+ const contextIds = await ContextIdStore.getContextIds();
781
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
782
+ const component = ComponentFactory.get(componentName);
783
+ await component.serviceRemove(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.serviceId), contextIds[ContextIdKeys.Organization]);
784
+ return {
785
+ statusCode: HttpStatusCode.noContent
786
+ };
787
+ }
788
+ /**
789
+ * Create a verifiable credential.
790
+ * @param httpRequestContext The request context for the API.
791
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
792
+ * @param request The request.
793
+ * @returns The response object with additional http response properties.
794
+ */
795
+ export async function identityVerifiableCredentialCreate(httpRequestContext, componentName, request) {
796
+ Guards.object(ROUTES_SOURCE, "request", request);
797
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
798
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
799
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.verificationMethodId", request.pathParams.verificationMethodId);
800
+ const contextIds = await ContextIdStore.getContextIds();
801
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
802
+ const component = ComponentFactory.get(componentName);
803
+ const result = await component.verifiableCredentialCreate(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.credentialId, request.body.subject, {
804
+ revocationIndex: request.body.revocationIndex,
805
+ expirationDate: Coerce.date(request.body.expirationDate)
806
+ }, contextIds[ContextIdKeys.Organization]);
807
+ return {
808
+ body: result
809
+ };
810
+ }
811
+ /**
812
+ * Verify a verifiable credential.
813
+ * @param httpRequestContext The request context for the API.
814
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
815
+ * @param request The request.
816
+ * @returns The response object with additional http response properties.
817
+ */
818
+ export async function identityVerifiableCredentialVerify(httpRequestContext, componentName, request) {
819
+ Guards.object(ROUTES_SOURCE, "request", request);
820
+ Guards.object(ROUTES_SOURCE, "request.query", request.query);
821
+ Guards.stringValue(ROUTES_SOURCE, "request.query.jwt", request.query.jwt);
822
+ const component = ComponentFactory.get(componentName);
823
+ const result = await component.verifiableCredentialVerify(request.query.jwt);
824
+ return {
825
+ body: result
826
+ };
827
+ }
828
+ /**
829
+ * Revoke a verifiable credential.
830
+ * @param httpRequestContext The request context for the API.
831
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
832
+ * @param request The request.
833
+ * @returns The response object with additional http response properties.
834
+ */
835
+ export async function identityVerifiableCredentialRevoke(httpRequestContext, componentName, request) {
836
+ Guards.object(ROUTES_SOURCE, "request", request);
837
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
838
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
839
+ const revocationIndex = Coerce.number(request.pathParams.revocationIndex);
840
+ Guards.integer(ROUTES_SOURCE, "request.pathParams.revocationIndex", revocationIndex);
841
+ const contextIds = await ContextIdStore.getContextIds();
842
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
843
+ const component = ComponentFactory.get(componentName);
844
+ await component.verifiableCredentialRevoke(request.pathParams.identity, revocationIndex, contextIds[ContextIdKeys.Organization]);
845
+ return {
846
+ statusCode: HttpStatusCode.noContent
847
+ };
848
+ }
849
+ /**
850
+ * Unrevoke a verifiable credential.
851
+ * @param httpRequestContext The request context for the API.
852
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
853
+ * @param request The request.
854
+ * @returns The response object with additional http response properties.
855
+ */
856
+ export async function identityVerifiableCredentialUnrevoke(httpRequestContext, componentName, request) {
857
+ Guards.object(ROUTES_SOURCE, "request", request);
858
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
859
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
860
+ const revocationIndex = Coerce.number(request.pathParams.revocationIndex);
861
+ Guards.integer(ROUTES_SOURCE, "request.pathParams.revocationIndex", revocationIndex);
862
+ const contextIds = await ContextIdStore.getContextIds();
863
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
864
+ const component = ComponentFactory.get(componentName);
865
+ await component.verifiableCredentialUnrevoke(request.pathParams.identity, revocationIndex, contextIds[ContextIdKeys.Organization]);
866
+ return {
867
+ statusCode: HttpStatusCode.noContent
868
+ };
869
+ }
870
+ /**
871
+ * Create a verifiable presentation.
872
+ * @param httpRequestContext The request context for the API.
873
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
874
+ * @param request The request.
875
+ * @returns The response object with additional http response properties.
876
+ */
877
+ export async function identityVerifiablePresentationCreate(httpRequestContext, componentName, request) {
878
+ Guards.object(ROUTES_SOURCE, "request", request);
879
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
880
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
881
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.verificationMethodId", request.pathParams.verificationMethodId);
882
+ const contextIds = await ContextIdStore.getContextIds();
883
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
884
+ const component = ComponentFactory.get(componentName);
885
+ const result = await component.verifiablePresentationCreate(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.presentationId, request.body.contexts, request.body.types, request.body.verifiableCredentials, request.body.expiresInMinutes, contextIds[ContextIdKeys.Organization]);
886
+ return {
887
+ body: result
888
+ };
889
+ }
890
+ /**
891
+ * Verify a verifiable presentation.
892
+ * @param httpRequestContext The request context for the API.
893
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
894
+ * @param request The request.
895
+ * @returns The response object with additional http response properties.
896
+ */
897
+ export async function identityVerifiablePresentationVerify(httpRequestContext, componentName, request) {
898
+ Guards.object(ROUTES_SOURCE, "request", request);
899
+ Guards.object(ROUTES_SOURCE, "request.query", request.query);
900
+ Guards.stringValue(ROUTES_SOURCE, "request.query.jwt", request.query.jwt);
901
+ const component = ComponentFactory.get(componentName);
902
+ const result = await component.verifiablePresentationVerify(request.query.jwt);
903
+ return {
904
+ body: result
905
+ };
906
+ }
907
+ /**
908
+ * Create an identity proof.
909
+ * @param httpRequestContext The request context for the API.
910
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
911
+ * @param request The request.
912
+ * @returns The response object with additional http response properties.
913
+ */
914
+ export async function identityProofCreate(httpRequestContext, componentName, request) {
915
+ Guards.object(ROUTES_SOURCE, "request", request);
916
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
917
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
918
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.verificationMethodId", request.pathParams.verificationMethodId);
919
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
920
+ const contextIds = await ContextIdStore.getContextIds();
921
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
922
+ const component = ComponentFactory.get(componentName);
923
+ const result = await component.proofCreate(request.pathParams.identity, request.body.proofType, request.body.document, contextIds[ContextIdKeys.Organization]);
924
+ return {
925
+ body: result
926
+ };
927
+ }
928
+ /**
929
+ * Verify an identity proof.
930
+ * @param httpRequestContext The request context for the API.
931
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
932
+ * @param request The request.
933
+ * @returns The response object with additional http response properties.
934
+ */
935
+ export async function identityProofVerify(httpRequestContext, componentName, request) {
936
+ Guards.object(ROUTES_SOURCE, "request", request);
937
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
938
+ const component = ComponentFactory.get(componentName);
939
+ const result = await component.proofVerify(request.body.document, request.body.proof);
940
+ return {
941
+ body: {
942
+ verified: result
943
+ }
944
+ };
945
+ }
946
+ //# sourceMappingURL=identityRoutes.js.map