@nmshd/runtime 3.4.4 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/buildInformation.js +5 -5
  2. package/dist/useCases/common/RuntimeErrors.d.ts +1 -1
  3. package/dist/useCases/common/RuntimeErrors.d.ts.map +1 -1
  4. package/dist/useCases/common/RuntimeErrors.js +2 -6
  5. package/dist/useCases/common/RuntimeErrors.js.map +1 -1
  6. package/dist/useCases/common/Schemas.d.ts.map +1 -1
  7. package/dist/useCases/common/Schemas.js +13 -0
  8. package/dist/useCases/common/Schemas.js.map +1 -1
  9. package/dist/useCases/consumption/attributes/GetSharedVersionsOfIdentityAttribute.d.ts +3 -1
  10. package/dist/useCases/consumption/attributes/GetSharedVersionsOfIdentityAttribute.d.ts.map +1 -1
  11. package/dist/useCases/consumption/attributes/GetSharedVersionsOfIdentityAttribute.js +11 -14
  12. package/dist/useCases/consumption/attributes/GetSharedVersionsOfIdentityAttribute.js.map +1 -1
  13. package/dist/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.d.ts.map +1 -1
  14. package/dist/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.js +8 -23
  15. package/dist/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.js.map +1 -1
  16. package/dist/useCases/consumption/attributes/ShareIdentityAttribute.d.ts.map +1 -1
  17. package/dist/useCases/consumption/attributes/ShareIdentityAttribute.js +9 -30
  18. package/dist/useCases/consumption/attributes/ShareIdentityAttribute.js.map +1 -1
  19. package/lib-web/nmshd.runtime.js +49 -79
  20. package/lib-web/nmshd.runtime.js.map +1 -1
  21. package/lib-web/nmshd.runtime.min.js +1 -1
  22. package/lib-web/nmshd.runtime.min.js.map +1 -1
  23. package/package.json +3 -3
@@ -1,9 +1,11 @@
1
1
  import { Result } from "@js-soft/ts-utils";
2
2
  import { AttributesController } from "@nmshd/consumption";
3
3
  import { LocalAttributeDTO } from "../../../types";
4
- import { AttributeIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common";
4
+ import { AddressString, AttributeIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common";
5
5
  export interface GetSharedVersionsOfIdentityAttributeRequest {
6
6
  attributeId: AttributeIdString;
7
+ peers?: AddressString[];
8
+ onlyLatestVersions?: boolean;
7
9
  }
8
10
  declare class Validator extends SchemaValidator<GetSharedVersionsOfIdentityAttributeRequest> {
9
11
  constructor(schemaRepository: SchemaRepository);
@@ -1 +1 @@
1
- {"version":3,"file":"GetSharedVersionsOfIdentityAttribute.d.ts","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/GetSharedVersionsOfIdentityAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAkB,MAAM,oBAAoB,CAAC;AAG1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAiB,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5G,MAAM,WAAW,2CAA2C;IACxD,WAAW,EAAE,iBAAiB,CAAC;CAClC;AAED,cAAM,SAAU,SAAQ,eAAe,CAAC,2CAA2C,CAAC;gBACrD,gBAAgB,EAAE,gBAAgB;CAGhE;AAED,qBAAa,2CAA4C,SAAQ,OAAO,CAAC,2CAA2C,EAAE,iBAAiB,EAAE,CAAC;IAE1H,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBAAnB,mBAAmB,EAAE,oBAAoB,EAC1D,SAAS,EAAE,SAAS;cAKhB,eAAe,CAAC,OAAO,EAAE,2CAA2C,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;CA0B9H"}
1
+ {"version":3,"file":"GetSharedVersionsOfIdentityAttribute.d.ts","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/GetSharedVersionsOfIdentityAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAkB,MAAM,oBAAoB,CAAC;AAG1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAiB,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG3H,MAAM,WAAW,2CAA2C;IACxD,WAAW,EAAE,iBAAiB,CAAC;IAC/B,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,cAAM,SAAU,SAAQ,eAAe,CAAC,2CAA2C,CAAC;gBACrD,gBAAgB,EAAE,gBAAgB;CAGhE;AAED,qBAAa,2CAA4C,SAAQ,OAAO,CAAC,2CAA2C,EAAE,iBAAiB,EAAE,CAAC;IAE1H,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBAAnB,mBAAmB,EAAE,oBAAoB,EAC1D,SAAS,EAAE,SAAS;cAKhB,eAAe,CAAC,OAAO,EAAE,2CAA2C,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;CAqB9H"}
@@ -34,23 +34,20 @@ let GetSharedVersionsOfIdentityAttributeUseCase = class GetSharedVersionsOfIdent
34
34
  this.attributeController = attributeController;
35
35
  }
36
36
  async executeInternal(request) {
37
- const attribute = await this.attributeController.getLocalAttribute(transport_1.CoreId.from(request.attributeId));
38
- if (typeof attribute === "undefined") {
39
- throw common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute);
37
+ const repositoryAttributeId = transport_1.CoreId.from(request.attributeId);
38
+ const repositoryAttribute = await this.attributeController.getLocalAttribute(repositoryAttributeId);
39
+ if (typeof repositoryAttribute === "undefined") {
40
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute));
40
41
  }
41
- if (attribute.isRelationshipAttribute()) {
42
- throw common_1.RuntimeErrors.general.invalidPropertyValue("Attribute '${request.attributeId}' is a RelationshipAttribute.");
42
+ if (!repositoryAttribute.isRepositoryAttribute()) {
43
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttributeId));
43
44
  }
