@twin.org/identity-service 0.9.3-next.3 → 0.9.3-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,9 @@ import { HealthCategory, HealthStatus } from "@twin.org/api-models";
4
4
  import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
5
5
  import { BaseError, ComponentFactory, GeneralError, Guards, Is, Urn } from "@twin.org/core";
6
6
  import { AccountHelper } from "@twin.org/dlt-account";
7
- import { DocumentHelper, IdentityConnectorFactory, IdentityMetricIds, IdentitySpanAttributes, IdentitySpanNames, IdentityMetrics, IdentityResolverConnectorFactory } from "@twin.org/identity-models";
7
+ import { DocumentHelper, IdentityConnectorFactory, IdentityMetricIds, IdentityMetrics, IdentityResolverConnectorFactory } from "@twin.org/identity-models";
8
8
  import { DidVerificationMethodType, ProofTypes } from "@twin.org/standards-w3c-did";
9
9
  import { MetricHelper } from "@twin.org/telemetry-models";
10
- import { TracingHelper } from "@twin.org/tracing-models";
11
10
  import { VaultConnectorFactory } from "@twin.org/vault-models";
12
11
  import { Jwt } from "@twin.org/web";
13
12
  /**
@@ -33,11 +32,6 @@ export class IdentityService {
33
32
  * @internal
34
33
  */
35
34
  _telemetryComponent;
36
- /**
37
- * The optional tracing component for recording spans.
38
- * @internal
39
- */
40
- _tracingComponent;
41
35
  /**
42
36
  * Create a new instance of IdentityService.
43
37
  * @param options The options for the service.
@@ -51,7 +45,6 @@ export class IdentityService {
51
45
  this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
52
46
  this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
53
47
  this._telemetryComponent = ComponentFactory.getIfExists(options?.telemetryComponentType);
54
- this._tracingComponent = ComponentFactory.getIfExists(options?.tracingComponentType);
55
48
  }
56
49
  /**
57
50
  * Returns the class name of the component.
@@ -181,19 +174,17 @@ export class IdentityService {
181
174
  */
182
175
  async identityCreate(namespace, controller) {
183
176
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
184
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.Create, undefined, async () => {
185
- try {
186
- const identityConnector = this.getConnectorByNamespace(namespace);
187
- const result = await identityConnector.createDocument(controller);
188
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsCreated, {
189
- namespace: namespace ?? this._defaultNamespace
190
- });
191
- return result;
192
- }
193
- catch (error) {
194
- throw new GeneralError(IdentityService.CLASS_NAME, "identityCreateFailed", undefined, error);
195
- }
196
- });
177
+ try {
178
+ const identityConnector = this.getConnectorByNamespace(namespace);
179
+ const result = await identityConnector.createDocument(controller);
180
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsCreated, {
181
+ namespace: namespace ?? this._defaultNamespace
182
+ });
183
+ return result;
184
+ }
185
+ catch (error) {
186
+ throw new GeneralError(IdentityService.CLASS_NAME, "identityCreateFailed", undefined, error);
187
+ }
197
188
  }
