@nmshd/consumption 2.0.0-beta.13 → 2.0.0-beta.14
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/consumption/ConsumptionBaseController.d.ts +1 -1
- package/dist/consumption/ConsumptionBaseController.js +2 -3
- package/dist/consumption/ConsumptionBaseController.js.map +1 -1
- package/dist/consumption/ConsumptionController.js +1 -1
- package/dist/consumption/ConsumptionController.js.map +1 -1
- package/dist/modules/attributes/LocalAttributesController.d.ts +3 -2
- package/dist/modules/attributes/LocalAttributesController.js +13 -4
- package/dist/modules/attributes/LocalAttributesController.js.map +1 -1
- package/dist/modules/attributes/local/{CreateRelationshipAttributeParams.d.ts → CreateAttributeParams.d.ts} +3 -3
- package/dist/modules/attributes/local/{CreateRelationshipAttributeParams.js → CreateAttributeParams.js} +10 -10
- package/dist/modules/attributes/local/CreateAttributeParams.js.map +1 -0
- package/dist/modules/attributes/local/QueryTranslator.d.ts +5 -1
- package/dist/modules/attributes/local/QueryTranslator.js +50 -1
- package/dist/modules/attributes/local/QueryTranslator.js.map +1 -1
- package/dist/modules/drafts/DraftsController.js +1 -1
- package/dist/modules/drafts/DraftsController.js.map +1 -1
- package/dist/modules/requests/index.d.ts +2 -2
- package/dist/modules/requests/index.js +2 -2
- package/dist/modules/requests/index.js.map +1 -1
- package/dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.d.ts +7 -0
- package/dist/modules/requests/itemProcessors/{createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js → createAttribute/AcceptCreateAttributeRequestItemParameters.js} +7 -7
- package/dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js.map +1 -0
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.d.ts +11 -0
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js +70 -0
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js.map +1 -0
- package/dist/modules/requests/itemProcessors/utility/validateQuery.d.ts +2 -2
- package/dist/modules/requests/itemProcessors/utility/validateQuery.js +4 -4
- package/dist/modules/requests/itemProcessors/utility/validateQuery.js.map +1 -1
- package/dist/modules/settings/SettingsController.js +1 -1
- package/dist/modules/settings/SettingsController.js.map +1 -1
- package/lib-web/nmshd.consumption.js +138 -55
- package/lib-web/nmshd.consumption.js.map +1 -1
- package/lib-web/nmshd.consumption.min.js +1 -1
- package/lib-web/nmshd.consumption.min.js.map +1 -1
- package/package.json +2 -2
- package/dist/modules/attributes/local/CreateRelationshipAttributeParams.js.map +0 -1
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.d.ts +0 -7
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js.map +0 -1
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.d.ts +0 -11
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js +0 -44
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js.map +0 -1
|
@@ -17,10 +17,10 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
17
17
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
18
18
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
19
19
|
exports.buildInformation = {
|
|
20
|
-
version: "2.0.0-beta.
|
|
21
|
-
build: "
|
|
22
|
-
date: "2022-09-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "2.0.0-beta.14",
|
|
21
|
+
build: "65",
|
|
22
|
+
date: "2022-09-08T16:46:17+00:00",
|
|
23
|
+
commit: "5e08a83edb35bff3255290783a568dc0123b7394",
|
|
24
24
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.1.0","ts-simple-nameof":"^1.3.1"},
|
|
25
25
|
libraries: {
|
|
26
26
|
transport: transport_1.buildInformation,
|
|
@@ -58,9 +58,8 @@ class ConsumptionBaseController {
|
|
|
58
58
|
init() {
|
|
59
59
|
return Promise.resolve(this);
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return await Promise.all(parsePromises);
|
|
61
|
+
parseArray(values, type) {
|
|
62
|
+
return values.map((v) => type.from(v));
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
exports.ConsumptionBaseController = ConsumptionBaseController;
|
|
@@ -121,7 +120,7 @@ class ConsumptionController {
|
|
|
121
120
|
getDefaultProcessors() {
|
|
122
121
|
return new Map([
|
|
123
122
|
[content_1.ShareAttributeRequestItem, modules_1.ShareAttributeRequestItemProcessor],
|
|
124
|
-
[content_1.
|
|
123
|
+
[content_1.CreateAttributeRequestItem, modules_1.CreateAttributeRequestItemProcessor],
|
|
125
124
|
[content_1.ReadAttributeRequestItem, modules_1.ReadAttributeRequestItemProcessor],
|
|
126
125
|
[content_1.ProposeAttributeRequestItem, modules_1.ProposeAttributeRequestItemProcessor],
|
|
127
126
|
[content_1.ConsentRequestItem, modules_1.GenericRequestItemProcessor],
|
|
@@ -413,11 +412,11 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
413
412
|
}
|
|
414
413
|
async getLocalAttributes(query) {
|
|
415
414
|
const attributes = await this.attributes.find(query);
|
|
416
|
-
return
|
|
415
|
+
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
417
416
|
}
|
|
418
417
|
async getValidLocalAttributes(query) {
|
|
419
418
|
const attributes = await this.attributes.find(query);
|
|
420
|
-
const items =
|
|
419
|
+
const items = this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
421
420
|
return this.filterCurrent(items);
|
|
422
421
|
}
|
|
423
422
|
async executeRelationshipAttributeQuery(query) {
|
|
@@ -425,7 +424,16 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
425
424
|
const dbQuery = QueryTranslator_1.RelationshipAttributeQueryTranslator.translate(parsedQuery);
|
|
426
425
|
dbQuery["content.confidentiality"] = { $ne: "private" };
|
|
427
426
|
const attributes = await this.attributes.find(dbQuery);
|
|
428
|
-
|
|
427
|
+
const attribute = attributes.length > 0 ? attributes[0] : undefined;
|
|
428
|
+
return attribute === undefined ? undefined : LocalAttribute_1.LocalAttribute.from(attribute);
|
|
429
|
+
}
|
|
430
|
+
async executeThirdPartyRelationshipAttributeQuery(query) {
|
|
431
|
+
const parsedQuery = content_1.ThirdPartyRelationshipAttributeQuery.from(query);
|
|
432
|
+
const dbQuery = QueryTranslator_1.ThirdPartyRelationshipAttributeQueryTranslator.translate(parsedQuery);
|
|
433
|
+
dbQuery["content.confidentiality"] = { $ne: "private" };
|
|
434
|
+
const attributes = await this.attributes.find(dbQuery);
|
|
435
|
+
const attribute = attributes.length > 0 ? attributes[0] : undefined;
|
|
436
|
+
return attribute ?? LocalAttribute_1.LocalAttribute.from(attribute);
|
|
429
437
|
}
|
|
430
438
|
async executeIdentityAttributeQuery(query) {
|
|
431
439
|
const parsedQuery = content_1.IdentityAttributeQuery.from(query);
|
|
@@ -433,7 +441,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
433
441
|
dbQuery["content.owner"] = this.identity.address.toString();
|
|
434
442
|
dbQuery["shareInfo"] = { $exists: false };
|
|
435
443
|
const attributes = await this.attributes.find(dbQuery);
|
|
436
|
-
return
|
|
444
|
+
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
437
445
|
}
|
|
438
446
|
async createLocalAttribute(params) {
|
|
439
447
|
const localAttribute = await LocalAttribute_1.LocalAttribute.fromAttribute(params.content);
|
|
@@ -982,7 +990,7 @@ exports.LocalAttributeShareInfo = LocalAttributeShareInfo;
|
|
|
982
990
|
"use strict";
|
|
983
991
|
|
|
984
992
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
985
|
-
exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
993
|
+
exports.ThirdPartyRelationshipAttributeQueryTranslator = exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
986
994
|
const docdb_querytranslator_1 = __webpack_require__(/*! @js-soft/docdb-querytranslator */ "./node_modules/@js-soft/docdb-querytranslator/dist/index.js");
|
|
987
995
|
const luxon_1 = __webpack_require__(/*! luxon */ "./node_modules/luxon/build/node/luxon.js");
|
|
988
996
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
@@ -1052,6 +1060,55 @@ class RelationshipAttributeQueryTranslator {
|
|
|
1052
1060
|
}
|
|
1053
1061
|
exports.RelationshipAttributeQueryTranslator = RelationshipAttributeQueryTranslator;
|
|
1054
1062
|
RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
1063
|
+
whitelist: {
|
|
1064
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
1065
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
1066
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: true,
|
|
1067
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: true,
|
|
1068
|
+
attributeType: true
|
|
1069
|
+
},
|
|
1070
|
+
alias: {
|
|
1071
|
+
// key
|
|
1072
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: [
|
|
1073
|
+
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.key)}`
|
|
1074
|
+
],
|
|
1075
|
+
// @type of attribute
|
|
1076
|
+
attributeType: [`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.@type`],
|
|
1077
|
+
// owner
|
|
1078
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: [
|
|
1079
|
+
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.owner)}`
|
|
1080
|
+
]
|
|
1081
|
+
},
|
|
1082
|
+
custom: {
|
|
1083
|
+
// validFrom
|
|
1084
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: (query, input) => {
|
|
1085
|
+
if (!input) {
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
const validFromUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
|
|
1089
|
+
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)}`] = {
|
|
1090
|
+
$gte: validFromUtcString
|
|
1091
|
+
};
|
|
1092
|
+
},
|
|
1093
|
+
// validTo
|
|
1094
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: (query, input) => {
|
|
1095
|
+
if (!input) {
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
const validToUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
|
|
1099
|
+
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validTo)}`] = {
|
|
1100
|
+
$lte: validToUtcString
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
class ThirdPartyRelationshipAttributeQueryTranslator {
|
|
1106
|
+
static translate(query) {
|
|
1107
|
+
return this.translator.parse({ ...query.toJSON(), attributeType: "RelationshipAttribute" });
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
exports.ThirdPartyRelationshipAttributeQueryTranslator = ThirdPartyRelationshipAttributeQueryTranslator;
|
|
1111
|
+
ThirdPartyRelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
1055
1112
|
whitelist: {
|
|
1056
1113
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
1057
1114
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
@@ -1215,7 +1272,7 @@ class DraftsController extends consumption_1.ConsumptionBaseController {
|
|
|
1215
1272
|
}
|
|
1216
1273
|
async getDrafts(query) {
|
|
1217
1274
|
const items = await this.drafts.find(query);
|
|
1218
|
-
return
|
|
1275
|
+
return this.parseArray(items, Draft_1.Draft);
|
|
1219
1276
|
}
|
|
1220
1277
|
async createDraft(content, type = "") {
|
|
1221
1278
|
const draft = Draft_1.Draft.from({
|
|
@@ -2241,8 +2298,8 @@ __exportStar(__webpack_require__(/*! ./incoming/IncomingRequestsController */ ".
|
|
|
2241
2298
|
__exportStar(__webpack_require__(/*! ./incoming/received/ReceivedIncomingRequestParameters */ "./dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js"), exports);
|
|
2242
2299
|
__exportStar(__webpack_require__(/*! ./incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters */ "./dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js"), exports);
|
|
2243
2300
|
__exportStar(__webpack_require__(/*! ./itemProcessors/AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js"), exports);
|
|
2244
|
-
__exportStar(__webpack_require__(/*! ./itemProcessors/
|
|
2245
|
-
__exportStar(__webpack_require__(/*! ./itemProcessors/
|
|
2301
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js"), exports);
|
|
2302
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/CreateAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js"), exports);
|
|
2246
2303
|
__exportStar(__webpack_require__(/*! ./itemProcessors/GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js"), exports);
|
|
2247
2304
|
__exportStar(__webpack_require__(/*! ./itemProcessors/IRequestItemProcessor */ "./dist/modules/requests/itemProcessors/IRequestItemProcessor.js"), exports);
|
|
2248
2305
|
__exportStar(__webpack_require__(/*! ./itemProcessors/ProcessorConstructor */ "./dist/modules/requests/itemProcessors/ProcessorConstructor.js"), exports);
|
|
@@ -2462,10 +2519,10 @@ exports.ErrorValidationResult = ErrorValidationResult;
|
|
|
2462
2519
|
|
|
2463
2520
|
/***/ }),
|
|
2464
2521
|
|
|
2465
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2466
|
-
|
|
2467
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2468
|
-
|
|
2522
|
+
/***/ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js":
|
|
2523
|
+
/*!************************************************************************************************************!*\
|
|
2524
|
+
!*** ./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js ***!
|
|
2525
|
+
\************************************************************************************************************/
|
|
2469
2526
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2470
2527
|
|
|
2471
2528
|
"use strict";
|
|
@@ -2477,61 +2534,87 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
2477
2534
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2478
2535
|
};
|
|
2479
2536
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2480
|
-
exports.
|
|
2537
|
+
exports.AcceptCreateAttributeRequestItemParameters = void 0;
|
|
2481
2538
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2482
|
-
let
|
|
2539
|
+
let AcceptCreateAttributeRequestItemParameters = class AcceptCreateAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
2483
2540
|
static from(value) {
|
|
2484
2541
|
return this.fromAny(value);
|
|
2485
2542
|
}
|
|
2486
2543
|
};
|
|
2487
|
-
|
|
2488
|
-
(0, ts_serval_1.type)("
|
|
2489
|
-
],
|
|
2490
|
-
exports.
|
|
2491
|
-
//# sourceMappingURL=
|
|
2544
|
+
AcceptCreateAttributeRequestItemParameters = __decorate([
|
|
2545
|
+
(0, ts_serval_1.type)("AcceptCreateAttributeRequestItemParameters")
|
|
2546
|
+
], AcceptCreateAttributeRequestItemParameters);
|
|
2547
|
+
exports.AcceptCreateAttributeRequestItemParameters = AcceptCreateAttributeRequestItemParameters;
|
|
2548
|
+
//# sourceMappingURL=AcceptCreateAttributeRequestItemParameters.js.map
|
|
2492
2549
|
|
|
2493
2550
|
/***/ }),
|
|
2494
2551
|
|
|
2495
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2496
|
-
|
|
2497
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2498
|
-
|
|
2552
|
+
/***/ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js":
|
|
2553
|
+
/*!*****************************************************************************************************!*\
|
|
2554
|
+
!*** ./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js ***!
|
|
2555
|
+
\*****************************************************************************************************/
|
|
2499
2556
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2500
2557
|
|
|
2501
2558
|
"use strict";
|
|
2502
2559
|
|
|
2503
2560
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2504
|
-
exports.
|
|
2561
|
+
exports.CreateAttributeRequestItemProcessor = void 0;
|
|
2505
2562
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2506
2563
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2507
2564
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
2508
2565
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2509
|
-
class
|
|
2510
|
-
canCreateOutgoingRequestItem(requestItem, _request,
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2566
|
+
class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
2567
|
+
canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
2568
|
+
const recipientIsAttributeOwner = requestItem.attribute.owner.equals(recipient);
|
|
2569
|
+
const senderIsAttributeOwner = requestItem.attribute.owner.equals(this.currentIdentityAddress);
|
|
2570
|
+
const ownerIsEmptyString = requestItem.attribute.owner.toString() === "";
|
|
2571
|
+
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2572
|
+
if (senderIsAttributeOwner) {
|
|
2573
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot create own Attributes with a CreateAttributeRequestItem. Use a ShareAttributeRequestItem instead."));
|
|
2574
|
+
}
|
|
2575
|
+
if (recipientIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
|
|
2576
|
+
return ValidationResult_1.ValidationResult.success();
|
|
2577
|
+
}
|
|
2578
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("The owner of the given `attribute` can only be the recipient's address or an empty string. The latter will default to the recipient's address."));
|
|
2514
2579
|
}
|
|
2515
|
-
|
|
2580
|
+
if (recipientIsAttributeOwner || senderIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
|
|
2581
|
+
return ValidationResult_1.ValidationResult.success();
|
|
2582
|
+
}
|
|
2583
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("The owner of the given 'attribute' can only be the sender's address, the recipient's address or an empty string. The latter will default to the recipient's address."));
|
|
2516
2584
|
}
|
|
2517
2585
|
async accept(requestItem, _params, requestInfo) {
|
|
2518
|
-
requestItem.attribute.owner
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2586
|
+
if (requestItem.attribute.owner.toString() === "") {
|
|
2587
|
+
requestItem.attribute.owner = this.currentIdentityAddress;
|
|
2588
|
+
}
|
|
2589
|
+
let sharedAttribute;
|
|
2590
|
+
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2591
|
+
const repositoryAttribute = await this.consumptionController.attributes.createLocalAttribute({
|
|
2592
|
+
content: requestItem.attribute
|
|
2593
|
+
});
|
|
2594
|
+
sharedAttribute = await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
2595
|
+
peer: requestInfo.peer,
|
|
2596
|
+
requestReference: requestInfo.id,
|
|
2597
|
+
sourceAttributeId: repositoryAttribute.id
|
|
2598
|
+
});
|
|
2599
|
+
}
|
|
2600
|
+
else {
|
|
2601
|
+
sharedAttribute = await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2602
|
+
content: requestItem.attribute,
|
|
2603
|
+
peer: requestInfo.peer,
|
|
2604
|
+
requestReference: requestInfo.id
|
|
2605
|
+
});
|
|
2606
|
+
}
|
|
2607
|
+
return content_1.CreateAttributeAcceptResponseItem.from({
|
|
2525
2608
|
result: content_1.ResponseItemResult.Accepted,
|
|
2526
|
-
attributeId:
|
|
2609
|
+
attributeId: sharedAttribute.id
|
|
2527
2610
|
});
|
|
2528
2611
|
}
|
|
2529
2612
|
async applyIncomingResponseItem(responseItem, requestItem, requestInfo) {
|
|
2530
|
-
if (!(responseItem instanceof content_1.
|
|
2613
|
+
if (!(responseItem instanceof content_1.CreateAttributeAcceptResponseItem)) {
|
|
2531
2614
|
return;
|
|
2532
2615
|
}
|
|
2533
2616
|
if (requestItem.attribute.owner.toString() === "") {
|
|
2534
|
-
requestItem.attribute.owner =
|
|
2617
|
+
requestItem.attribute.owner = requestInfo.peer;
|
|
2535
2618
|
}
|
|
2536
2619
|
await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2537
2620
|
id: responseItem.attributeId,
|
|
@@ -2541,8 +2624,8 @@ class CreateRelationshipAttributeRequestItemProcessor extends GenericRequestItem
|
|
|
2541
2624
|
});
|
|
2542
2625
|
}
|
|
2543
2626
|
}
|
|
2544
|
-
exports.
|
|
2545
|
-
//# sourceMappingURL=
|
|
2627
|
+
exports.CreateAttributeRequestItemProcessor = CreateAttributeRequestItemProcessor;
|
|
2628
|
+
//# sourceMappingURL=CreateAttributeRequestItemProcessor.js.map
|
|
2546
2629
|
|
|
2547
2630
|
/***/ }),
|
|
2548
2631
|
|
|
@@ -2995,14 +3078,14 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
2995
3078
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2996
3079
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2997
3080
|
function validateQuery(query, sender, recipient) {
|
|
2998
|
-
if (query instanceof content_1.
|
|
2999
|
-
if (query.thirdParty
|
|
3081
|
+
if (query instanceof content_1.ThirdPartyRelationshipAttributeQuery) {
|
|
3082
|
+
if (query.thirdParty.equals(sender)) {
|
|
3000
3083
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query an Attribute with the own address as third party."));
|
|
3001
3084
|
}
|
|
3002
|
-
if (query.thirdParty
|
|
3085
|
+
if (query.thirdParty.equals(recipient)) {
|
|
3003
3086
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query an Attribute with the recipient's address as third party."));
|
|
3004
3087
|
}
|
|
3005
|
-
if (query.owner.equals(sender)
|
|
3088
|
+
if (query.owner.equals(sender)) {
|
|
3006
3089
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query own Attributes from a third party."));
|
|
3007
3090
|
}
|
|
3008
3091
|
}
|
|
@@ -3800,7 +3883,7 @@ class SettingsController extends consumption_1.ConsumptionBaseController {
|
|
|
3800
3883
|
}
|
|
3801
3884
|
async getSettings(query) {
|
|
3802
3885
|
const items = await this.settings.find(query);
|
|
3803
|
-
return
|
|
3886
|
+
return this.parseArray(items, Setting_1.Setting);
|
|
3804
3887
|
}
|
|
3805
3888
|
async createSetting(parameters) {
|
|
3806
3889
|
const setting = Setting_1.Setting.from({
|