44
- const allVersions = await this.attributeController.getVersionsOfAttribute(transport_1.CoreId.from(request.attributeId));
45
- // queried ID doesn't belong to a repository attribute
46
- if (attribute.shareInfo !== undefined) {
47
- return ts_utils_1.Result.ok(AttributeMapper_1.AttributeMapper.toAttributeDTOList(allVersions));
45
+ if (request.peers?.length === 0) {
46
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.invalidPropertyValue("The `peers` property may not be an empty array."));
48
47
  }
49
- const query = {
50
- "shareInfo.sourceAttribute": { $in: allVersions.map((x) => x.id.toString()) }
51
- };
52
- const sharedAttributes = await this.attributeController.getLocalAttributes(query);
53
- return ts_utils_1.Result.ok(AttributeMapper_1.AttributeMapper.toAttributeDTOList(sharedAttributes));
48
+ const peers = request.peers?.map((address) => transport_1.CoreAddress.from(address));
49
+ const sharedVersions = await this.attributeController.getSharedVersionsOfRepositoryAttribute(repositoryAttributeId, peers, request.onlyLatestVersions);
50
+ return ts_utils_1.Result.ok(AttributeMapper_1.AttributeMapper.toAttributeDTOList(sharedVersions));
54
51
  }
55
52
  };
56
53
  exports.GetSharedVersionsOfIdentityAttributeUseCase = GetSharedVersionsOfIdentityAttributeUseCase;
@@ -1 +1 @@
1
- {"version":3,"file":"GetSharedVersionsOfIdentityAttribute.js","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/GetSharedVersionsOfIdentityAttribute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAA2C;AAC3C,oDAA0E;AAC1E,gDAA0C;AAC1C,mDAAwC;AAExC,yCAA4G;AAC5G,uDAAoD;AAMpD,IAAM,SAAS,GAAf,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EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE;SAChF,CAAC;QAEF,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAElF,OAAO,iBAAM,CAAC,EAAE,CAAC,iCAAe,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC3E,CAAC;CACJ,CAAA;AAlCY,kGAA2C;sDAA3C,2CAA2C;IAE/C,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;qCADuC,kCAAoB;QAC/C,SAAS;GAHvB,2CAA2C,CAkCvD"}
1
+ {"version":3,"file":"GetSharedVersionsOfIdentityAttribute.js","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/GetSharedVersionsOfIdentityAttribute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAA2C;AAC3C,oDAA0E;AAC1E,gDAAuD;AACvD,mDAAwC;AAExC,yCAA2H;AAC3H,uDAAoD;AAQpD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAA4D;IAChF,YAA2B,gBAAkC;QACzD,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,6CAA6C,CAAC,CAAC,CAAC;IACrF,CAAC;CACJ,CAAA;AAJK,SAAS;IACS,WAAA,uBAAM,CAAA;qCAAmB,yBAAgB;GAD3D,SAAS,CAId;AAED,IAAa,2CAA2C,GAAxD,MAAa,2CAA4C,SAAQ,gBAAyE;IACtI,YAC6B,mBAAyC,EAC1D,SAAoB;QAE5B,KAAK,CAAC,SAAS,CAAC,CAAC;QAHQ,wBAAmB,GAAnB,mBAAmB,CAAsB;IAItE,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,OAAoD;QAChF,MAAM,qBAAqB,GAAG,kBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC/D,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;QAEpG,IAAI,OAAO,mBAAmB,KAAK,WAAW,EAAE,CAAC;YAC7C,OAAO,iBAAM,CAAC,IAAI,CAAC,sBAAa,CAAC,OAAO,CAAC,cAAc,CAAC,4BAAc,CAAC,CAAC,CAAC;QAC7E,CAAC;QAED,IAAI,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,EAAE,CAAC;YAC/C,OAAO,iBAAM,CAAC,IAAI,CAAC,sBAAa,CAAC,UAAU,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAC9F,CAAC;QAED,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,iBAAM,CAAC,IAAI,CAAC,sBAAa,CAAC,OAAO,CAAC,oBAAoB,CAAC,iDAAiD,CAAC,CAAC,CAAC;QACtH,CAAC;QAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,uBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACzE,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,sCAAsC,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAEvJ,OAAO,iBAAM,CAAC,EAAE,CAAC,iCAAe,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC;IACzE,CAAC;CACJ,CAAA;AA7BY,kGAA2C;sDAA3C,2CAA2C;IAE/C,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;qCADuC,kCAAoB;QAC/C,SAAS;GAHvB,2CAA2C,CA6BvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotifyPeerAboutIdentityAttributeSuccession.d.ts","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAA6D,MAAM,oBAAoB,CAAC;AAErH,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAiB,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG3H,MAAM,WAAW,kDAAkD;IAC/D,WAAW,EAAE,iBAAiB,CAAC;IAC/B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iDAAiD;IAC9D,WAAW,EAAE,iBAAiB,CAAC;IAC/B,IAAI,EAAE,aAAa,CAAC;CACvB;AAED,cAAM,SAAU,SAAQ,eAAe,CAAC,iDAAiD,CAAC;gBAC3D,gBAAgB,EAAE,gBAAgB;CAGhE;AAED,qBAAa,iDAAkD,SAAQ,OAAO,CAC1E,iDAAiD,EACjD,kDAAkD,CACrD;IAEe,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,oBAAoB,EACzC,iBAAiB,EAAE,iBAAiB,EACrD,SAAS,EAAE,SAAS;cAKhB,eAAe,CAAC,OAAO,EAAE,iDAAiD,GAAG,OAAO,CAAC,MAAM,CAAC,kDAAkD,CAAC,CAAC;CAoFnK"}
1
+ {"version":3,"file":"NotifyPeerAboutIdentityAttributeSuccession.d.ts","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAA6D,MAAM,oBAAoB,CAAC;AAErH,OAAO,EAAE,iBAAiB,EAAe,MAAM,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAiB,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG3H,MAAM,WAAW,kDAAkD;IAC/D,WAAW,EAAE,iBAAiB,CAAC;IAC/B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iDAAiD;IAC9D,WAAW,EAAE,iBAAiB,CAAC;IAC/B,IAAI,EAAE,aAAa,CAAC;CACvB;AAED,cAAM,SAAU,SAAQ,eAAe,CAAC,iDAAiD,CAAC;gBAC3D,gBAAgB,EAAE,gBAAgB;CAGhE;AAED,qBAAa,iDAAkD,SAAQ,OAAO,CAC1E,iDAAiD,EACjD,kDAAkD,CACrD;IAEe,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,oBAAoB,EACzC,iBAAiB,EAAE,iBAAiB,EACrD,SAAS,EAAE,SAAS;cAKhB,eAAe,CAAC,OAAO,EAAE,iDAAiD,GAAG,OAAO,CAAC,MAAM,CAAC,kDAAkD,CAAC,CAAC;CA+DnK"}
@@ -39,33 +39,18 @@ let NotifyPeerAboutIdentityAttributeSuccessionUseCase = class NotifyPeerAboutIde
39
39
  async executeInternal(request) {
40
40
  const repositoryAttributeSuccessorId = transport_1.CoreId.from(request.attributeId);
41
41
  const repositoryAttributeSuccessor = await this.attributeController.getLocalAttribute(repositoryAttributeSuccessorId);
42
- if (typeof repositoryAttributeSuccessor === "undefined")
42
+ if (typeof repositoryAttributeSuccessor === "undefined") {
43
43
  return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute.name));
