@twin.org/identity-service 0.0.2-next.7 → 0.0.2-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +90 -88
- package/dist/esm/index.mjs +90 -88
- package/dist/types/identityProfileService.d.ts +3 -3
- package/dist/types/identityResolverService.d.ts +1 -1
- package/dist/types/identityService.d.ts +1 -1
- package/docs/changelog.md +32 -0
- package/docs/open-api/spec.json +65 -68
- package/docs/reference/classes/IdentityProfileService.md +3 -7
- package/docs/reference/classes/IdentityResolverService.md +1 -5
- package/docs/reference/classes/IdentityService.md +1 -5
- package/locales/en.json +0 -2
- package/package.json +21 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -379,7 +379,7 @@ async function identitiesList(httpRequestContext, componentName, request) {
|
|
|
379
379
|
};
|
|
380
380
|
});
|
|
381
381
|
return {
|
|
382
|
-
body: await component.list(publicFilters, apiModels.HttpParameterHelper.arrayFromString(request?.query?.publicPropertyNames), request?.query?.cursor, core.Coerce.integer(request.query?.
|
|
382
|
+
body: await component.list(publicFilters, apiModels.HttpParameterHelper.arrayFromString(request?.query?.publicPropertyNames), request?.query?.cursor, core.Coerce.integer(request.query?.limit))
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
|
|
@@ -392,7 +392,7 @@ class IdentityProfileService {
|
|
|
392
392
|
/**
|
|
393
393
|
* Runtime name for the class.
|
|
394
394
|
*/
|
|
395
|
-
CLASS_NAME = "IdentityProfileService";
|
|
395
|
+
static CLASS_NAME = "IdentityProfileService";
|
|
396
396
|
/**
|
|
397
397
|
* The identity profile connector.
|
|
398
398
|
* @internal
|
|
@@ -413,15 +413,15 @@ class IdentityProfileService {
|
|
|
413
413
|
* @returns Nothing.
|
|
414
414
|
*/
|
|
415
415
|
async create(publicProfile, privateProfile, identity) {
|
|
416
|
-
core.Guards.stringValue(
|
|
416
|
+
core.Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
417
417
|
try {
|
|
418
418
|
await this._identityProfileConnector.create(identity, publicProfile, privateProfile);
|
|
419
419
|
}
|
|
420
420
|
catch (error) {
|
|
421
|
-
if (core.BaseError.someErrorClass(error,
|
|
421
|
+
if (core.BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
422
422
|
throw error;
|
|
423
423
|
}
|
|
424
|
-
throw new core.GeneralError(
|
|
424
|
+
throw new core.GeneralError(IdentityProfileService.CLASS_NAME, "createFailed", { identity }, error);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
/**
|
|
@@ -432,11 +432,11 @@ class IdentityProfileService {
|
|
|
432
432
|
* @returns The items identity and the properties.
|
|
433
433
|
*/
|
|
434
434
|
async get(publicPropertyNames, privatePropertyNames, identity) {
|
|
435
|
-
core.Guards.stringValue(
|
|
435
|
+
core.Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
436
436
|
try {
|
|
437
437
|
const result = await this._identityProfileConnector.get(identity, publicPropertyNames, privatePropertyNames);
|
|
438
438
|
if (core.Is.undefined(result)) {
|
|
439
|
-
throw new core.NotFoundError(
|
|
439
|
+
throw new core.NotFoundError(IdentityProfileService.CLASS_NAME, "notFound", identity);
|
|
440
440
|
}
|
|
441
441
|
return {
|
|
442
442
|
identity,
|
|
@@ -445,10 +445,10 @@ class IdentityProfileService {
|
|
|
445
445
|
};
|
|
446
446
|
}
|
|
447
447
|
catch (error) {
|
|
448
|
-
if (core.BaseError.someErrorClass(error,
|
|
448
|
+
if (core.BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
449
449
|
throw error;
|
|
450
450
|
}
|
|
451
|
-
throw new core.GeneralError(
|
|
451
|
+
throw new core.GeneralError(IdentityProfileService.CLASS_NAME, "getFailed", undefined, error);
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
/**
|
|
@@ -458,19 +458,19 @@ class IdentityProfileService {
|
|
|
458
458
|
* @returns The items properties.
|
|
459
459
|
*/
|
|
460
460
|
async getPublic(identity, propertyNames) {
|
|
461
|
-
core.Guards.stringValue(
|
|
461
|
+
core.Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
462
462
|
try {
|
|
463
463
|
const result = await this._identityProfileConnector.get(identity, propertyNames);
|
|
464
464
|
if (core.Is.undefined(result)) {
|
|
465
|
-
throw new core.NotFoundError(
|
|
465
|
+
throw new core.NotFoundError(IdentityProfileService.CLASS_NAME, "notFound", identity);
|
|
466
466
|
}
|
|
467
467
|
return result.publicProfile;
|
|
468
468
|
}
|
|
469
469
|
catch (error) {
|
|
470
|
-
if (core.BaseError.someErrorClass(error,
|
|
470
|
+
if (core.BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
471
471
|
throw error;
|
|
472
472
|
}
|
|
473
|
-
throw new core.GeneralError(
|
|
473
|
+
throw new core.GeneralError(IdentityProfileService.CLASS_NAME, "getPublicFailed", undefined, error);
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
@@ -481,19 +481,19 @@ class IdentityProfileService {
|
|
|
481
481
|
* @returns Nothing.
|
|
482
482
|
*/
|
|
483
483
|
async update(publicProfile, privateProfile, identity) {
|
|
484
|
-
core.Guards.stringValue(
|
|
484
|
+
core.Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
485
485
|
try {
|
|
486
486
|
const result = await this._identityProfileConnector.get(identity);
|
|
487
487
|
if (core.Is.undefined(result)) {
|
|
488
|
-
throw new core.NotFoundError(
|
|
488
|
+
throw new core.NotFoundError(IdentityProfileService.CLASS_NAME, "notFound", identity);
|
|
489
489
|
}
|
|
490
490
|
await this._identityProfileConnector.update(identity, publicProfile, privateProfile);
|
|
491
491
|
}
|
|
492
492
|
catch (error) {
|
|
493
|
-
if (core.BaseError.someErrorClass(error,
|
|
493
|
+
if (core.BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
494
494
|
throw error;
|
|
495
495
|
}
|
|
496
|
-
throw new core.GeneralError(
|
|
496
|
+
throw new core.GeneralError(IdentityProfileService.CLASS_NAME, "updateFailed", { identity }, error);
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
/**
|
|
@@ -502,19 +502,19 @@ class IdentityProfileService {
|
|
|
502
502
|
* @returns Nothing.
|
|
503
503
|
*/
|
|
504
504
|
async remove(identity) {
|
|
505
|
-
core.Guards.stringValue(
|
|
505
|
+
core.Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
506
506
|
try {
|
|
507
507
|
const result = await this._identityProfileConnector.get(identity);
|
|
508
508
|
if (core.Is.undefined(result)) {
|
|
509
|
-
throw new core.NotFoundError(
|
|
509
|
+
throw new core.NotFoundError(IdentityProfileService.CLASS_NAME, "notFound", identity);
|
|
510
510
|
}
|
|
511
511
|
await this._identityProfileConnector.remove(identity);
|
|
512
512
|
}
|
|
513
513
|
catch (error) {
|
|
514
|
-
if (core.BaseError.someErrorClass(error,
|
|
514
|
+
if (core.BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
515
515
|
throw error;
|
|
516
516
|
}
|
|
517
|
-
throw new core.GeneralError(
|
|
517
|
+
throw new core.GeneralError(IdentityProfileService.CLASS_NAME, "removeFailed", { identity }, error);
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
520
|
/**
|
|
@@ -522,17 +522,17 @@ class IdentityProfileService {
|
|
|
522
522
|
* @param publicFilters The filters to apply to the identities public profiles.
|
|
523
523
|
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
524
524
|
* @param cursor The cursor for paged requests.
|
|
525
|
-
* @param
|
|
525
|
+
* @param limit The maximum number of items in a page.
|
|
526
526
|
* @returns The list of items and cursor for paging.
|
|
527
527
|
*/
|
|
528
|
-
async list(publicFilters, publicPropertyNames, cursor,
|
|
528
|
+
async list(publicFilters, publicPropertyNames, cursor, limit) {
|
|
529
529
|
try {
|
|
530
530
|
// We don't want to return private profile for this type of query
|
|
531
531
|
// as it would expose the values to the REST api
|
|
532
|
-
return this._identityProfileConnector.list(publicFilters, undefined, publicPropertyNames, undefined, cursor,
|
|
532
|
+
return this._identityProfileConnector.list(publicFilters, undefined, publicPropertyNames, undefined, cursor, limit);
|
|
533
533
|
}
|
|
534
534
|
catch (error) {
|
|
535
|
-
throw new core.GeneralError(
|
|
535
|
+
throw new core.GeneralError(IdentityProfileService.CLASS_NAME, "listFailed", undefined, error);
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
}
|
|
@@ -631,7 +631,7 @@ class IdentityResolverService {
|
|
|
631
631
|
/**
|
|
632
632
|
* Runtime name for the class.
|
|
633
633
|
*/
|
|
634
|
-
CLASS_NAME = "IdentityResolverService";
|
|
634
|
+
static CLASS_NAME = "IdentityResolverService";
|
|
635
635
|
/**
|
|
636
636
|
* The default namespace for the connector to use.
|
|
637
637
|
* @internal
|
|
@@ -649,7 +649,7 @@ class IdentityResolverService {
|
|
|
649
649
|
constructor(options) {
|
|
650
650
|
const names = identityModels.IdentityResolverConnectorFactory.names();
|
|
651
651
|
if (names.length === 0) {
|
|
652
|
-
throw new core.GeneralError(
|
|
652
|
+
throw new core.GeneralError(IdentityResolverService.CLASS_NAME, "noConnectors");
|
|
653
653
|
}
|
|
654
654
|
this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
|
|
655
655
|
this._fallbackResolverConnectorType = options?.fallbackResolverConnectorType ?? "universal";
|
|
@@ -660,14 +660,14 @@ class IdentityResolverService {
|
|
|
660
660
|
* @returns The resolved document.
|
|
661
661
|
*/
|
|
662
662
|
async identityResolve(identity) {
|
|
663
|
-
core.Urn.guard(
|
|
663
|
+
core.Urn.guard(IdentityResolverService.CLASS_NAME, "identity", identity);
|
|
664
664
|
try {
|
|
665
665
|
const identityResolverConnector = this.getConnectorByUri(identity);
|
|
666
666
|
const document = await identityResolverConnector.resolveDocument(identity);
|
|
667
667
|
return document;
|
|
668
668
|
}
|
|
669
669
|
catch (error) {
|
|
670
|
-
throw new core.GeneralError(
|
|
670
|
+
throw new core.GeneralError(IdentityResolverService.CLASS_NAME, "identityResolveFailed", {
|
|
671
671
|
identity
|
|
672
672
|
}, error);
|
|
673
673
|
}
|
|
@@ -685,7 +685,7 @@ class IdentityResolverService {
|
|
|
685
685
|
// Let's see if a fallback 'universal' connector is registered
|
|
686
686
|
connector = identityModels.IdentityResolverConnectorFactory.getIfExists(this._fallbackResolverConnectorType);
|
|
687
687
|
if (core.Is.empty(connector)) {
|
|
688
|
-
throw new core.GeneralError(
|
|
688
|
+
throw new core.GeneralError(IdentityResolverService.CLASS_NAME, "connectorNotFound", {
|
|
689
689
|
namespace: namespaceMethod
|
|
690
690
|
});
|
|
691
691
|
}
|
|
@@ -701,7 +701,7 @@ class IdentityResolverService {
|
|
|
701
701
|
getConnectorByUri(id) {
|
|
702
702
|
const idUri = core.Urn.fromValidString(id);
|
|
703
703
|
if (idUri.namespaceIdentifier() !== "did") {
|
|
704
|
-
throw new core.GeneralError(
|
|
704
|
+
throw new core.GeneralError(IdentityResolverService.CLASS_NAME, "namespaceMismatch", {
|
|
705
705
|
namespace: "did",
|
|
706
706
|
id
|
|
707
707
|
});
|
|
@@ -1649,7 +1649,7 @@ class IdentityService {
|
|
|
1649
1649
|
/**
|
|
1650
1650
|
* Runtime name for the class.
|
|
1651
1651
|
*/
|
|
1652
|
-
CLASS_NAME = "IdentityService";
|
|
1652
|
+
static CLASS_NAME = "IdentityService";
|
|
1653
1653
|
/**
|
|
1654
1654
|
* The default namespace for the connector to use.
|
|
1655
1655
|
* @internal
|
|
@@ -1662,7 +1662,7 @@ class IdentityService {
|
|
|
1662
1662
|
constructor(options) {
|
|
1663
1663
|
const names = identityModels.IdentityConnectorFactory.names();
|
|
1664
1664
|
if (names.length === 0) {
|
|
1665
|
-
throw new core.GeneralError(
|
|
1665
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "noConnectors");
|
|
1666
1666
|
}
|
|
1667
1667
|
this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
|
|
1668
1668
|
}
|
|
@@ -1673,13 +1673,13 @@ class IdentityService {
|
|
|
1673
1673
|
* @returns The created identity document.
|
|
1674
1674
|
*/
|
|
1675
1675
|
async identityCreate(namespace, controller) {
|
|
1676
|
-
core.Guards.stringValue(
|
|
1676
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1677
1677
|
try {
|
|
1678
1678
|
const identityConnector = this.getConnectorByNamespace(namespace);
|
|
1679
1679
|
return identityConnector.createDocument(controller);
|
|
1680
1680
|
}
|
|
1681
1681
|
catch (error) {
|
|
1682
|
-
throw new core.GeneralError(
|
|
1682
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "identityCreateFailed", undefined, error);
|
|
1683
1683
|
}
|
|
1684
1684
|
}
|
|
1685
1685
|
/**
|
|
@@ -1689,14 +1689,14 @@ class IdentityService {
|
|
|
1689
1689
|
* @returns Nothing.
|
|
1690
1690
|
*/
|
|
1691
1691
|
async identityRemove(identity, controller) {
|
|
1692
|
-
core.Guards.stringValue(
|
|
1693
|
-
core.Guards.stringValue(
|
|
1692
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "identity", identity);
|
|
1693
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1694
1694
|
try {
|
|
1695
1695
|
const identityConnector = this.getConnectorByUri(identity);
|
|
1696
1696
|
return identityConnector.removeDocument(controller, identity);
|
|
1697
1697
|
}
|
|
1698
1698
|
catch (error) {
|
|
1699
|
-
throw new core.GeneralError(
|
|
1699
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "identityRemoveFailed", { identity }, error);
|
|
1700
1700
|
}
|
|
1701
1701
|
}
|
|
1702
1702
|
/**
|
|
@@ -1710,16 +1710,16 @@ class IdentityService {
|
|
|
1710
1710
|
* @throws NotSupportedError if the platform does not support multiple keys.
|
|
1711
1711
|
*/
|
|
1712
1712
|
async verificationMethodCreate(identity, verificationMethodType, verificationMethodId, controller) {
|
|
1713
|
-
core.Guards.stringValue(
|
|
1714
|
-
core.Urn.guard(
|
|
1715
|
-
core.Guards.arrayOneOf(
|
|
1713
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1714
|
+
core.Urn.guard(IdentityService.CLASS_NAME, "identity", identity);
|
|
1715
|
+
core.Guards.arrayOneOf(IdentityService.CLASS_NAME, "verificationMethodType", verificationMethodType, Object.values(standardsW3cDid.DidVerificationMethodType));
|
|
1716
1716
|
try {
|
|
1717
1717
|
const identityConnector = this.getConnectorByUri(identity);
|
|
1718
1718
|
const verificationMethod = await identityConnector.addVerificationMethod(controller, identity, verificationMethodType, verificationMethodId);
|
|
1719
1719
|
return verificationMethod;
|
|
1720
1720
|
}
|
|
1721
1721
|
catch (error) {
|
|
1722
|
-
throw new core.GeneralError(
|
|
1722
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "verificationMethodCreateFailed", { identity }, error);
|
|
1723
1723
|
}
|
|
1724
1724
|
}
|
|
1725
1725
|
/**
|
|
@@ -1731,15 +1731,15 @@ class IdentityService {
|
|
|
1731
1731
|
* @throws NotSupportedError if the platform does not support multiple revocable keys.
|
|
1732
1732
|
*/
|
|
1733
1733
|
async verificationMethodRemove(verificationMethodId, controller) {
|
|
1734
|
-
core.Guards.stringValue(
|
|
1735
|
-
core.Urn.guard(
|
|
1734
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1735
|
+
core.Urn.guard(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
1736
1736
|
try {
|
|
1737
1737
|
const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
|
|
1738
1738
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1739
1739
|
await identityConnector.removeVerificationMethod(controller, verificationMethodId);
|
|
1740
1740
|
}
|
|
1741
1741
|
catch (error) {
|
|
1742
|
-
throw new core.GeneralError(
|
|
1742
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "verificationMethodRemoveFailed", { verificationMethodId }, error);
|
|
1743
1743
|
}
|
|
1744
1744
|
}
|
|
1745
1745
|
/**
|
|
@@ -1753,20 +1753,20 @@ class IdentityService {
|
|
|
1753
1753
|
* @throws NotFoundError if the id can not be resolved.
|
|
1754
1754
|
*/
|
|
1755
1755
|
async serviceCreate(identity, serviceId, serviceType, serviceEndpoint, controller) {
|
|
1756
|
-
core.Guards.stringValue(
|
|
1757
|
-
core.Urn.guard(
|
|
1758
|
-
core.Guards.stringValue(
|
|
1756
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1757
|
+
core.Urn.guard(IdentityService.CLASS_NAME, "identity", identity);
|
|
1758
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "serviceId", serviceId);
|
|
1759
1759
|
if (core.Is.array(serviceType)) {
|
|
1760
|
-
core.Guards.arrayValue(
|
|
1760
|
+
core.Guards.arrayValue(IdentityService.CLASS_NAME, "serviceType", serviceType);
|
|
1761
1761
|
}
|
|
1762
1762
|
else {
|
|
1763
|
-
core.Guards.stringValue(
|
|
1763
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "serviceType", serviceType);
|
|
1764
1764
|
}
|
|
1765
1765
|
if (core.Is.array(serviceEndpoint)) {
|
|
1766
|
-
core.Guards.arrayValue(
|
|
1766
|
+
core.Guards.arrayValue(IdentityService.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
|
|
1767
1767
|
}
|
|
1768
1768
|
else {
|
|
1769
|
-
core.Guards.stringValue(
|
|
1769
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
|
|
1770
1770
|
}
|
|
1771
1771
|
try {
|
|
1772
1772
|
const identityConnector = this.getConnectorByUri(identity);
|
|
@@ -1774,7 +1774,7 @@ class IdentityService {
|
|
|
1774
1774
|
return service;
|
|
1775
1775
|
}
|
|
1776
1776
|
catch (error) {
|
|
1777
|
-
throw new core.GeneralError(
|
|
1777
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "serviceCreateFailed", { identity, serviceId }, error);
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
1780
|
/**
|
|
@@ -1785,15 +1785,15 @@ class IdentityService {
|
|
|
1785
1785
|
* @throws NotFoundError if the id can not be resolved.
|
|
1786
1786
|
*/
|
|
1787
1787
|
async serviceRemove(serviceId, controller) {
|
|
1788
|
-
core.Guards.stringValue(
|
|
1789
|
-
core.Urn.guard(
|
|
1788
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1789
|
+
core.Urn.guard(IdentityService.CLASS_NAME, "serviceId", serviceId);
|
|
1790
1790
|
try {
|
|
1791
1791
|
const idParts = identityModels.DocumentHelper.parseId(serviceId);
|
|
1792
1792
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1793
1793
|
await identityConnector.removeService(controller, serviceId);
|
|
1794
1794
|
}
|
|
1795
1795
|
catch (error) {
|
|
1796
|
-
throw new core.GeneralError(
|
|
1796
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "serviceRemoveFailed", { serviceId }, error);
|
|
1797
1797
|
}
|
|
1798
1798
|
}
|
|
1799
1799
|
/**
|
|
@@ -1809,9 +1809,9 @@ class IdentityService {
|
|
|
1809
1809
|
* @throws NotFoundError if the id can not be resolved.
|
|
1810
1810
|
*/
|
|
1811
1811
|
async verifiableCredentialCreate(verificationMethodId, id, subject, options, controller) {
|
|
1812
|
-
core.Guards.stringValue(
|
|
1813
|
-
core.Urn.guard(
|
|
1814
|
-
core.Guards.objectValue(
|
|
1812
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1813
|
+
core.Urn.guard(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
1814
|
+
core.Guards.objectValue(IdentityService.CLASS_NAME, "subject", subject);
|
|
1815
1815
|
try {
|
|
1816
1816
|
const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
|
|
1817
1817
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
@@ -1819,7 +1819,7 @@ class IdentityService {
|
|
|
1819
1819
|
return service;
|
|
1820
1820
|
}
|
|
1821
1821
|
catch (error) {
|
|
1822
|
-
throw new core.GeneralError(
|
|
1822
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialCreateFailed", { verificationMethodId }, error);
|
|
1823
1823
|
}
|
|
1824
1824
|
}
|
|
1825
1825
|
/**
|
|
@@ -1828,7 +1828,7 @@ class IdentityService {
|
|
|
1828
1828
|
* @returns The credential stored in the jwt and the revocation status.
|
|
1829
1829
|
*/
|
|
1830
1830
|
async verifiableCredentialVerify(credentialJwt) {
|
|
1831
|
-
core.Guards.stringValue(
|
|
1831
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "credentialJwt", credentialJwt);
|
|
1832
1832
|
const jwtDecoded = await web.Jwt.decode(credentialJwt);
|
|
1833
1833
|
const jwtHeader = jwtDecoded.header;
|
|
1834
1834
|
const jwtPayload = jwtDecoded.payload;
|
|
@@ -1837,7 +1837,7 @@ class IdentityService {
|
|
|
1837
1837
|
core.Is.undefined(jwtPayload) ||
|
|
1838
1838
|
core.Is.undefined(jwtPayload.iss) ||
|
|
1839
1839
|
core.Is.undefined(jwtSignature)) {
|
|
1840
|
-
throw new core.GeneralError(
|
|
1840
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "jwtDecodeFailed");
|
|
1841
1841
|
}
|
|
1842
1842
|
try {
|
|
1843
1843
|
const identityConnector = this.getConnectorByUri(jwtPayload.iss);
|
|
@@ -1845,7 +1845,7 @@ class IdentityService {
|
|
|
1845
1845
|
return service;
|
|
1846
1846
|
}
|
|
1847
1847
|
catch (error) {
|
|
1848
|
-
throw new core.GeneralError(
|
|
1848
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
|
|
1849
1849
|
}
|
|
1850
1850
|
}
|
|
1851
1851
|
/**
|
|
@@ -1856,9 +1856,9 @@ class IdentityService {
|
|
|
1856
1856
|
* @returns Nothing.
|
|
1857
1857
|
*/
|
|
1858
1858
|
async verifiableCredentialRevoke(issuerIdentity, credentialIndex, controller) {
|
|
1859
|
-
core.Guards.stringValue(
|
|
1860
|
-
core.Guards.stringValue(
|
|
1861
|
-
core.Guards.number(
|
|
1859
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1860
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "issuerIdentity", issuerIdentity);
|
|
1861
|
+
core.Guards.number(IdentityService.CLASS_NAME, "credentialIndex", credentialIndex);
|
|
1862
1862
|
try {
|
|
1863
1863
|
const idParts = identityModels.DocumentHelper.parseId(issuerIdentity);
|
|
1864
1864
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
@@ -1867,7 +1867,7 @@ class IdentityService {
|
|
|
1867
1867
|
]);
|
|
1868
1868
|
}
|
|
1869
1869
|
catch (error) {
|
|
1870
|
-
throw new core.GeneralError(
|
|
1870
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialRevokeFailed", { issuerIdentity, credentialIndex }, error);
|
|
1871
1871
|
}
|
|
1872
1872
|
}
|
|
1873
1873
|
/**
|
|
@@ -1878,9 +1878,9 @@ class IdentityService {
|
|
|
1878
1878
|
* @returns Nothing.
|
|
1879
1879
|
*/
|
|
1880
1880
|
async verifiableCredentialUnrevoke(issuerIdentity, credentialIndex, controller) {
|
|
1881
|
-
core.Guards.stringValue(
|
|
1882
|
-
core.Guards.stringValue(
|
|
1883
|
-
core.Guards.number(
|
|
1881
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1882
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "issuerIdentity", issuerIdentity);
|
|
1883
|
+
core.Guards.number(IdentityService.CLASS_NAME, "credentialIndex", credentialIndex);
|
|
1884
1884
|
try {
|
|
1885
1885
|
const idParts = identityModels.DocumentHelper.parseId(issuerIdentity);
|
|
1886
1886
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
@@ -1889,7 +1889,7 @@ class IdentityService {
|
|
|
1889
1889
|
]);
|
|
1890
1890
|
}
|
|
1891
1891
|
catch (error) {
|
|
1892
|
-
throw new core.GeneralError(
|
|
1892
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialUnrevokeFailed", { issuerIdentity, credentialIndex }, error);
|
|
1893
1893
|
}
|
|
1894
1894
|
}
|
|
1895
1895
|
/**
|
|
@@ -1905,15 +1905,15 @@ class IdentityService {
|
|
|
1905
1905
|
* @throws NotFoundError if the id can not be resolved.
|
|
1906
1906
|
*/
|
|
1907
1907
|
async verifiablePresentationCreate(verificationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes, controller) {
|
|
1908
|
-
core.Guards.stringValue(
|
|
1909
|
-
core.Guards.stringValue(
|
|
1908
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1909
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
1910
1910
|
try {
|
|
1911
1911
|
const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
|
|
1912
1912
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1913
1913
|
return identityConnector.createVerifiablePresentation(controller, verificationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes);
|
|
1914
1914
|
}
|
|
1915
1915
|
catch (error) {
|
|
1916
|
-
throw new core.GeneralError(
|
|
1916
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationCreateFailed", { verificationMethodId }, error);
|
|
1917
1917
|
}
|
|
1918
1918
|
}
|
|
1919
1919
|
/**
|
|
@@ -1922,7 +1922,7 @@ class IdentityService {
|
|
|
1922
1922
|
* @returns The presentation stored in the jwt and the revocation status.
|
|
1923
1923
|
*/
|
|
1924
1924
|
async verifiablePresentationVerify(presentationJwt) {
|
|
1925
|
-
core.Guards.stringValue(
|
|
1925
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "presentationJwt", presentationJwt);
|
|
1926
1926
|
const jwtDecoded = await web.Jwt.decode(presentationJwt);
|
|
1927
1927
|
const jwtHeader = jwtDecoded.header;
|
|
1928
1928
|
const jwtPayload = jwtDecoded.payload;
|
|
@@ -1931,7 +1931,7 @@ class IdentityService {
|
|
|
1931
1931
|
core.Is.undefined(jwtPayload) ||
|
|
1932
1932
|
core.Is.undefined(jwtPayload.iss) ||
|
|
1933
1933
|
core.Is.undefined(jwtSignature)) {
|
|
1934
|
-
throw new core.GeneralError(
|
|
1934
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "jwtDecodeFailed");
|
|
1935
1935
|
}
|
|
1936
1936
|
try {
|
|
1937
1937
|
const identityConnector = this.getConnectorByUri(jwtPayload.iss);
|
|
@@ -1939,7 +1939,7 @@ class IdentityService {
|
|
|
1939
1939
|
return service;
|
|
1940
1940
|
}
|
|
1941
1941
|
catch (error) {
|
|
1942
|
-
throw new core.GeneralError(
|
|
1942
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationVerifyFailed", undefined, error);
|
|
1943
1943
|
}
|
|
1944
1944
|
}
|
|
1945
1945
|
/**
|
|
@@ -1951,17 +1951,17 @@ class IdentityService {
|
|
|
1951
1951
|
* @returns The proof.
|
|
1952
1952
|
*/
|
|
1953
1953
|
async proofCreate(verificationMethodId, proofType, unsecureDocument, controller) {
|
|
1954
|
-
core.Guards.stringValue(
|
|
1955
|
-
core.Guards.stringValue(
|
|
1956
|
-
core.Guards.arrayOneOf(
|
|
1957
|
-
core.Guards.object(
|
|
1954
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1955
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
1956
|
+
core.Guards.arrayOneOf(IdentityService.CLASS_NAME, "proofType", proofType, Object.values(standardsW3cDid.ProofTypes));
|
|
1957
|
+
core.Guards.object(IdentityService.CLASS_NAME, "unsecureDocument", unsecureDocument);
|
|
1958
1958
|
try {
|
|
1959
1959
|
const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
|
|
1960
1960
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1961
1961
|
return identityConnector.createProof(controller, verificationMethodId, proofType, unsecureDocument);
|
|
1962
1962
|
}
|
|
1963
1963
|
catch (error) {
|
|
1964
|
-
throw new core.GeneralError(
|
|
1964
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "proofCreateFailed", { verificationMethodId }, error);
|
|
1965
1965
|
}
|
|
1966
1966
|
}
|
|
1967
1967
|
/**
|
|
@@ -1971,16 +1971,16 @@ class IdentityService {
|
|
|
1971
1971
|
* @returns True if the proof is verified.
|
|
1972
1972
|
*/
|
|
1973
1973
|
async proofVerify(document, proof) {
|
|
1974
|
-
core.Guards.object(
|
|
1975
|
-
core.Guards.object(
|
|
1976
|
-
core.Guards.stringValue(
|
|
1974
|
+
core.Guards.object(IdentityService.CLASS_NAME, "document", document);
|
|
1975
|
+
core.Guards.object(IdentityService.CLASS_NAME, "proof", proof);
|
|
1976
|
+
core.Guards.stringValue(IdentityService.CLASS_NAME, "proof.verificationMethod", proof.verificationMethod);
|
|
1977
1977
|
try {
|
|
1978
1978
|
const idParts = identityModels.DocumentHelper.parseId(proof.verificationMethod);
|
|
1979
1979
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1980
1980
|
return identityConnector.verifyProof(document, proof);
|
|
1981
1981
|
}
|
|
1982
1982
|
catch (error) {
|
|
1983
|
-
throw new core.GeneralError(
|
|
1983
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "proofVerifyFailed", undefined, error);
|
|
1984
1984
|
}
|
|
1985
1985
|
}
|
|
1986
1986
|
/**
|
|
@@ -1993,7 +1993,9 @@ class IdentityService {
|
|
|
1993
1993
|
const namespaceMethod = namespace ?? this._defaultNamespace;
|
|
1994
1994
|
const connector = identityModels.IdentityConnectorFactory.getIfExists(namespaceMethod);
|
|
1995
1995
|
if (core.Is.empty(connector)) {
|
|
1996
|
-
throw new core.GeneralError(
|
|
1996
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "connectorNotFound", {
|
|
1997
|
+
namespace: namespaceMethod
|
|
1998
|
+
});
|
|
1997
1999
|
}
|
|
1998
2000
|
return connector;
|
|
1999
2001
|
}
|
|
@@ -2006,7 +2008,7 @@ class IdentityService {
|
|
|
2006
2008
|
getConnectorByUri(id) {
|
|
2007
2009
|
const idUri = core.Urn.fromValidString(id);
|
|
2008
2010
|
if (idUri.namespaceIdentifier() !== "did") {
|
|
2009
|
-
throw new core.GeneralError(
|
|
2011
|
+
throw new core.GeneralError(IdentityService.CLASS_NAME, "namespaceMismatch", {
|
|
2010
2012
|
namespace: "did",
|
|
2011
2013
|
id
|
|
2012
2014
|
});
|