@nmshd/transport 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buildInformation.js +5 -5
- 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/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 +279 -129
- 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.1",
|
|
33565
|
+
build: "64",
|
|
33566
|
+
date: "2024-04-08T14:17:48+00:00",
|
|
33567
|
+
commit: "2c9d6dbb7fd529de72e9693b07ad44c49073c795",
|
|
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
|
|
@@ -38246,6 +38246,11 @@ class DeviceController extends core_1.TransportController {
|
|
|
38246
38246
|
password: credentials.password
|
|
38247
38247
|
};
|
|
38248
38248
|
}
|
|
38249
|
+
async markAsOffboarded() {
|
|
38250
|
+
this.device.isOffboarded = true;
|
|
38251
|
+
await this.parent.devices.update(this.device);
|
|
38252
|
+
await this.parent.syncDatawallet();
|
|
38253
|
+
}
|
|
38249
38254
|
}
|
|
38250
38255
|
exports.DeviceController = DeviceController;
|
|
38251
38256
|
__decorate([
|
|
@@ -38712,7 +38717,8 @@ let Device = class Device extends core_1.CoreSynchronizable {
|
|
|
38712
38717
|
(0, ts_simple_nameof_1.nameof)((d) => d.lastLoginAt),
|
|
38713
38718
|
(0, ts_simple_nameof_1.nameof)((d) => d.username),
|
|
38714
38719
|
(0, ts_simple_nameof_1.nameof)((d) => d.initialPassword),
|
|
38715
|
-
(0, ts_simple_nameof_1.nameof)((d) => d.datawalletVersion)
|
|
38720
|
+
(0, ts_simple_nameof_1.nameof)((d) => d.datawalletVersion),
|
|
38721
|
+
(0, ts_simple_nameof_1.nameof)((d) => d.isOffboarded)
|
|
38716
38722
|
];
|
|
38717
38723
|
this.userdataProperties = [(0, ts_simple_nameof_1.nameof)((d) => d.name), (0, ts_simple_nameof_1.nameof)((d) => d.description)];
|
|
38718
38724
|
}
|
|
@@ -38786,6 +38792,11 @@ __decorate([
|
|
|
38786
38792
|
(0, ts_serval_1.serialize)(),
|
|
38787
38793
|
__metadata("design:type", Number)
|
|
38788
38794
|
], Device.prototype, "datawalletVersion", void 0);
|
|
38795
|
+
__decorate([
|
|
38796
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
38797
|
+
(0, ts_serval_1.serialize)(),
|
|
38798
|
+
__metadata("design:type", Boolean)
|
|
38799
|
+
], Device.prototype, "isOffboarded", void 0);
|
|
38789
38800
|
exports.Device = Device = __decorate([
|
|
38790
38801
|
(0, ts_serval_1.type)("Device")
|
|
38791
38802
|
], Device);
|
|
@@ -39843,7 +39854,6 @@ __exportStar(__webpack_require__(/*! ./sync/backbone/StartSyncRun */ "./dist/mod
|
|
|
39843
39854
|
__exportStar(__webpack_require__(/*! ./sync/backbone/SyncClient */ "./dist/modules/sync/backbone/SyncClient.js"), exports);
|
|
39844
39855
|
__exportStar(__webpack_require__(/*! ./sync/ChangedItems */ "./dist/modules/sync/ChangedItems.js"), exports);
|
|
39845
39856
|
__exportStar(__webpack_require__(/*! ./sync/DatawalletModificationsProcessor */ "./dist/modules/sync/DatawalletModificationsProcessor.js"), exports);
|
|
39846
|
-
__exportStar(__webpack_require__(/*! ./sync/ExternalEventsProcessor */ "./dist/modules/sync/ExternalEventsProcessor.js"), exports);
|
|
39847
39857
|
__exportStar(__webpack_require__(/*! ./sync/local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js"), exports);
|
|
39848
39858
|
var SyncCallback_1 = __webpack_require__(/*! ./sync/SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
39849
39859
|
Object.defineProperty(exports, "SyncStep", ({ enumerable: true, get: function () { return SyncCallback_1.SyncStep; } }));
|
|
@@ -43667,22 +43677,26 @@ exports.SecretContainerPlain = SecretContainerPlain = __decorate([
|
|
|
43667
43677
|
/*!*******************************************!*\
|
|
43668
43678
|
!*** ./dist/modules/sync/ChangedItems.js ***!
|
|
43669
43679
|
\*******************************************/
|
|
43670
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
43680
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
43671
43681
|
|
|
43672
43682
|
"use strict";
|
|
43673
43683
|
|
|
43674
43684
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
43675
43685
|
exports.ChangedItems = void 0;
|
|
43686
|
+
const Message_1 = __webpack_require__(/*! ../messages/local/Message */ "./dist/modules/messages/local/Message.js");
|
|
43687
|
+
const Relationship_1 = __webpack_require__(/*! ../relationships/local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
|
|
43676
43688
|
class ChangedItems {
|
|
43677
43689
|
constructor(relationships = [], messages = []) {
|
|
43678
43690
|
this.relationships = relationships;
|
|
43679
43691
|
this.messages = messages;
|
|
43680
43692
|
}
|
|
43681
|
-
|
|
43682
|
-
|
|
43683
|
-
|
|
43684
|
-
|
|
43685
|
-
|
|
43693
|
+
addItem(item) {
|
|
43694
|
+
if (item instanceof Message_1.Message) {
|
|
43695
|
+
this.messages.push(item);
|
|
43696
|
+
}
|
|
43697
|
+
else if (item instanceof Relationship_1.Relationship) {
|
|
43698
|
+
this.relationships.push(item);
|
|
43699
|
+
}
|
|
43686
43700
|
}
|
|
43687
43701
|
}
|
|
43688
43702
|
exports.ChangedItems = ChangedItems;
|
|
@@ -43792,11 +43806,11 @@ const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
|
43792
43806
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
43793
43807
|
const File_1 = __webpack_require__(/*! ../files/local/File */ "./dist/modules/files/local/File.js");
|
|
43794
43808
|
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
43809
|
const Relationship_1 = __webpack_require__(/*! ../relationships/local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
|
|
43810
|
+
const RelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
|
|
43797
43811
|
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
43812
|
const DatawalletModification_1 = __webpack_require__(/*! ./local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
|
|
43813
|
+
const SyncCallback_1 = __webpack_require__(/*! ./SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
43800
43814
|
class DatawalletModificationsProcessor {
|
|
43801
43815
|
get log() {
|
|
43802
43816
|
return this.logger;
|
|
@@ -43996,112 +44010,6 @@ exports.CacheFetcher = CacheFetcher;
|
|
|
43996
44010
|
|
|
43997
44011
|
/***/ }),
|
|
43998
44012
|
|
|
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
44013
|
/***/ "./dist/modules/sync/SyncCallback.js":
|
|
44106
44014
|
/*!*******************************************!*\
|
|
44107
44015
|
!*** ./dist/modules/sync/SyncCallback.js ***!
|
|
@@ -44158,16 +44066,16 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
44158
44066
|
exports.SyncController = void 0;
|
|
44159
44067
|
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "../../node_modules/@js-soft/ts-utils/dist/index.js");
|
|
44160
44068
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
44069
|
+
const StartSyncRun_1 = __webpack_require__(/*! ./backbone/StartSyncRun */ "./dist/modules/sync/backbone/StartSyncRun.js");
|
|
44070
|
+
const SyncClient_1 = __webpack_require__(/*! ./backbone/SyncClient */ "./dist/modules/sync/backbone/SyncClient.js");
|
|
44161
44071
|
const ChangedItems_1 = __webpack_require__(/*! ./ChangedItems */ "./dist/modules/sync/ChangedItems.js");
|
|
44162
44072
|
const DatawalletModificationMapper_1 = __webpack_require__(/*! ./DatawalletModificationMapper */ "./dist/modules/sync/DatawalletModificationMapper.js");
|
|
44163
44073
|
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");
|
|
44074
|
+
const externalEventProcessors_1 = __webpack_require__(/*! ./externalEventProcessors */ "./dist/modules/sync/externalEventProcessors/index.js");
|
|
44168
44075
|
const DatawalletModification_1 = __webpack_require__(/*! ./local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
|
|
44169
44076
|
const DeviceMigrations_1 = __webpack_require__(/*! ./migrations/DeviceMigrations */ "./dist/modules/sync/migrations/DeviceMigrations.js");
|
|
44170
44077
|
const IdentityMigrations_1 = __webpack_require__(/*! ./migrations/IdentityMigrations */ "./dist/modules/sync/migrations/IdentityMigrations.js");
|
|
44078
|
+
const SyncCallback_1 = __webpack_require__(/*! ./SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
44171
44079
|
class SyncController extends core_1.TransportController {
|
|
44172
44080
|
get cacheFetcher() {
|
|
44173
44081
|
if (!this._cacheFetcher) {
|
|
@@ -44179,6 +44087,7 @@ class SyncController extends core_1.TransportController {
|
|
|
44179
44087
|
super(core_1.ControllerName.Sync, parent);
|
|
44180
44088
|
this.unpushedDatawalletModifications = unpushedDatawalletModifications;
|
|
44181
44089
|
this.datawalletEnabled = datawalletEnabled;
|
|
44090
|
+
this.externalEventRegistry = new externalEventProcessors_1.ExternalEventProcessorRegistry();
|
|
44182
44091
|
this.client = dependencyOverrides.syncClient ?? new SyncClient_1.SyncClient(this.config, this.parent.authenticator);
|
|
44183
44092
|
this.identityMigrations = new IdentityMigrations_1.IdentityMigrations(this.parent);
|
|
44184
44093
|
this.deviceMigrations = new DeviceMigrations_1.DeviceMigrations(this.parent);
|
|
@@ -44431,12 +44340,44 @@ class SyncController extends core_1.TransportController {
|
|
|
44431
44340
|
throw getExternalEventsResult.error;
|
|
44432
44341
|
}
|
|
44433
44342
|
const externalEvents = await getExternalEventsResult.value.collect();
|
|
44434
|
-
const
|
|
44435
|
-
|
|
44343
|
+
const syncStep = reporter.createStep(SyncCallback_1.SyncStep.ExternalEventsProcessing, externalEvents.length);
|
|
44344
|
+
const results = [];
|
|
44345
|
+
const changedItems = new ChangedItems_1.ChangedItems();
|
|
44346
|
+
for (const externalEvent of externalEvents) {
|
|
44347
|
+
try {
|
|
44348
|
+
const externalEventProcessorConstructor = this.externalEventRegistry.getProcessorForItem(externalEvent.type);
|
|
44349
|
+
const item = await new externalEventProcessorConstructor(this.eventBus, this.parent).execute(externalEvent);
|
|
44350
|
+
if (item)
|
|
44351
|
+
changedItems.addItem(item);
|
|
44352
|
+
results.push({
|
|
44353
|
+
externalEventId: externalEvent.id
|
|
44354
|
+
});
|
|
44355
|
+
}
|
|
44356
|
+
catch (e) {
|
|
44357
|
+
this.log.error("There was an error while trying to apply an external event: ", e);
|
|
44358
|
+
let errorCode;
|
|
44359
|
+
if (e.code) {
|
|
44360
|
+
errorCode = e.code;
|
|
44361
|
+
}
|
|
44362
|
+
else if (e.message) {
|
|
44363
|
+
errorCode = e.message;
|
|
44364
|
+
}
|
|
44365
|
+
else {
|
|
44366
|
+
errorCode = JSON.stringify(e);
|
|
44367
|
+
}
|
|
44368
|
+
results.push({
|
|
44369
|
+
externalEventId: externalEvent.id,
|
|
44370
|
+
errorCode: errorCode
|
|
44371
|
+
});
|
|
44372
|
+
}
|
|
44373
|
+
finally {
|
|
44374
|
+
syncStep.progress();
|
|
44375
|
+
}
|
|
44376
|
+
}
|
|
44436
44377
|
externalEventStep.finish();
|
|
44437
44378
|
return {
|
|
44438
|
-
externalEventResults:
|
|
44439
|
-
changedItems:
|
|
44379
|
+
externalEventResults: results,
|
|
44380
|
+
changedItems: changedItems
|
|
44440
44381
|
};
|
|
44441
44382
|
}
|
|
44442
44383
|
async finalizeExternalEventsSyncRun(externalEventResults) {
|
|
@@ -44875,6 +44816,215 @@ exports.SyncClient = SyncClient;
|
|
|
44875
44816
|
|
|
44876
44817
|
/***/ }),
|
|
44877
44818
|
|
|
44819
|
+
/***/ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js":
|
|
44820
|
+
/*!*****************************************************************************!*\
|
|
44821
|
+
!*** ./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js ***!
|
|
44822
|
+
\*****************************************************************************/
|
|
44823
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
44824
|
+
|
|
44825
|
+
"use strict";
|
|
44826
|
+
|
|
44827
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44828
|
+
exports.ExternalEventProcessor = void 0;
|
|
44829
|
+
class ExternalEventProcessor {
|
|
44830
|
+
constructor(eventBus, accountController) {
|
|
44831
|
+
this.eventBus = eventBus;
|
|
44832
|
+
this.accountController = accountController;
|
|
44833
|
+
}
|
|
44834
|
+
get ownAddress() {
|
|
44835
|
+
return this.accountController.identity.address.toString();
|
|
44836
|
+
}
|
|
44837
|
+
}
|
|
44838
|
+
exports.ExternalEventProcessor = ExternalEventProcessor;
|
|
44839
|
+
//# sourceMappingURL=ExternalEventProcessor.js.map
|
|
44840
|
+
|
|
44841
|
+
/***/ }),
|
|
44842
|
+
|
|
44843
|
+
/***/ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js":
|
|
44844
|
+
/*!*************************************************************************************!*\
|
|
44845
|
+
!*** ./dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js ***!
|
|
44846
|
+
\*************************************************************************************/
|
|
44847
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44848
|
+
|
|
44849
|
+
"use strict";
|
|
44850
|
+
|
|
44851
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44852
|
+
exports.ExternalEventProcessorRegistry = void 0;
|
|
44853
|
+
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
44854
|
+
const MessageDeliveredExternalEventProcessor_1 = __webpack_require__(/*! ./MessageDeliveredExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js");
|
|
44855
|
+
const MessageReceivedExternalEventProcessor_1 = __webpack_require__(/*! ./MessageReceivedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js");
|
|
44856
|
+
const RelationshipChangeCompletedExternalEventProcessor_1 = __webpack_require__(/*! ./RelationshipChangeCompletedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js");
|
|
44857
|
+
const RelationshipChangeCreatedExternalEventProcessor_1 = __webpack_require__(/*! ./RelationshipChangeCreatedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js");
|
|
44858
|
+
class ExternalEventProcessorRegistry {
|
|
44859
|
+
constructor() {
|
|
44860
|
+
this.processors = new Map();
|
|
44861
|
+
this.registerProcessor("MessageReceived", MessageReceivedExternalEventProcessor_1.MessageReceivedExternalEventProcessor);
|
|
44862
|
+
this.registerProcessor("MessageDelivered", MessageDeliveredExternalEventProcessor_1.MessageDeliveredExternalEventProcessor);
|
|
44863
|
+
this.registerProcessor("RelationshipChangeCreated", RelationshipChangeCreatedExternalEventProcessor_1.RelationshipChangeCreatedExternalEventProcessor);
|
|
44864
|
+
this.registerProcessor("RelationshipChangeCompleted", RelationshipChangeCompletedExternalEventProcessor_1.RelationshipChangeCompletedExternalEventProcessor);
|
|
44865
|
+
}
|
|
44866
|
+
registerProcessor(externalEventName, externalEventProcessor) {
|
|
44867
|
+
if (this.processors.has(externalEventName)) {
|
|
44868
|
+
throw new core_1.TransportError(`There is already a externalEventProcessor registered for '${externalEventName}'. Use 'replaceProcessorForType' if you want to replace it.`);
|
|
44869
|
+
}
|
|
44870
|
+
this.processors.set(externalEventName, externalEventProcessor);
|
|
44871
|
+
}
|
|
44872
|
+
registerOrReplaceProcessor(externalEventName, externalEventProcessor) {
|
|
44873
|
+
this.processors.set(externalEventName, externalEventProcessor);
|
|
44874
|
+
}
|
|
44875
|
+
getProcessorForItem(externalEventName) {
|
|
44876
|
+
const externalEventProcessor = this.processors.get(externalEventName);
|
|
44877
|
+
if (!externalEventProcessor) {
|
|
44878
|
+
throw new core_1.TransportError(`There was no processor registered for '${externalEventName}'.`);
|
|
44879
|
+
}
|
|
44880
|
+
return externalEventProcessor;
|
|
44881
|
+
}
|
|
44882
|
+
}
|
|
44883
|
+
exports.ExternalEventProcessorRegistry = ExternalEventProcessorRegistry;
|
|
44884
|
+
//# sourceMappingURL=ExternalEventProcessorRegistry.js.map
|
|
44885
|
+
|
|
44886
|
+
/***/ }),
|
|
44887
|
+
|
|
44888
|
+
/***/ "./dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js":
|
|
44889
|
+
/*!*********************************************************************************************!*\
|
|
44890
|
+
!*** ./dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js ***!
|
|
44891
|
+
\*********************************************************************************************/
|
|
44892
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44893
|
+
|
|
44894
|
+
"use strict";
|
|
44895
|
+
|
|
44896
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44897
|
+
exports.MessageDeliveredExternalEventProcessor = void 0;
|
|
44898
|
+
const events_1 = __webpack_require__(/*! ../../../events */ "./dist/events/index.js");
|
|
44899
|
+
const ExternalEventProcessor_1 = __webpack_require__(/*! ./ExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js");
|
|
44900
|
+
class MessageDeliveredExternalEventProcessor extends ExternalEventProcessor_1.ExternalEventProcessor {
|
|
44901
|
+
async execute(externalEvent) {
|
|
44902
|
+
const messageReceivedPayload = externalEvent.payload;
|
|
44903
|
+
const updatedMessages = await this.accountController.messages.updateCache([messageReceivedPayload.id]);
|
|
44904
|
+
const deliveredMessage = updatedMessages[0];
|
|
44905
|
+
this.eventBus.publish(new events_1.MessageDeliveredEvent(this.ownAddress, deliveredMessage));
|
|
44906
|
+
return deliveredMessage;
|
|
44907
|
+
}
|
|
44908
|
+
}
|
|
44909
|
+
exports.MessageDeliveredExternalEventProcessor = MessageDeliveredExternalEventProcessor;
|
|
44910
|
+
//# sourceMappingURL=MessageDeliveredExternalEventProcessor.js.map
|
|
44911
|
+
|
|
44912
|
+
/***/ }),
|
|
44913
|
+
|
|
44914
|
+
/***/ "./dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js":
|
|
44915
|
+
/*!********************************************************************************************!*\
|
|
44916
|
+
!*** ./dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js ***!
|
|
44917
|
+
\********************************************************************************************/
|
|
44918
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44919
|
+
|
|
44920
|
+
"use strict";
|
|
44921
|
+
|
|
44922
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44923
|
+
exports.MessageReceivedExternalEventProcessor = void 0;
|
|
44924
|
+
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
44925
|
+
const events_1 = __webpack_require__(/*! ../../../events */ "./dist/events/index.js");
|
|
44926
|
+
const ExternalEventProcessor_1 = __webpack_require__(/*! ./ExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js");
|
|
44927
|
+
class MessageReceivedExternalEventProcessor extends ExternalEventProcessor_1.ExternalEventProcessor {
|
|
44928
|
+
async execute(externalEvent) {
|
|
44929
|
+
const newMessagePayload = externalEvent.payload;
|
|
44930
|
+
const newMessage = await this.accountController.messages.loadPeerMessage(core_1.CoreId.from(newMessagePayload.id));
|
|
44931
|
+
this.eventBus.publish(new events_1.MessageReceivedEvent(this.ownAddress, newMessage));
|
|
44932
|
+
return newMessage;
|
|
44933
|
+
}
|
|
44934
|
+
}
|
|
44935
|
+
exports.MessageReceivedExternalEventProcessor = MessageReceivedExternalEventProcessor;
|
|
44936
|
+
//# sourceMappingURL=MessageReceivedExternalEventProcessor.js.map
|
|
44937
|
+
|
|
44938
|
+
/***/ }),
|
|
44939
|
+
|
|
44940
|
+
/***/ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js":
|
|
44941
|
+
/*!********************************************************************************************************!*\
|
|
44942
|
+
!*** ./dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js ***!
|
|
44943
|
+
\********************************************************************************************************/
|
|
44944
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44945
|
+
|
|
44946
|
+
"use strict";
|
|
44947
|
+
|
|
44948
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44949
|
+
exports.RelationshipChangeCompletedExternalEventProcessor = void 0;
|
|
44950
|
+
const events_1 = __webpack_require__(/*! ../../../events */ "./dist/events/index.js");
|
|
44951
|
+
const ExternalEventProcessor_1 = __webpack_require__(/*! ./ExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js");
|
|
44952
|
+
class RelationshipChangeCompletedExternalEventProcessor extends ExternalEventProcessor_1.ExternalEventProcessor {
|
|
44953
|
+
async execute(externalEvent) {
|
|
44954
|
+
const payload = externalEvent.payload;
|
|
44955
|
+
const relationship = await this.accountController.relationships.applyChangeById(payload.changeId);
|
|
44956
|
+
if (relationship) {
|
|
44957
|
+
this.eventBus.publish(new events_1.RelationshipChangedEvent(this.ownAddress, relationship));
|
|
44958
|
+
return relationship;
|
|
44959
|
+
}
|
|
44960
|
+
return;
|
|
44961
|
+
}
|
|
44962
|
+
}
|
|
44963
|
+
exports.RelationshipChangeCompletedExternalEventProcessor = RelationshipChangeCompletedExternalEventProcessor;
|
|
44964
|
+
//# sourceMappingURL=RelationshipChangeCompletedExternalEventProcessor.js.map
|
|
44965
|
+
|
|
44966
|
+
/***/ }),
|
|
44967
|
+
|
|
44968
|
+
/***/ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js":
|
|
44969
|
+
/*!******************************************************************************************************!*\
|
|
44970
|
+
!*** ./dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js ***!
|
|
44971
|
+
\******************************************************************************************************/
|
|
44972
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44973
|
+
|
|
44974
|
+
"use strict";
|
|
44975
|
+
|
|
44976
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44977
|
+
exports.RelationshipChangeCreatedExternalEventProcessor = void 0;
|
|
44978
|
+
const events_1 = __webpack_require__(/*! ../../../events */ "./dist/events/index.js");
|
|
44979
|
+
const ExternalEventProcessor_1 = __webpack_require__(/*! ./ExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js");
|
|
44980
|
+
class RelationshipChangeCreatedExternalEventProcessor extends ExternalEventProcessor_1.ExternalEventProcessor {
|
|
44981
|
+
async execute(externalEvent) {
|
|
44982
|
+
const payload = externalEvent.payload;
|
|
44983
|
+
const relationship = await this.accountController.relationships.applyChangeById(payload.changeId);
|
|
44984
|
+
if (relationship) {
|
|
44985
|
+
this.eventBus.publish(new events_1.RelationshipChangedEvent(this.ownAddress, relationship));
|
|
44986
|
+
return relationship;
|
|
44987
|
+
}
|
|
44988
|
+
return;
|
|
44989
|
+
}
|
|
44990
|
+
}
|
|
44991
|
+
exports.RelationshipChangeCreatedExternalEventProcessor = RelationshipChangeCreatedExternalEventProcessor;
|
|
44992
|
+
//# sourceMappingURL=RelationshipChangeCreatedExternalEventProcessor.js.map
|
|
44993
|
+
|
|
44994
|
+
/***/ }),
|
|
44995
|
+
|
|
44996
|
+
/***/ "./dist/modules/sync/externalEventProcessors/index.js":
|
|
44997
|
+
/*!************************************************************!*\
|
|
44998
|
+
!*** ./dist/modules/sync/externalEventProcessors/index.js ***!
|
|
44999
|
+
\************************************************************/
|
|
45000
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
45001
|
+
|
|
45002
|
+
"use strict";
|
|
45003
|
+
|
|
45004
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
45005
|
+
if (k2 === undefined) k2 = k;
|
|
45006
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
45007
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
45008
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
45009
|
+
}
|
|
45010
|
+
Object.defineProperty(o, k2, desc);
|
|
45011
|
+
}) : (function(o, m, k, k2) {
|
|
45012
|
+
if (k2 === undefined) k2 = k;
|
|
45013
|
+
o[k2] = m[k];
|
|
45014
|
+
}));
|
|
45015
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
45016
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
45017
|
+
};
|
|
45018
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
45019
|
+
__exportStar(__webpack_require__(/*! ./ExternalEventProcessorRegistry */ "./dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js"), exports);
|
|
45020
|
+
__exportStar(__webpack_require__(/*! ./MessageDeliveredExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/MessageDeliveredExternalEventProcessor.js"), exports);
|
|
45021
|
+
__exportStar(__webpack_require__(/*! ./MessageReceivedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.js"), exports);
|
|
45022
|
+
__exportStar(__webpack_require__(/*! ./RelationshipChangeCompletedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js"), exports);
|
|
45023
|
+
__exportStar(__webpack_require__(/*! ./RelationshipChangeCreatedExternalEventProcessor */ "./dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js"), exports);
|
|
45024
|
+
//# sourceMappingURL=index.js.map
|
|
45025
|
+
|
|
45026
|
+
/***/ }),
|
|
45027
|
+
|
|
44878
45028
|
/***/ "./dist/modules/sync/local/DatawalletModification.js":
|
|
44879
45029
|
/*!***********************************************************!*\
|
|
44880
45030
|
!*** ./dist/modules/sync/local/DatawalletModification.js ***!
|