44
- if (!repositoryAttributeSuccessor.isRepositoryAttribute())
45
- return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttributeSuccessor.id));
46
- const query = {
47
- "content.owner": this.accountController.identity.address.toString(),
48
- "content.@type": "IdentityAttribute",
49
- "shareInfo.sourceAttribute": repositoryAttributeSuccessorId.toString(),
50
- "shareInfo.peer": request.peer
51
- };
52
- const ownSharedIdentityAttributesOfRepositoryAttributeSuccessor = await this.attributeController.getLocalAttributes(query);
53
- if (ownSharedIdentityAttributesOfRepositoryAttributeSuccessor.length > 0) {
54
- return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeSuccessor[0].id));
55
44
  }
56
- const repositoryAttributeVersions = await this.attributeController.getVersionsOfAttribute(repositoryAttributeSuccessorId);
57
- const repositoryAttributeVersionIds = repositoryAttributeVersions.map((x) => x.id.toString());
58
- const candidatePredecessorsQuery = {
59
- "shareInfo.sourceAttribute": { $in: repositoryAttributeVersionIds },
60
- "shareInfo.peer": request.peer,
61
- succeededBy: { $exists: false }
62
- };
63
- const candidatePredecessors = await this.attributeController.getLocalAttributes(candidatePredecessorsQuery);
45
+ if (!repositoryAttributeSuccessor.isRepositoryAttribute()) {
46
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttributeSuccessorId));
47
+ }
48
+ const candidatePredecessors = await this.attributeController.getSharedVersionsOfRepositoryAttribute(repositoryAttributeSuccessorId, [transport_1.CoreAddress.from(request.peer)]);
64
49
  if (candidatePredecessors.length === 0) {
65
- throw common_1.RuntimeErrors.general.recordNotFoundWithMessage("No shared predecessor found. If this is the fist version you want to share with this peer, use `ShareIdentityAttribute`.");
50
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.noOtherVersionOfIdentityAttributeHasBeenSharedWithPeerBefore(repositoryAttributeSuccessorId, request.peer));
66
51
  }
67
- if (candidatePredecessors.length > 1) {
68
- throw common_1.RuntimeErrors.attributes.detectedErroneousAttribute(request.attributeId, "The attribute has shared copies of predecessing versions that are not in a succession chain.");
52
+ if (candidatePredecessors[0].shareInfo?.sourceAttribute?.toString() === request.attributeId) {
53
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, candidatePredecessors[0].id));
69
54
  }
