@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/esm/index.mjs
CHANGED
|
@@ -377,7 +377,7 @@ async function identitiesList(httpRequestContext, componentName, request) {
|
|
|
377
377
|
};
|
|
378
378
|
});
|
|
379
379
|
return {
|
|
380
|
-
body: await component.list(publicFilters, HttpParameterHelper.arrayFromString(request?.query?.publicPropertyNames), request?.query?.cursor, Coerce.integer(request.query?.
|
|
380
|
+
body: await component.list(publicFilters, HttpParameterHelper.arrayFromString(request?.query?.publicPropertyNames), request?.query?.cursor, Coerce.integer(request.query?.limit))
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
383
|
|
|
@@ -390,7 +390,7 @@ class IdentityProfileService {
|
|
|
390
390
|
/**
|
|
391
391
|
* Runtime name for the class.
|
|
392
392
|
*/
|
|
393
|
-
CLASS_NAME = "IdentityProfileService";
|
|
393
|
+
static CLASS_NAME = "IdentityProfileService";
|
|
394
394
|
/**
|
|
395
395
|
* The identity profile connector.
|
|
396
396
|
* @internal
|
|
@@ -411,15 +411,15 @@ class IdentityProfileService {
|
|
|
411
411
|
* @returns Nothing.
|
|
412
412
|
*/
|
|
413
413
|
async create(publicProfile, privateProfile, identity) {
|
|
414
|
-
Guards.stringValue(
|
|
414
|
+
Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
415
415
|
try {
|
|
416
416
|
await this._identityProfileConnector.create(identity, publicProfile, privateProfile);
|
|
417
417
|
}
|
|
418
418
|
catch (error) {
|
|
419
|
-
if (BaseError.someErrorClass(error,
|
|
419
|
+
if (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
420
420
|
throw error;
|
|
421
421
|
}
|
|
422
|
-
throw new GeneralError(
|
|
422
|
+
throw new GeneralError(IdentityProfileService.CLASS_NAME, "createFailed", { identity }, error);
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
@@ -430,11 +430,11 @@ class IdentityProfileService {
|
|
|
430
430
|
* @returns The items identity and the properties.
|
|
431
431
|
*/
|
|
432
432
|
async get(publicPropertyNames, privatePropertyNames, identity) {
|
|
433
|
-
Guards.stringValue(
|
|
433
|
+
Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
434
434
|
try {
|
|
435
435
|
const result = await this._identityProfileConnector.get(identity, publicPropertyNames, privatePropertyNames);
|
|
436
436
|
if (Is.undefined(result)) {
|
|
437
|
-
throw new NotFoundError(
|
|
437
|
+
throw new NotFoundError(IdentityProfileService.CLASS_NAME, "notFound", identity);
|
|
438
438
|
}
|
|
439
439
|
return {
|
|
440
440
|
identity,
|
|
@@ -443,10 +443,10 @@ class IdentityProfileService {
|
|
|
443
443
|
};
|
|
444
444
|
}
|
|
445
445
|
catch (error) {
|
|
446
|
-
if (BaseError.someErrorClass(error,
|
|
446
|
+
if (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
447
447
|
throw error;
|
|
448
448
|
}
|
|
449
|
-
throw new GeneralError(
|
|
449
|
+
throw new GeneralError(IdentityProfileService.CLASS_NAME, "getFailed", undefined, error);
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
452
|
/**
|
|
@@ -456,19 +456,19 @@ class IdentityProfileService {
|
|
|
456
456
|
* @returns The items properties.
|
|
457
457
|
*/
|
|
458
458
|
async getPublic(identity, propertyNames) {
|
|
459
|
-
Guards.stringValue(
|
|
459
|
+
Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
460
460
|
try {
|
|
461
461
|
const result = await this._identityProfileConnector.get(identity, propertyNames);
|
|
462
462
|
if (Is.undefined(result)) {
|
|
463
|
-
throw new NotFoundError(
|
|
463
|
+
throw new NotFoundError(IdentityProfileService.CLASS_NAME, "notFound", identity);
|
|
464
464
|
}
|
|
465
465
|
return result.publicProfile;
|
|
466
466
|
}
|
|
467
467
|
catch (error) {
|
|
468
|
-
if (BaseError.someErrorClass(error,
|
|
468
|
+
if (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
469
469
|
throw error;
|
|
470
470
|
}
|
|
471
|
-
throw new GeneralError(
|
|
471
|
+
throw new GeneralError(IdentityProfileService.CLASS_NAME, "getPublicFailed", undefined, error);
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
/**
|
|
@@ -479,19 +479,19 @@ class IdentityProfileService {
|
|
|
479
479
|
* @returns Nothing.
|
|
480
480
|
*/
|
|
481
481
|
async update(publicProfile, privateProfile, identity) {
|
|
482
|
-
Guards.stringValue(
|
|
482
|
+
Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
483
483
|
try {
|
|
484
484
|
const result = await this._identityProfileConnector.get(identity);
|
|
485
485
|
if (Is.undefined(result)) {
|
|
486
|
-
throw new NotFoundError(
|
|
486
|
+
throw new NotFoundError(IdentityProfileService.CLASS_NAME, "notFound", identity);
|
|
487
487
|
}
|
|
488
488
|
await this._identityProfileConnector.update(identity, publicProfile, privateProfile);
|
|
489
489
|
}
|
|
490
490
|
catch (error) {
|
|
491
|
-
if (BaseError.someErrorClass(error,
|
|
491
|
+
if (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
492
492
|
throw error;
|
|
493
493
|
}
|
|
494
|
-
throw new GeneralError(
|
|
494
|
+
throw new GeneralError(IdentityProfileService.CLASS_NAME, "updateFailed", { identity }, error);
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
/**
|
|
@@ -500,19 +500,19 @@ class IdentityProfileService {
|
|
|
500
500
|
* @returns Nothing.
|
|
501
501
|
*/
|
|
502
502
|
async remove(identity) {
|
|
503
|
-
Guards.stringValue(
|
|
503
|
+
Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
|
|
504
504
|
try {
|
|
505
505
|
const result = await this._identityProfileConnector.get(identity);
|
|
506
506
|
if (Is.undefined(result)) {
|
|
507
|
-
throw new NotFoundError(
|
|
507
|
+
throw new NotFoundError(IdentityProfileService.CLASS_NAME, "notFound", identity);
|
|
508
508
|
}
|
|
509
509
|
await this._identityProfileConnector.remove(identity);
|
|
510
510
|
}
|
|
511
511
|
catch (error) {
|
|
512
|
-
if (BaseError.someErrorClass(error,
|
|
512
|
+
if (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {
|
|
513
513
|
throw error;
|
|
514
514
|
}
|
|
515
|
-
throw new GeneralError(
|
|
515
|
+
throw new GeneralError(IdentityProfileService.CLASS_NAME, "removeFailed", { identity }, error);
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
/**
|
|
@@ -520,17 +520,17 @@ class IdentityProfileService {
|
|
|
520
520
|
* @param publicFilters The filters to apply to the identities public profiles.
|
|
521
521
|
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
522
522
|
* @param cursor The cursor for paged requests.
|
|
523
|
-
* @param
|
|
523
|
+
* @param limit The maximum number of items in a page.
|
|
524
524
|
* @returns The list of items and cursor for paging.
|
|
525
525
|
*/
|
|
526
|
-
async list(publicFilters, publicPropertyNames, cursor,
|
|
526
|
+
async list(publicFilters, publicPropertyNames, cursor, limit) {
|
|
527
527
|
try {
|
|
528
528
|
// We don't want to return private profile for this type of query
|
|
529
529
|
// as it would expose the values to the REST api
|
|
530
|
-
return this._identityProfileConnector.list(publicFilters, undefined, publicPropertyNames, undefined, cursor,
|
|
530
|
+
return this._identityProfileConnector.list(publicFilters, undefined, publicPropertyNames, undefined, cursor, limit);
|
|
531
531
|
}
|
|
532
532
|
catch (error) {
|
|
533
|
-
throw new GeneralError(
|
|
533
|
+
throw new GeneralError(IdentityProfileService.CLASS_NAME, "listFailed", undefined, error);
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
}
|
|
@@ -629,7 +629,7 @@ class IdentityResolverService {
|
|
|
629
629
|
/**
|
|
630
630
|
* Runtime name for the class.
|
|
631
631
|
*/
|
|
632
|
-
CLASS_NAME = "IdentityResolverService";
|
|
632
|
+
static CLASS_NAME = "IdentityResolverService";
|
|
633
633
|
/**
|
|
634
634
|
* The default namespace for the connector to use.
|
|
635
635
|
* @internal
|
|
@@ -647,7 +647,7 @@ class IdentityResolverService {
|
|
|
647
647
|
constructor(options) {
|
|
648
648
|
const names = IdentityResolverConnectorFactory.names();
|
|
649
649
|
if (names.length === 0) {
|
|
650
|
-
throw new GeneralError(
|
|
650
|
+
throw new GeneralError(IdentityResolverService.CLASS_NAME, "noConnectors");
|
|
651
651
|
}
|
|
652
652
|
this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
|
|
653
653
|
this._fallbackResolverConnectorType = options?.fallbackResolverConnectorType ?? "universal";
|
|
@@ -658,14 +658,14 @@ class IdentityResolverService {
|
|
|
658
658
|
* @returns The resolved document.
|
|
659
659
|
*/
|
|
660
660
|
async identityResolve(identity) {
|
|
661
|
-
Urn.guard(
|
|
661
|
+
Urn.guard(IdentityResolverService.CLASS_NAME, "identity", identity);
|
|
662
662
|
try {
|
|
663
663
|
const identityResolverConnector = this.getConnectorByUri(identity);
|
|
664
664
|
const document = await identityResolverConnector.resolveDocument(identity);
|
|
665
665
|
return document;
|
|
666
666
|
}
|
|
667
667
|
catch (error) {
|
|
668
|
-
throw new GeneralError(
|
|
668
|
+
throw new GeneralError(IdentityResolverService.CLASS_NAME, "identityResolveFailed", {
|
|
669
669
|
identity
|
|
670
670
|
}, error);
|
|
671
671
|
}
|
|
@@ -683,7 +683,7 @@ class IdentityResolverService {
|
|
|
683
683
|
// Let's see if a fallback 'universal' connector is registered
|
|
684
684
|
connector = IdentityResolverConnectorFactory.getIfExists(this._fallbackResolverConnectorType);
|
|
685
685
|
if (Is.empty(connector)) {
|
|
686
|
-
throw new GeneralError(
|
|
686
|
+
throw new GeneralError(IdentityResolverService.CLASS_NAME, "connectorNotFound", {
|
|
687
687
|
namespace: namespaceMethod
|
|
688
688
|
});
|
|
689
689
|
}
|
|
@@ -699,7 +699,7 @@ class IdentityResolverService {
|
|
|
699
699
|
getConnectorByUri(id) {
|
|
700
700
|
const idUri = Urn.fromValidString(id);
|
|
701
701
|
if (idUri.namespaceIdentifier() !== "did") {
|
|
702
|
-
throw new GeneralError(
|
|
702
|
+
throw new GeneralError(IdentityResolverService.CLASS_NAME, "namespaceMismatch", {
|
|
703
703
|
namespace: "did",
|
|
704
704
|
id
|
|
705
705
|
});
|
|
@@ -1647,7 +1647,7 @@ class IdentityService {
|
|
|
1647
1647
|
/**
|
|
1648
1648
|
* Runtime name for the class.
|
|
1649
1649
|
*/
|
|
1650
|
-
CLASS_NAME = "IdentityService";
|
|
1650
|
+
static CLASS_NAME = "IdentityService";
|
|
1651
1651
|
/**
|
|
1652
1652
|
* The default namespace for the connector to use.
|
|
1653
1653
|
* @internal
|
|
@@ -1660,7 +1660,7 @@ class IdentityService {
|
|
|
1660
1660
|
constructor(options) {
|
|
1661
1661
|
const names = IdentityConnectorFactory.names();
|
|
1662
1662
|
if (names.length === 0) {
|
|
1663
|
-
throw new GeneralError(
|
|
1663
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "noConnectors");
|
|
1664
1664
|
}
|
|
1665
1665
|
this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
|
|
1666
1666
|
}
|
|
@@ -1671,13 +1671,13 @@ class IdentityService {
|
|
|
1671
1671
|
* @returns The created identity document.
|
|
1672
1672
|
*/
|
|
1673
1673
|
async identityCreate(namespace, controller) {
|
|
1674
|
-
Guards.stringValue(
|
|
1674
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1675
1675
|
try {
|
|
1676
1676
|
const identityConnector = this.getConnectorByNamespace(namespace);
|
|
1677
1677
|
return identityConnector.createDocument(controller);
|
|
1678
1678
|
}
|
|
1679
1679
|
catch (error) {
|
|
1680
|
-
throw new GeneralError(
|
|
1680
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "identityCreateFailed", undefined, error);
|
|
1681
1681
|
}
|
|
1682
1682
|
}
|
|
1683
1683
|
/**
|
|
@@ -1687,14 +1687,14 @@ class IdentityService {
|
|
|
1687
1687
|
* @returns Nothing.
|
|
1688
1688
|
*/
|
|
1689
1689
|
async identityRemove(identity, controller) {
|
|
1690
|
-
Guards.stringValue(
|
|
1691
|
-
Guards.stringValue(
|
|
1690
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "identity", identity);
|
|
1691
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1692
1692
|
try {
|
|
1693
1693
|
const identityConnector = this.getConnectorByUri(identity);
|
|
1694
1694
|
return identityConnector.removeDocument(controller, identity);
|
|
1695
1695
|
}
|
|
1696
1696
|
catch (error) {
|
|
1697
|
-
throw new GeneralError(
|
|
1697
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "identityRemoveFailed", { identity }, error);
|
|
1698
1698
|
}
|
|
1699
1699
|
}
|
|
1700
1700
|
/**
|
|
@@ -1708,16 +1708,16 @@ class IdentityService {
|
|
|
1708
1708
|
* @throws NotSupportedError if the platform does not support multiple keys.
|
|
1709
1709
|
*/
|
|
1710
1710
|
async verificationMethodCreate(identity, verificationMethodType, verificationMethodId, controller) {
|
|
1711
|
-
Guards.stringValue(
|
|
1712
|
-
Urn.guard(
|
|
1713
|
-
Guards.arrayOneOf(
|
|
1711
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1712
|
+
Urn.guard(IdentityService.CLASS_NAME, "identity", identity);
|
|
1713
|
+
Guards.arrayOneOf(IdentityService.CLASS_NAME, "verificationMethodType", verificationMethodType, Object.values(DidVerificationMethodType));
|
|
1714
1714
|
try {
|
|
1715
1715
|
const identityConnector = this.getConnectorByUri(identity);
|
|
1716
1716
|
const verificationMethod = await identityConnector.addVerificationMethod(controller, identity, verificationMethodType, verificationMethodId);
|
|
1717
1717
|
return verificationMethod;
|
|
1718
1718
|
}
|
|
1719
1719
|
catch (error) {
|
|
1720
|
-
throw new GeneralError(
|
|
1720
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "verificationMethodCreateFailed", { identity }, error);
|
|
1721
1721
|
}
|
|
1722
1722
|
}
|
|
1723
1723
|
/**
|
|
@@ -1729,15 +1729,15 @@ class IdentityService {
|
|
|
1729
1729
|
* @throws NotSupportedError if the platform does not support multiple revocable keys.
|
|
1730
1730
|
*/
|
|
1731
1731
|
async verificationMethodRemove(verificationMethodId, controller) {
|
|
1732
|
-
Guards.stringValue(
|
|
1733
|
-
Urn.guard(
|
|
1732
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1733
|
+
Urn.guard(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
1734
1734
|
try {
|
|
1735
1735
|
const idParts = DocumentHelper.parseId(verificationMethodId);
|
|
1736
1736
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1737
1737
|
await identityConnector.removeVerificationMethod(controller, verificationMethodId);
|
|
1738
1738
|
}
|
|
1739
1739
|
catch (error) {
|
|
1740
|
-
throw new GeneralError(
|
|
1740
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "verificationMethodRemoveFailed", { verificationMethodId }, error);
|
|
1741
1741
|
}
|
|
1742
1742
|
}
|
|
1743
1743
|
/**
|
|
@@ -1751,20 +1751,20 @@ class IdentityService {
|
|
|
1751
1751
|
* @throws NotFoundError if the id can not be resolved.
|
|
1752
1752
|
*/
|
|
1753
1753
|
async serviceCreate(identity, serviceId, serviceType, serviceEndpoint, controller) {
|
|
1754
|
-
Guards.stringValue(
|
|
1755
|
-
Urn.guard(
|
|
1756
|
-
Guards.stringValue(
|
|
1754
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1755
|
+
Urn.guard(IdentityService.CLASS_NAME, "identity", identity);
|
|
1756
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "serviceId", serviceId);
|
|
1757
1757
|
if (Is.array(serviceType)) {
|
|
1758
|
-
Guards.arrayValue(
|
|
1758
|
+
Guards.arrayValue(IdentityService.CLASS_NAME, "serviceType", serviceType);
|
|
1759
1759
|
}
|
|
1760
1760
|
else {
|
|
1761
|
-
Guards.stringValue(
|
|
1761
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "serviceType", serviceType);
|
|
1762
1762
|
}
|
|
1763
1763
|
if (Is.array(serviceEndpoint)) {
|
|
1764
|
-
Guards.arrayValue(
|
|
1764
|
+
Guards.arrayValue(IdentityService.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
|
|
1765
1765
|
}
|
|
1766
1766
|
else {
|
|
1767
|
-
Guards.stringValue(
|
|
1767
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
|
|
1768
1768
|
}
|
|
1769
1769
|
try {
|
|
1770
1770
|
const identityConnector = this.getConnectorByUri(identity);
|
|
@@ -1772,7 +1772,7 @@ class IdentityService {
|
|
|
1772
1772
|
return service;
|
|
1773
1773
|
}
|
|
1774
1774
|
catch (error) {
|
|
1775
|
-
throw new GeneralError(
|
|
1775
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "serviceCreateFailed", { identity, serviceId }, error);
|
|
1776
1776
|
}
|
|
1777
1777
|
}
|
|
1778
1778
|
/**
|
|
@@ -1783,15 +1783,15 @@ class IdentityService {
|
|
|
1783
1783
|
* @throws NotFoundError if the id can not be resolved.
|
|
1784
1784
|
*/
|
|
1785
1785
|
async serviceRemove(serviceId, controller) {
|
|
1786
|
-
Guards.stringValue(
|
|
1787
|
-
Urn.guard(
|
|
1786
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1787
|
+
Urn.guard(IdentityService.CLASS_NAME, "serviceId", serviceId);
|
|
1788
1788
|
try {
|
|
1789
1789
|
const idParts = DocumentHelper.parseId(serviceId);
|
|
1790
1790
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1791
1791
|
await identityConnector.removeService(controller, serviceId);
|
|
1792
1792
|
}
|
|
1793
1793
|
catch (error) {
|
|
1794
|
-
throw new GeneralError(
|
|
1794
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "serviceRemoveFailed", { serviceId }, error);
|
|
1795
1795
|
}
|
|
1796
1796
|
}
|
|
1797
1797
|
/**
|
|
@@ -1807,9 +1807,9 @@ class IdentityService {
|
|
|
1807
1807
|
* @throws NotFoundError if the id can not be resolved.
|
|
1808
1808
|
*/
|
|
1809
1809
|
async verifiableCredentialCreate(verificationMethodId, id, subject, options, controller) {
|
|
1810
|
-
Guards.stringValue(
|
|
1811
|
-
Urn.guard(
|
|
1812
|
-
Guards.objectValue(
|
|
1810
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1811
|
+
Urn.guard(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
1812
|
+
Guards.objectValue(IdentityService.CLASS_NAME, "subject", subject);
|
|
1813
1813
|
try {
|
|
1814
1814
|
const idParts = DocumentHelper.parseId(verificationMethodId);
|
|
1815
1815
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
@@ -1817,7 +1817,7 @@ class IdentityService {
|
|
|
1817
1817
|
return service;
|
|
1818
1818
|
}
|
|
1819
1819
|
catch (error) {
|
|
1820
|
-
throw new GeneralError(
|
|
1820
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialCreateFailed", { verificationMethodId }, error);
|
|
1821
1821
|
}
|
|
1822
1822
|
}
|
|
1823
1823
|
/**
|
|
@@ -1826,7 +1826,7 @@ class IdentityService {
|
|
|
1826
1826
|
* @returns The credential stored in the jwt and the revocation status.
|
|
1827
1827
|
*/
|
|
1828
1828
|
async verifiableCredentialVerify(credentialJwt) {
|
|
1829
|
-
Guards.stringValue(
|
|
1829
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "credentialJwt", credentialJwt);
|
|
1830
1830
|
const jwtDecoded = await Jwt.decode(credentialJwt);
|
|
1831
1831
|
const jwtHeader = jwtDecoded.header;
|
|
1832
1832
|
const jwtPayload = jwtDecoded.payload;
|
|
@@ -1835,7 +1835,7 @@ class IdentityService {
|
|
|
1835
1835
|
Is.undefined(jwtPayload) ||
|
|
1836
1836
|
Is.undefined(jwtPayload.iss) ||
|
|
1837
1837
|
Is.undefined(jwtSignature)) {
|
|
1838
|
-
throw new GeneralError(
|
|
1838
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "jwtDecodeFailed");
|
|
1839
1839
|
}
|
|
1840
1840
|
try {
|
|
1841
1841
|
const identityConnector = this.getConnectorByUri(jwtPayload.iss);
|
|
@@ -1843,7 +1843,7 @@ class IdentityService {
|
|
|
1843
1843
|
return service;
|
|
1844
1844
|
}
|
|
1845
1845
|
catch (error) {
|
|
1846
|
-
throw new GeneralError(
|
|
1846
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialVerifyFailed", undefined, error);
|
|
1847
1847
|
}
|
|
1848
1848
|
}
|
|
1849
1849
|
/**
|
|
@@ -1854,9 +1854,9 @@ class IdentityService {
|
|
|
1854
1854
|
* @returns Nothing.
|
|
1855
1855
|
*/
|
|
1856
1856
|
async verifiableCredentialRevoke(issuerIdentity, credentialIndex, controller) {
|
|
1857
|
-
Guards.stringValue(
|
|
1858
|
-
Guards.stringValue(
|
|
1859
|
-
Guards.number(
|
|
1857
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1858
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "issuerIdentity", issuerIdentity);
|
|
1859
|
+
Guards.number(IdentityService.CLASS_NAME, "credentialIndex", credentialIndex);
|
|
1860
1860
|
try {
|
|
1861
1861
|
const idParts = DocumentHelper.parseId(issuerIdentity);
|
|
1862
1862
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
@@ -1865,7 +1865,7 @@ class IdentityService {
|
|
|
1865
1865
|
]);
|
|
1866
1866
|
}
|
|
1867
1867
|
catch (error) {
|
|
1868
|
-
throw new GeneralError(
|
|
1868
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialRevokeFailed", { issuerIdentity, credentialIndex }, error);
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
1871
|
/**
|
|
@@ -1876,9 +1876,9 @@ class IdentityService {
|
|
|
1876
1876
|
* @returns Nothing.
|
|
1877
1877
|
*/
|
|
1878
1878
|
async verifiableCredentialUnrevoke(issuerIdentity, credentialIndex, controller) {
|
|
1879
|
-
Guards.stringValue(
|
|
1880
|
-
Guards.stringValue(
|
|
1881
|
-
Guards.number(
|
|
1879
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1880
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "issuerIdentity", issuerIdentity);
|
|
1881
|
+
Guards.number(IdentityService.CLASS_NAME, "credentialIndex", credentialIndex);
|
|
1882
1882
|
try {
|
|
1883
1883
|
const idParts = DocumentHelper.parseId(issuerIdentity);
|
|
1884
1884
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
@@ -1887,7 +1887,7 @@ class IdentityService {
|
|
|
1887
1887
|
]);
|
|
1888
1888
|
}
|
|
1889
1889
|
catch (error) {
|
|
1890
|
-
throw new GeneralError(
|
|
1890
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "verifiableCredentialUnrevokeFailed", { issuerIdentity, credentialIndex }, error);
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
1893
|
/**
|
|
@@ -1903,15 +1903,15 @@ class IdentityService {
|
|
|
1903
1903
|
* @throws NotFoundError if the id can not be resolved.
|
|
1904
1904
|
*/
|
|
1905
1905
|
async verifiablePresentationCreate(verificationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes, controller) {
|
|
1906
|
-
Guards.stringValue(
|
|
1907
|
-
Guards.stringValue(
|
|
1906
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1907
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
1908
1908
|
try {
|
|
1909
1909
|
const idParts = DocumentHelper.parseId(verificationMethodId);
|
|
1910
1910
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1911
1911
|
return identityConnector.createVerifiablePresentation(controller, verificationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes);
|
|
1912
1912
|
}
|
|
1913
1913
|
catch (error) {
|
|
1914
|
-
throw new GeneralError(
|
|
1914
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationCreateFailed", { verificationMethodId }, error);
|
|
1915
1915
|
}
|
|
1916
1916
|
}
|
|
1917
1917
|
/**
|
|
@@ -1920,7 +1920,7 @@ class IdentityService {
|
|
|
1920
1920
|
* @returns The presentation stored in the jwt and the revocation status.
|
|
1921
1921
|
*/
|
|
1922
1922
|
async verifiablePresentationVerify(presentationJwt) {
|
|
1923
|
-
Guards.stringValue(
|
|
1923
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "presentationJwt", presentationJwt);
|
|
1924
1924
|
const jwtDecoded = await Jwt.decode(presentationJwt);
|
|
1925
1925
|
const jwtHeader = jwtDecoded.header;
|
|
1926
1926
|
const jwtPayload = jwtDecoded.payload;
|
|
@@ -1929,7 +1929,7 @@ class IdentityService {
|
|
|
1929
1929
|
Is.undefined(jwtPayload) ||
|
|
1930
1930
|
Is.undefined(jwtPayload.iss) ||
|
|
1931
1931
|
Is.undefined(jwtSignature)) {
|
|
1932
|
-
throw new GeneralError(
|
|
1932
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "jwtDecodeFailed");
|
|
1933
1933
|
}
|
|
1934
1934
|
try {
|
|
1935
1935
|
const identityConnector = this.getConnectorByUri(jwtPayload.iss);
|
|
@@ -1937,7 +1937,7 @@ class IdentityService {
|
|
|
1937
1937
|
return service;
|
|
1938
1938
|
}
|
|
1939
1939
|
catch (error) {
|
|
1940
|
-
throw new GeneralError(
|
|
1940
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "verifiablePresentationVerifyFailed", undefined, error);
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
1943
1943
|
/**
|
|
@@ -1949,17 +1949,17 @@ class IdentityService {
|
|
|
1949
1949
|
* @returns The proof.
|
|
1950
1950
|
*/
|
|
1951
1951
|
async proofCreate(verificationMethodId, proofType, unsecureDocument, controller) {
|
|
1952
|
-
Guards.stringValue(
|
|
1953
|
-
Guards.stringValue(
|
|
1954
|
-
Guards.arrayOneOf(
|
|
1955
|
-
Guards.object(
|
|
1952
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
|
|
1953
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
1954
|
+
Guards.arrayOneOf(IdentityService.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
|
|
1955
|
+
Guards.object(IdentityService.CLASS_NAME, "unsecureDocument", unsecureDocument);
|
|
1956
1956
|
try {
|
|
1957
1957
|
const idParts = DocumentHelper.parseId(verificationMethodId);
|
|
1958
1958
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1959
1959
|
return identityConnector.createProof(controller, verificationMethodId, proofType, unsecureDocument);
|
|
1960
1960
|
}
|
|
1961
1961
|
catch (error) {
|
|
1962
|
-
throw new GeneralError(
|
|
1962
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "proofCreateFailed", { verificationMethodId }, error);
|
|
1963
1963
|
}
|
|
1964
1964
|
}
|
|
1965
1965
|
/**
|
|
@@ -1969,16 +1969,16 @@ class IdentityService {
|
|
|
1969
1969
|
* @returns True if the proof is verified.
|
|
1970
1970
|
*/
|
|
1971
1971
|
async proofVerify(document, proof) {
|
|
1972
|
-
Guards.object(
|
|
1973
|
-
Guards.object(
|
|
1974
|
-
Guards.stringValue(
|
|
1972
|
+
Guards.object(IdentityService.CLASS_NAME, "document", document);
|
|
1973
|
+
Guards.object(IdentityService.CLASS_NAME, "proof", proof);
|
|
1974
|
+
Guards.stringValue(IdentityService.CLASS_NAME, "proof.verificationMethod", proof.verificationMethod);
|
|
1975
1975
|
try {
|
|
1976
1976
|
const idParts = DocumentHelper.parseId(proof.verificationMethod);
|
|
1977
1977
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
1978
1978
|
return identityConnector.verifyProof(document, proof);
|
|
1979
1979
|
}
|
|
1980
1980
|
catch (error) {
|
|
1981
|
-
throw new GeneralError(
|
|
1981
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "proofVerifyFailed", undefined, error);
|
|
1982
1982
|
}
|
|
1983
1983
|
}
|
|
1984
1984
|
/**
|
|
@@ -1991,7 +1991,9 @@ class IdentityService {
|
|
|
1991
1991
|
const namespaceMethod = namespace ?? this._defaultNamespace;
|
|
1992
1992
|
const connector = IdentityConnectorFactory.getIfExists(namespaceMethod);
|
|
1993
1993
|
if (Is.empty(connector)) {
|
|
1994
|
-
throw new GeneralError(
|
|
1994
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "connectorNotFound", {
|
|
1995
|
+
namespace: namespaceMethod
|
|
1996
|
+
});
|
|
1995
1997
|
}
|
|
1996
1998
|
return connector;
|
|
1997
1999
|
}
|
|
@@ -2004,7 +2006,7 @@ class IdentityService {
|
|
|
2004
2006
|
getConnectorByUri(id) {
|
|
2005
2007
|
const idUri = Urn.fromValidString(id);
|
|
2006
2008
|
if (idUri.namespaceIdentifier() !== "did") {
|
|
2007
|
-
throw new GeneralError(
|
|
2009
|
+
throw new GeneralError(IdentityService.CLASS_NAME, "namespaceMismatch", {
|
|
2008
2010
|
namespace: "did",
|
|
2009
2011
|
id
|
|
2010
2012
|
});
|
|
@@ -8,7 +8,7 @@ export declare class IdentityProfileService<T extends IJsonLdDocument = IJsonLdD
|
|
|
8
8
|
/**
|
|
9
9
|
* Runtime name for the class.
|
|
10
10
|
*/
|
|
11
|
-
readonly CLASS_NAME: string;
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
13
|
* Create a new instance of IdentityProfileService.
|
|
14
14
|
* @param options The dependencies for the identity profile service.
|
|
@@ -60,13 +60,13 @@ export declare class IdentityProfileService<T extends IJsonLdDocument = IJsonLdD
|
|
|
60
60
|
* @param publicFilters The filters to apply to the identities public profiles.
|
|
61
61
|
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
62
62
|
* @param cursor The cursor for paged requests.
|
|
63
|
-
* @param
|
|
63
|
+
* @param limit The maximum number of items in a page.
|
|
64
64
|
* @returns The list of items and cursor for paging.
|
|
65
65
|
*/
|
|
66
66
|
list(publicFilters?: {
|
|
67
67
|
propertyName: string;
|
|
68
68
|
propertyValue: unknown;
|
|
69
|
-
}[], publicPropertyNames?: (keyof T)[], cursor?: string,
|
|
69
|
+
}[], publicPropertyNames?: (keyof T)[], cursor?: string, limit?: number): Promise<{
|
|
70
70
|
/**
|
|
71
71
|
* The identities.
|
|
72
72
|
*/
|
|
@@ -8,7 +8,7 @@ export declare class IdentityResolverService implements IIdentityResolverCompone
|
|
|
8
8
|
/**
|
|
9
9
|
* Runtime name for the class.
|
|
10
10
|
*/
|
|
11
|
-
readonly CLASS_NAME: string;
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
13
|
* Create a new instance of IdentityResolverService.
|
|
14
14
|
* @param options The options for the service.
|
|
@@ -9,7 +9,7 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
9
9
|
/**
|
|
10
10
|
* Runtime name for the class.
|
|
11
11
|
*/
|
|
12
|
-
readonly CLASS_NAME: string;
|
|
12
|
+
static readonly CLASS_NAME: string;
|
|
13
13
|
/**
|
|
14
14
|
* Create a new instance of IdentityService.
|
|
15
15
|
* @param options The options for the service.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @twin.org/identity-service - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.9](https://github.com/twinfoundation/identity/compare/identity-service-v0.0.2-next.8...identity-service-v0.0.2-next.9) (2025-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/identity-models bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/identity-connector-entity-storage bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
18
|
+
|
|
19
|
+
## [0.0.2-next.8](https://github.com/twinfoundation/identity/compare/identity-service-v0.0.2-next.7...identity-service-v0.0.2-next.8) (2025-09-25)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Miscellaneous Chores
|
|
23
|
+
|
|
24
|
+
* **identity-service:** Synchronize repo versions
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @twin.org/identity-models bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
32
|
+
* devDependencies
|
|
33
|
+
* @twin.org/identity-connector-entity-storage bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
34
|
+
|
|
3
35
|
## [0.0.2-next.7](https://github.com/twinfoundation/identity/compare/identity-service-v0.0.2-next.6...identity-service-v0.0.2-next.7) (2025-09-23)
|
|
4
36
|
|
|
5
37
|
|