@nmshd/runtime 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buildInformation.js +4 -4
- package/dist/useCases/common/RuntimeErrors.d.ts +2 -1
- package/dist/useCases/common/RuntimeErrors.js +5 -2
- package/dist/useCases/common/RuntimeErrors.js.map +1 -1
- package/dist/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.js +11 -16
- package/dist/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.js.map +1 -1
- package/dist/useCases/consumption/attributes/ShareIdentityAttribute.js +34 -6
- package/dist/useCases/consumption/attributes/ShareIdentityAttribute.js.map +1 -1
- package/lib-web/nmshd.runtime.js +54 -28
- package/lib-web/nmshd.runtime.js.map +1 -1
- package/lib-web/nmshd.runtime.min.js +1 -1
- package/lib-web/nmshd.runtime.min.js.map +1 -1
- package/package.json +4 -4
package/dist/buildInformation.js
CHANGED
|
@@ -7,10 +7,10 @@ const content_1 = require("@nmshd/content");
|
|
|
7
7
|
const crypto_1 = require("@nmshd/crypto");
|
|
8
8
|
const transport_1 = require("@nmshd/transport");
|
|
9
9
|
exports.buildInformation = {
|
|
10
|
-
version: "3.0.
|
|
11
|
-
build: "
|
|
12
|
-
date: "2023-12-
|
|
13
|
-
commit: "
|
|
10
|
+
version: "3.0.2",
|
|
11
|
+
build: "178",
|
|
12
|
+
date: "2023-12-06T12:47:16+00:00",
|
|
13
|
+
commit: "6de01f71ecc145a07497a233fc24216ac36b96f9",
|
|
14
14
|
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.7.4","@nmshd/content":"2.8.1","@nmshd/crypto":"2.0.5","@nmshd/transport":"2.1.4","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.1.13","ts-simple-nameof":"1.3.1","typescript-ioc":"3.2.2"},
|
|
15
15
|
libraries: {
|
|
16
16
|
serval: ts_serval_1.buildInformation,
|
|
@@ -46,7 +46,8 @@ declare class Notifications {
|
|
|
46
46
|
}
|
|
47
47
|
declare class Attributes {
|
|
48
48
|
isNoIdentityAttribute(attributeId: CoreId | string): ApplicationError;
|
|
49
|
-
identityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId: CoreId | string, peer: CoreAddress | string,
|
|
49
|
+
identityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId: CoreId | string, peer: CoreAddress | string, ownSharedIdentityAttributeId: CoreId | string): ApplicationError;
|
|
50
|
+
anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId: CoreId | string, peer: CoreAddress | string, ownSharedIdentityAttributeId: CoreId | string): ApplicationError;
|
|
50
51
|
detectedErroneousAttribute(attributeId: CoreId | string, message?: string): ApplicationError;
|
|
51
52
|
}
|
|
52
53
|
export declare class RuntimeErrors {
|
|
@@ -107,8 +107,11 @@ class Attributes {
|
|
|
107
107
|
isNoIdentityAttribute(attributeId) {
|
|
108
108
|
return new ts_utils_1.ApplicationError("error.runtime.attributes.isNoIdentityAttribute", `Attribute '${attributeId.toString()}' is not an identity attribute.`);
|
|
109
109
|
}
|
|
110
|
-
identityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId, peer,
|
|
111
|
-
return new ts_utils_1.ApplicationError("error.runtime.attributes.identityAttributeHasAlreadyBeenSharedWithPeer", `Identity attribute '${repositoryAttributeId.toString()}' has already been shared with peer '${peer.toString()}'. Id of shared identity attribute: ${
|
|
110
|
+
identityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId, peer, ownSharedIdentityAttributeId) {
|
|
111
|
+
return new ts_utils_1.ApplicationError("error.runtime.attributes.identityAttributeHasAlreadyBeenSharedWithPeer", `Identity attribute '${repositoryAttributeId.toString()}' has already been shared with peer '${peer.toString()}'. Id of shared identity attribute: ${ownSharedIdentityAttributeId.toString()}.`);
|
|
112
|
+
}
|
|
113
|
+
anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId, peer, ownSharedIdentityAttributeId) {
|
|
114
|
+
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()}.`);
|
|
112
115
|
}
|
|
113
116
|
detectedErroneousAttribute(attributeId, message) {
|
|
114
117
|
let msg = `Detected an error regarding attribute '${attributeId.toString()}'.`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeErrors.js","sourceRoot":"","sources":["../../../src/useCases/common/RuntimeErrors.ts"],"names":[],"mappings":";;;AAAA,gDAAqD;AAErD,2DAAwD;AAExD,MAAM,OAAO;IACF,OAAO,CAAC,OAAe,EAAE,IAAU;QACtC,OAAO,IAAI,2BAAgB,CAAC,uBAAuB,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;IAEM,kBAAkB;QACrB,OAAO,IAAI,2BAAgB,CAAC,kCAAkC,EAAE,gFAAgF,CAAC,CAAC;IACtJ,CAAC;IAEM,cAAc;QACjB,OAAO,IAAI,2BAAgB,CAAC,8BAA8B,EAAE,6FAA6F,CAAC,CAAC;IAC/J,CAAC;IAEM,cAAc;QACjB,OAAO,IAAI,2BAAgB,CAAC,8BAA8B,EAAE,yEAAyE,CAAC,CAAC;IAC3I,CAAC;IAEM,UAAU;QACb,OAAO,IAAI,2BAAgB,CAAC,0BAA0B,EAAE,yFAAyF,CAAC,CAAC;IACvJ,CAAC;IAEM,cAAc,CAAC,UAA8B;QAChD,OAAO,IAAI,CAAC,yBAAyB,CAAC,GAAG,UAAU,YAAY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C,CAAC;IAC5F,CAAC;CACJ;AAED,MAAa,aAAa;;AAA1B,sCAUC;AAT0B,qBAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AACxB,oBAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AACtB,qBAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AACxB,mBAAK,GAAG,IAAI,KAAK,EAAE,CAAC;AACpB,mCAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC;AACpD,sBAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;AAC1B,wBAAU,GAAG,IAAI,UAAU,EAAE,CAAC;AAC9B,2BAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AACpC,wBAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -39,35 +39,30 @@ 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")
|
|
43
|
-
return ts_utils_1.Result.fail(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
if (typeof repositoryAttributeSuccessor.succeededBy !== "undefined") {
|
|
49
|
-
return ts_utils_1.Result.fail(consumption_1.CoreErrors.attributes.invalidSuccessor("Successor repository attribute already has a successor. Can only share latest identity attribute from a succession chain."));
|
|
50
|
-
}
|
|
51
|
-
const sharedAttributesQuery = {
|
|
42
|
+
if (typeof repositoryAttributeSuccessor === "undefined")
|
|
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 = {
|
|
52
47
|
"content.owner": this.accountController.identity.address.toString(),
|
|
53
48
|
"content.@type": "IdentityAttribute",
|
|
54
|
-
"shareInfo.sourceAttribute":
|
|
49
|
+
"shareInfo.sourceAttribute": repositoryAttributeSuccessorId.toString(),
|
|
55
50
|
"shareInfo.peer": request.peer
|
|
56
51
|
};
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer,
|
|
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));
|
|
60
55
|
}
|
|
61
56
|
const repositoryAttributeVersions = await this.attributeController.getVersionsOfAttribute(repositoryAttributeSuccessorId);
|
|
62
57
|
const repositoryAttributeVersionIds = repositoryAttributeVersions.map((x) => x.id.toString());
|
|
63
58
|
const candidatePredecessorsQuery = {
|
|
64
59
|
"shareInfo.sourceAttribute": { $in: repositoryAttributeVersionIds },
|
|
65
60
|
"shareInfo.peer": request.peer,
|
|
66
|
-
|
|
61
|
+
succeededBy: { $exists: false }
|
|
67
62
|
};
|
|
68
63
|
const candidatePredecessors = await this.attributeController.getLocalAttributes(candidatePredecessorsQuery);
|
|
69
64
|
if (candidatePredecessors.length === 0) {
|
|
70
|
-
throw common_1.RuntimeErrors.general.recordNotFoundWithMessage("No shared predecessor found. If this is the fist version you want to share with this peer, use `
|
|
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`.");
|
|
71
66
|
}
|
|
72
67
|
if (candidatePredecessors.length > 1) {
|
|
73
68
|
throw common_1.RuntimeErrors.attributes.detectedErroneousAttribute(request.attributeId, "The attribute has shared copies of predecessing versions that are not in a succession chain.");
|
package/dist/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotifyPeerAboutIdentityAttributeSuccession.js","sourceRoot":"","sources":["../../../../src/useCases/consumption/attributes/NotifyPeerAboutIdentityAttributeSuccession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAA2C;AAC3C,
|
|
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;AAYpD,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,MA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|
|
@@ -39,19 +39,47 @@ let ShareIdentityAttributeUseCase = class ShareIdentityAttributeUseCase extends
|
|
|
39
39
|
}
|
|
40
40
|
async executeInternal(request) {
|
|
41
41
|
const repositoryAttribute = await this.attributeController.getLocalAttribute(transport_1.CoreId.from(request.attributeId));
|
|
42
|
-
if (
|
|
43
|
-
return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute));
|
|
42
|
+
if (typeof repositoryAttribute === "undefined")
|
|
43
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute.name));
|
|
44
44
|
if (!repositoryAttribute.isRepositoryAttribute())
|
|
45
45
|
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttribute.id));
|
|
46
|
-
const
|
|
46
|
+
const query = {
|
|
47
47
|
"content.owner": this.accountController.identity.address.toString(),
|
|
48
48
|
"content.@type": "IdentityAttribute",
|
|
49
49
|
"shareInfo.sourceAttribute": request.attributeId,
|
|
50
50
|
"shareInfo.peer": request.peer
|
|
51
51
|
};
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer,
|
|
52
|
+
const ownSharedIdentityAttributesOfRepositoryAttribute = await this.attributeController.getLocalAttributes(query);
|
|
53
|
+
if (ownSharedIdentityAttributesOfRepositoryAttribute.length > 0) {
|
|
54
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttribute[0].id));
|
|
55
|
+
}
|
|
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
|
+
}
|
|
55
83
|
}
|
|
56
84
|
const requestMetadata = request.requestMetadata ?? {};
|
|
57
85
|
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,OAAsC;QAClE,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,kBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QAC/G,IAAI,
|
|
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,yCAAk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AC;QAEH,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACtF,IAAI,sBAAsB,CAAC,OAAO,EAAE;YAAE,OAAO,iBAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAEvF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACzE,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC,uBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1H,MAAM,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,CAAC;QAE9C,OAAO,iBAAM,CAAC,EAAE,CAAC,wBAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC;IACpE,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"}
|
package/lib-web/nmshd.runtime.js
CHANGED
|
@@ -555,10 +555,10 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
555
555
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
556
556
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
557
557
|
exports.buildInformation = {
|
|
558
|
-
version: "3.0.
|
|
559
|
-
build: "
|
|
560
|
-
date: "2023-12-
|
|
561
|
-
commit: "
|
|
558
|
+
version: "3.0.2",
|
|
559
|
+
build: "178",
|
|
560
|
+
date: "2023-12-06T12:47:16+00:00",
|
|
561
|
+
commit: "6de01f71ecc145a07497a233fc24216ac36b96f9",
|
|
562
562
|
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.7.4","@nmshd/content":"2.8.1","@nmshd/crypto":"2.0.5","@nmshd/transport":"2.1.4","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.1.13","ts-simple-nameof":"1.3.1","typescript-ioc":"3.2.2"},
|
|
563
563
|
libraries: {
|
|
564
564
|
serval: ts_serval_1.buildInformation,
|
|
@@ -6516,8 +6516,11 @@ class Attributes {
|
|
|
6516
6516
|
isNoIdentityAttribute(attributeId) {
|
|
6517
6517
|
return new ts_utils_1.ApplicationError("error.runtime.attributes.isNoIdentityAttribute", `Attribute '${attributeId.toString()}' is not an identity attribute.`);
|
|
6518
6518
|
}
|
|
6519
|
-
identityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId, peer,
|
|
6520
|
-
return new ts_utils_1.ApplicationError("error.runtime.attributes.identityAttributeHasAlreadyBeenSharedWithPeer", `Identity attribute '${repositoryAttributeId.toString()}' has already been shared with peer '${peer.toString()}'. Id of shared identity attribute: ${
|
|
6519
|
+
identityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId, peer, ownSharedIdentityAttributeId) {
|
|
6520
|
+
return new ts_utils_1.ApplicationError("error.runtime.attributes.identityAttributeHasAlreadyBeenSharedWithPeer", `Identity attribute '${repositoryAttributeId.toString()}' has already been shared with peer '${peer.toString()}'. Id of shared identity attribute: ${ownSharedIdentityAttributeId.toString()}.`);
|
|
6521
|
+
}
|
|
6522
|
+
anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(repositoryAttributeId, peer, ownSharedIdentityAttributeId) {
|
|
6523
|
+
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()}.`);
|
|
6521
6524
|
}
|
|
6522
6525
|
detectedErroneousAttribute(attributeId, message) {
|
|
6523
6526
|
let msg = `Detected an error regarding attribute '${attributeId.toString()}'.`;
|
|
@@ -29217,35 +29220,30 @@ let NotifyPeerAboutIdentityAttributeSuccessionUseCase = class NotifyPeerAboutIde
|
|
|
29217
29220
|
async executeInternal(request) {
|
|
29218
29221
|
const repositoryAttributeSuccessorId = transport_1.CoreId.from(request.attributeId);
|
|
29219
29222
|
const repositoryAttributeSuccessor = await this.attributeController.getLocalAttribute(repositoryAttributeSuccessorId);
|
|
29220
|
-
if (typeof repositoryAttributeSuccessor === "undefined")
|
|
29221
|
-
return ts_utils_1.Result.fail(
|
|
29222
|
-
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
}
|
|
29226
|
-
if (typeof repositoryAttributeSuccessor.succeededBy !== "undefined") {
|
|
29227
|
-
return ts_utils_1.Result.fail(consumption_1.CoreErrors.attributes.invalidSuccessor("Successor repository attribute already has a successor. Can only share latest identity attribute from a succession chain."));
|
|
29228
|
-
}
|
|
29229
|
-
const sharedAttributesQuery = {
|
|
29223
|
+
if (typeof repositoryAttributeSuccessor === "undefined")
|
|
29224
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute.name));
|
|
29225
|
+
if (!repositoryAttributeSuccessor.isRepositoryAttribute())
|
|
29226
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttributeSuccessor.id));
|
|
29227
|
+
const query = {
|
|
29230
29228
|
"content.owner": this.accountController.identity.address.toString(),
|
|
29231
29229
|
"content.@type": "IdentityAttribute",
|
|
29232
|
-
"shareInfo.sourceAttribute":
|
|
29230
|
+
"shareInfo.sourceAttribute": repositoryAttributeSuccessorId.toString(),
|
|
29233
29231
|
"shareInfo.peer": request.peer
|
|
29234
29232
|
};
|
|
29235
|
-
const
|
|
29236
|
-
if (
|
|
29237
|
-
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer,
|
|
29233
|
+
const ownSharedIdentityAttributesOfRepositoryAttributeSuccessor = await this.attributeController.getLocalAttributes(query);
|
|
29234
|
+
if (ownSharedIdentityAttributesOfRepositoryAttributeSuccessor.length > 0) {
|
|
29235
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeSuccessor[0].id));
|
|
29238
29236
|
}
|
|
29239
29237
|
const repositoryAttributeVersions = await this.attributeController.getVersionsOfAttribute(repositoryAttributeSuccessorId);
|
|
29240
29238
|
const repositoryAttributeVersionIds = repositoryAttributeVersions.map((x) => x.id.toString());
|
|
29241
29239
|
const candidatePredecessorsQuery = {
|
|
29242
29240
|
"shareInfo.sourceAttribute": { $in: repositoryAttributeVersionIds },
|
|
29243
29241
|
"shareInfo.peer": request.peer,
|
|
29244
|
-
|
|
29242
|
+
succeededBy: { $exists: false }
|
|
29245
29243
|
};
|
|
29246
29244
|
const candidatePredecessors = await this.attributeController.getLocalAttributes(candidatePredecessorsQuery);
|
|
29247
29245
|
if (candidatePredecessors.length === 0) {
|
|
29248
|
-
throw common_1.RuntimeErrors.general.recordNotFoundWithMessage("No shared predecessor found. If this is the fist version you want to share with this peer, use `
|
|
29246
|
+
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`.");
|
|
29249
29247
|
}
|
|
29250
29248
|
if (candidatePredecessors.length > 1) {
|
|
29251
29249
|
throw common_1.RuntimeErrors.attributes.detectedErroneousAttribute(request.attributeId, "The attribute has shared copies of predecessing versions that are not in a succession chain.");
|
|
@@ -29347,19 +29345,47 @@ let ShareIdentityAttributeUseCase = class ShareIdentityAttributeUseCase extends
|
|
|
29347
29345
|
}
|
|
29348
29346
|
async executeInternal(request) {
|
|
29349
29347
|
const repositoryAttribute = await this.attributeController.getLocalAttribute(transport_1.CoreId.from(request.attributeId));
|
|
29350
|
-
if (
|
|
29351
|
-
return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute));
|
|
29348
|
+
if (typeof repositoryAttribute === "undefined")
|
|
29349
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.general.recordNotFound(consumption_1.LocalAttribute.name));
|
|
29352
29350
|
if (!repositoryAttribute.isRepositoryAttribute())
|
|
29353
29351
|
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.isNoIdentityAttribute(repositoryAttribute.id));
|
|
29354
|
-
const
|
|
29352
|
+
const query = {
|
|
29355
29353
|
"content.owner": this.accountController.identity.address.toString(),
|
|
29356
29354
|
"content.@type": "IdentityAttribute",
|
|
29357
29355
|
"shareInfo.sourceAttribute": request.attributeId,
|
|
29358
29356
|
"shareInfo.peer": request.peer
|
|
29359
29357
|
};
|
|
29360
|
-
const
|
|
29361
|
-
if (
|
|
29362
|
-
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer,
|
|
29358
|
+
const ownSharedIdentityAttributesOfRepositoryAttribute = await this.attributeController.getLocalAttributes(query);
|
|
29359
|
+
if (ownSharedIdentityAttributesOfRepositoryAttribute.length > 0) {
|
|
29360
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.identityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttribute[0].id));
|
|
29361
|
+
}
|
|
29362
|
+
let repositoryAttributeVersion = repositoryAttribute;
|
|
29363
|
+
while (typeof repositoryAttributeVersion.succeededBy !== "undefined") {
|
|
29364
|
+
repositoryAttributeVersion = (await this.attributeController.getLocalAttribute(repositoryAttributeVersion.succeededBy));
|
|
29365
|
+
const query = {
|
|
29366
|
+
"content.owner": this.accountController.identity.address.toString(),
|
|
29367
|
+
"content.@type": "IdentityAttribute",
|
|
29368
|
+
"shareInfo.sourceAttribute": repositoryAttributeVersion.id.toString(),
|
|
29369
|
+
"shareInfo.peer": request.peer
|
|
29370
|
+
};
|
|
29371
|
+
const ownSharedIdentityAttributesOfRepositoryAttributeVersion = await this.attributeController.getLocalAttributes(query);
|
|
29372
|
+
if (ownSharedIdentityAttributesOfRepositoryAttributeVersion.length > 0) {
|
|
29373
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeVersion[0].id));
|
|
29374
|
+
}
|
|
29375
|
+
}
|
|
29376
|
+
repositoryAttributeVersion = repositoryAttribute;
|
|
29377
|
+
while (typeof repositoryAttributeVersion.succeeds !== "undefined") {
|
|
29378
|
+
repositoryAttributeVersion = (await this.attributeController.getLocalAttribute(repositoryAttributeVersion.succeeds));
|
|
29379
|
+
const query = {
|
|
29380
|
+
"content.owner": this.accountController.identity.address.toString(),
|
|
29381
|
+
"content.@type": "IdentityAttribute",
|
|
29382
|
+
"shareInfo.sourceAttribute": repositoryAttributeVersion.id.toString(),
|
|
29383
|
+
"shareInfo.peer": request.peer
|
|
29384
|
+
};
|
|
29385
|
+
const ownSharedIdentityAttributesOfRepositoryAttributeVersion = await this.attributeController.getLocalAttributes(query);
|
|
29386
|
+
if (ownSharedIdentityAttributesOfRepositoryAttributeVersion.length > 0) {
|
|
29387
|
+
return ts_utils_1.Result.fail(common_1.RuntimeErrors.attributes.anotherVersionOfIdentityAttributeHasAlreadyBeenSharedWithPeer(request.attributeId, request.peer, ownSharedIdentityAttributesOfRepositoryAttributeVersion[0].id));
|
|
29388
|
+
}
|
|
29363
29389
|
}
|
|
29364
29390
|
const requestMetadata = request.requestMetadata ?? {};
|
|
29365
29391
|
const requestParams = consumption_1.CreateOutgoingRequestParameters.from({
|