70
55
  const ownSharedIdentityAttributePredecessor = candidatePredecessors[0];
71
56
  const notificationId = await consumption_1.ConsumptionIds.notification.generate();
@@ -1 +1 @@
1
- {"version":3,"file":"NotifyPeerAboutIdentityAttributeSuccession.js","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAA2C;AAC3C,oDAAqH;AACrH,4CAA4F;AAC5F,gDAAgF;AAChF,mDAAwC;AAExC,yCAA2H;AAC3H,uDAAoD;AAapD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAAkE;IACtF,YAA2B,gBAAkC;QACzD,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAC3F,CAAC;CACJ,CAAA;AAJK,SAAS;IACS,WAAA,uBAAM,CAAA;qCAAmB,yBAAgB;GAD3D,SAAS,CAId;AAED,IAAa,iDAAiD,GAA9D,MAAa,iDAAkD,SAAQ,gBAGtE;IACG,YAC6B,iBAAoC,EACpC,mBAAyC,EACzC,iBAAoC,EACrD,SAAoB;QAE5B,KAAK,CAAC,SAAS,CAAC,CAAC;QALQ,sBAAiB,GAAjB,iBAAiB,CAAmB;QAC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IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;qCAHqC,6BAAiB;QACf,kCAAoB;QACtB,6BAAiB;QAC1C,SAAS;GARvB,iDAAiD,CAiG7D"}
1
+ {"version":3,"file":"NotifyPeerAboutIdentityAttributeSuccession.js","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAA2C;AAC3C,oDAAqH;AACrH,4CAA4F;AAC5F,gDAA6F;AAC7F,mDAAwC;AAExC,yCAA2H;AAC3H,uDAAoD;AAapD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAAkE;IACtF,YAA2B,gBAAkC;QACzD,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAC3F,CAAC;CACJ,CAAA;AAJK,SAAS;IACS,WAAA,uBAAM,CAAA;qCAAmB,yBAAgB;GAD3D,SAAS,CAId;AAED,IAAa,iDAAiD,GAA9D,MAAa,iDAAkD,SAAQ,gBAGtE;IACG,YAC6B,iBAAoC,EACpC,mBAAyC,EACzC,iBAAoC,EACrD,SAAoB;QAE5B,KAAK,CAAC,SAAS,CAAC,CAAC;QALQ,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,wBAAmB,GAAnB,mBAAmB,CAAsB;QACzC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAIjE,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,OAA0D;QACtF,MAAM,8BAA8B,GAAG,kBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACxE,MAAM,4BAA4B,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,CAAC;QAEtH,IAAI,OAAO,4BAA4B,KAAK,WAAW,EAAE,CAAC;YACtD,OAAO,iBAAM,CAAC,IAAI,CAAC,s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;YAC9E,cAAc,EAAE,cAAc;SACjC,CAAC;QACF,OAAO,iBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAA;AA5EY,8GAAiD;4DAAjD,iDAAiD;IAKrD,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;qCAHqC,6BAAiB;QACf,kCAAoB;QACtB,6BAAiB;QAC1C,SAAS;GARvB,iDAAiD,CA4E7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"ShareIdentityAttribute.d.ts","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/ShareIdentityAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAmD,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEvI,OAAO,EAAE,iBAAiB,EAAuB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE7F,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,qBAAqB,EAAiB,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGlJ,MAAM,WAAW,6BAA6B;IAC1C,WAAW,EAAE,iBAAiB,CAAC;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,eAAe,CAAC,EAAE;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,SAAS,CAAC,EAAE,qBAAqB,CAAC;KACrC,CAAC;CACL;AAED,cAAM,SAAU,SAAQ,eAAe,CAAC,6BAA6B,CAAC;gBACvC,gBAAgB,EAAE,gBAAgB;CAGhE;AAED,qBAAa,6BAA8B,S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M,SAAU,SAAQ,eAAe,CAAC,6BAA6B,CAAC;gBACvC,gBAAgB,EAAE,gBAAgB;CAGhE;AAED,qBAAa,6BAA8B,SAAQ,OAAO,CAAC,6BAA6B,EAAE,eAAe,CAAC;IAE1F,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAHjB,mBAAmB,EAAE,oBAAoB,EACzC,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,0BAA0B,EAC9C,iBAAiB,EAAE,iBAAiB,EACrD,SAAS,EAAE,SAAS;cAKhB,eAAe,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;CAgE5G"}
@@ -38,11 +38,14 @@ let ShareIdentityAttributeUseCase = class ShareIdentityAttributeUseCase extends
38
38
  this.messageController = messageController;
39
39
  }
40
40
  async executeInternal(request) {
41
- const repositoryAttribute = await this.attributeController.getLocalAttribute(transport_1.CoreId.from(request.attributeId));
42
- if (typeof repositoryAttribute === "undefined")
41
+ const repositoryAttributeId = transport_1.CoreId.from(request.attributeId);
42
+ const repositoryAttribute = await this.attributeController.getLocalAttribute(repositoryAttributeId);
43
+ if (typeof repositoryAttribute === "undefined") {
43
44
  return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute.name));
