@nmshd/transport 2.4.0 → 2.4.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 +5 -5
- package/dist/modules/accounts/AccountController.d.ts.map +1 -1
- package/dist/modules/accounts/AccountController.js +1 -2
- package/dist/modules/accounts/AccountController.js.map +1 -1
- package/dist/modules/devices/DeviceController.d.ts +1 -0
- package/dist/modules/devices/DeviceController.d.ts.map +1 -1
- package/dist/modules/devices/DeviceController.js +5 -0
- package/dist/modules/devices/DeviceController.js.map +1 -1
- package/dist/modules/devices/DevicesController.js +1 -1
- package/dist/modules/devices/DevicesController.js.map +1 -1
- package/dist/modules/devices/local/Device.d.ts +2 -0
- package/dist/modules/devices/local/Device.d.ts.map +1 -1
- package/dist/modules/devices/local/Device.js +7 -1
- package/dist/modules/devices/local/Device.js.map +1 -1
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.d.ts.map +1 -1
- package/dist/modules/index.js +0 -1
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/sync/ChangedItems.d.ts +1 -2
- package/dist/modules/sync/ChangedItems.d.ts.map +1 -1
- package/dist/modules/sync/ChangedItems.js +9 -5
- package/dist/modules/sync/ChangedItems.js.map +1 -1
- package/dist/modules/sync/DatawalletModificationsProcessor.d.ts +6 -6
- package/dist/modules/sync/DatawalletModificationsProcessor.d.ts.map +1 -1
- package/dist/modules/sync/DatawalletModificationsProcessor.js +2 -2
- package/dist/modules/sync/DatawalletModificationsProcessor.js.map +1 -1
- package/dist/modules/sync/SyncController.d.ts +1 -0
- package/dist/modules/sync/SyncController.d.ts.map +1 -1
- package/dist/modules/sync/SyncController.js +41 -8
- package/dist/modules/sync/SyncController.js.map +1 -1
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessor.d.ts +14 -0
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessor.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js +14 -0
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.d.ts +9 -0
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js +35 -0
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.d.ts +7 -0
- package/dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js +16 -0
- package/dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.d.ts +7 -0
- package/dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js +16 -0
- package/dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.d.ts +7 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js +18 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.d.ts +7 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js +18 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/index.d.ts +6 -0
- package/dist/modules/sync/externalEventProcessors/index.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/index.js +22 -0
- package/dist/modules/sync/externalEventProcessors/index.js.map +1 -0
- package/lib-web/nmshd.transport.js +281 -132
- package/lib-web/nmshd.transport.js.map +1 -1
- package/lib-web/nmshd.transport.min.js +1 -1
- package/lib-web/nmshd.transport.min.js.map +1 -1
- package/package.json +4 -4
- package/dist/modules/sync/ExternalEventsProcessor.d.ts +0 -25
- package/dist/modules/sync/ExternalEventsProcessor.d.ts.map +0 -1
- package/dist/modules/sync/ExternalEventsProcessor.js +0 -96
- package/dist/modules/sync/ExternalEventsProcessor.js.map +0 -1
|
@@ -33561,11 +33561,11 @@ exports.buildInformation = void 0;
|
|
|
33561
33561
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
33562
33562
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
33563
33563
|
exports.buildInformation = {
|
|
33564
|
-
version: "2.4.
|
|
33565
|
-
build: "
|
|
33566
|
-
date: "2024-04-
|
|
33567
|
-
commit: "
|
|
33568
|
-
dependencies: {"@js-soft/docdb-access-abstractions":"1.0.
|
|
33564
|
+
version: "2.4.2",
|
|
33565
|
+
build: "65",
|
|
33566
|
+
date: "2024-04-09T13:51:36+00:00",
|
|
33567
|
+
commit: "3a175d3b3aa55c1abb812effdc45026acd26236b",
|
|
33568
|
+
dependencies: {"@js-soft/docdb-access-abstractions":"1.0.4","@js-soft/logging-abstractions":"^1.0.1","@js-soft/simple-logger":"1.0.4","@js-soft/ts-utils":"^2.3.3","axios":"^1.6.8","fast-json-patch":"^3.1.1","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.4.4","qs":"^6.12.0","reflect-metadata":"^0.2.2","ts-simple-nameof":"^1.3.1","uuid":"^9.0.1"},
|
|
33569
33569
|
libraries: {
|
|
33570
33570
|
crypto: crypto_1.buildInformation,
|
|
33571
33571
|
serval: ts_serval_1.buildInformation
|
|
@@ -36588,7 +36588,6 @@ class AccountController {
|
|
|
36588
36588
|
createdAt: core_1.CoreDate.from(deviceResponse.createdAt),
|
|
36589
36589
|
createdByDevice: deviceId,
|
|
36590
36590
|
id: deviceId,
|
|
36591
|
-
description: "",
|
|
36592
36591
|
name: "Device 1",
|
|
36593
36592
|
lastLoginAt: core_1.CoreDate.utc(),
|
|
36594
36593
|
operatingSystem: deviceInfo.operatingSystem,
|
|
@@ -36632,7 +36631,7 @@ class AccountController {
|
|
|
36632
36631
|
const device = Device_1.Device.from({
|
|
36633
36632
|
id: deviceSharedSecret.id,
|
|
36634
36633
|
name: deviceSharedSecret.name ? deviceSharedSecret.name : "",
|
|
36635
|
-
description: deviceSharedSecret.description
|
|
36634
|
+
description: deviceSharedSecret.description,
|
|
36636
36635
|
lastLoginAt: core_1.CoreDate.utc(),
|
|
36637
36636
|
createdAt: deviceSharedSecret.createdAt,
|
|
36638
36637
|
createdByDevice: deviceSharedSecret.createdByDevice,
|
|
@@ -38246,6 +38245,11 @@ class DeviceController extends core_1.TransportController {
|
|
|
38246
38245
|
password: credentials.password
|
|
38247
38246
|
};
|
|
38248
38247
|
}
|
|
38248
|
+
async markAsOffboarded() {
|
|
38249
|
+
this.device.isOffboarded = true;
|
|
38250
|
+
await this.parent.devices.update(this.device);
|
|
38251
|
+
await this.parent.syncDatawallet();
|
|
38252
|
+
}
|
|
38249
38253
|
}
|
|
38250
38254
|
exports.DeviceController = DeviceController;
|
|
38251
38255
|
__decorate([
|
|
@@ -38516,7 +38520,7 @@ class DevicesController extends TransportController_1.TransportController {
|
|
|
38516
38520
|
async addExistingDevice(device) {
|
|
38517
38521
|
await this.devices.create(device);
|
|
38518
38522
|
}
|
|
38519
|
-
async createDevice(name = "", description
|
|
38523
|
+
async createDevice(name = "", description, isAdmin = false) {
|
|
38520
38524
|
const [signedChallenge, devicePwdDn] = await Promise.all([this.parent.challenges.createChallenge(Challenge_1.ChallengeType.Identity), util_1.PasswordGenerator.createStrongPassword(45, 50)]);
|
|
38521
38525
|
this.log.trace("Device Creation Challenge signed. Creating device on backbone...");
|
|
38522
38526
|
const response = (await this.client.createDevice({
|
|
@@ -38712,7 +38716,8 @@ let Device = class Device extends core_1.CoreSynchronizable {
|
|
|
38712
38716
|
(0, ts_simple_nameof_1.nameof)((d) => d.lastLoginAt),
|
|
38713
38717
|
(0, ts_simple_nameof_1.nameof)((d) => d.username),
|
|
38714
38718
|
(0, ts_simple_nameof_1.nameof)((d) => d.initialPassword),
|
|
38715
|
-
(0, ts_simple_nameof_1.nameof)((d) => d.datawalletVersion)
|
|
38719
|
+
(0, ts_simple_nameof_1.nameof)((d) => d.datawalletVersion),
|
|
38720
|
+
(0, ts_simple_nameof_1.nameof)((d) => d.isOffboarded)
|
|
38716
38721
|
];
|
|
38717
38722
|
this.userdataProperties = [(0, ts_simple_nameof_1.nameof)((d) => d.name), (0, ts_simple_nameof_1.nameof)((d) => d.description)];
|
|
38718
38723
|
}
|
|
@@ -38786,6 +38791,11 @@ __decorate([
|
|
|
38786
38791
|
(0, ts_serval_1.serialize)(),
|
|
38787
38792
|
__metadata("design:type", Number)
|
|
38788
38793
|
], Device.prototype, "datawalletVersion", void 0);
|
|
38794
|
+
__decorate([
|
|
38795
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
38796
|
+
(0, ts_serval_1.serialize)(),
|
|
38797
|
+
__metadata("design:type", Boolean)
|
|
38798
|
+
], Device.prototype, "isOffboarded", void 0);
|
|
38789
38799
|
exports.Device = Device = __decorate([
|
|
38790
38800
|
(0, ts_serval_1.type)("Device")
|
|
38791
38801
|
], Device);
|
|
@@ -39843,7 +39853,6 @@ __exportStar(__webpack_require__(/*! ./sync/backbone/StartSyncRun */ "./dist/mod
|
|
|
39843
39853
|
__exportStar(__webpack_require__(/*! ./sync/backbone/SyncClient */ "./dist/modules/sync/backbone/SyncClient.js"), exports);
|
|
39844
39854
|
__exportStar(__webpack_require__(/*! ./sync/ChangedItems */ "./dist/modules/sync/ChangedItems.js"), exports);
|
|
39845
39855
|
__exportStar(__webpack_require__(/*! ./sync/DatawalletModificationsProcessor */ "./dist/modules/sync/DatawalletModificationsProcessor.js"), exports);
|
|
39846
|
-
__exportStar(__webpack_require__(/*! ./sync/ExternalEventsProcessor */ "./dist/modules/sync/ExternalEventsProcessor.js"), exports);
|
|
39847
39856
|
__exportStar(__webpack_require__(/*! ./sync/local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js"), exports);
|
|
39848
39857
|
var SyncCallback_1 = __webpack_require__(/*! ./sync/SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
39849
39858
|
Object.defineProperty(exports, "SyncStep", ({ enumerable: true, get: function () { return SyncCallback_1.SyncStep; } }));
|
|
@@ -43667,22 +43676,26 @@ exports.SecretContainerPlain = SecretContainerPlain = __decorate([
|
|
|
43667
43676
|
/*!*******************************************!*\
|
|
43668
43677
|
!*** ./dist/modules/sync/ChangedItems.js ***!
|
|
43669
43678
|
\*******************************************/
|
|
43670
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
43679
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
43671
43680
|
|
|
43672
43681
|
"use strict";
|
|
43673
43682
|
|
|
43674
43683
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
43675
43684
|
exports.ChangedItems = void 0;
|
|
43685
|
+
const Message_1 = __webpack_require__(/*! ../messages/local/Message */ "./dist/modules/messages/local/Message.js");
|
|
43686
|
+
const Relationship_1 = __webpack_require__(/*! ../relationships/local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
|
|
43676
43687
|
class ChangedItems {
|
|
43677
43688
|
constructor(relationships = [], messages = []) {
|
|
43678
43689
|
this.relationships = relationships;
|
|
43679
43690
|
this.messages = messages;
|
|
43680
43691
|
}
|
|
43681
|
-
|
|
43682
|
-
|
|
43683
|
-
|
|
43684
|
-
|
|
43685
|
-
|
|
43692
|
+
addItem(item) {
|
|
43693
|
+
if (item instanceof Message_1.Message) {
|
|
43694
|
+
this.messages.push(item);
|
|
43695
|
+
}
|
|
43696
|
+
else if (item instanceof Relationship_1.Relationship) {
|
|
43697
|
+
this.relationships.push(item);
|
|
43698
|
+
}
|
|
43686
43699
|
}
|
|
43687
43700
|
}
|
|
43688
43701
|
exports.ChangedItems = ChangedItems;
|
|
@@ -43792,11 +43805,11 @@ const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
|
43792
43805
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
43793
43806
|
const File_1 = __webpack_require__(/*! ../files/local/File */ "./dist/modules/files/local/File.js");
|
|
43794
43807
|
const Message_1 = __webpack_require__(/*! ../messages/local/Message */ "./dist/modules/messages/local/Message.js");
|
|
43795
|
-
const RelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
|
|
43796
43808
|
const Relationship_1 = __webpack_require__(/*! ../relationships/local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
|
|
43809
|
+
const RelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
|
|
43797
43810
|
const Token_1 = __webpack_require__(/*! ../tokens/local/Token */ "./dist/modules/tokens/local/Token.js");
|
|
43798
|
-
const SyncCallback_1 = __webpack_require__(/*! ./SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
43799
43811
|
const DatawalletModification_1 = __webpack_require__(/*! ./local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
|
|
43812
|
+
const SyncCallback_1 = __webpack_require__(/*! ./SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
43800
43813
|
class DatawalletModificationsProcessor {
|
|
43801
43814
|
get log() {
|
|
43802
43815
|
return this.logger;
|
|
@@ -43996,112 +44009,6 @@ exports.CacheFetcher = CacheFetcher;
|
|
|
43996
44009
|
|
|
43997
44010
|
/***/ }),
|
|
43998
44011
|
|
|
43999
|
-
/***/ "./dist/modules/sync/ExternalEventsProcessor.js":
|
|
44000
|
-
/*!******************************************************!*\
|
|
44001
|
-
!*** ./dist/modules/sync/ExternalEventsProcessor.js ***!
|
|
44002
|
-
\******************************************************/
|
|
44003
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44004
|
-
|
|
44005
|
-
"use strict";
|
|
44006
|
-
|
|
44007
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44008
|
-
exports.ExternalEventsProcessor = void 0;
|
|
44009
|
-
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
44010
|
-
const events_1 = __webpack_require__(/*! ../../events */ "./dist/events/index.js");
|
|
44011
|
-
const ChangedItems_1 = __webpack_require__(/*! ./ChangedItems */ "./dist/modules/sync/ChangedItems.js");
|
|
44012
|
-
const SyncCallback_1 = __webpack_require__(/*! ./SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
44013
|
-
class ExternalEventsProcessor {
|
|
44014
|
-
constructor(messagesController, relationshipsController, externalEvents, reporter, eventBus, ownAddress) {
|
|
44015
|
-
this.messagesController = messagesController;
|
|
44016
|
-
this.relationshipsController = relationshipsController;
|
|
44017
|
-
this.externalEvents = externalEvents;
|
|
44018
|
-
this.eventBus = eventBus;
|
|
44019
|
-
this.ownAddress = ownAddress;
|
|
44020
|
-
this.changedItems = new ChangedItems_1.ChangedItems();
|
|
44021
|
-
this.results = [];
|
|
44022
|
-
this.log = core_1.TransportLoggerFactory.getLogger(ExternalEventsProcessor);
|
|
44023
|
-
this.syncStep = reporter.createStep(SyncCallback_1.SyncStep.ExternalEventsProcessing, externalEvents.length);
|
|
44024
|
-
}
|
|
44025
|
-
async execute() {
|
|
44026
|
-
for (const externalEvent of this.externalEvents) {
|
|
44027
|
-
try {
|
|
44028
|
-
switch (externalEvent.type) {
|
|
44029
|
-
case "MessageReceived":
|
|
44030
|
-
await this.applyMessageReceivedEvent(externalEvent);
|
|
44031
|
-
break;
|
|
44032
|
-
case "MessageDelivered":
|
|
44033
|
-
await this.applyMessageDeliveredEvent(externalEvent);
|
|
44034
|
-
break;
|
|
44035
|
-
case "RelationshipChangeCreated":
|
|
44036
|
-
await this.applyRelationshipChangeCreatedEvent(externalEvent);
|
|
44037
|
-
break;
|
|
44038
|
-
case "RelationshipChangeCompleted":
|
|
44039
|
-
await this.applyRelationshipChangeCompletedEvent(externalEvent);
|
|
44040
|
-
break;
|
|
44041
|
-
default:
|
|
44042
|
-
throw new core_1.TransportError(`'${externalEvent.type}' is not a supported external event type.`);
|
|
44043
|
-
}
|
|
44044
|
-
this.results.push({
|
|
44045
|
-
externalEventId: externalEvent.id
|
|
44046
|
-
});
|
|
44047
|
-
}
|
|
44048
|
-
catch (e) {
|
|
44049
|
-
this.log.error("There was an error while trying to apply an external event: ", e);
|
|
44050
|
-
let errorCode;
|
|
44051
|
-
if (e.code) {
|
|
44052
|
-
errorCode = e.code;
|
|
44053
|
-
}
|
|
44054
|
-
else if (e.message) {
|
|
44055
|
-
errorCode = e.message;
|
|
44056
|
-
}
|
|
44057
|
-
else {
|
|
44058
|
-
errorCode = JSON.stringify(e);
|
|
44059
|
-
}
|
|
44060
|
-
this.results.push({
|
|
44061
|
-
externalEventId: externalEvent.id,
|
|
44062
|
-
errorCode: errorCode
|
|
44063
|
-
});
|
|
44064
|
-
}
|
|
44065
|
-
finally {
|
|
44066
|
-
this.syncStep.progress();
|
|
44067
|
-
}
|
|
44068
|
-
}
|
|
44069
|
-
}
|
|
44070
|
-
async applyRelationshipChangeCompletedEvent(externalEvent) {
|
|
44071
|
-
const payload = externalEvent.payload;
|
|
44072
|
-
const relationship = await this.relationshipsController.applyChangeById(payload.changeId);
|
|
44073
|
-
if (relationship) {
|
|
44074
|
-
this.eventBus.publish(new events_1.RelationshipChangedEvent(this.ownAddress, relationship));
|
|
44075
|
-
this.changedItems.addRelationship(relationship);
|
|
44076
|
-
}
|
|
44077
|
-
}
|
|
44078
|
-
async applyRelationshipChangeCreatedEvent(externalEvent) {
|
|
44079
|
-
const payload = externalEvent.payload;
|
|
44080
|
-
const relationship = await this.relationshipsController.applyChangeById(payload.changeId);
|
|
44081
|
-
if (relationship) {
|
|
44082
|
-
this.eventBus.publish(new events_1.RelationshipChangedEvent(this.ownAddress, relationship));
|
|
44083
|
-
this.changedItems.addRelationship(relationship);
|
|
44084
|
-
}
|
|
44085
|
-
}
|
|
44086
|
-
async applyMessageDeliveredEvent(externalEvent) {
|
|
44087
|
-
const messageReceivedPayload = externalEvent.payload;
|
|
44088
|
-
const updatedMessages = await this.messagesController.updateCache([messageReceivedPayload.id]);
|
|
44089
|
-
const deliveredMessage = updatedMessages[0];
|
|
44090
|
-
this.eventBus.publish(new events_1.MessageDeliveredEvent(this.ownAddress, deliveredMessage));
|
|
44091
|
-
this.changedItems.addMessage(deliveredMessage);
|
|
44092
|
-
}
|
|
44093
|
-
async applyMessageReceivedEvent(externalEvent) {
|
|
44094
|
-
const newMessagePayload = externalEvent.payload;
|
|
44095
|
-
const newMessage = await this.messagesController.loadPeerMessage(core_1.CoreId.from(newMessagePayload.id));
|
|
44096
|
-
this.eventBus.publish(new events_1.MessageReceivedEvent(this.ownAddress, newMessage));
|
|
44097
|
-
this.changedItems.addMessage(newMessage);
|
|
44098
|
-
}
|
|
44099
|
-
}
|
|
44100
|
-
exports.ExternalEventsProcessor = ExternalEventsProcessor;
|
|
44101
|
-
//# sourceMappingURL=ExternalEventsProcessor.js.map
|
|
44102
|
-
|
|
44103
|
-
/***/ }),
|
|
44104
|
-
|
|
44105
44012
|
/***/ "./dist/modules/sync/SyncCallback.js":
|
|
44106
44013
|
/*!*******************************************!*\
|
|
44107
44014
|
!*** ./dist/modules/sync/SyncCallback.js ***!
|
|
@@ -44158,16 +44065,16 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
44158
44065
|
exports.SyncController = void 0;
|
|
44159
44066
|
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "../../node_modules/@js-soft/ts-utils/dist/index.js");
|
|
44160
44067
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
44068
|
+
const StartSyncRun_1 = __webpack_require__(/*! ./backbone/StartSyncRun */ "./dist/modules/sync/backbone/StartSyncRun.js");
|
|
44069
|
+
const SyncClient_1 = __webpack_require__(/*! ./backbone/SyncClient */ "./dist/modules/sync/backbone/SyncClient.js");
|
|
44161
44070
|
const ChangedItems_1 = __webpack_require__(/*! ./ChangedItems */ "./dist/modules/sync/ChangedItems.js");
|
|
44162
44071
|
const DatawalletModificationMapper_1 = __webpack_require__(/*! ./DatawalletModificationMapper */ "./dist/modules/sync/DatawalletModificationMapper.js");
|
|
44163
44072
|
const DatawalletModificationsProcessor_1 = __webpack_require__(/*! ./DatawalletModificationsProcessor */ "./dist/modules/sync/DatawalletModificationsProcessor.js");
|
|
44164
|
-
const
|
|
44165
|
-
const SyncCallback_1 = __webpack_require__(/*! ./SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
44166
|
-
const StartSyncRun_1 = __webpack_require__(/*! ./backbone/StartSyncRun */ "./dist/modules/sync/backbone/StartSyncRun.js");
|
|
44167
|
-
const SyncClient_1 = __webpack_require__(/*! ./backbone/SyncClient */ "./dist/modules/sync/backbone/SyncClient.js");
|
|
44073
|
+
const externalEventProcessors_1 = __webpack_require__(/*! ./externalEventProcessors */ "./dist/modules/sync/externalEventProcessors/index.js");
|
|
44168
44074
|
const DatawalletModification_1 = __webpack_require__(/*! ./local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
|
|
44169
44075
|
const DeviceMigrations_1 = __webpack_require__(/*! ./migrations/DeviceMigrations */ "./dist/modules/sync/migrations/DeviceMigrations.js");
|
|
44170
44076
|
const IdentityMigrations_1 = __webpack_require__(/*! ./migrations/IdentityMigrations */ "./dist/modules/sync/migrations/IdentityMigrations.js");
|
|
44077
|
+
const SyncCallback_1 = __webpack_require__(/*! ./SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
44171
44078
|
class SyncController extends core_1.TransportController {
|
|
44172
44079
|
get cacheFetcher() {
|
|
44173
44080
|
if (!this._cacheFetcher) {
|
|
@@ -44179,6 +44086,7 @@ class SyncController extends core_1.TransportController {
|
|
|
44179
44086
|
super(core_1.ControllerName.Sync, parent);
|
|
44180
44087
|
this.unpushedDatawalletModifications = unpushedDatawalletModifications;
|
|
44181
44088
|
this.datawalletEnabled = datawalletEnabled;
|
|
44089
|
+
this.externalEventRegistry = new externalEventProcessors_1.ExternalEventProcessorRegistry();
|
|
44182
44090
|
this.client = dependencyOverrides.syncClient ?? new SyncClient_1.SyncClient(this.config, this.parent.authenticator);
|
|
44183
44091
|
this.identityMigrations = new IdentityMigrations_1.IdentityMigrations(this.parent);
|
|
44184
44092
|
this.deviceMigrations = new DeviceMigrations_1.DeviceMigrations(this.parent);
|
|
@@ -44431,12 +44339,44 @@ class SyncController extends core_1.TransportController {
|
|
|
44431
44339
|
throw getExternalEventsResult.error;
|
|
44432
44340
|
}
|
|
44433
44341
|
const externalEvents = await getExternalEventsResult.value.collect();
|
|
44434
|
-
const
|
|
44435
|
-
|
|
44342
|
+
const syncStep = reporter.createStep(SyncCallback_1.SyncStep.ExternalEventsProcessing, externalEvents.length);
|
|
44343
|
+
const results = [];
|
|
44344
|
+
const changedItems = new ChangedItems_1.ChangedItems();
|
|
44345
|
+
for (const externalEvent of externalEvents) {
|
|
44346
|
+
try {
|
|
44347
|
+
const externalEventProcessorConstructor = this.externalEventRegistry.getProcessorForItem(externalEvent.type);
|
|
44348
|
+
const item = await new externalEventProcessorConstructor(this.eventBus, this.parent).execute(externalEvent);
|
|
44349
|
+
if (item)
|
|
44350
|
+
changedItems.addItem(item);
|
|
44351
|
+
results.push({
|
|
44352
|
+
externalEventId: externalEvent.id
|
|
44353
|
+
});
|
|
44354
|
+
}
|
|
44355
|
+
catch (e) {
|
|
44356
|
+
this.log.error("There was an error while trying to apply an external event: ", e);
|
|
44357
|
+
let errorCode;
|
|
44358
|
+
if (e.code) {
|
|
44359
|
+
errorCode = e.code;
|
|
44360
|
+
}
|
|
44361
|
+
else if (e.message) {
|
|
44362
|
+
errorCode = e.message;
|
|
44363
|
+
}
|
|
44364
|
+
else {
|
|
44365
|
+
errorCode = JSON.stringify(e);
|
|
44366
|
+
}
|
|
44367
|
+
results.push({
|
|
44368
|
+
externalEventId: externalEvent.id,
|
|
44369
|
+
errorCode: errorCode
|
|
44370
|
+
});
|
|
44371
|
+
}
|
|
44372
|
+
finally {
|
|
44373
|
+
syncStep.progress();
|
|
44374
|
+
}
|
|
44375
|
+
}
|
|
44436
44376
|
externalEventStep.finish();
|
|
44437
44377
|
return {
|
|
44438
|
-
externalEventResults:
|
|
44439
|
-
changedItems:
|
|
44378
|
+
externalEventResults: results,
|
|
44379
|
+
changedItems: changedItems
|
|
44440
44380
|
};
|
|
44441
44381
|
}
|
|
44442
44382
|
async finalizeExternalEventsSyncRun(externalEventResults) {
|
|
@@ -44875,6 +44815,215 @@ exports.SyncClient = SyncClient;
|
|
|
44875
44815
|
|
|
44876
44816
|
/***/ }),
|
|
44877
44817
|
|
|
44818
|
+
/***/ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js":
|
|
44819
|
+
/*!*****************************************************************************!*\
|
|
44820
|
+
!*** ./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js ***!
|
|
44821
|
+
\*****************************************************************************/
|
|
44822
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
44823
|
+
|
|
44824
|
+
"use strict";
|
|
44825
|
+
|
|
44826
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44827
|
+
exports.ExternalEventProcessor = void 0;
|
|
44828
|
+
class ExternalEventProcessor {
|
|
44829
|
+
constructor(eventBus, accountController) {
|
|
44830
|
+
this.eventBus = eventBus;
|
|
44831
|
+
this.accountController = accountController;
|
|
44832
|
+
}
|
|
44833
|
+
get ownAddress() {
|
|
44834
|
+
return this.accountController.identity.address.toString();
|
|
44835
|
+
}
|
|
44836
|
+
}
|
|
44837
|
+
exports.ExternalEventProcessor = ExternalEventProcessor;
|
|
44838
|
+
//# sourceMappingURL=ExternalEventProcessor.js.map
|
|
44839
|
+
|
|
44840
|
+
/***/ }),
|
|
44841
|
+
|
|
44842
|
+
/***/ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js":
|
|
44843
|
+
/*!*************************************************************************************!*\
|
|
44844
|
+
!*** ./dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js ***!
|
|
44845
|
+
\*************************************************************************************/
|
|
44846
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44847
|
+
|
|
44848
|
+
"use strict";
|
|
44849
|
+
|
|
44850
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44851
|
+
exports.ExternalEventProcessorRegistry = void 0;
|
|
44852
|
+
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
44853
|
+
const MessageDeliveredExternalEventProcessor_1 = __webpack_require__(/*! ./MessageDeliveredExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js");
|
|
44854
|
+
const MessageReceivedExternalEventProcessor_1 = __webpack_require__(/*! ./MessageReceivedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js");
|
|
44855
|
+
const RelationshipChangeCompletedExternalEventProcessor_1 = __webpack_require__(/*! ./RelationshipChangeCompletedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js");
|
|
44856
|
+
const RelationshipChangeCreatedExternalEventProcessor_1 = __webpack_require__(/*! ./RelationshipChangeCreatedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js");
|
|
44857
|
+
class ExternalEventProcessorRegistry {
|
|
44858
|
+
constructor() {
|
|
44859
|
+
this.processors = new Map();
|
|
44860
|
+
this.registerProcessor("MessageReceived", MessageReceivedExternalEventProcessor_1.MessageReceivedExternalEventProcessor);
|
|
44861
|
+
this.registerProcessor("MessageDelivered", MessageDeliveredExternalEventProcessor_1.MessageDeliveredExternalEventProcessor);
|
|
44862
|
+
this.registerProcessor("RelationshipChangeCreated", RelationshipChangeCreatedExternalEventProcessor_1.RelationshipChangeCreatedExternalEventProcessor);
|
|
44863
|
+
this.registerProcessor("RelationshipChangeCompleted", RelationshipChangeCompletedExternalEventProcessor_1.RelationshipChangeCompletedExternalEventProcessor);
|
|
44864
|
+
}
|
|
44865
|
+
registerProcessor(externalEventName, externalEventProcessor) {
|
|
44866
|
+
if (this.processors.has(externalEventName)) {
|
|
44867
|
+
throw new core_1.TransportError(`There is already a externalEventProcessor registered for '${externalEventName}'. Use 'replaceProcessorForType' if you want to replace it.`);
|
|
44868
|
+
}
|
|
44869
|
+
this.processors.set(externalEventName, externalEventProcessor);
|
|
44870
|
+
}
|
|
44871
|
+
registerOrReplaceProcessor(externalEventName, externalEventProcessor) {
|
|
44872
|
+
this.processors.set(externalEventName, externalEventProcessor);
|
|
44873
|
+
}
|
|
44874
|
+
getProcessorForItem(externalEventName) {
|
|
44875
|
+
const externalEventProcessor = this.processors.get(externalEventName);
|
|
44876
|
+
if (!externalEventProcessor) {
|
|
44877
|
+
throw new core_1.TransportError(`There was no processor registered for '${externalEventName}'.`);
|
|
44878
|
+
}
|
|
44879
|
+
return externalEventProcessor;
|
|
44880
|
+
}
|
|
44881
|
+
}
|
|
44882
|
+
exports.ExternalEventProcessorRegistry = ExternalEventProcessorRegistry;
|
|
44883
|
+
//# sourceMappingURL=ExternalEventProcessorRegistry.js.map
|
|
44884
|
+
|
|
44885
|
+
/***/ }),
|
|
44886
|
+
|
|
44887
|
+
/***/ "./dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js":
|
|
44888
|
+
/*!*********************************************************************************************!*\
|
|
44889
|
+
!*** ./dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js ***!
|
|
44890
|
+
\*********************************************************************************************/
|
|
44891
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44892
|
+
|
|
44893
|
+
"use strict";
|
|
44894
|
+
|
|
44895
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44896
|
+
exports.MessageDeliveredExternalEventProcessor = void 0;
|
|
44897
|
+
const events_1 = __webpack_require__(/*! ../../../events */ "./dist/events/index.js");
|
|
44898
|
+
const ExternalEventProcessor_1 = __webpack_require__(/*! ./ExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js");
|
|
44899
|
+
class MessageDeliveredExternalEventProcessor extends ExternalEventProcessor_1.ExternalEventProcessor {
|
|
44900
|
+
async execute(externalEvent) {
|
|
44901
|
+
const messageReceivedPayload = externalEvent.payload;
|
|
44902
|
+
const updatedMessages = await this.accountController.messages.updateCache([messageReceivedPayload.id]);
|
|
44903
|
+
const deliveredMessage = updatedMessages[0];
|
|
44904
|
+
this.eventBus.publish(new events_1.MessageDeliveredEvent(this.ownAddress, deliveredMessage));
|
|
44905
|
+
return deliveredMessage;
|
|
44906
|
+
}
|
|
44907
|
+
}
|
|
44908
|
+
exports.MessageDeliveredExternalEventProcessor = MessageDeliveredExternalEventProcessor;
|
|
44909
|
+
//# sourceMappingURL=MessageDeliveredExternalEventProcessor.js.map
|
|
44910
|
+
|
|
44911
|
+
/***/ }),
|
|
44912
|
+
|
|
44913
|
+
/***/ "./dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js":
|
|
44914
|
+
/*!********************************************************************************************!*\
|
|
44915
|
+
!*** ./dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js ***!
|
|
44916
|
+
\********************************************************************************************/
|
|
44917
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44918
|
+
|
|
44919
|
+
"use strict";
|
|
44920
|
+
|
|
44921
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44922
|
+
exports.MessageReceivedExternalEventProcessor = void 0;
|
|
44923
|
+
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
44924
|
+
const events_1 = __webpack_require__(/*! ../../../events */ "./dist/events/index.js");
|
|
44925
|
+
const ExternalEventProcessor_1 = __webpack_require__(/*! ./ExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js");
|
|
44926
|
+
class MessageReceivedExternalEventProcessor extends ExternalEventProcessor_1.ExternalEventProcessor {
|
|
44927
|
+
async execute(externalEvent) {
|
|
44928
|
+
const newMessagePayload = externalEvent.payload;
|
|
44929
|
+
const newMessage = await this.accountController.messages.loadPeerMessage(core_1.CoreId.from(newMessagePayload.id));
|
|
44930
|
+
this.eventBus.publish(new events_1.MessageReceivedEvent(this.ownAddress, newMessage));
|
|
44931
|
+
return newMessage;
|
|
44932
|
+
}
|
|
44933
|
+
}
|
|
44934
|
+
exports.MessageReceivedExternalEventProcessor = MessageReceivedExternalEventProcessor;
|
|
44935
|
+
//# sourceMappingURL=MessageReceivedExternalEventProcessor.js.map
|
|
44936
|
+
|
|
44937
|
+
/***/ }),
|
|
44938
|
+
|
|
44939
|
+
/***/ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js":
|
|
44940
|
+
/*!********************************************************************************************************!*\
|
|
44941
|
+
!*** ./dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js ***!
|
|
44942
|
+
\********************************************************************************************************/
|
|
44943
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44944
|
+
|
|
44945
|
+
"use strict";
|
|
44946
|
+
|
|
44947
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44948
|
+
exports.RelationshipChangeCompletedExternalEventProcessor = void 0;
|
|
44949
|
+
const events_1 = __webpack_require__(/*! ../../../events */ "./dist/events/index.js");
|
|
44950
|
+
const ExternalEventProcessor_1 = __webpack_require__(/*! ./ExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js");
|
|
44951
|
+
class RelationshipChangeCompletedExternalEventProcessor extends ExternalEventProcessor_1.ExternalEventProcessor {
|
|
44952
|
+
async execute(externalEvent) {
|
|
44953
|
+
const payload = externalEvent.payload;
|
|
44954
|
+
const relationship = await this.accountController.relationships.applyChangeById(payload.changeId);
|
|
44955
|
+
if (relationship) {
|
|
44956
|
+
this.eventBus.publish(new events_1.RelationshipChangedEvent(this.ownAddress, relationship));
|
|
44957
|
+
return relationship;
|
|
44958
|
+
}
|
|
44959
|
+
return;
|
|
44960
|
+
}
|
|
44961
|
+
}
|
|
44962
|
+
exports.RelationshipChangeCompletedExternalEventProcessor = RelationshipChangeCompletedExternalEventProcessor;
|
|
44963
|
+
//# sourceMappingURL=RelationshipChangeCompletedExternalEventProcessor.js.map
|
|
44964
|
+
|
|
44965
|
+
/***/ }),
|
|
44966
|
+
|
|
44967
|
+
/***/ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js":
|
|
44968
|
+
/*!******************************************************************************************************!*\
|
|
44969
|
+
!*** ./dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js ***!
|
|
44970
|
+
\******************************************************************************************************/
|
|
44971
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44972
|
+
|
|
44973
|
+
"use strict";
|
|
44974
|
+
|
|
44975
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44976
|
+
exports.RelationshipChangeCreatedExternalEventProcessor = void 0;
|
|
44977
|
+
const events_1 = __webpack_require__(/*! ../../../events */ "./dist/events/index.js");
|
|
44978
|
+
const ExternalEventProcessor_1 = __webpack_require__(/*! ./ExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js");
|
|
44979
|
+
class RelationshipChangeCreatedExternalEventProcessor extends ExternalEventProcessor_1.ExternalEventProcessor {
|
|
44980
|
+
async execute(externalEvent) {
|
|
44981
|
+
const payload = externalEvent.payload;
|
|
44982
|
+
const relationship = await this.accountController.relationships.applyChangeById(payload.changeId);
|
|
44983
|
+
if (relationship) {
|
|
44984
|
+
this.eventBus.publish(new events_1.RelationshipChangedEvent(this.ownAddress, relationship));
|
|
44985
|
+
return relationship;
|
|
44986
|
+
}
|
|
44987
|
+
return;
|
|
44988
|
+
}
|
|
44989
|
+
}
|
|
44990
|
+
exports.RelationshipChangeCreatedExternalEventProcessor = RelationshipChangeCreatedExternalEventProcessor;
|
|
44991
|
+
//# sourceMappingURL=RelationshipChangeCreatedExternalEventProcessor.js.map
|
|
44992
|
+
|
|
44993
|
+
/***/ }),
|
|
44994
|
+
|
|
44995
|
+
/***/ "./dist/modules/sync/externalEventProcessors/index.js":
|
|
44996
|
+
/*!************************************************************!*\
|
|
44997
|
+
!*** ./dist/modules/sync/externalEventProcessors/index.js ***!
|
|
44998
|
+
\************************************************************/
|
|
44999
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
45000
|
+
|
|
45001
|
+
"use strict";
|
|
45002
|
+
|
|
45003
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
45004
|
+
if (k2 === undefined) k2 = k;
|
|
45005
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
45006
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
45007
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
45008
|
+
}
|
|
45009
|
+
Object.defineProperty(o, k2, desc);
|
|
45010
|
+
}) : (function(o, m, k, k2) {
|
|
45011
|
+
if (k2 === undefined) k2 = k;
|
|
45012
|
+
o[k2] = m[k];
|
|
45013
|
+
}));
|
|
45014
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
45015
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
45016
|
+
};
|
|
45017
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
45018
|
+
__exportStar(__webpack_require__(/*! ./ExternalEventProcessorRegistry */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js"), exports);
|
|
45019
|
+
__exportStar(__webpack_require__(/*! ./MessageDeliveredExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js"), exports);
|
|
45020
|
+
__exportStar(__webpack_require__(/*! ./MessageReceivedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js"), exports);
|
|
45021
|
+
__exportStar(__webpack_require__(/*! ./RelationshipChangeCompletedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js"), exports);
|
|
45022
|
+
__exportStar(__webpack_require__(/*! ./RelationshipChangeCreatedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js"), exports);
|
|
45023
|
+
//# sourceMappingURL=index.js.map
|
|
45024
|
+
|
|
45025
|
+
/***/ }),
|
|
45026
|
+
|
|
44878
45027
|
/***/ "./dist/modules/sync/local/DatawalletModification.js":
|
|
44879
45028
|
/*!***********************************************************!*\
|
|
44880
45029
|
!*** ./dist/modules/sync/local/DatawalletModification.js ***!
|