198
189
  /**
199
190
  * Remove an identity.
@@ -206,17 +197,15 @@ export class IdentityService {
206
197
  async identityRemove(identity, options, controller) {
207
198
  Guards.stringValue(IdentityService.CLASS_NAME, "identity", identity);
208
199
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
209
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.Remove, { attributes: { [IdentitySpanAttributes.Id]: identity } }, async () => {
210
- try {
211
- const identityConnector = this.getConnectorByUri(identity);
212
- const result = await identityConnector.removeDocument(controller, identity, options);
213
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsRemoved);
214
- return result;
215
- }
216
- catch (error) {
217
- throw new GeneralError(IdentityService.CLASS_NAME, "identityRemoveFailed", { identity }, error);
218
- }
219
- });
200
+ try {
201
+ const identityConnector = this.getConnectorByUri(identity);
202
+ const result = await identityConnector.removeDocument(controller, identity, options);
203
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsRemoved);
204
+ return result;
205
+ }
206
+ catch (error) {
207
+ throw new GeneralError(IdentityService.CLASS_NAME, "identityRemoveFailed", { identity }, error);
208
+ }
220
209
  }
221
210
  /**
222
211
  * Add a verification method to the document in JSON Web key Format.
@@ -232,16 +221,14 @@ export class IdentityService {
232
221
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
233
222
  Urn.guard(IdentityService.CLASS_NAME, "identity", identity);
234
223
  Guards.arrayOneOf(IdentityService.CLASS_NAME, "verificationMethodType", verificationMethodType, Object.values(DidVerificationMethodType));
235
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerificationMethodCreate, { attributes: { [IdentitySpanAttributes.Id]: identity } }, async () => {
236
- try {
237
- const identityConnector = this.getConnectorByUri(identity);
238
- const verificationMethod = await identityConnector.addVerificationMethod(controller, identity, verificationMethodType, verificationMethodId);
239
- return verificationMethod;
240
- }
241
- catch (error) {
242
- throw new GeneralError(IdentityService.CLASS_NAME, "verificationMethodCreateFailed", { identity }, error);
243
- }
244
- });
224
+ try {
225
+ const identityConnector = this.getConnectorByUri(identity);
226
+ const verificationMethod = await identityConnector.addVerificationMethod(controller, identity, verificationMethodType, verificationMethodId);
227
+ return verificationMethod;
228
+ }
229
+ catch (error) {
230
+ throw new GeneralError(IdentityService.CLASS_NAME, "verificationMethodCreateFailed", { identity }, error);
231
+ }
245
232
  }
246
233
  /**
247
234
  * Remove a verification method from the document.
@@ -256,16 +243,14 @@ export class IdentityService {
256
243
  async verificationMethodRemove(verificationMethodId, options, controller) {
257
244
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
258
245
  Urn.guard(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
259
- await TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerificationMethodRemove, { attributes: { [IdentitySpanAttributes.VerificationMethodId]: verificationMethodId } }, async () => {
260
- try {
261
- const idParts = DocumentHelper.parseId(verificationMethodId);
262
- const identityConnector = this.getConnectorByUri(idParts.id);
263
- await identityConnector.removeVerificationMethod(controller, verificationMethodId, options);
264
- }
265
- catch (error) {
266
- throw new GeneralError(IdentityService.CLASS_NAME, "verificationMethodRemoveFailed", { verificationMethodId }, error);
267
- }
268
- });
246
+ try {
247
+ const idParts = DocumentHelper.parseId(verificationMethodId);
248
+ const identityConnector = this.getConnectorByUri(idParts.id);
249
+ await identityConnector.removeVerificationMethod(controller, verificationMethodId, options);
250
+ }
251
+ catch (error) {
252
+ throw new GeneralError(IdentityService.CLASS_NAME, "verificationMethodRemoveFailed", { verificationMethodId }, error);
253
+ }
269
254
  }
270
255
  /**
271
256
  * Add a service to the document.
@@ -293,16 +278,14 @@ export class IdentityService {
293
278
  else {
294
279
  Guards.stringValue(IdentityService.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
295
280
  }
296
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.ServiceCreate, { attributes: { [IdentitySpanAttributes.Id]: identity } }, async () => {
297
- try {
298
- const identityConnector = this.getConnectorByUri(identity);
299
- const service = await identityConnector.addService(controller, identity, serviceId, serviceType, serviceEndpoint);
300
- return service;
301
- }
302
- catch (error) {
303
- throw new GeneralError(IdentityService.CLASS_NAME, "serviceCreateFailed", { identity, serviceId }, error);
304
- }
305
- });
281
+ try {
282
+ const identityConnector = this.getConnectorByUri(identity);
283
+ const service = await identityConnector.addService(controller, identity, serviceId, serviceType, serviceEndpoint);
284
+ return service;
285
+ }
286
+ catch (error) {
287
+ throw new GeneralError(IdentityService.CLASS_NAME, "serviceCreateFailed", { identity, serviceId }, error);
288
+ }
306
289
  }
307
290
  /**
308
291
  * Remove a service from the document.
@@ -314,16 +297,14 @@ export class IdentityService {
314
297
  async serviceRemove(serviceId, controller) {
315
298
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
316
299
  Urn.guard(IdentityService.CLASS_NAME, "serviceId", serviceId);
317
- await TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.ServiceRemove, { attributes: { [IdentitySpanAttributes.ServiceId]: serviceId } }, async () => {
318
- try {
319
- const idParts = DocumentHelper.parseId(serviceId);
320
- const identityConnector = this.getConnectorByUri(idParts.id);
321
- await identityConnector.removeService(controller, serviceId);
322
- }
323
- catch (error) {
324
- throw new GeneralError(IdentityService.CLASS_NAME, "serviceRemoveFailed", { serviceId }, error);
325
- }
326
- });
300
+ try {
301
+ const idParts = DocumentHelper.parseId(serviceId);
302
+ const identityConnector = this.getConnectorByUri(idParts.id);
303
+ await identityConnector.removeService(controller, serviceId);
304
+ }
305
+ catch (error) {
306
+ throw new GeneralError(IdentityService.CLASS_NAME, "serviceRemoveFailed", { serviceId }, error);
307
+ }
327
308
  }
328
309
  /**
329
310
  * Add an alias to the alsoKnownAs property on the document.
@@ -339,16 +320,14 @@ export class IdentityService {
339
320
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
340
321
  Guards.stringValue(IdentityService.CLASS_NAME, "documentId", documentId);
341
322
  Guards.stringValue(IdentityService.CLASS_NAME, "alias", alias);
342
- await TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.AlsoKnownAsAdd, { attributes: { [IdentitySpanAttributes.Id]: documentId } }, async () => {
343
- try {
344
- const idParts = DocumentHelper.parseId(documentId);
345
- const identityConnector = this.getConnectorByUri(idParts.id);
346
- await identityConnector.addAlsoKnownAs(controller, documentId, alias);
347
- }
348
- catch (error) {
349
- throw new GeneralError(IdentityService.CLASS_NAME, "alsoKnownAsAddFailed", { identity: documentId, alias }, error);
350
- }
351
- });
323
+ try {
324
+ const idParts = DocumentHelper.parseId(documentId);
325
+ const identityConnector = this.getConnectorByUri(idParts.id);
326
+ await identityConnector.addAlsoKnownAs(controller, documentId, alias);
327
+ }
328
+ catch (error) {
329
+ throw new GeneralError(IdentityService.CLASS_NAME, "alsoKnownAsAddFailed", { identity: documentId, alias }, error);
330
+ }
352
331
  }
353
332
  /**
354
333
  * Remove an alias from the alsoKnownAs property on the document.
@@ -364,16 +343,14 @@ export class IdentityService {
364
343
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
365
344
  Guards.stringValue(IdentityService.CLASS_NAME, "documentId", documentId);
366
345
  Guards.stringValue(IdentityService.CLASS_NAME, "alias", alias);
367
- await TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.AlsoKnownAsRemove, { attributes: { [IdentitySpanAttributes.Id]: documentId } }, async () => {
368
- try {
369
- const idParts = DocumentHelper.parseId(documentId);
370
- const identityConnector = this.getConnectorByUri(idParts.id);
371
- await identityConnector.removeAlsoKnownAs(controller, documentId, alias);
372
- }
373
- catch (error) {
374
- throw new GeneralError(IdentityService.CLASS_NAME, "alsoKnownAsRemoveFailed", { identity: documentId, alias }, error);
375
- }
376
- });
346
+ try {
347
+ const idParts = DocumentHelper.parseId(documentId);
348
+ const identityConnector = this.getConnectorByUri(idParts.id);
349
+ await identityConnector.removeAlsoKnownAs(controller, documentId, alias);
350
+ }
351
+ catch (error) {
352
+ throw new GeneralError(IdentityService.CLASS_NAME, "alsoKnownAsRemoveFailed", { identity: documentId, alias }, error);
353
+ }
377
354
  }
378
355
  /**
379
356
  * Create a verifiable credential for a verification method.
@@ -393,21 +370,19 @@ export class IdentityService {
393
370
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
394
371
  Urn.guard(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
395
372
  Guards.object(IdentityService.CLASS_NAME, "subject", subject);
396
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerifiableCredentialCreate, { attributes: { [IdentitySpanAttributes.VerificationMethodId]: verificationMethodId } }, async () => {
397
- try {
398
- const idParts = DocumentHelper.parseId(verificationMethodId);
399
- const identityConnector = this.getConnectorByUri(idParts.id);
400
- const service = await identityConnector.createVerifiableCredential(controller, verificationMethodId, id, subject, options);
401
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsCreated, {
402
- hasRevocation: Is.number(options?.revocationIndex),
403
- hasExpiration: Is.date(options?.expirationDate)
404
- });
405
- return service;
406
- }
407
- catch (error) {
408
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialCreateFailed", { verificationMethodId }, error);
409
- }
410
- });
373
+ try {
374
+ const idParts = DocumentHelper.parseId(verificationMethodId);
375
+ const identityConnector = this.getConnectorByUri(idParts.id);
376
+ const service = await identityConnector.createVerifiableCredential(controller, verificationMethodId, id, subject, options);
377
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsCreated, {
378
+ hasRevocation: Is.number(options?.revocationIndex),
379
+ hasExpiration: Is.date(options?.expirationDate)
380
+ });
381
+ return service;
382
+ }
383
+ catch (error) {
384
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialCreateFailed", { verificationMethodId }, error);
385
+ }
411
386
  }
412
387
  /**
413
388
  * Verify a verifiable credential is valid.
@@ -419,24 +394,20 @@ export class IdentityService {
419
394
  Guards.objectValue(IdentityService.CLASS_NAME, "credential", credential);
420
395
  Guards.stringValue(IdentityService.CLASS_NAME, "credential.issuer", credential.issuer);
421
396
  Guards.objectValue(IdentityService.CLASS_NAME, "credential.proof", credential.proof);
422
- const issuer = credential.issuer;
423
- const verifiableCredential = credential;
424
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerifiableCredentialVerify, undefined, async () => {
425
- try {
426
- const identityConnector = this.getConnectorByUri(issuer);
427
- const service = await identityConnector.checkVerifiableCredential(verifiableCredential);
428
- if (service.revoked) {
429
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerificationFailed, { failureReason: "revoked" });
430
- }
431
- else {
432
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);
433
- }
434
- return service;
397
+ try {
398
+ const identityConnector = this.getConnectorByUri(credential.issuer);
399
+ const service = await identityConnector.checkVerifiableCredential(credential);
400
+ if (service.revoked) {
401
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerificationFailed, { failureReason: "revoked" });
435
402
  }
436
- catch (error) {
437
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
403
+ else {
404
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);
438
405
  }
439
- });
406
+ return service;
407
+ }
408
+ catch (error) {
409
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
410
+ }
440
411
  }
441
412
  Guards.stringValue(IdentityService.CLASS_NAME, "credential", credential);
442
413
  const jwtDecoded = await Jwt.decode(credential);
@@ -449,23 +420,20 @@ export class IdentityService {
449
420
  Is.undefined(jwtSignature)) {
450
421
  throw new GeneralError(IdentityService.CLASS_NAME, "jwtDecodeFailed");
451
422
  }
452
- const issuer = jwtPayload.iss;
453
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerifiableCredentialVerify, undefined, async () => {
454
- try {
455
- const identityConnector = this.getConnectorByUri(issuer);
456
- const service = await identityConnector.checkVerifiableCredential(credential);
457
- if (service.revoked) {
458
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerificationFailed, { failureReason: "revoked" });
459
- }
460
- else {
461
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);
462
- }
463
- return service;
423
+ try {
424
+ const identityConnector = this.getConnectorByUri(jwtPayload.iss);
425
+ const service = await identityConnector.checkVerifiableCredential(credential);
426
+ if (service.revoked) {
427
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerificationFailed, { failureReason: "revoked" });
464
428
  }
465
- catch (error) {
466
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
429
+ else {
430
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);
467
431
  }
468
- });
432
+ return service;
433
+ }
434
+ catch (error) {
435
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
436
+ }
469
437
  }
470
438
  /**
471
439
  * Revoke verifiable credential.
@@ -478,18 +446,16 @@ export class IdentityService {
478
446
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
479
447
  Guards.stringValue(IdentityService.CLASS_NAME, "issuerIdentity", issuerIdentity);
480
448
  Guards.number(IdentityService.CLASS_NAME, "credentialIndex", credentialIndex);
481
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerifiableCredentialRevoke, { attributes: { [IdentitySpanAttributes.Id]: issuerIdentity } }, async () => {
482
- try {
483
- const idParts = DocumentHelper.parseId(issuerIdentity);
484
- const identityConnector = this.getConnectorByUri(idParts.id);
485
- const result = await identityConnector.revokeVerifiableCredentials(controller, issuerIdentity, [credentialIndex]);
486
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsRevoked);
487
- return result;
488
- }
489
- catch (error) {
490
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialRevokeFailed", { issuerIdentity, credentialIndex }, error);
491
- }
492
- });
449
+ try {
450
+ const idParts = DocumentHelper.parseId(issuerIdentity);
451
+ const identityConnector = this.getConnectorByUri(idParts.id);
452
+ const result = await identityConnector.revokeVerifiableCredentials(controller, issuerIdentity, [credentialIndex]);
453
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsRevoked);
454
+ return result;
455
+ }
456
+ catch (error) {
457
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialRevokeFailed", { issuerIdentity, credentialIndex }, error);
458
+ }
493
459
  }
494
460
  /**
495
461
  * Unrevoke verifiable credential.
@@ -502,18 +468,16 @@ export class IdentityService {
502
468
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
503
469
  Guards.stringValue(IdentityService.CLASS_NAME, "issuerIdentity", issuerIdentity);
504
470
  Guards.number(IdentityService.CLASS_NAME, "credentialIndex", credentialIndex);
505
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerifiableCredentialUnrevoke, { attributes: { [IdentitySpanAttributes.Id]: issuerIdentity } }, async () => {
506
- try {
507
- const idParts = DocumentHelper.parseId(issuerIdentity);
508
- const identityConnector = this.getConnectorByUri(idParts.id);
509
- const result = await identityConnector.unrevokeVerifiableCredentials(controller, issuerIdentity, [credentialIndex]);
510
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsUnrevoked);
511
- return result;
512
- }
513
- catch (error) {
514
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialUnrevokeFailed", { issuerIdentity, credentialIndex }, error);
515
- }
516
- });
471
+ try {
472
+ const idParts = DocumentHelper.parseId(issuerIdentity);
473
+ const identityConnector = this.getConnectorByUri(idParts.id);
474
+ const result = await identityConnector.unrevokeVerifiableCredentials(controller, issuerIdentity, [credentialIndex]);
475
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsUnrevoked);
476
+ return result;
477
+ }
478
+ catch (error) {
479
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialUnrevokeFailed", { issuerIdentity, credentialIndex }, error);
480
+ }
517
481
  }
518
482
  /**
519
483
  * Create a verifiable presentation from the supplied verifiable credentials.
@@ -533,20 +497,18 @@ export class IdentityService {
533
497
  async verifiablePresentationCreate(verificationMethodId, presentationId, contexts, types, verifiableCredentials, options, controller) {
534
498
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
535
499
  Guards.stringValue(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
536
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerifiablePresentationCreate, { attributes: { [IdentitySpanAttributes.VerificationMethodId]: verificationMethodId } }, async () => {
537
- try {
538
- const idParts = DocumentHelper.parseId(verificationMethodId);
539
- const identityConnector = this.getConnectorByUri(idParts.id);
540
- const result = await identityConnector.createVerifiablePresentation(controller, verificationMethodId, presentationId, contexts, types, verifiableCredentials, options);
541
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsCreated, {
542
- credentialCount: verifiableCredentials.length
543
- });
544
- return result;
545
- }
546
- catch (error) {
547
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationCreateFailed", { verificationMethodId }, error);
548
- }
549
- });
500
+ try {
501
+ const idParts = DocumentHelper.parseId(verificationMethodId);
502
+ const identityConnector = this.getConnectorByUri(idParts.id);
503
+ const result = await identityConnector.createVerifiablePresentation(controller, verificationMethodId, presentationId, contexts, types, verifiableCredentials, options);
504
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsCreated, {
505
+ credentialCount: verifiableCredentials.length
506
+ });
507
+ return result;
508
+ }
509
+ catch (error) {
510
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationCreateFailed", { verificationMethodId }, error);
511
+ }
550
512
  }
551
513
  /**
552
514
  * Verify a verifiable presentation is valid.
@@ -573,22 +535,20 @@ export class IdentityService {
573
535
  holder = presentation.holder;
574
536
  }
575
537
  Guards.stringValue(IdentityService.CLASS_NAME, "holder", holder);
576
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.VerifiablePresentationVerify, undefined, async () => {
577
- try {
578
- const identityConnector = this.getConnectorByUri(holder);
579
- const service = await identityConnector.checkVerifiablePresentation(presentation);
580
- if (service.revoked) {
581
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerificationFailed, { failureReason: "revoked" });
582
- }
583
- else {
584
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerified);
585
- }
586
- return service;
538
+ try {
539
+ const identityConnector = this.getConnectorByUri(holder);
540
+ const service = await identityConnector.checkVerifiablePresentation(presentation);
541
+ if (service.revoked) {
542
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerificationFailed, { failureReason: "revoked" });
587
543
  }
588
- catch (error) {
589
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationVerifyFailed", undefined, error);
544
+ else {
545
+ await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerified);
590
546
  }
591
- });
547
+ return service;
548
+ }
549
+ catch (error) {
550
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationVerifyFailed", undefined, error);
551
+ }
592
552
  }
593
553
  /**
594
554
  * Create a proof for a document with the specified verification method.
@@ -603,17 +563,15 @@ export class IdentityService {
603
563
  Guards.stringValue(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
604
564
  Guards.arrayOneOf(IdentityService.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
605
565
  Guards.object(IdentityService.CLASS_NAME, "unsecureDocument", unsecureDocument);
606
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.ProofCreate, { attributes: { [IdentitySpanAttributes.VerificationMethodId]: verificationMethodId } }, async () => {
607
- try {
608
- const idParts = DocumentHelper.parseId(verificationMethodId);
609
- const identityConnector = this.getConnectorByUri(idParts.id);
610
- const result = await identityConnector.createProof(controller, verificationMethodId, proofType, unsecureDocument);
611
- return result;
612
- }
613
- catch (error) {
614
- throw new GeneralError(IdentityService.CLASS_NAME, "proofCreateFailed", { verificationMethodId }, error);
615
- }
616
- });
566
+ try {
567
+ const idParts = DocumentHelper.parseId(verificationMethodId);
568
+ const identityConnector = this.getConnectorByUri(idParts.id);
569
+ const result = await identityConnector.createProof(controller, verificationMethodId, proofType, unsecureDocument);
570
+ return result;
571
+ }
572
+ catch (error) {
573
+ throw new GeneralError(IdentityService.CLASS_NAME, "proofCreateFailed", { verificationMethodId }, error);
574
+ }
617
575
  }
618
576
  /**
619
577
  * Verify proof for a document with the specified verification method.
@@ -625,18 +583,15 @@ export class IdentityService {
625
583
  Guards.object(IdentityService.CLASS_NAME, "document", document);
626
584
  Guards.object(IdentityService.CLASS_NAME, "proof", proof);
627
585
  Guards.stringValue(IdentityService.CLASS_NAME, "proof.verificationMethod", proof.verificationMethod);
628
- const verificationMethod = proof.verificationMethod;
629
- return TracingHelper.withSpan(this._tracingComponent, IdentitySpanNames.ProofVerify, undefined, async () => {
630
- try {
631
- const idParts = DocumentHelper.parseId(verificationMethod);
632
- const identityConnector = this.getConnectorByUri(idParts.id);
633
- const result = await identityConnector.verifyProof(document, proof);
634
- return result;
635
- }
636
- catch (error) {
637
- throw new GeneralError(IdentityService.CLASS_NAME, "proofVerifyFailed", undefined, error);
638
- }
639
- });
586
+ try {
587
+ const idParts = DocumentHelper.parseId(proof.verificationMethod);
588
+ const identityConnector = this.getConnectorByUri(idParts.id);
589
+ const result = await identityConnector.verifyProof(document, proof);
590
+ return result;
591
+ }
592
+ catch (error) {
593
+ throw new GeneralError(IdentityService.CLASS_NAME, "proofVerifyFailed", undefined, error);
594
+ }
640
595
  }
641
596
  /**
642
597
  * Get the connector from the namespace.
@@ -1 +1 @@
1
- {"version":3,"file":"identityService.js","sourceRoot":"","sources":["../../src/identityService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,cAAc,EACd,YAAY,EAIZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,gCAAgC,EAIhC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EACzB,UAAU,EAOV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAA4B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,aAAa,EAA0B,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAwB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC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YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAC3F,CAAC;QACF,CAAC,CACD,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACK,uBAAuB,CAAC,SAAkB;QACjD,MAAM,eAAe,GAAG,SAAS,IAAI,IAAI,CAAC,iBAAiB,CAAC;QAE5D,MAAM,SAAS,GAAG,wBAAwB,CAAC,WAAW,CAAqB,eAAe,CAAC,CAAC;QAE5F,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,eAAe;aAC1B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHealthCategory,\n\tHealthStatus,\n\ttype HealthApplicationCallback,\n\ttype IHealth,\n\ttype IHealthProviderComponent\n} from \"@twin.org/api-models\";\nimport type { IContextIds } from \"@twin.org/context\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { BaseError, ComponentFactory, GeneralError, Guards, Is, Urn } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { AccountHelper } from \"@twin.org/dlt-account\";\nimport {\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityMetricIds,\n\tIdentitySpanAttributes,\n\tIdentitySpanNames,\n\tIdentityMetrics,\n\tIdentityResolverConnectorFactory,\n\ttype IIdentityComponent,\n\ttype IIdentityConnector,\n\ttype IIdentityResolverConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IProof,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport { MetricHelper, type ITelemetryComponent } from \"@twin.org/telemetry-models\";\nimport { TracingHelper, type ITracingComponent } from \"@twin.org/tracing-models\";\nimport { type IVaultConnector, VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport { Jwt } from \"@twin.org/web\";\nimport type { IIdentityServiceConstructorOptions } from \"./models/IIdentityServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity contract.\n */\nexport class IdentityService implements IIdentityComponent, IHealthProviderComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * The vault connector type used for mnemonic migration during health check init.\n\t * @internal\n\t */\n\tprivate readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * The telemetry component.\n\t * @internal\n\t */\n\tprivate readonly _telemetryComponent?: ITelemetryComponent;\n\n\t/**\n\t * The optional tracing component for recording spans.\n\t * @internal\n\t */\n\tprivate readonly _tracingComponent?: ITracingComponent;\n\n\t/**\n\t * Create a new instance of IdentityService.\n\t * @param options The options for the service.\n\t * @throws GeneralError if no connectors are registered.\n\t */\n\tconstructor(options?: IIdentityServiceConstructorOptions) {\n\t\tconst names = IdentityConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\n\t\tthis._telemetryComponent = ComponentFactory.getIfExists<ITelemetryComponent>(\n\t\t\toptions?.telemetryComponentType\n\t\t);\n\t\tthis._tracingComponent = ComponentFactory.getIfExists<ITracingComponent>(\n\t\t\toptions?.tracingComponentType\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Register all identity metrics with the telemetry component.\n\t * @returns A promise that resolves when all metrics have been registered.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tif (Is.undefined(this._telemetryComponent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait MetricHelper.createMetrics(this._telemetryComponent, IdentityMetrics);\n\t}\n\n\t/**\n\t * Creates a temporary DID document for the application health check.\n\t * @param contextIds The context IDs accumulated by prior init steps.\n\t */\n\tpublic async healthApplicationInit(contextIds: IContextIds): Promise<void> {\n\t\t// The wallet service has already setup a temporary controller DID mnemonic for the health check\n\t\t// so we can use that to create a new document and add a verification method to it.\n\t\tconst controller = contextIds[ContextIdKeys.Organization];\n\t\tif (!Is.stringValue(controller)) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst connector = this.getConnectorByNamespace();\n\t\t\tconst doc = await connector.createDocument(controller);\n\t\t\tawait connector.addVerificationMethod(\n\t\t\t\tcontroller,\n\t\t\t\tdoc.id,\n\t\t\t\tDidVerificationMethodType.AssertionMethod,\n\t\t\t\t\"health-assertion\"\n\t\t\t);\n\n\t\t\t// The original seed/mnemonic/keys were created with the temp orgId\n\t\t\t// so we need to migrate them to the new document id so that the health check can resolve the DID.\n\t\t\tawait AccountHelper.renameAccountKeys(undefined, this._vaultConnector, controller, doc.id);\n\n\t\t\t// Replace the updated contextIds with the new document id for the health check.\n\t\t\tcontextIds[ContextIdKeys.Organization] = doc.id;\n\t\t} catch {}\n\t}\n\n\t/**\n\t * Returns the application health status of the identity service by resolving the DID created\n\t * in healthApplicationInit.\n\t * @param callback Callback for deferred results.\n\t * @returns The health status of the service.\n\t */\n\tpublic async healthApplication(\n\t\tcallback: HealthApplicationCallback\n\t): Promise<IHealth[] | undefined> {\n\t\tconst contextIds = (await ContextIdStore.getContextIds()) ?? {};\n\t\tconst orgDid = contextIds[ContextIdKeys.Organization];\n\n\t\tif (!Is.stringValue(orgDid)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: IdentityService.CLASS_NAME,\n\t\t\t\t\tcategory: HealthCategory.Application,\n\t\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tmessage: \"createDocumentFailed\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tdid: orgDid\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t];\n\t\t}\n\n\t\ttry {\n\t\t\tconst resolverConnector =\n\t\t\t\tIdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(\n\t\t\t\t\tthis._defaultNamespace\n\t\t\t\t);\n\t\t\tif (!Is.undefined(resolverConnector)) {\n\t\t\t\tconst resolved = await resolverConnector.resolveDocument(orgDid);\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: IdentityService.CLASS_NAME,\n\t\t\t\t\t\tcategory: HealthCategory.Application,\n\t\t\t\t\t\tstatus: Is.object(resolved) ? HealthStatus.Ok : HealthStatus.Error,\n\t\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\t\tmessage: Is.object(resolved) ? undefined : \"resolveDocumentFailed\",\n\t\t\t\t\t\tdata: { did: orgDid }\n\t\t\t\t\t}\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: IdentityService.CLASS_NAME,\n\t\t\t\t\tcategory: HealthCategory.Application,\n\t\t\t\t\tstatus: HealthStatus.Ok,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tdata: { did: orgDid }\n\t\t\t\t}\n\t\t\t];\n\t\t} catch (error) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: IdentityService.CLASS_NAME,\n\t\t\t\t\tcategory: HealthCategory.Application,\n\t\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tmessage: \"resolveDocumentFailed\",\n\t\t\t\t\tdata: { did: orgDid },\n\t\t\t\t\terror: BaseError.fromError(error)\n\t\t\t\t}\n\t\t\t];\n\t\t}\n\t}\n\n\t/**\n\t * Removes the DID document created in healthApplicationInit.\n\t */\n\tpublic async healthApplicationTeardown(): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst orgId = contextIds?.[ContextIdKeys.Organization];\n\t\tif (!Is.stringValue(orgId)) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst connector = this.getConnectorByNamespace();\n\t\t\tawait connector.removeVerificationMethod(orgId, `${orgId}#health-assertion`, {\n\t\t\t\tremoveKeys: true\n\t\t\t});\n\t\t\tawait connector.removeDocument(orgId, orgId);\n\t\t} catch {}\n\t}\n\n\t/**\n\t * Create a new identity.\n\t * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string, controller?: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.Create,\n\t\t\tundefined,\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst identityConnector = this.getConnectorByNamespace(namespace);\n\t\t\t\t\tconst result = await identityConnector.createDocument(controller);\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.DidsCreated,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tnamespace: namespace ?? this._defaultNamespace\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"identityCreateFailed\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private keys from the vault.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the identity has been removed.\n\t */\n\tpublic async identityRemove(\n\t\tidentity: string,\n\t\toptions?: { removeKeys?: boolean },\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.Remove,\n\t\t\t{ attributes: { [IdentitySpanAttributes.Id]: identity } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\t\t\t\t\tconst result = await identityConnector.removeDocument(controller, identity, options);\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.DidsRemoved\n\t\t\t\t\t);\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"identityRemoveFailed\",\n\t\t\t\t\t\t{ identity },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param identity The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async verificationMethodCreate(\n\t\tidentity: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string,\n\t\tcontroller?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\n\t\tGuards.arrayOneOf(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.VerificationMethodCreate,\n\t\t\t{ attributes: { [IdentitySpanAttributes.Id]: identity } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\t\t\tconst verificationMethod = await identityConnector.addVerificationMethod(\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tidentity,\n\t\t\t\t\t\tverificationMethodType,\n\t\t\t\t\t\tverificationMethodId\n\t\t\t\t\t);\n\n\t\t\t\t\treturn verificationMethod;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"verificationMethodCreateFailed\",\n\t\t\t\t\t\t{ identity },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private key from the vault.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the verification method has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async verificationMethodRemove(\n\t\tverificationMethodId: string,\n\t\toptions?: { removeKeys?: boolean },\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\n\t\tawait TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.VerificationMethodRemove,\n\t\t\t{ attributes: { [IdentitySpanAttributes.VerificationMethodId]: verificationMethodId } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tawait identityConnector.removeVerificationMethod(\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tverificationMethodId,\n\t\t\t\t\t\toptions\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"verificationMethodRemoveFailed\",\n\t\t\t\t\t\t{ verificationMethodId },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param identity The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceCreate(\n\t\tidentity: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[],\n\t\tcontroller?: string\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.ServiceCreate,\n\t\t\t{ attributes: { [IdentitySpanAttributes.Id]: identity } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\t\t\tconst service = await identityConnector.addService(\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tidentity,\n\t\t\t\t\t\tserviceId,\n\t\t\t\t\t\tserviceType,\n\t\t\t\t\t\tserviceEndpoint\n\t\t\t\t\t);\n\n\t\t\t\t\treturn service;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"serviceCreateFailed\",\n\t\t\t\t\t\t{ identity, serviceId },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\tawait TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.ServiceRemove,\n\t\t\t{ attributes: { [IdentitySpanAttributes.ServiceId]: serviceId } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tawait identityConnector.removeService(controller, serviceId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"serviceRemoveFailed\",\n\t\t\t\t\t\t{ serviceId },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the alias has been added.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async alsoKnownAsAdd(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\tawait TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.AlsoKnownAsAdd,\n\t\t\t{ attributes: { [IdentitySpanAttributes.Id]: documentId } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tawait identityConnector.addAlsoKnownAs(controller, documentId, alias);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"alsoKnownAsAddFailed\",\n\t\t\t\t\t\t{ identity: documentId, alias },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the alias has been removed.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async alsoKnownAsRemove(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\tawait TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.AlsoKnownAsRemove,\n\t\t\t{ attributes: { [IdentitySpanAttributes.Id]: documentId } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tawait identityConnector.removeAlsoKnownAs(controller, documentId, alias);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"alsoKnownAsRemoveFailed\",\n\t\t\t\t\t\t{ identity: documentId, alias },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable credential in jwt format.\n\t * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async verifiableCredentialCreate(\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t},\n\t\tcontroller?: string\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\t\tGuards.object(IdentityService.CLASS_NAME, nameof(subject), subject);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.VerifiableCredentialCreate,\n\t\t\t{ attributes: { [IdentitySpanAttributes.VerificationMethodId]: verificationMethodId } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tconst service = await identityConnector.createVerifiableCredential(\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tverificationMethodId,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsubject,\n\t\t\t\t\t\toptions\n\t\t\t\t\t);\n\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsCreated,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thasRevocation: Is.number(options?.revocationIndex),\n\t\t\t\t\t\t\thasExpiration: Is.date(options?.expirationDate)\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\treturn service;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"verifiableCredentialCreateFailed\",\n\t\t\t\t\t\t{ verificationMethodId },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Verify a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiableCredentialVerify(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential.issuer), credential.issuer);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\n\t\t\tconst issuer = credential.issuer;\n\t\t\tconst verifiableCredential = credential;\n\n\t\t\treturn TracingHelper.withSpan(\n\t\t\t\tthis._tracingComponent,\n\t\t\t\tIdentitySpanNames.VerifiableCredentialVerify,\n\t\t\t\tundefined,\n\t\t\t\tasync () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst identityConnector = this.getConnectorByUri(issuer);\n\n\t\t\t\t\t\tconst service = await identityConnector.checkVerifiableCredential(verifiableCredential);\n\n\t\t\t\t\t\tif (service.revoked) {\n\t\t\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\t\t\tIdentityMetricIds.VcsVerified\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn service;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\terror\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential), credential);\n\n\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\tconst jwtHeader = jwtDecoded.header;\n\t\tconst jwtPayload = jwtDecoded.payload;\n\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\tif (\n\t\t\tIs.undefined(jwtHeader) ||\n\t\t\tIs.undefined(jwtPayload) ||\n\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\tIs.undefined(jwtSignature)\n\t\t) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t}\n\n\t\tconst issuer = jwtPayload.iss;\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.VerifiableCredentialVerify,\n\t\t\tundefined,\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(issuer);\n\n\t\t\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\t\t\tif (service.revoked) {\n\t\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\t\tIdentityMetricIds.VcsVerified\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn service;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the credential has been revoked.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.VerifiableCredentialRevoke,\n\t\t\t{ attributes: { [IdentitySpanAttributes.Id]: issuerIdentity } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tconst result = await identityConnector.revokeVerifiableCredentials(\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tissuerIdentity,\n\t\t\t\t\t\t[credentialIndex]\n\t\t\t\t\t);\n\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsRevoked\n\t\t\t\t\t);\n\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"verifiableCredentialRevokeFailed\",\n\t\t\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the credential has been unrevoked.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.VerifiableCredentialUnrevoke,\n\t\t\t{ attributes: { [IdentitySpanAttributes.Id]: issuerIdentity } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tconst result = await identityConnector.unrevokeVerifiableCredentials(\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tissuerIdentity,\n\t\t\t\t\t\t[credentialIndex]\n\t\t\t\t\t);\n\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsUnrevoked\n\t\t\t\t\t);\n\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"verifiableCredentialUnrevokeFailed\",\n\t\t\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param options Additional options for creating the verifiable presentation.\n\t * @param options.expirationDate The date the verifiable presentation is valid until.\n\t * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable presentation in jwt format.\n\t * @param options.jwtPayloadFields\tAdditional fields to include in the JWT payload when creating the verifiable presentation in jwt format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async verifiablePresentationCreate(\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredential)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t},\n\t\tcontroller?: string\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.VerifiablePresentationCreate,\n\t\t\t{ attributes: { [IdentitySpanAttributes.VerificationMethodId]: verificationMethodId } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tconst result = await identityConnector.createVerifiablePresentation(\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tverificationMethodId,\n\t\t\t\t\t\tpresentationId,\n\t\t\t\t\t\tcontexts,\n\t\t\t\t\t\ttypes,\n\t\t\t\t\t\tverifiableCredentials,\n\t\t\t\t\t\toptions\n\t\t\t\t\t);\n\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VpsCreated,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcredentialCount: verifiableCredentials.length\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"verifiablePresentationCreateFailed\",\n\t\t\t\t\t\t{ verificationMethodId },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Verify a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiablePresentationVerify(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentation;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tlet holder;\n\t\tif (Is.stringValue(presentation)) {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(presentation), presentation);\n\n\t\t\tconst jwtDecoded = await Jwt.decode(presentation);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t\t}\n\n\t\t\tholder = jwtPayload.iss;\n\t\t} else {\n\t\t\tholder = presentation.holder;\n\t\t}\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(holder), holder);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.VerifiablePresentationVerify,\n\t\t\tundefined,\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(holder);\n\n\t\t\t\t\tconst service = await identityConnector.checkVerifiablePresentation(presentation);\n\n\t\t\t\t\tif (service.revoked) {\n\t\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\t\tIdentityMetricIds.VpsVerificationFailed,\n\t\t\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\t\tIdentityMetricIds.VpsVerified\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn service;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"verifiablePresentationVerifyFailed\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Create a proof for a document with the specified verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject,\n\t\tcontroller?: string\n\t): Promise<IProof> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.ProofCreate,\n\t\t\t{ attributes: { [IdentitySpanAttributes.VerificationMethodId]: verificationMethodId } },\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tconst result = await identityConnector.createProof(\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tverificationMethodId,\n\t\t\t\t\t\tproofType,\n\t\t\t\t\t\tunsecureDocument\n\t\t\t\t\t);\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\t\"proofCreateFailed\",\n\t\t\t\t\t\t{ verificationMethodId },\n\t\t\t\t\t\terror\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Verify proof for a document with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async proofVerify(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(IdentityService.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityService.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\tconst verificationMethod = proof.verificationMethod;\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracingComponent,\n\t\t\tIdentitySpanNames.ProofVerify,\n\t\t\tundefined,\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst idParts = DocumentHelper.parseId(verificationMethod);\n\n\t\t\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\t\t\tconst result = await identityConnector.verifyProof(document, proof);\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"proofVerifyFailed\", undefined, error);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @throws GeneralError if the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tconst connector = IdentityConnectorFactory.getIfExists<IIdentityConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\tnamespace: namespaceMethod\n\t\t\t});\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @throws GeneralError if the namespace does not match or the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityService.js","sourceRoot":"","sources":["../../src/identityService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,cAAc,EACd,YAAY,EAIZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,gCAAgC,EAIhC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EACzB,UAAU,EAOV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAA4B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAwB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,eAAe;IAC3B;;OAEG;IACI,MAAM,CAAU,UAAU,qBAAqC;IAEtE;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACc,eAAe,CAAkB;IAElD;;;OAGG;IACc,mBAAmB,CAAuB;IAE3D;;;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SAAS,IAAI,IAAI,CAAC,iBAAiB,CAAC;QAE5D,MAAM,SAAS,GAAG,wBAAwB,CAAC,WAAW,CAAqB,eAAe,CAAC,CAAC;QAE5F,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,eAAe;aAC1B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHealthCategory,\n\tHealthStatus,\n\ttype HealthApplicationCallback,\n\ttype IHealth,\n\ttype IHealthProviderComponent\n} from \"@twin.org/api-models\";\nimport type { IContextIds } from \"@twin.org/context\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { BaseError, ComponentFactory, GeneralError, Guards, Is, Urn } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { AccountHelper } from \"@twin.org/dlt-account\";\nimport {\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityMetricIds,\n\tIdentityMetrics,\n\tIdentityResolverConnectorFactory,\n\ttype IIdentityComponent,\n\ttype IIdentityConnector,\n\ttype IIdentityResolverConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IProof,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport { MetricHelper, type ITelemetryComponent } from \"@twin.org/telemetry-models\";\nimport { type IVaultConnector, VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport { Jwt } from \"@twin.org/web\";\nimport type { IIdentityServiceConstructorOptions } from \"./models/IIdentityServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity contract.\n */\nexport class IdentityService implements IIdentityComponent, IHealthProviderComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * The vault connector type used for mnemonic migration during health check init.\n\t * @internal\n\t */\n\tprivate readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * The telemetry component.\n\t * @internal\n\t */\n\tprivate readonly _telemetryComponent?: ITelemetryComponent;\n\n\t/**\n\t * Create a new instance of IdentityService.\n\t * @param options The options for the service.\n\t * @throws GeneralError if no connectors are registered.\n\t */\n\tconstructor(options?: IIdentityServiceConstructorOptions) {\n\t\tconst names = IdentityConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\n\t\tthis._telemetryComponent = ComponentFactory.getIfExists<ITelemetryComponent>(\n\t\t\toptions?.telemetryComponentType\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Register all identity metrics with the telemetry component.\n\t * @returns A promise that resolves when all metrics have been registered.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tif (Is.undefined(this._telemetryComponent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait MetricHelper.createMetrics(this._telemetryComponent, IdentityMetrics);\n\t}\n\n\t/**\n\t * Creates a temporary DID document for the application health check.\n\t * @param contextIds The context IDs accumulated by prior init steps.\n\t */\n\tpublic async healthApplicationInit(contextIds: IContextIds): Promise<void> {\n\t\t// The wallet service has already setup a temporary controller DID mnemonic for the health check\n\t\t// so we can use that to create a new document and add a verification method to it.\n\t\tconst controller = contextIds[ContextIdKeys.Organization];\n\t\tif (!Is.stringValue(controller)) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst connector = this.getConnectorByNamespace();\n\t\t\tconst doc = await connector.createDocument(controller);\n\t\t\tawait connector.addVerificationMethod(\n\t\t\t\tcontroller,\n\t\t\t\tdoc.id,\n\t\t\t\tDidVerificationMethodType.AssertionMethod,\n\t\t\t\t\"health-assertion\"\n\t\t\t);\n\n\t\t\t// The original seed/mnemonic/keys were created with the temp orgId\n\t\t\t// so we need to migrate them to the new document id so that the health check can resolve the DID.\n\t\t\tawait AccountHelper.renameAccountKeys(undefined, this._vaultConnector, controller, doc.id);\n\n\t\t\t// Replace the updated contextIds with the new document id for the health check.\n\t\t\tcontextIds[ContextIdKeys.Organization] = doc.id;\n\t\t} catch {}\n\t}\n\n\t/**\n\t * Returns the application health status of the identity service by resolving the DID created\n\t * in healthApplicationInit.\n\t * @param callback Callback for deferred results.\n\t * @returns The health status of the service.\n\t */\n\tpublic async healthApplication(\n\t\tcallback: HealthApplicationCallback\n\t): Promise<IHealth[] | undefined> {\n\t\tconst contextIds = (await ContextIdStore.getContextIds()) ?? {};\n\t\tconst orgDid = contextIds[ContextIdKeys.Organization];\n\n\t\tif (!Is.stringValue(orgDid)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: IdentityService.CLASS_NAME,\n\t\t\t\t\tcategory: HealthCategory.Application,\n\t\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tmessage: \"createDocumentFailed\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tdid: orgDid\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t];\n\t\t}\n\n\t\ttry {\n\t\t\tconst resolverConnector =\n\t\t\t\tIdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(\n\t\t\t\t\tthis._defaultNamespace\n\t\t\t\t);\n\t\t\tif (!Is.undefined(resolverConnector)) {\n\t\t\t\tconst resolved = await resolverConnector.resolveDocument(orgDid);\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: IdentityService.CLASS_NAME,\n\t\t\t\t\t\tcategory: HealthCategory.Application,\n\t\t\t\t\t\tstatus: Is.object(resolved) ? HealthStatus.Ok : HealthStatus.Error,\n\t\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\t\tmessage: Is.object(resolved) ? undefined : \"resolveDocumentFailed\",\n\t\t\t\t\t\tdata: { did: orgDid }\n\t\t\t\t\t}\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: IdentityService.CLASS_NAME,\n\t\t\t\t\tcategory: HealthCategory.Application,\n\t\t\t\t\tstatus: HealthStatus.Ok,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tdata: { did: orgDid }\n\t\t\t\t}\n\t\t\t];\n\t\t} catch (error) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: IdentityService.CLASS_NAME,\n\t\t\t\t\tcategory: HealthCategory.Application,\n\t\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tmessage: \"resolveDocumentFailed\",\n\t\t\t\t\tdata: { did: orgDid },\n\t\t\t\t\terror: BaseError.fromError(error)\n\t\t\t\t}\n\t\t\t];\n\t\t}\n\t}\n\n\t/**\n\t * Removes the DID document created in healthApplicationInit.\n\t */\n\tpublic async healthApplicationTeardown(): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst orgId = contextIds?.[ContextIdKeys.Organization];\n\t\tif (!Is.stringValue(orgId)) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst connector = this.getConnectorByNamespace();\n\t\t\tawait connector.removeVerificationMethod(orgId, `${orgId}#health-assertion`, {\n\t\t\t\tremoveKeys: true\n\t\t\t});\n\t\t\tawait connector.removeDocument(orgId, orgId);\n\t\t} catch {}\n\t}\n\n\t/**\n\t * Create a new identity.\n\t * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string, controller?: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByNamespace(namespace);\n\t\t\tconst result = await identityConnector.createDocument(controller);\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsCreated, {\n\t\t\t\tnamespace: namespace ?? this._defaultNamespace\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"identityCreateFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private keys from the vault.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the identity has been removed.\n\t */\n\tpublic async identityRemove(\n\t\tidentity: string,\n\t\toptions?: { removeKeys?: boolean },\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\t\t\tconst result = await identityConnector.removeDocument(controller, identity, options);\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsRemoved);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"identityRemoveFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param identity The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async verificationMethodCreate(\n\t\tidentity: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string,\n\t\tcontroller?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\n\t\tGuards.arrayOneOf(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst verificationMethod = await identityConnector.addVerificationMethod(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t);\n\n\t\t\treturn verificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodCreateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private key from the vault.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the verification method has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async verificationMethodRemove(\n\t\tverificationMethodId: string,\n\t\toptions?: { removeKeys?: boolean },\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeVerificationMethod(controller, verificationMethodId, options);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodRemoveFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param identity The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceCreate(\n\t\tidentity: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[],\n\t\tcontroller?: string\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst service = await identityConnector.addService(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tserviceId,\n\t\t\t\tserviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceCreateFailed\",\n\t\t\t\t{ identity, serviceId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeService(controller, serviceId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceRemoveFailed\",\n\t\t\t\t{ serviceId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the alias has been added.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async alsoKnownAsAdd(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.addAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsAddFailed\",\n\t\t\t\t{ identity: documentId, alias },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the alias has been removed.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async alsoKnownAsRemove(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsRemoveFailed\",\n\t\t\t\t{ identity: documentId, alias },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable credential in jwt format.\n\t * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async verifiableCredentialCreate(\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t},\n\t\tcontroller?: string\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\t\tGuards.object(IdentityService.CLASS_NAME, nameof(subject), subject);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst service = await identityConnector.createVerifiableCredential(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tid,\n\t\t\t\tsubject,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsCreated, {\n\t\t\t\thasRevocation: Is.number(options?.revocationIndex),\n\t\t\t\thasExpiration: Is.date(options?.expirationDate)\n\t\t\t});\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiableCredentialVerify(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential.issuer), credential.issuer);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\n\t\t\ttry {\n\t\t\t\tconst identityConnector = this.getConnectorByUri(credential.issuer);\n\n\t\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\t\tif (service.revoked) {\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsVerified\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn service;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\t\tundefined,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential), credential);\n\n\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\tconst jwtHeader = jwtDecoded.header;\n\t\tconst jwtPayload = jwtDecoded.payload;\n\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\tif (\n\t\t\tIs.undefined(jwtHeader) ||\n\t\t\tIs.undefined(jwtPayload) ||\n\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\tIs.undefined(jwtSignature)\n\t\t) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(jwtPayload.iss);\n\n\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\tif (service.revoked) {\n\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);\n\t\t\t}\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the credential has been revoked.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.revokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsRevoked);\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialRevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the credential has been unrevoked.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.unrevokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsUnrevoked);\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialUnrevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param options Additional options for creating the verifiable presentation.\n\t * @param options.expirationDate The date the verifiable presentation is valid until.\n\t * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable presentation in jwt format.\n\t * @param options.jwtPayloadFields\tAdditional fields to include in the JWT payload when creating the verifiable presentation in jwt format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async verifiablePresentationCreate(\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredential)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t},\n\t\tcontroller?: string\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createVerifiablePresentation(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsCreated, {\n\t\t\t\tcredentialCount: verifiableCredentials.length\n\t\t\t});\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiablePresentationVerify(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentation;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tlet holder;\n\t\tif (Is.stringValue(presentation)) {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(presentation), presentation);\n\n\t\t\tconst jwtDecoded = await Jwt.decode(presentation);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t\t}\n\n\t\t\tholder = jwtPayload.iss;\n\t\t} else {\n\t\t\tholder = presentation.holder;\n\t\t}\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(holder), holder);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(holder);\n\n\t\t\tconst service = await identityConnector.checkVerifiablePresentation(presentation);\n\n\t\t\tif (service.revoked) {\n\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\tIdentityMetricIds.VpsVerificationFailed,\n\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerified);\n\t\t\t}\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationVerifyFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a proof for a document with the specified verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject,\n\t\tcontroller?: string\n\t): Promise<IProof> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"proofCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify proof for a document with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async proofVerify(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(IdentityService.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityService.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(proof.verificationMethod);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.verifyProof(document, proof);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"proofVerifyFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @throws GeneralError if the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tconst connector = IdentityConnectorFactory.getIfExists<IIdentityConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\tnamespace: namespaceMethod\n\t\t\t});\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @throws GeneralError if the namespace does not match or the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IIdentityServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IIdentityServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IIdentityServiceConfig } from \"./IIdentityServiceConfig.js\";\n\n/**\n * Options for the identity service constructor.\n */\nexport interface IIdentityServiceConstructorOptions {\n\t/**\n\t * The configuration for the identity service.\n\t */\n\tconfig?: IIdentityServiceConfig;\n\n\t/**\n\t * The component type for the optional telemetry component used for event metrics.\n\t */\n\ttelemetryComponentType?: string;\n\n\t/**\n\t * The component type for the optional tracing component used for spans.\n\t */\n\ttracingComponentType?: string;\n\n\t/**\n\t * The vault connector type to use for migrating the mnemonic during health check initialisation.\n\t * @default vault\n\t */\n\tvaultConnectorType?: string;\n}\n"]}
1
+ {"version":3,"file":"IIdentityServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IIdentityServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IIdentityServiceConfig } from \"./IIdentityServiceConfig.js\";\n\n/**\n * Options for the identity service constructor.\n */\nexport interface IIdentityServiceConstructorOptions {\n\t/**\n\t * The configuration for the identity service.\n\t */\n\tconfig?: IIdentityServiceConfig;\n\n\t/**\n\t * The component type for the optional telemetry component used for event metrics.\n\t */\n\ttelemetryComponentType?: string;\n\n\t/**\n\t * The vault connector type to use for migrating the mnemonic during health check initialisation.\n\t * @default vault\n\t */\n\tvaultConnectorType?: string;\n}\n"]}
@@ -11,10 +11,6 @@ export interface IIdentityServiceConstructorOptions {
11
11
  * The component type for the optional telemetry component used for event metrics.
12
12
  */
13
13
  telemetryComponentType?: string;
14
- /**
15
- * The component type for the optional tracing component used for spans.
16
- */
17
- tracingComponentType?: string;
18
14
  /**
19
15
  * The vault connector type to use for migrating the mnemonic during health check initialisation.
20
16
  * @default vault
package/docs/changelog.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.3-next.4](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.9.3-next.3...identity-service-v0.9.3-next.4) (2026-09-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * remove inline service tracing in favour of the tracing facade ([#228](https://github.com/iotaledger/twin-identity/issues/228)) ([583e587](https://github.com/iotaledger/twin-identity/commit/583e5873fa396b26207db5ac0ae9a1779866853c))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/identity-models bumped from 0.9.3-next.3 to 0.9.3-next.4
16
+ * devDependencies
17
+ * @twin.org/identity-connector-entity-storage bumped from 0.9.3-next.3 to 0.9.3-next.4
18
+
3
19
  ## [0.9.3-next.3](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.9.3-next.2...identity-service-v0.9.3-next.3) (2026-09-07)
4
20
 
5
21
 
@@ -20,14 +20,6 @@ The component type for the optional telemetry component used for event metrics.
20
20
 
21
21
  ***
22
22
 
23
- ### tracingComponentType? {#tracingcomponenttype}
24
-
25
- > `optional` **tracingComponentType?**: `string`
26
-
27
- The component type for the optional tracing component used for spans.
28
-
29
- ***
30
-
31
23
  ### vaultConnectorType? {#vaultconnectortype}
32
24
 
33
25
  > `optional` **vaultConnectorType?**: `string`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-service",
3
- "version": "0.9.3-next.3",
3
+ "version": "0.9.3-next.4",
4
4
  "description": "Service contracts and REST endpoint definitions for exposing identity workflows through stable interfaces.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,11 +21,10 @@
21
21
  "@twin.org/data-json-ld": "next",
22
22
  "@twin.org/dlt-account": "next",
23
23
  "@twin.org/entity": "next",
24
- "@twin.org/identity-models": "0.9.3-next.3",
24
+ "@twin.org/identity-models": "0.9.3-next.4",
25
25
  "@twin.org/nameof": "next",
26
26
  "@twin.org/standards-w3c-did": "next",
27
27
  "@twin.org/telemetry-models": "next",
28
- "@twin.org/tracing-models": "next",
29
28
  "@twin.org/vault-models": "next",
30
29
  "@twin.org/wallet-models": "next",
31
30
  "@twin.org/web": "next"