44
- if (!repositoryAttribute.isRepositoryAttribute())
45
+ }
46
+ if (!repositoryAttribute.isRepositoryAttribute()) {
45
47
  return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttribute.id));
48
+ }
46
49
  const query = {
47
50
  "content.owner": this.accountController.identity.address.toString(),
48
51
  "content.@type": "IdentityAttribute",
@@ -53,33 +56,9 @@ let ShareIdentityAttributeUseCase = class ShareIdentityAttributeUseCase extends
53
56
  if (ownSharedIdentityAttributesOfRepositoryAttribute.length > 0) {
54
57
  return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttribute[0].id));
55
58
  }
56
- let repositoryAttributeVersion = repositoryAttribute;
57
- while (typeof repositoryAttributeVersion.succeededBy !== "undefined") {
58
- repositoryAttributeVersion = (await this.attributeController.getLocalAttribute(repositoryAttributeVersion.succeededBy));
59
- const query = {
60
- "content.owner": this.accountController.identity.address.toString(),
61
- "content.@type": "IdentityAttribute",
62
- "shareInfo.sourceAttribute": repositoryAttributeVersion.id.toString(),
63
- "shareInfo.peer": request.peer
64
- };
65
- const ownSharedIdentityAttributesOfRepositoryAttributeVersion = await this.attributeController.getLocalAttributes(query);
66
- if (ownSharedIdentityAttributesOfRepositoryAttributeVersion.length > 0) {
67
- return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeVersion[0].id));
68
- }
69
- }
70
- repositoryAttributeVersion = repositoryAttribute;
71
- while (typeof repositoryAttributeVersion.succeeds !== "undefined") {
72
- repositoryAttributeVersion = (await this.attributeController.getLocalAttribute(repositoryAttributeVersion.succeeds));
73
- const query = {
74
- "content.owner": this.accountController.identity.address.toString(),
75
- "content.@type": "IdentityAttribute",
76
- "shareInfo.sourceAttribute": repositoryAttributeVersion.id.toString(),
77
- "shareInfo.peer": request.peer
78
- };
79
- const ownSharedIdentityAttributesOfRepositoryAttributeVersion = await this.attributeController.getLocalAttributes(query);
80
- if (ownSharedIdentityAttributesOfRepositoryAttributeVersion.length > 0) {
81
- return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeVersion[0].id));
82
- }
59
+ const ownSharedIdentityAttributesOfRepositoryAttributeVersion = await this.attributeController.getSharedVersionsOfRepositoryAttribute(repositoryAttributeId, [transport_1.CoreAddress.from(request.peer)], false);
60
+ if (ownSharedIdentityAttributesOfRepositoryAttributeVersion.length > 0) {
61
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeVersion[0].id));
83
62
  }
84
63
  const requestMetadata = request.requestMetadata ?? {};
