@twin.org/identity-service 0.9.2-next.8 → 0.9.2

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,9 +4,10 @@ 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, IdentityMetrics, IdentityResolverConnectorFactory } from "@twin.org/identity-models";
7
+ import { DocumentHelper, IdentityConnectorFactory, IdentityMetricIds, IdentitySpanAttributes, IdentitySpanNames, 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";
10
11
  import { VaultConnectorFactory } from "@twin.org/vault-models";
11
12
  import { Jwt } from "@twin.org/web";
12
13
  /**
@@ -32,6 +33,11 @@ export class IdentityService {
32
33
  * @internal
33
34
  */
34
35
  _telemetryComponent;
36
+ /**
37
+ * The optional tracing component for recording spans.
38
+ * @internal
39
+ */
40
+ _tracingComponent;
35
41
  /**
36
42
  * Create a new instance of IdentityService.
37
43
  * @param options The options for the service.
@@ -45,6 +51,7 @@ export class IdentityService {
45
51
  this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
46
52
  this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
47
53
  this._telemetryComponent = ComponentFactory.getIfExists(options?.telemetryComponentType);
54
+ this._tracingComponent = ComponentFactory.getIfExists(options?.tracingComponentType);
48
55
  }
49
56
  /**
50
57
  * Returns the class name of the component.
@@ -174,17 +181,19 @@ export class IdentityService {
174
181
  */
175
182
  async identityCreate(namespace, controller) {
176
183
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
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
- }
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
+ });
188
197
  }