85
64
  const requestParams = consumption_1.CreateOutgoingRequestParameters.from({
@@ -1 +1 @@
1
- {"version":3,"file":"ShareIdentityAttribute.js","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/ShareIdentityAttribute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAA2C;AAC3C,oDAAuI;AACvI,4CAAoE;AACpE,gDAA6F;AAC7F,mDAAwC;AAExC,yCAAkJ;AAClJ,0CAA4C;AAa5C,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAA8C;IAClE,YAA2B,gBAAkC;QACzD,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACvE,CAAC;CACJ,CAAA;AAJK,SAAS;IACS,WAAA,uBAAM,CAAA;qCAAmB,yBAAgB;GAD3D,SAAS,CAId;AAED,IAAa,6BAA6B,GAA1C,MAAa,6BAA8B,SAAQ,gBAAuD;IACtG,YAC6B,mBAAyC,EACzC,iBAAoC,EACpC,kBAA8C,EAC9C,iBAAoC,EACrD,SAAoB;QAE5B,KAAK,CAAC,SAAS,CAAC,CAAC;QANQ,wBAAmB,GAAnB,mBAAmB,CAAsB;QACzC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,uBAAkB,GAAlB,kBAAkB,CAA4B;QAC9C,sBAAiB,GAAjB,iBAAiB,CAAmB;IAIjE,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,O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CAAC;CACJ,CAAA;AA9FY,sEAA6B;wCAA7B,6BAA6B;IAEjC,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;qCAJuC,kCAAoB;QACtB,6BAAiB;QAChB,wCAA0B;QAC3B,6BAAiB;QAC1C,SAAS;GANvB,6BAA6B,CA8FzC"}
1
+ {"version":3,"file":"ShareIdentityAttribute.js","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/ShareIdentityAttribute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAA2C;AAC3C,oDAAuI;AACvI,4CAAoE;AACpE,gDAA6F;AAC7F,mDAAwC;AAExC,yCAAkJ;AAClJ,0CAA4C;AAa5C,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAA8C;IAClE,YAA2B,gBAAkC;QACzD,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACvE,CAAC;CACJ,CAAA;AAJK,SAAS;IACS,WAAA,uBAAM,CAAA;qCAAmB,yBAAgB;GAD3D,SAAS,CAId;AAED,IAAa,6BAA6B,GAA1C,MAAa,6BAA8B,SAAQ,gBAAuD;IACtG,YAC6B,mBAAyC,EACzC,iBAAoC,EACpC,kBAA8C,EAC9C,iBAAoC,EACrD,SAAoB;QAE5B,KAAK,CAAC,SAAS,CAAC,CAAC;QANQ,wBAAmB,GAAnB,mBAAmB,CAAsB;QACzC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,uBAAkB,GAAlB,kBAAkB,CAA4B;QAC9C,sBAAiB,GAAjB,iBAAiB,CAAmB;IAIjE,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,OAAsC;QAClE,MAAM,qBAAqB,GAAG,kBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC/D,MAAM,mBAAmB,GAAG,MAAM,IAA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ACJ,CAAA;AA3EY,sEAA6B;wCAA7B,6BAA6B;IAEjC,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;IACN,WAAA,uBAAM,CAAA;qCAJuC,kCAAoB;QACtB,6BAAiB;QAChB,wCAA0B;QAC3B,6BAAiB;QAC1C,SAAS;GANvB,6BAA6B,CA2EzC"}
@@ -45705,11 +45705,11 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
45705
45705
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
45706
45706
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
45707
45707
  exports.buildInformation = {
45708
- version: "3.4.4",
45709
- build: "7",
45710
- date: "2024-02-01T16:51:09+00:00",
45711
- commit: "d0645cc813de59473acac670d171461b443b680d",
45712
- dependencies: {"@js-soft/docdb-querytranslator":"^1.1.2","@js-soft/logging-abstractions":"^1.0.1","@js-soft/ts-serval":"2.0.10","@js-soft/ts-utils":"^2.3.3","@nmshd/consumption":"3.9.2","@nmshd/content":"2.8.4","@nmshd/crypto":"2.0.5","@nmshd/transport":"2.2.1","ajv":"^8.12.0","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.4.4","qrcode":"1.5.3","reflect-metadata":"^0.2.1","ts-simple-nameof":"^1.3.1","typescript-ioc":"3.2.2"},
45708
+ version: "3.5.1",
45709
+ build: "10",
45710
+ date: "2024-02-06T09:47:34+00:00",
45711
+ commit: "c3fcf5e36d8a936f8e6d3c300bfc0028b63996c4",
45712
+ dependencies: {"@js-soft/docdb-querytranslator":"^1.1.2","@js-soft/logging-abstractions":"^1.0.1","@js-soft/ts-serval":"2.0.10","@js-soft/ts-utils":"^2.3.3","@nmshd/consumption":"3.9.2","@nmshd/content":"2.8.4","@nmshd/crypto":"2.0.5","@nmshd/transport":"2.2.2","ajv":"^8.12.0","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.4.4","qrcode":"1.5.3","reflect-metadata":"^0.2.1","ts-simple-nameof":"^1.3.1","typescript-ioc":"3.2.2"},
45713
45713
  libraries: {
45714
45714
  serval: ts_serval_1.buildInformation,
45715
45715
  consumption: consumption_1.buildInformation,
@@ -51691,12 +51691,8 @@ class Attributes {
51691
51691
  anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId, peer, ownSharedIdentityAttributeId) {
51692
51692
  return new ts_utils_1.ApplicationError("error.runtime.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer", `Another version of identity attribute '${repositoryAttributeId.toString()}' has already been shared with peer '${peer.toString()}'. Id of previously shared identity attribute: ${ownSharedIdentityAttributeId.toString()}.`);
51693
51693
  }
51694
- detectedErroneousAttribute(attributeId, message) {
51695
- let msg = `Detected an error regarding attribute '${attributeId.toString()}'.`;
51696
- if (typeof message !== "undefined") {
51697
- msg += ` ${message}`;
51698
- }
51699
- return new ts_utils_1.ApplicationError("error.runtime.attributes.detectedErroneousAttribute", msg);
51694
+ noOtherVersionOfIdentityAttributeHasBeenSharedWithPeerBefore(repositoryAttributeId, peer) {
51695
+ return new ts_utils_1.ApplicationError("error.runtime.attributes.noOtherVersionOfIdentityAttributeHasBeenSharedWithPeerBefore", `No other version of identity attribute '${repositoryAttributeId.toString()}' has been shared with peer '${peer.toString()}' before. If you wish to execute an initial sharing of this attribute, use 'ShareIdentityAttribute'.`);
51700
51696
  }
51701
51697
  }
51702
51698
  class RuntimeErrors {
@@ -68726,6 +68722,15 @@ exports.GetSharedVersionsOfIdentityAttributeRequest = {
68726
68722
  "properties": {
68727
68723
  "attributeId": {
68728
68724
  "$ref": "#/definitions/AttributeIdString"
68725
+ },
68726
+ "peers": {
68727
+ "type": "array",
68728
+ "items": {
68729
+ "$ref": "#/definitions/AddressString"
68730
+ }
68731
+ },
68732
+ "onlyLatestVersions": {
68733
+ "type": "boolean"
68729
68734
  }
68730
68735
  },
68731
68736
  "required": [
@@ -68736,6 +68741,10 @@ exports.GetSharedVersionsOfIdentityAttributeRequest = {
68736
68741
  "AttributeIdString": {
68737
68742
  "type": "string",
68738
68743
  "pattern": "ATT[A-Za-z0-9]{17}"
68744
+ },
68745
+ "AddressString": {
68746
+ "type": "string",
68747
+ "pattern": "id1[A-Za-z0-9]{32,33}"
68739
68748
  }
68740
68749
  }
68741
68750
  };
@@ -74800,23 +74809,20 @@ let GetSharedVersionsOfIdentityAttributeUseCase = class GetSharedVersionsOfIdent
74800
74809
  this.attributeController = attributeController;
74801
74810
  }
74802
74811
  async executeInternal(request) {
74803
- const attribute = await this.attributeController.getLocalAttribute(transport_1.CoreId.from(request.attributeId));
74804
- if (typeof attribute === "undefined") {
74805
- throw common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute);
74812
+ const repositoryAttributeId = transport_1.CoreId.from(request.attributeId);
74813
+ const repositoryAttribute = await this.attributeController.getLocalAttribute(repositoryAttributeId);
74814
+ if (typeof repositoryAttribute === "undefined") {
74815
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute));
74806
74816
  }
74807
- if (attribute.isRelationshipAttribute()) {
74808
- throw common_1.RuntimeErrors.general.invalidPropertyValue("Attribute '${request.attributeId}' is a RelationshipAttribute.");
74817
+ if (!repositoryAttribute.isRepositoryAttribute()) {
74818
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttributeId));
74809
74819
  }
74810
- const allVersions = await this.attributeController.getVersionsOfAttribute(transport_1.CoreId.from(request.attributeId));
74811
- // queried ID doesn't belong to a repository attribute
74812
- if (attribute.shareInfo !== undefined) {
74813
- return ts_utils_1.Result.ok(AttributeMapper_1.AttributeMapper.toAttributeDTOList(allVersions));
74820
+ if (request.peers?.length === 0) {
74821
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.invalidPropertyValue("The `peers` property may not be an empty array."));
74814
74822
  }
74815
- const query = {
74816
- "shareInfo.sourceAttribute": { $in: allVersions.map((x) => x.id.toString()) }
74817
- };
74818
- const sharedAttributes = await this.attributeController.getLocalAttributes(query);
74819
- return ts_utils_1.Result.ok(AttributeMapper_1.AttributeMapper.toAttributeDTOList(sharedAttributes));
74823
+ const peers = request.peers?.map((address) => transport_1.CoreAddress.from(address));
74824
+ const sharedVersions = await this.attributeController.getSharedVersionsOfRepositoryAttribute(repositoryAttributeId, peers, request.onlyLatestVersions);
74825
+ return ts_utils_1.Result.ok(AttributeMapper_1.AttributeMapper.toAttributeDTOList(sharedVersions));
74820
74826
  }
74821
74827
  };
74822
74828
  exports.GetSharedVersionsOfIdentityAttributeUseCase = GetSharedVersionsOfIdentityAttributeUseCase;
@@ -74940,33 +74946,18 @@ let NotifyPeerAboutIdentityAttributeSuccessionUseCase = class NotifyPeerAboutIde
74940
74946
  async executeInternal(request) {
74941
74947
  const repositoryAttributeSuccessorId = transport_1.CoreId.from(request.attributeId);
74942
74948
  const repositoryAttributeSuccessor = await this.attributeController.getLocalAttribute(repositoryAttributeSuccessorId);
74943
- if (typeof repositoryAttributeSuccessor === "undefined")
74949
+ if (typeof repositoryAttributeSuccessor === "undefined") {
74944
74950
  return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute.name));
74945
- if (!repositoryAttributeSuccessor.isRepositoryAttribute())
74946
- return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttributeSuccessor.id));
74947
- const query = {
74948
- "content.owner": this.accountController.identity.address.toString(),
74949
- "content.@type": "IdentityAttribute",
74950
- "shareInfo.sourceAttribute": repositoryAttributeSuccessorId.toString(),
74951
- "shareInfo.peer": request.peer
74952
- };
74953
- const ownSharedIdentityAttributesOfRepositoryAttributeSuccessor = await this.attributeController.getLocalAttributes(query);
74954
- if (ownSharedIdentityAttributesOfRepositoryAttributeSuccessor.length > 0) {
74955
- return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeSuccessor[0].id));
74956
- }
74957
- const repositoryAttributeVersions = await this.attributeController.getVersionsOfAttribute(repositoryAttributeSuccessorId);
74958
- const repositoryAttributeVersionIds = repositoryAttributeVersions.map((x) => x.id.toString());
74959
- const candidatePredecessorsQuery = {
74960
- "shareInfo.sourceAttribute": { $in: repositoryAttributeVersionIds },
74961
- "shareInfo.peer": request.peer,
74962
- succeededBy: { $exists: false }
74963
- };
74964
- const candidatePredecessors = await this.attributeController.getLocalAttributes(candidatePredecessorsQuery);
74951
+ }
74952
+ if (!repositoryAttributeSuccessor.isRepositoryAttribute()) {
74953
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttributeSuccessorId));
74954
+ }
74955
+ const candidatePredecessors = await this.attributeController.getSharedVersionsOfRepositoryAttribute(repositoryAttributeSuccessorId, [transport_1.CoreAddress.from(request.peer)]);
74965
74956
  if (candidatePredecessors.length === 0) {
74966
- throw common_1.RuntimeErrors.general.recordNotFoundWithMessage("No shared predecessor found. If this is the fist version you want to share with this peer, use `ShareIdentityAttribute`.");
74957
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.noOtherVersionOfIdentityAttributeHasBeenSharedWithPeerBefore(repositoryAttributeSuccessorId, request.peer));
74967
74958
  }
74968
- if (candidatePredecessors.length > 1) {
74969
- throw common_1.RuntimeErrors.attributes.detectedErroneousAttribute(request.attributeId, "The attribute has shared copies of predecessing versions that are not in a succession chain.");
74959
+ if (candidatePredecessors[0].shareInfo?.sourceAttribute?.toString() === request.attributeId) {
74960
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, candidatePredecessors[0].id));
74970
74961
  }
74971
74962
  const ownSharedIdentityAttributePredecessor = candidatePredecessors[0];
74972
74963
  const notificationId = await consumption_1.ConsumptionIds.notification.generate();
@@ -75065,11 +75056,14 @@ let ShareIdentityAttributeUseCase = class ShareIdentityAttributeUseCase extends
75065
75056
  this.messageController = messageController;
75066
75057
  }
75067
75058
  async executeInternal(request) {
75068
- const repositoryAttribute = await this.attributeController.getLocalAttribute(transport_1.CoreId.from(request.attributeId));
75069
- if (typeof repositoryAttribute === "undefined")
75059
+ const repositoryAttributeId = transport_1.CoreId.from(request.attributeId);
75060
+ const repositoryAttribute = await this.attributeController.getLocalAttribute(repositoryAttributeId);
75061
+ if (typeof repositoryAttribute === "undefined") {
75070
75062
  return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute.name));