189
198
  /**
190
199
  * Remove an identity.
@@ -197,15 +206,17 @@ export class IdentityService {
197
206
  async identityRemove(identity, options, controller) {
198
207
  Guards.stringValue(IdentityService.CLASS_NAME, "identity", identity);
199
208
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
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
- }
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
+ });
209
220
  }
210
221
  /**
211
222
  * Add a verification method to the document in JSON Web key Format.
@@ -221,14 +232,16 @@ export class IdentityService {
221
232
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
222
233
  Urn.guard(IdentityService.CLASS_NAME, "identity", identity);
223
234
  Guards.arrayOneOf(IdentityService.CLASS_NAME, "verificationMethodType", verificationMethodType, Object.values(DidVerificationMethodType));
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
- }
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
+ });
232
245
  }
233
246
  /**
234
247
  * Remove a verification method from the document.
@@ -243,14 +256,16 @@ export class IdentityService {
243
256
  async verificationMethodRemove(verificationMethodId, options, controller) {
244
257
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
245
258
  Urn.guard(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
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
- }
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
+ });
254
269
  }
255
270
  /**
256
271
  * Add a service to the document.
@@ -278,14 +293,16 @@ export class IdentityService {
278
293
  else {
279
294
  Guards.stringValue(IdentityService.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
280
295
  }
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
- }
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
+ });
289
306
  }
290
307
  /**
291
308
  * Remove a service from the document.
@@ -297,14 +314,16 @@ export class IdentityService {
297
314
  async serviceRemove(serviceId, controller) {
298
315
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
299
316
  Urn.guard(IdentityService.CLASS_NAME, "serviceId", serviceId);
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
- }
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
+ });
308
327
  }
309
328
  /**
310
329
  * Add an alias to the alsoKnownAs property on the document.
@@ -320,14 +339,16 @@ export class IdentityService {
320
339
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
321
340
  Guards.stringValue(IdentityService.CLASS_NAME, "documentId", documentId);
322
341
  Guards.stringValue(IdentityService.CLASS_NAME, "alias", alias);
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
- }
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
+ });
331
352
  }
332
353
  /**
333
354
  * Remove an alias from the alsoKnownAs property on the document.
@@ -343,14 +364,16 @@ export class IdentityService {
343
364
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
344
365
  Guards.stringValue(IdentityService.CLASS_NAME, "documentId", documentId);
345
366
  Guards.stringValue(IdentityService.CLASS_NAME, "alias", alias);
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
- }
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
+ });
354
377
  }
355
378
  /**
356
379
  * Create a verifiable credential for a verification method.
@@ -370,19 +393,21 @@ export class IdentityService {
370
393
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
371
394
  Urn.guard(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
372
395
  Guards.object(IdentityService.CLASS_NAME, "subject", subject);
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
- }
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
+ });
386
411
  }
387
412
  /**
388
413
  * Verify a verifiable credential is valid.
@@ -394,20 +419,24 @@ export class IdentityService {
394
419
  Guards.objectValue(IdentityService.CLASS_NAME, "credential", credential);
395
420
  Guards.stringValue(IdentityService.CLASS_NAME, "credential.issuer", credential.issuer);
396
421
  Guards.objectValue(IdentityService.CLASS_NAME, "credential.proof", credential.proof);
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" });
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;
402
435
  }
403
- else {
404
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);
436
+ catch (error) {
437
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
405
438
  }
406
- return service;
407
- }
408
- catch (error) {
409
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
410
- }
439
+ });
411
440
  }
412
441
  Guards.stringValue(IdentityService.CLASS_NAME, "credential", credential);
413
442
  const jwtDecoded = await Jwt.decode(credential);
@@ -420,20 +449,23 @@ export class IdentityService {
420
449
  Is.undefined(jwtSignature)) {
421
450
  throw new GeneralError(IdentityService.CLASS_NAME, "jwtDecodeFailed");
422
451
  }
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" });
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;
428
464
  }
429
- else {
430
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);
465
+ catch (error) {
466
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
431
467
  }
432
- return service;
433
- }
434
- catch (error) {
435
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
436
- }
468
+ });
437
469
  }
438
470
  /**
439
471
  * Revoke verifiable credential.
@@ -446,16 +478,18 @@ export class IdentityService {
446
478
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
447
479
  Guards.stringValue(IdentityService.CLASS_NAME, "issuerIdentity", issuerIdentity);
448
480
  Guards.number(IdentityService.CLASS_NAME, "credentialIndex", credentialIndex);
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
- }
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
+ });
459
493
  }
460
494
  /**
461
495
  * Unrevoke verifiable credential.
@@ -468,16 +502,18 @@ export class IdentityService {
468
502
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
469
503
  Guards.stringValue(IdentityService.CLASS_NAME, "issuerIdentity", issuerIdentity);
470
504
  Guards.number(IdentityService.CLASS_NAME, "credentialIndex", credentialIndex);
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
- }
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
+ });
481
517
  }
482
518
  /**
483
519
  * Create a verifiable presentation from the supplied verifiable credentials.
@@ -497,18 +533,20 @@ export class IdentityService {
497
533
  async verifiablePresentationCreate(verificationMethodId, presentationId, contexts, types, verifiableCredentials, options, controller) {
498
534
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
499
535
  Guards.stringValue(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
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
- }
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
+ });
512
550
  }
513
551
  /**
514
552
  * Verify a verifiable presentation is valid.
@@ -535,20 +573,22 @@ export class IdentityService {
535
573
  holder = presentation.holder;
536
574
  }
537
575
  Guards.stringValue(IdentityService.CLASS_NAME, "holder", holder);
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" });
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;
543
587
  }
544
- else {
545
- await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerified);
588
+ catch (error) {
589
+ throw new GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationVerifyFailed", undefined, error);
546
590
  }
547
- return service;
548
- }
549
- catch (error) {
550
- throw new GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationVerifyFailed", undefined, error);
551
- }
591
+ });
552
592
  }
553
593
  /**
554
594
  * Create a proof for a document with the specified verification method.
@@ -563,15 +603,17 @@ export class IdentityService {
563
603
  Guards.stringValue(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
564
604
  Guards.arrayOneOf(IdentityService.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
565
605
  Guards.object(IdentityService.CLASS_NAME, "unsecureDocument", unsecureDocument);
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
- }
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
+ });
575
617
  }
576
618
  /**
577
619
  * Verify proof for a document with the specified verification method.
@@ -583,15 +625,18 @@ export class IdentityService {
583
625
  Guards.object(IdentityService.CLASS_NAME, "document", document);
584
626
  Guards.object(IdentityService.CLASS_NAME, "proof", proof);
585
627
  Guards.stringValue(IdentityService.CLASS_NAME, "proof.verificationMethod", proof.verificationMethod);
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
- }
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
+ });
595
640
  }
596
641
  /**
597
642
  * 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,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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CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACF,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\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
+ {"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;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;;;OAGG;IACc,iBAAiB,CAAqB;IAEvD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,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 +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 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 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"]}
@@ -11,6 +11,10 @@ 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;
14
18
  /**
15
19
  * The vault connector type to use for migrating the mnemonic during health check initialisation.
16
20
  * @default vault
package/docs/changelog.md CHANGED
@@ -1,5 +1,90 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.2](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.9.2...identity-service-v0.9.2) (2026-08-24)
4
+
5
+
6
+ ### Features
7
+
8
+ * release to production ([dabf4c5](https://github.com/iotaledger/twin-identity/commit/dabf4c5bb19e04c09bfbc8533f23dc9d42b35e4c))
9
+ * release to production ([8450ad7](https://github.com/iotaledger/twin-identity/commit/8450ad727e0c4d665f2ce483e41798c2ff5b7d55))
10
+ * release to production ([#161](https://github.com/iotaledger/twin-identity/issues/161)) ([ad151fa](https://github.com/iotaledger/twin-identity/commit/ad151facfcaadc1d183d935a6db525379d48002f))
11
+ * release to production ([#179](https://github.com/iotaledger/twin-identity/issues/179)) ([062816b](https://github.com/iotaledger/twin-identity/commit/062816b110776b7e60f89b04142d42c6f24890a8))
12
+ * release to production ([#210](https://github.com/iotaledger/twin-identity/issues/210)) ([aec2d45](https://github.com/iotaledger/twin-identity/commit/aec2d45ed55b8bf96638dee835f54629170943ad))
13
+
14
+ ## [0.9.2-next.10](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.9.2-next.9...identity-service-v0.9.2-next.10) (2026-08-20)
15
+
16
+
17
+ ### Features
18
+
19
+ * tracing ([#205](https://github.com/iotaledger/twin-identity/issues/205)) ([add81ab](https://github.com/iotaledger/twin-identity/commit/add81ab4a258078c34ef0c57681d1675c81f8e2c))
20
+
21
+
22
+ ### Dependencies
23
+
24
+ * The following workspace dependencies were updated
25
+ * dependencies
26
+ * @twin.org/identity-models bumped from 0.9.2-next.9 to 0.9.2-next.10
27
+ * devDependencies
28
+ * @twin.org/identity-connector-entity-storage bumped from 0.9.2-next.9 to 0.9.2-next.10
29
+
30
+ ## [0.9.2-next.9](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.9.2-next.8...identity-service-v0.9.2-next.9) (2026-08-14)
31
+
32
+
33
+ ### Features
34
+
35
+ * add addAlsoKnownAs to identity connector ([#117](https://github.com/iotaledger/twin-identity/issues/117)) ([aa27cff](https://github.com/iotaledger/twin-identity/commit/aa27cff88e61e7c8c6e32aeb437fb01c6ee9f57a))
36
+ * add context id features ([#62](https://github.com/iotaledger/twin-identity/issues/62)) ([e02ecca](https://github.com/iotaledger/twin-identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
37
+ * add expiration date option to vc creation ([73e05e1](https://github.com/iotaledger/twin-identity/commit/73e05e1ae61112c7e056889969751f4ff82d9f29))
38
+ * add identity remove ([eebc13f](https://github.com/iotaledger/twin-identity/commit/eebc13f4c2cd994d2d9cce4da2128fb346c80ba7))
39
+ * add optional jwt payload and headers to vc and vp tokens ([#135](https://github.com/iotaledger/twin-identity/issues/135)) ([aa1de0f](https://github.com/iotaledger/twin-identity/commit/aa1de0f63be95ff62bae3c699aabc85ea93d74c2))
40
+ * add proof to vcs and verify vs documents ([#103](https://github.com/iotaledger/twin-identity/issues/103)) ([b60bf0c](https://github.com/iotaledger/twin-identity/commit/b60bf0cb7d453d67574c5c0e4f769e67cf7cd6d1))
41
+ * add telemetry metrics ([#132](https://github.com/iotaledger/twin-identity/issues/132)) ([b51cd78](https://github.com/iotaledger/twin-identity/commit/b51cd7816905fd55e250035daf1b8f2047cba83d))
42
+ * add validate-locales ([04d74b4](https://github.com/iotaledger/twin-identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
43
+ * admin endpoints ([#199](https://github.com/iotaledger/twin-identity/issues/199)) ([da6c189](https://github.com/iotaledger/twin-identity/commit/da6c18963ed551451d919e36aedc1dd8b005a12f))
44
+ * application health ([#188](https://github.com/iotaledger/twin-identity/issues/188)) ([a7f0c3e](https://github.com/iotaledger/twin-identity/commit/a7f0c3e919d8a77b7d2661ec33742f1cc1889751))
45
+ * common connector tests ([4f9642c](https://github.com/iotaledger/twin-identity/commit/4f9642ceb09843870909fc6819bf69fb20ef952a))
46
+ * eslint migration to flat config ([fd6246d](https://github.com/iotaledger/twin-identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
47
+ * expanded cli methods ([#121](https://github.com/iotaledger/twin-identity/issues/121)) ([80a52b7](https://github.com/iotaledger/twin-identity/commit/80a52b779237cd633d1f2813fa976585cef6e551))
48
+ * health and key removal ([934391f](https://github.com/iotaledger/twin-identity/commit/934391f9307beda34bc594e3aa506137e3df631b))
49
+ * health and key removal ([#191](https://github.com/iotaledger/twin-identity/issues/191)) ([8504101](https://github.com/iotaledger/twin-identity/commit/8504101a7a08b2a042a4e59f666c245308527088))
50
+ * identity key separator use slash ([1319d0d](https://github.com/iotaledger/twin-identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
51
+ * remove auth generator ([#98](https://github.com/iotaledger/twin-identity/issues/98)) ([a8969e8](https://github.com/iotaledger/twin-identity/commit/a8969e85a5a2804abfc787406e2d12eb168dd978))
52
+ * remove skipAuth from routes ([a2f8921](https://github.com/iotaledger/twin-identity/commit/a2f892133360a25cb7b6668342e5dad852c3a908))
53
+ * remove unused namespace ([1987f72](https://github.com/iotaledger/twin-identity/commit/1987f72089be5ece10aa96b1fb9c386221c95c75))
54
+ * rest enhancements ([f2307ff](https://github.com/iotaledger/twin-identity/commit/f2307ff6605ba87ac5bf991bdaa69ac7d8bbd56d))
55
+ * separate vc verification routes with query and body ([ea7d891](https://github.com/iotaledger/twin-identity/commit/ea7d8910472150cf76dbd51e282625e70226d9b3))
56
+ * typescript 6 update ([e8806ad](https://github.com/iotaledger/twin-identity/commit/e8806ad6858c37be3c0f54c41cf654023773bef3))
57
+ * update contexts ([#100](https://github.com/iotaledger/twin-identity/issues/100)) ([7c17f98](https://github.com/iotaledger/twin-identity/commit/7c17f983110b2fc5db1b19531d0b2a7c53e02aaa))
58
+ * update framework core ([c824497](https://github.com/iotaledger/twin-identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
59
+ * update namespaces and contexts ([#90](https://github.com/iotaledger/twin-identity/issues/90)) ([0c34d64](https://github.com/iotaledger/twin-identity/commit/0c34d64add8cca77856fa2d0357e774d72fbbfc1))
60
+ * update twindev schemas ([f5b2735](https://github.com/iotaledger/twin-identity/commit/f5b273561b52fa75e654e074927c164a465aa510))
61
+ * use new generateKid method ([f0fe779](https://github.com/iotaledger/twin-identity/commit/f0fe779323b675575bb9f80aa74f1957dc57a094))
62
+ * use shared store mechanism ([#27](https://github.com/iotaledger/twin-identity/issues/27)) ([ce41f3f](https://github.com/iotaledger/twin-identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
63
+
64
+
65
+ ### Bug Fixes
66
+
67
+ * allow empty subject data in vc ([5bbf14e](https://github.com/iotaledger/twin-identity/commit/5bbf14eefd3c99b6cdca1af0ca741954d1b02cd3))
68
+ * identity routes missing jwt fields ([b47470a](https://github.com/iotaledger/twin-identity/commit/b47470a8e59881d877c84f114892ee290d4254ca))
69
+ * identity subject type property ([#146](https://github.com/iotaledger/twin-identity/issues/146)) ([fe71dc6](https://github.com/iotaledger/twin-identity/commit/fe71dc66972120b42f1ff0e1dc8732cb48e1dd2a))
70
+ * Import path and bump version ([#21](https://github.com/iotaledger/twin-identity/issues/21)) ([ccea845](https://github.com/iotaledger/twin-identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
71
+ * Install sdk-wasm ([#20](https://github.com/iotaledger/twin-identity/issues/20)) ([75ec14e](https://github.com/iotaledger/twin-identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
72
+ * missing path params ([02acbde](https://github.com/iotaledger/twin-identity/commit/02acbde3033bf5d5435dca0bd8187cabad8f3028))
73
+ * proof create rest route identifier ([395dc57](https://github.com/iotaledger/twin-identity/commit/395dc5700f8ec1b3a607d18ffb68c8eec8ee751c))
74
+ * query params force coercion ([d9347d2](https://github.com/iotaledger/twin-identity/commit/d9347d29d4a9cc58759f30f5d8526de864ea7522))
75
+ * stricter pathParam types ([a174cdf](https://github.com/iotaledger/twin-identity/commit/a174cdf0ca4272bee35fcf20ab7e8e4e17b8b6f4))
76
+ * use async getStore in tests ([cfc0d87](https://github.com/iotaledger/twin-identity/commit/cfc0d873532e8ab2010f86f05bffaad3bbaf5786))
77
+ * use async getStore in tests ([3424c81](https://github.com/iotaledger/twin-identity/commit/3424c81cf7407ede4a89a026072720d52bf689b2))
78
+
79
+
80
+ ### Dependencies
81
+
82
+ * The following workspace dependencies were updated
83
+ * dependencies
84
+ * @twin.org/identity-models bumped from 0.9.2-next.8 to 0.9.2-next.9
85
+ * devDependencies
86
+ * @twin.org/identity-connector-entity-storage bumped from 0.9.2-next.8 to 0.9.2-next.9
87
+
3
88
  ## [0.9.2-next.8](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.9.2-next.7...identity-service-v0.9.2-next.8) (2026-08-14)
4
89
 
5
90
 
@@ -20,6 +20,14 @@ 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
+
23
31
  ### vaultConnectorType? {#vaultconnectortype}
24
32
 
25
33
  > `optional` **vaultConnectorType?**: `string`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-service",
3
- "version": "0.9.2-next.8",
3
+ "version": "0.9.2",
4
4
  "description": "Service contracts and REST endpoint definitions for exposing identity workflows through stable interfaces.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,20 +14,21 @@
14
14
  "node": ">=24.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-models": "next",
18
- "@twin.org/context": "next",
19
- "@twin.org/core": "next",
20
- "@twin.org/data-core": "next",
21
- "@twin.org/data-json-ld": "next",
22
- "@twin.org/dlt-account": "next",
23
- "@twin.org/entity": "next",
24
- "@twin.org/identity-models": "0.9.2-next.8",
25
- "@twin.org/nameof": "next",
26
- "@twin.org/standards-w3c-did": "next",
27
- "@twin.org/telemetry-models": "next",
28
- "@twin.org/vault-models": "next",
29
- "@twin.org/wallet-models": "next",
30
- "@twin.org/web": "next"
17
+ "@twin.org/api-models": "^0.9.2",
18
+ "@twin.org/context": "^0.9.2",
19
+ "@twin.org/core": "^0.9.2",
20
+ "@twin.org/data-core": "^0.9.2",
21
+ "@twin.org/data-json-ld": "^0.9.2",
22
+ "@twin.org/dlt-account": "^0.9.2",
23
+ "@twin.org/entity": "^0.9.2",
24
+ "@twin.org/identity-models": "^0.9.2",
25
+ "@twin.org/nameof": "^0.9.2",
26
+ "@twin.org/standards-w3c-did": "^0.9.2",
27
+ "@twin.org/telemetry-models": "^0.9.2",
28
+ "@twin.org/tracing-models": "^0.9.2",
29
+ "@twin.org/vault-models": "^0.9.2",
30
+ "@twin.org/wallet-models": "^0.9.1",
31
+ "@twin.org/web": "^0.9.2"
31
32
  },
32
33
  "main": "./dist/es/index.js",
33
34
  "types": "./dist/types/index.d.ts",