75071
- if (!repositoryAttribute.isRepositoryAttribute())
75063
+ }
75064
+ if (!repositoryAttribute.isRepositoryAttribute()) {
75072
75065
  return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttribute.id));
75066
+ }
75073
75067
  const query = {
75074
75068
  "content.owner": this.accountController.identity.address.toString(),
75075
75069
  "content.@type": "IdentityAttribute",
@@ -75080,33 +75074,9 @@ let ShareIdentityAttributeUseCase = class ShareIdentityAttributeUseCase extends
75080
75074
  if (ownSharedIdentityAttributesOfRepositoryAttribute.length > 0) {
75081
75075
  return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttribute[0].id));
75082
75076
  }
75083
- let repositoryAttributeVersion = repositoryAttribute;
75084
- while (typeof repositoryAttributeVersion.succeededBy !== "undefined") {
75085
- repositoryAttributeVersion = (await this.attributeController.getLocalAttribute(repositoryAttributeVersion.succeededBy));
75086
- const query = {
75087
- "content.owner": this.accountController.identity.address.toString(),
75088
- "content.@type": "IdentityAttribute",
75089
- "shareInfo.sourceAttribute": repositoryAttributeVersion.id.toString(),
75090
- "shareInfo.peer": request.peer
75091
- };
75092
- const ownSharedIdentityAttributesOfRepositoryAttributeVersion = await this.attributeController.getLocalAttributes(query);
75093
- if (ownSharedIdentityAttributesOfRepositoryAttributeVersion.length > 0) {
75094
- return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeVersion[0].id));
75095
- }
75096
- }
75097
- repositoryAttributeVersion = repositoryAttribute;
75098
- while (typeof repositoryAttributeVersion.succeeds !== "undefined") {
75099
- repositoryAttributeVersion = (await this.attributeController.getLocalAttribute(repositoryAttributeVersion.succeeds));
75100
- const query = {
75101
- "content.owner": this.accountController.identity.address.toString(),
75102
- "content.@type": "IdentityAttribute",
75103
- "shareInfo.sourceAttribute": repositoryAttributeVersion.id.toString(),
75104
- "shareInfo.peer": request.peer
75105
- };
75106
- const ownSharedIdentityAttributesOfRepositoryAttributeVersion = await this.attributeController.getLocalAttributes(query);
75107
- if (ownSharedIdentityAttributesOfRepositoryAttributeVersion.length > 0) {
75108
- return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeVersion[0].id));
75109
- }
75077
+ const ownSharedIdentityAttributesOfRepositoryAttributeVersion = await this.attributeController.getSharedVersionsOfRepositoryAttribute(repositoryAttributeId, [transport_1.CoreAddress.from(request.peer)], false);
75078
+ if (ownSharedIdentityAttributesOfRepositoryAttributeVersion.length > 0) {
75079
+ return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeVersion[0].id));
75110
75080
  }
75111
75081
  const requestMetadata = request.requestMetadata ?? {};
75112
75082
  const requestParams = consumption_1.CreateOutgoingRequestParameters.from({