@nmshd/transport 2.8.2 → 5.0.0-alpha.10
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/core/CoreErrors.d.ts +7 -5
- package/dist/core/CoreErrors.d.ts.map +1 -1
- package/dist/core/CoreErrors.js +16 -10
- package/dist/core/CoreErrors.js.map +1 -1
- package/dist/core/ICacheable.js +1 -2
- package/dist/core/ICacheable.js.map +1 -1
- package/dist/core/Transport.d.ts +2 -5
- package/dist/core/Transport.d.ts.map +1 -1
- package/dist/core/Transport.js +0 -5
- package/dist/core/Transport.js.map +1 -1
- package/dist/core/backbone/BackboneIds.d.ts +0 -1
- package/dist/core/backbone/BackboneIds.d.ts.map +1 -1
- package/dist/core/backbone/BackboneIds.js +0 -1
- package/dist/core/backbone/BackboneIds.js.map +1 -1
- package/dist/core/backbone/Paginator.d.ts.map +1 -1
- package/dist/core/backbone/RESTClient.d.ts +0 -3
- package/dist/core/backbone/RESTClient.d.ts.map +1 -1
- package/dist/core/backbone/RESTClientAuthenticate.d.ts +0 -1
- package/dist/core/backbone/RESTClientAuthenticate.d.ts.map +1 -1
- package/dist/core/backbone/RequestError.d.ts +2 -2
- package/dist/core/backbone/RequestError.d.ts.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/logging/logExecutionTime.js +2 -3
- package/dist/core/logging/logExecutionTime.js.map +1 -1
- package/dist/events/RelationshipDecomposedBySelfEvent.d.ts +10 -0
- package/dist/events/RelationshipDecomposedBySelfEvent.d.ts.map +1 -0
- package/dist/events/RelationshipDecomposedBySelfEvent.js +12 -0
- package/dist/events/RelationshipDecomposedBySelfEvent.js.map +1 -0
- package/dist/events/RelationshipReactivationCompletedEvent.d.ts +7 -0
- package/dist/events/RelationshipReactivationCompletedEvent.d.ts.map +1 -0
- package/dist/events/RelationshipReactivationCompletedEvent.js +12 -0
- package/dist/events/RelationshipReactivationCompletedEvent.js.map +1 -0
- package/dist/events/RelationshipReactivationRequestedEvent.d.ts +7 -0
- package/dist/events/RelationshipReactivationRequestedEvent.d.ts.map +1 -0
- package/dist/events/RelationshipReactivationRequestedEvent.js +12 -0
- package/dist/events/RelationshipReactivationRequestedEvent.js.map +1 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -0
- package/dist/events/index.js.map +1 -1
- package/dist/modules/accounts/AccountController.d.ts +8 -7
- package/dist/modules/accounts/AccountController.d.ts.map +1 -1
- package/dist/modules/accounts/AccountController.js +18 -17
- package/dist/modules/accounts/AccountController.js.map +1 -1
- package/dist/modules/accounts/IdentityController.d.ts +0 -2
- package/dist/modules/accounts/IdentityController.d.ts.map +1 -1
- package/dist/modules/accounts/IdentityController.js +0 -3
- package/dist/modules/accounts/IdentityController.js.map +1 -1
- package/dist/modules/accounts/IdentityDeletionProcessController.js.map +1 -1
- package/dist/modules/accounts/IdentityUtil.d.ts +2 -2
- package/dist/modules/accounts/IdentityUtil.d.ts.map +1 -1
- package/dist/modules/accounts/IdentityUtil.js +23 -26
- package/dist/modules/accounts/IdentityUtil.js.map +1 -1
- package/dist/modules/accounts/data/Identity.d.ts +0 -3
- package/dist/modules/accounts/data/Identity.d.ts.map +1 -1
- package/dist/modules/accounts/data/Identity.js +0 -6
- package/dist/modules/accounts/data/Identity.js.map +1 -1
- package/dist/modules/accounts/data/IdentitySecretCredentials.d.ts +0 -3
- package/dist/modules/accounts/data/IdentitySecretCredentials.d.ts.map +1 -1
- package/dist/modules/accounts/data/IdentitySecretCredentials.js +0 -6
- package/dist/modules/accounts/data/IdentitySecretCredentials.js.map +1 -1
- package/dist/modules/challenges/ChallengeController.d.ts.map +1 -1
- package/dist/modules/challenges/ChallengeController.js +3 -2
- package/dist/modules/challenges/ChallengeController.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 +6 -0
- package/dist/modules/devices/DeviceController.js.map +1 -1
- package/dist/modules/devices/backbone/BackboneUpdateDevice.d.ts +4 -0
- package/dist/modules/devices/backbone/BackboneUpdateDevice.d.ts.map +1 -0
- package/dist/modules/{relationships/backbone/BackboneGetRelationshipsChanges.js → devices/backbone/BackboneUpdateDevice.js} +1 -1
- package/dist/modules/devices/backbone/BackboneUpdateDevice.js.map +1 -0
- package/dist/modules/devices/backbone/DeviceAuthClient.d.ts +2 -0
- package/dist/modules/devices/backbone/DeviceAuthClient.d.ts.map +1 -1
- package/dist/modules/devices/backbone/DeviceAuthClient.js +3 -0
- package/dist/modules/devices/backbone/DeviceAuthClient.js.map +1 -1
- package/dist/modules/devices/local/Device.d.ts.map +1 -1
- package/dist/modules/devices/local/Device.js +3 -1
- package/dist/modules/devices/local/Device.js.map +1 -1
- package/dist/modules/files/FileController.d.ts.map +1 -1
- package/dist/modules/files/FileController.js +6 -1
- package/dist/modules/files/FileController.js.map +1 -1
- package/dist/modules/files/backbone/FileClient.d.ts +0 -1
- package/dist/modules/files/backbone/FileClient.d.ts.map +1 -1
- package/dist/modules/index.d.ts +12 -15
- package/dist/modules/index.d.ts.map +1 -1
- package/dist/modules/index.js +12 -17
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/messages/MessageController.d.ts +3 -0
- package/dist/modules/messages/MessageController.d.ts.map +1 -1
- package/dist/modules/messages/MessageController.js +85 -17
- package/dist/modules/messages/MessageController.js.map +1 -1
- package/dist/modules/messages/local/CachedMessage.d.ts +3 -3
- package/dist/modules/messages/local/CachedMessage.d.ts.map +1 -1
- package/dist/modules/messages/local/CachedMessage.js +2 -2
- package/dist/modules/messages/local/CachedMessage.js.map +1 -1
- package/dist/modules/messages/local/CachedMessageRecipient.d.ts +19 -0
- package/dist/modules/messages/local/CachedMessageRecipient.d.ts.map +1 -0
- package/dist/modules/{relationships/transmission/changes/RelationshipChangeRequest.js → messages/local/CachedMessageRecipient.js} +23 -25
- package/dist/modules/messages/local/CachedMessageRecipient.js.map +1 -0
- package/dist/modules/messages/local/Message.d.ts +1 -3
- package/dist/modules/messages/local/Message.d.ts.map +1 -1
- package/dist/modules/messages/local/Message.js +1 -12
- package/dist/modules/messages/local/Message.js.map +1 -1
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.d.ts +2 -0
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.d.ts.map +1 -1
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js +21 -2
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js.map +1 -1
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js +2 -2
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js.map +1 -1
- package/dist/modules/relationships/RelationshipSecretController.d.ts +4 -5
- package/dist/modules/relationships/RelationshipSecretController.d.ts.map +1 -1
- package/dist/modules/relationships/RelationshipSecretController.js +8 -8
- package/dist/modules/relationships/RelationshipSecretController.js.map +1 -1
- package/dist/modules/relationships/RelationshipsController.d.ts +22 -23
- package/dist/modules/relationships/RelationshipsController.d.ts.map +1 -1
- package/dist/modules/relationships/RelationshipsController.js +272 -324
- package/dist/modules/relationships/RelationshipsController.js.map +1 -1
- package/dist/modules/relationships/backbone/BackboneGetRelationships.d.ts +2 -11
- package/dist/modules/relationships/backbone/BackboneGetRelationships.d.ts.map +1 -1
- package/dist/modules/relationships/backbone/BackbonePostRelationship.d.ts +7 -0
- package/dist/modules/relationships/backbone/BackbonePostRelationship.d.ts.map +1 -0
- package/dist/modules/relationships/backbone/{BackbonePostRelationshipsChanges.js → BackbonePostRelationship.js} +1 -1
- package/dist/modules/relationships/backbone/BackbonePostRelationship.js.map +1 -0
- package/dist/modules/relationships/backbone/BackbonePutRelationship.d.ts +6 -0
- package/dist/modules/relationships/backbone/BackbonePutRelationship.d.ts.map +1 -0
- package/dist/modules/relationships/backbone/BackbonePutRelationship.js +3 -0
- package/dist/modules/relationships/backbone/BackbonePutRelationship.js.map +1 -0
- package/dist/modules/relationships/backbone/BackboneRelationship.d.ts +14 -0
- package/dist/modules/relationships/backbone/BackboneRelationship.d.ts.map +1 -0
- package/dist/modules/relationships/backbone/BackboneRelationship.js +3 -0
- package/dist/modules/relationships/backbone/BackboneRelationship.js.map +1 -0
- package/dist/modules/relationships/backbone/RelationshipClient.d.ts +15 -12
- package/dist/modules/relationships/backbone/RelationshipClient.d.ts.map +1 -1
- package/dist/modules/relationships/backbone/RelationshipClient.js +23 -21
- package/dist/modules/relationships/backbone/RelationshipClient.js.map +1 -1
- package/dist/modules/relationships/local/CachedRelationship.d.ts +6 -4
- package/dist/modules/relationships/local/CachedRelationship.d.ts.map +1 -1
- package/dist/modules/relationships/local/CachedRelationship.js +10 -8
- package/dist/modules/relationships/local/CachedRelationship.js.map +1 -1
- package/dist/modules/relationships/local/Relationship.d.ts +3 -8
- package/dist/modules/relationships/local/Relationship.d.ts.map +1 -1
- package/dist/modules/relationships/local/Relationship.js +5 -35
- package/dist/modules/relationships/local/Relationship.js.map +1 -1
- package/dist/modules/relationships/local/RelationshipAuditLog.d.ts +6 -0
- package/dist/modules/relationships/local/RelationshipAuditLog.d.ts.map +1 -0
- package/dist/modules/relationships/local/RelationshipAuditLog.js +26 -0
- package/dist/modules/relationships/local/RelationshipAuditLog.js.map +1 -0
- package/dist/modules/relationships/local/RelationshipAuditLogEntry.d.ts +21 -0
- package/dist/modules/relationships/local/RelationshipAuditLogEntry.d.ts.map +1 -0
- package/dist/modules/relationships/local/RelationshipAuditLogEntry.js +63 -0
- package/dist/modules/relationships/local/RelationshipAuditLogEntry.js.map +1 -0
- package/dist/modules/relationships/local/SendRelationshipParameters.d.ts +2 -2
- package/dist/modules/relationships/local/SendRelationshipParameters.d.ts.map +1 -1
- package/dist/modules/relationships/local/SendRelationshipParameters.js +1 -1
- package/dist/modules/relationships/local/SendRelationshipParameters.js.map +1 -1
- package/dist/modules/relationships/transmission/RelationshipAuditLog.d.ts +24 -0
- package/dist/modules/relationships/transmission/RelationshipAuditLog.d.ts.map +1 -0
- package/dist/modules/relationships/transmission/RelationshipAuditLog.js +17 -0
- package/dist/modules/relationships/transmission/RelationshipAuditLog.js.map +1 -0
- package/dist/modules/relationships/transmission/RelationshipStatus.d.ts +2 -2
- package/dist/modules/relationships/transmission/RelationshipStatus.d.ts.map +1 -1
- package/dist/modules/relationships/transmission/RelationshipStatus.js +1 -1
- package/dist/modules/relationships/transmission/RelationshipStatus.js.map +1 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentCipher.d.ts +13 -0
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentCipher.d.ts.map +1 -0
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestCipher.js → RelationshipCreationContentCipher.js} +9 -9
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentCipher.js.map +1 -0
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentSigned.d.ts +14 -0
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentSigned.d.ts.map +1 -0
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestSigned.js → RelationshipCreationContentSigned.js} +10 -10
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentSigned.js.map +1 -0
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentWrapper.d.ts +15 -0
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentWrapper.d.ts.map +1 -0
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestContentWrapper.js → RelationshipCreationContentWrapper.js} +10 -10
- package/dist/modules/relationships/transmission/requests/RelationshipCreationContentWrapper.js.map +1 -0
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.d.ts +13 -0
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.d.ts.map +1 -0
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseCipher.js → RelationshipCreationResponseContentCipher.js} +10 -10
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.js.map +1 -0
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentSigned.d.ts +14 -0
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentSigned.d.ts.map +1 -0
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseSigned.js → RelationshipCreationResponseContentSigned.js} +10 -10
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentSigned.js.map +1 -0
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentWrapper.d.ts +9 -0
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentWrapper.d.ts.map +1 -0
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseContentWrapper.js → RelationshipCreationResponseContentWrapper.js} +8 -13
- package/dist/modules/relationships/transmission/responses/RelationshipCreationResponseContentWrapper.js.map +1 -0
- package/dist/modules/sync/DatawalletModificationsProcessor.d.ts +1 -3
- package/dist/modules/sync/DatawalletModificationsProcessor.d.ts.map +1 -1
- package/dist/modules/sync/DatawalletModificationsProcessor.js +4 -14
- package/dist/modules/sync/DatawalletModificationsProcessor.js.map +1 -1
- package/dist/modules/sync/SyncController.d.ts +3 -4
- package/dist/modules/sync/SyncController.d.ts.map +1 -1
- package/dist/modules/sync/SyncController.js +32 -46
- package/dist/modules/sync/SyncController.js.map +1 -1
- package/dist/modules/sync/SynchronizedCollection.d.ts.map +1 -1
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.d.ts.map +1 -1
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js +6 -4
- package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js.map +1 -1
- package/dist/modules/sync/externalEventProcessors/{RelationshipChangeCompletedExternalEventProcessor.d.ts → RelationshipReactivationCompletedExternalEventProcessor.d.ts} +2 -2
- package/dist/modules/sync/externalEventProcessors/RelationshipReactivationCompletedExternalEventProcessor.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/{RelationshipChangeCompletedExternalEventProcessor.js → RelationshipReactivationCompletedExternalEventProcessor.js} +11 -13
- package/dist/modules/sync/externalEventProcessors/RelationshipReactivationCompletedExternalEventProcessor.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipReactivationRequestedExternalEventProcessor.d.ts +7 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipReactivationRequestedExternalEventProcessor.d.ts.map +1 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipReactivationRequestedExternalEventProcessor.js +33 -0
- package/dist/modules/sync/externalEventProcessors/RelationshipReactivationRequestedExternalEventProcessor.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/{RelationshipChangeCreatedExternalEventProcessor.d.ts → RelationshipStatusChangedExternalEventProcessor.d.ts} +2 -2
- package/dist/modules/sync/externalEventProcessors/{RelationshipChangeCreatedExternalEventProcessor.d.ts.map → RelationshipStatusChangedExternalEventProcessor.d.ts.map} +1 -1
- package/dist/modules/sync/externalEventProcessors/{RelationshipChangeCreatedExternalEventProcessor.js → RelationshipStatusChangedExternalEventProcessor.js} +10 -18
- package/dist/modules/sync/externalEventProcessors/RelationshipStatusChangedExternalEventProcessor.js.map +1 -0
- package/dist/modules/sync/externalEventProcessors/index.d.ts +3 -2
- package/dist/modules/sync/externalEventProcessors/index.d.ts.map +1 -1
- package/dist/modules/sync/externalEventProcessors/index.js +3 -2
- package/dist/modules/sync/externalEventProcessors/index.js.map +1 -1
- package/dist/modules/tokens/TokenController.d.ts +2 -1
- package/dist/modules/tokens/TokenController.d.ts.map +1 -1
- package/dist/modules/tokens/TokenController.js +13 -1
- package/dist/modules/tokens/TokenController.js.map +1 -1
- package/package.json +5 -5
- package/dist/core/ProgressReporter.d.ts +0 -19
- package/dist/core/ProgressReporter.d.ts.map +0 -1
- package/dist/core/ProgressReporter.js +0 -43
- package/dist/core/ProgressReporter.js.map +0 -1
- package/dist/modules/accounts/data/Realm.d.ts +0 -6
- package/dist/modules/accounts/data/Realm.d.ts.map +0 -1
- package/dist/modules/accounts/data/Realm.js +0 -10
- package/dist/modules/accounts/data/Realm.js.map +0 -1
- package/dist/modules/relationships/backbone/BackboneGetRelationshipsChanges.d.ts +0 -24
- package/dist/modules/relationships/backbone/BackboneGetRelationshipsChanges.d.ts.map +0 -1
- package/dist/modules/relationships/backbone/BackboneGetRelationshipsChanges.js.map +0 -1
- package/dist/modules/relationships/backbone/BackbonePostRelationshipsChanges.d.ts +0 -9
- package/dist/modules/relationships/backbone/BackbonePostRelationshipsChanges.d.ts.map +0 -1
- package/dist/modules/relationships/backbone/BackbonePostRelationshipsChanges.js.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChange.d.ts +0 -27
- package/dist/modules/relationships/transmission/changes/RelationshipChange.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChange.js +0 -72
- package/dist/modules/relationships/transmission/changes/RelationshipChange.js.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChangeRequest.d.ts +0 -20
- package/dist/modules/relationships/transmission/changes/RelationshipChangeRequest.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChangeRequest.js.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChangeResponse.d.ts +0 -20
- package/dist/modules/relationships/transmission/changes/RelationshipChangeResponse.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChangeResponse.js +0 -53
- package/dist/modules/relationships/transmission/changes/RelationshipChangeResponse.js.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChangeStatus.d.ts +0 -7
- package/dist/modules/relationships/transmission/changes/RelationshipChangeStatus.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChangeStatus.js +0 -11
- package/dist/modules/relationships/transmission/changes/RelationshipChangeStatus.js.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChangeType.d.ts +0 -6
- package/dist/modules/relationships/transmission/changes/RelationshipChangeType.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/changes/RelationshipChangeType.js +0 -10
- package/dist/modules/relationships/transmission/changes/RelationshipChangeType.js.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestCipher.d.ts +0 -13
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestCipher.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestCipher.js.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.d.ts +0 -15
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestSigned.d.ts +0 -14
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestSigned.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestSigned.js.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseCipher.d.ts +0 -13
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseCipher.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseCipher.js.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.d.ts +0 -12
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseSigned.d.ts +0 -14
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseSigned.d.ts.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseSigned.js.map +0 -1
- package/dist/modules/sync/SyncCallback.d.ts +0 -18
- package/dist/modules/sync/SyncCallback.d.ts.map +0 -1
- package/dist/modules/sync/SyncCallback.js +0 -25
- package/dist/modules/sync/SyncCallback.js.map +0 -1
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.d.ts.map +0 -1
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCompletedExternalEventProcessor.js.map +0 -1
- package/dist/modules/sync/externalEventProcessors/RelationshipChangeCreatedExternalEventProcessor.js.map +0 -1
|
@@ -23,18 +23,16 @@ const RelationshipTemplate_1 = require("../relationshipTemplates/local/Relations
|
|
|
23
23
|
const RelationshipClient_1 = require("./backbone/RelationshipClient");
|
|
24
24
|
const CachedRelationship_1 = require("./local/CachedRelationship");
|
|
25
25
|
const Relationship_1 = require("./local/Relationship");
|
|
26
|
+
const RelationshipAuditLog_1 = require("./local/RelationshipAuditLog");
|
|
26
27
|
const SendRelationshipParameters_1 = require("./local/SendRelationshipParameters");
|
|
27
|
-
const
|
|
28
|
-
const RelationshipChangeResponse_1 = require("./transmission/changes/RelationshipChangeResponse");
|
|
29
|
-
const RelationshipChangeStatus_1 = require("./transmission/changes/RelationshipChangeStatus");
|
|
30
|
-
const RelationshipChangeType_1 = require("./transmission/changes/RelationshipChangeType");
|
|
28
|
+
const RelationshipAuditLog_2 = require("./transmission/RelationshipAuditLog");
|
|
31
29
|
const RelationshipStatus_1 = require("./transmission/RelationshipStatus");
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
30
|
+
const RelationshipCreationContentCipher_1 = require("./transmission/requests/RelationshipCreationContentCipher");
|
|
31
|
+
const RelationshipCreationContentSigned_1 = require("./transmission/requests/RelationshipCreationContentSigned");
|
|
32
|
+
const RelationshipCreationContentWrapper_1 = require("./transmission/requests/RelationshipCreationContentWrapper");
|
|
33
|
+
const RelationshipCreationResponseContentCipher_1 = require("./transmission/responses/RelationshipCreationResponseContentCipher");
|
|
34
|
+
const RelationshipCreationResponseContentSigned_1 = require("./transmission/responses/RelationshipCreationResponseContentSigned");
|
|
35
|
+
const RelationshipCreationResponseContentWrapper_1 = require("./transmission/responses/RelationshipCreationResponseContentWrapper");
|
|
38
36
|
class RelationshipsController extends core_1.TransportController {
|
|
39
37
|
constructor(parent, secrets) {
|
|
40
38
|
super(core_1.ControllerName.Relationships, parent);
|
|
@@ -48,7 +46,8 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
48
46
|
}
|
|
49
47
|
async getRelationships(query) {
|
|
50
48
|
const relationshipDocs = await this.relationships.find(query);
|
|
51
|
-
|
|
49
|
+
const relationships = this.parseArray(relationshipDocs, Relationship_1.Relationship);
|
|
50
|
+
return relationships;
|
|
52
51
|
}
|
|
53
52
|
async updateCache(ids) {
|
|
54
53
|
if (ids.length < 1) {
|
|
@@ -57,7 +56,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
57
56
|
const resultItems = (await this.client.getRelationships({ ids })).value;
|
|
58
57
|
const promises = [];
|
|
59
58
|
for await (const resultItem of resultItems) {
|
|
60
|
-
promises.push(this.
|
|
59
|
+
promises.push(this.updateExistingRelationshipInDb(resultItem.id, resultItem));
|
|
61
60
|
}
|
|
62
61
|
return await Promise.all(promises);
|
|
63
62
|
}
|
|
@@ -67,20 +66,26 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
67
66
|
const backboneRelationships = await (await this.client.getRelationships({ ids: ids.map((id) => id.id) })).value.collect();
|
|
68
67
|
const decryptionPromises = backboneRelationships.map(async (r) => {
|
|
69
68
|
const relationshipDoc = await this.relationships.read(r.id);
|
|
69
|
+
if (!relationshipDoc) {
|
|
70
|
+
this._log.error(`Relationship '${r.id}' not found in local database and the cache fetching was therefore skipped. This should not happen and might be a bug in the application logic.`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
70
73
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
71
74
|
return {
|
|
72
75
|
id: core_1.CoreId.from(r.id),
|
|
73
76
|
cache: await this.decryptRelationship(r, relationship.relationshipSecretId)
|
|
74
77
|
};
|
|
75
78
|
});
|
|
76
|
-
|
|
79
|
+
const caches = await Promise.all(decryptionPromises);
|
|
80
|
+
return caches.filter((c) => c !== undefined);
|
|
77
81
|
}
|
|
78
|
-
async
|
|
82
|
+
async updateExistingRelationshipInDb(id, response) {
|
|
79
83
|
const relationshipDoc = await this.relationships.read(id);
|
|
80
84
|
if (!relationshipDoc)
|
|
81
85
|
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, id);
|
|
82
86
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
83
87
|
await this.updateCacheOfRelationship(relationship, response);
|
|
88
|
+
relationship.status = response.status;
|
|
84
89
|
await this.relationships.update(relationshipDoc, relationship);
|
|
85
90
|
return relationship;
|
|
86
91
|
}
|
|
@@ -88,19 +93,15 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
88
93
|
const query = { peerAddress: address.toString() };
|
|
89
94
|
if (status)
|
|
90
95
|
query[`${(0, ts_simple_nameof_1.nameof)((r) => r.status)}`] = status;
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (!relationshipDoc) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
return Relationship_1.Relationship.from(relationshipDoc);
|
|
96
|
+
const relationships = await this.relationships.find(query);
|
|
97
|
+
if (relationships.length === 0)
|
|
98
|
+
return undefined;
|
|
99
|
+
if (relationships.length === 1)
|
|
100
|
+
return Relationship_1.Relationship.from(relationships[0]);
|
|
101
|
+
const newestRelationship = relationships.reduce((prev, current) => {
|
|
102
|
+
return prev.createdAt > current.createdAt ? prev : current;
|
|
103
|
+
});
|
|
104
|
+
return Relationship_1.Relationship.from(newestRelationship);
|
|
104
105
|
}
|
|
105
106
|
async getActiveRelationshipToIdentity(address) {
|
|
106
107
|
return await this.getRelationshipToIdentity(address, RelationshipStatus_1.RelationshipStatus.Active);
|
|
@@ -110,7 +111,8 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
110
111
|
if (!relationshipDoc) {
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
+
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
115
|
+
return relationship;
|
|
114
116
|
}
|
|
115
117
|
async sign(relationship, content) {
|
|
116
118
|
return await this.secrets.sign(relationship.relationshipSecretId, content);
|
|
@@ -128,9 +130,9 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
128
130
|
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
129
131
|
}
|
|
130
132
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
131
|
-
const
|
|
133
|
+
const creationContentCipher = await this.prepareCreationContent(secretId, template, parameters.creationContent);
|
|
132
134
|
const result = await this.client.createRelationship({
|
|
133
|
-
|
|
135
|
+
creationContent: creationContentCipher.toBase64(),
|
|
134
136
|
relationshipTemplateId: template.id.toString()
|
|
135
137
|
});
|
|
136
138
|
if (result.isError) {
|
|
@@ -140,7 +142,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
140
142
|
throw result.error;
|
|
141
143
|
}
|
|
142
144
|
const backboneResponse = result.value;
|
|
143
|
-
const newRelationship = Relationship_1.Relationship.
|
|
145
|
+
const newRelationship = Relationship_1.Relationship.fromBackboneAndCreationContent(backboneResponse, template, template.cache.identity, parameters.creationContent, secretId);
|
|
144
146
|
await this.relationships.create(newRelationship);
|
|
145
147
|
this.eventBus.publish(new events_1.RelationshipChangedEvent(this.parent.identity.address.toString(), newRelationship));
|
|
146
148
|
return newRelationship;
|
|
@@ -156,14 +158,113 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
156
158
|
await this.relationships.update(relationshipDoc, relationship);
|
|
157
159
|
return relationship;
|
|
158
160
|
}
|
|
159
|
-
async
|
|
160
|
-
|
|
161
|
+
async accept(relationshipId) {
|
|
162
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
163
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Pending);
|
|
164
|
+
const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1];
|
|
165
|
+
if (!lastAuditLogEntry.createdBy.equals(relationship.peer.address)) {
|
|
166
|
+
throw CoreErrors_1.CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can accept the relationship ${relationshipId.toString()}`);
|
|
167
|
+
}
|
|
168
|
+
return await this.completeOperationWithBackboneCall(RelationshipAuditLog_2.RelationshipAuditLogEntryReason.AcceptanceOfCreation, relationshipId);
|
|
169
|
+
}
|
|
170
|
+
async reject(relationshipId) {
|
|
171
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
172
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Pending);
|
|
173
|
+
const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1];
|
|
174
|
+
if (!lastAuditLogEntry.createdBy.equals(relationship.peer.address)) {
|
|
175
|
+
throw CoreErrors_1.CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can reject the relationship ${relationshipId.toString()}. Revoke the relationship instead.`);
|
|
176
|
+
}
|
|
177
|
+
return await this.completeOperationWithBackboneCall(RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RejectionOfCreation, relationshipId);
|
|
178
|
+
}
|
|
179
|
+
async revoke(relationshipId) {
|
|
180
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
181
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Pending);
|
|
182
|
+
const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1];
|
|
183
|
+
if (lastAuditLogEntry.createdBy.equals(relationship.peer.address)) {
|
|
184
|
+
throw CoreErrors_1.CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can revoke the relationship ${relationshipId.toString()}. Reject the relationship instead.`);
|
|
185
|
+
}
|
|
186
|
+
return await this.completeOperationWithBackboneCall(RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RevocationOfCreation, relationshipId);
|
|
187
|
+
}
|
|
188
|
+
async terminate(relationshipId) {
|
|
189
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
190
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Active);
|
|
191
|
+
return await this.completeOperationWithBackboneCall(RelationshipAuditLog_2.RelationshipAuditLogEntryReason.Termination, relationshipId);
|
|
192
|
+
}
|
|
193
|
+
async requestReactivation(relationshipId) {
|
|
194
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
195
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Terminated);
|
|
196
|
+
const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1];
|
|
197
|
+
if (lastAuditLogEntry.reason === RelationshipAuditLog_2.RelationshipAuditLogEntryReason.ReactivationRequested) {
|
|
198
|
+
if (lastAuditLogEntry.createdBy.equals(relationship.peer.address)) {
|
|
199
|
+
throw CoreErrors_1.CoreErrors.relationships.reactivationAlreadyRequested(`Your peer has already requested the reactivation of the relationship ${relationshipId.toString()}. You can accept the reactivation instead.`);
|
|
200
|
+
}
|
|
201
|
+
throw CoreErrors_1.CoreErrors.relationships.reactivationAlreadyRequested(`You have already requested the reactivation of the relationship ${relationshipId.toString()}.`);
|
|
202
|
+
}
|
|
203
|
+
return await this.completeOperationWithBackboneCall(RelationshipAuditLog_2.RelationshipAuditLogEntryReason.ReactivationRequested, relationshipId);
|
|
161
204
|
}
|
|
162
|
-
async
|
|
163
|
-
|
|
205
|
+
async rejectReactivation(relationshipId) {
|
|
206
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
207
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Terminated);
|
|
208
|
+
const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1];
|
|
209
|
+
if (lastAuditLogEntry.reason !== RelationshipAuditLog_2.RelationshipAuditLogEntryReason.ReactivationRequested) {
|
|
210
|
+
throw CoreErrors_1.CoreErrors.relationships.reactivationNotRequested(relationshipId.toString());
|
|
211
|
+
}
|
|
212
|
+
if (!lastAuditLogEntry.createdBy.equals(relationship.peer.address)) {
|
|
213
|
+
throw CoreErrors_1.CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can reject the reactivation of the relationship ${relationshipId.toString()}. Revoke the relationship reactivation instead.`);
|
|
214
|
+
}
|
|
215
|
+
return await this.completeOperationWithBackboneCall(RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RejectionOfReactivation, relationshipId);
|
|
164
216
|
}
|
|
165
|
-
async
|
|
166
|
-
|
|
217
|
+
async revokeReactivation(relationshipId) {
|
|
218
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
219
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Terminated);
|
|
220
|
+
const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1];
|
|
221
|
+
if (lastAuditLogEntry.reason !== RelationshipAuditLog_2.RelationshipAuditLogEntryReason.ReactivationRequested) {
|
|
222
|
+
throw CoreErrors_1.CoreErrors.relationships.reactivationNotRequested(relationshipId.toString());
|
|
223
|
+
}
|
|
224
|
+
if (lastAuditLogEntry.createdBy.equals(relationship.peer.address)) {
|
|
225
|
+
throw CoreErrors_1.CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can revoke the reactivation of the relationship ${relationshipId.toString()}. Reject the relationship reactivation instead.`);
|
|
226
|
+
}
|
|
227
|
+
return await this.completeOperationWithBackboneCall(RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RevocationOfReactivation, relationshipId);
|
|
228
|
+
}
|
|
229
|
+
async acceptReactivation(relationshipId) {
|
|
230
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
231
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Terminated);
|
|
232
|
+
const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1];
|
|
233
|
+
if (lastAuditLogEntry.reason !== RelationshipAuditLog_2.RelationshipAuditLogEntryReason.ReactivationRequested) {
|
|
234
|
+
throw CoreErrors_1.CoreErrors.relationships.reactivationNotRequested(relationshipId.toString());
|
|
235
|
+
}
|
|
236
|
+
if (!lastAuditLogEntry.createdBy.equals(relationship.peer.address)) {
|
|
237
|
+
throw CoreErrors_1.CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can accept the reactivation of the relationship ${relationshipId.toString()}.`);
|
|
238
|
+
}
|
|
239
|
+
return await this.completeOperationWithBackboneCall(RelationshipAuditLog_2.RelationshipAuditLogEntryReason.AcceptanceOfReactivation, relationshipId);
|
|
240
|
+
}
|
|
241
|
+
async decompose(relationshipId) {
|
|
242
|
+
const relationship = await this.getRelationshipWithCache(relationshipId);
|
|
243
|
+
this.assertRelationshipStatus(relationship, RelationshipStatus_1.RelationshipStatus.Terminated, RelationshipStatus_1.RelationshipStatus.DeletionProposed);
|
|
244
|
+
const result = await this.client.decomposeRelationship(relationshipId.toString());
|
|
245
|
+
if (result.isError)
|
|
246
|
+
throw result.error;
|
|
247
|
+
const isSecretDeletionSuccessful = await this.secrets.deleteSecretForRelationship(relationship.relationshipSecretId);
|
|
248
|
+
if (!isSecretDeletionSuccessful) {
|
|
249
|
+
this._log.error("Decomposition failed to delete secrets");
|
|
250
|
+
}
|
|
251
|
+
await this.relationships.delete({ id: relationshipId });
|
|
252
|
+
this.eventBus.publish(new events_1.RelationshipDecomposedBySelfEvent(this.parent.identity.address.toString(), { relationshipId }));
|
|
253
|
+
}
|
|
254
|
+
async getRelationshipWithCache(id) {
|
|
255
|
+
const relationship = await this.getRelationship(id);
|
|
256
|
+
if (!relationship)
|
|
257
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, id.toString());
|
|
258
|
+
if (!relationship.cache)
|
|
259
|
+
await this.updateCacheOfRelationship(relationship);
|
|
260
|
+
if (!relationship.cache)
|
|
261
|
+
throw this.newCacheEmptyError(Relationship_1.Relationship, id.toString());
|
|
262
|
+
return relationship;
|
|
263
|
+
}
|
|
264
|
+
assertRelationshipStatus(relationship, ...status) {
|
|
265
|
+
if (status.includes(relationship.status))
|
|
266
|
+
return;
|
|
267
|
+
throw CoreErrors_1.CoreErrors.relationships.wrongRelationshipStatus(relationship.id.toString(), relationship.status);
|
|
167
268
|
}
|
|
168
269
|
async updateCacheOfRelationship(relationship, response) {
|
|
169
270
|
if (!response) {
|
|
@@ -173,322 +274,188 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
173
274
|
relationship.setCache(cachedRelationship);
|
|
174
275
|
}
|
|
175
276
|
async decryptRelationship(response, relationshipSecretId) {
|
|
277
|
+
if (!response.creationContent)
|
|
278
|
+
throw new core_1.TransportError("Creation content is missing");
|
|
176
279
|
const templateId = core_1.CoreId.from(response.relationshipTemplateId);
|
|
177
280
|
this._log.trace(`Parsing relationship template ${templateId} for ${response.id}...`);
|
|
178
281
|
const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId);
|
|
179
282
|
if (!template) {
|
|
180
283
|
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
|
|
181
284
|
}
|
|
182
|
-
this._log.trace(`Parsing relationship
|
|
183
|
-
const
|
|
184
|
-
for (const change of response.changes) {
|
|
185
|
-
switch (change.type) {
|
|
186
|
-
case RelationshipChangeType_1.RelationshipChangeType.Creation:
|
|
187
|
-
changesPromises.push(this.parseCreationChange(change, relationshipSecretId, templateId));
|
|
188
|
-
break;
|
|
189
|
-
default:
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const changes = await Promise.all(changesPromises);
|
|
285
|
+
this._log.trace(`Parsing relationship creation content of ${response.id}...`);
|
|
286
|
+
const creationContent = await this.decryptCreationContent(response.creationContent, core_1.CoreAddress.from(response.from), relationshipSecretId);
|
|
194
287
|
const cachedRelationship = CachedRelationship_1.CachedRelationship.from({
|
|
195
|
-
|
|
196
|
-
template
|
|
288
|
+
creationContent: creationContent.content,
|
|
289
|
+
template,
|
|
290
|
+
auditLog: RelationshipAuditLog_1.RelationshipAuditLog.fromBackboneAuditLog(response.auditLog)
|
|
197
291
|
});
|
|
198
292
|
return cachedRelationship;
|
|
199
293
|
}
|
|
200
|
-
async
|
|
294
|
+
async prepareCreationContent(relationshipSecretId, template, content) {
|
|
201
295
|
if (!template.cache) {
|
|
202
296
|
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
203
297
|
}
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
content
|
|
298
|
+
const publicCreationContentCrypto = await this.secrets.createRequestorSecrets(template.cache, relationshipSecretId);
|
|
299
|
+
const creationContent = RelationshipCreationContentWrapper_1.RelationshipCreationContentWrapper.from({
|
|
300
|
+
content,
|
|
207
301
|
identity: this.parent.identity.identity,
|
|
208
302
|
templateId: template.id
|
|
209
303
|
});
|
|
210
|
-
const
|
|
211
|
-
const buffer = CoreUtil_1.CoreUtil.toBuffer(
|
|
304
|
+
const serializedCreationContent = creationContent.serialize();
|
|
305
|
+
const buffer = CoreUtil_1.CoreUtil.toBuffer(serializedCreationContent);
|
|
212
306
|
const [deviceSignature, relationshipSignature] = await Promise.all([this.parent.activeDevice.sign(buffer), this.secrets.sign(relationshipSecretId, buffer)]);
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
deviceSignature
|
|
216
|
-
relationshipSignature
|
|
307
|
+
const signedCreationContent = RelationshipCreationContentSigned_1.RelationshipCreationContentSigned.from({
|
|
308
|
+
serializedCreationContent,
|
|
309
|
+
deviceSignature,
|
|
310
|
+
relationshipSignature
|
|
217
311
|
});
|
|
218
|
-
const cipher = await this.secrets.
|
|
219
|
-
const
|
|
220
|
-
cipher
|
|
221
|
-
|
|
312
|
+
const cipher = await this.secrets.encryptCreationContent(relationshipSecretId, signedCreationContent);
|
|
313
|
+
const creationContentCipher = RelationshipCreationContentCipher_1.RelationshipCreationContentCipher.from({
|
|
314
|
+
cipher,
|
|
315
|
+
publicCreationContentCrypto
|
|
222
316
|
});
|
|
223
|
-
return
|
|
224
|
-
}
|
|
225
|
-
async applyChangeById(changeId) {
|
|
226
|
-
const relationshipChange = (await this.client.getRelationshipChange(changeId.toString())).value;
|
|
227
|
-
return await this.applyChange(relationshipChange);
|
|
228
|
-
}
|
|
229
|
-
async applyChange(change) {
|
|
230
|
-
switch (change.type) {
|
|
231
|
-
case RelationshipChangeType_1.RelationshipChangeType.Creation:
|
|
232
|
-
return await this.applyCreationChange(change);
|
|
233
|
-
case RelationshipChangeType_1.RelationshipChangeType.Termination:
|
|
234
|
-
case RelationshipChangeType_1.RelationshipChangeType.TerminationCancellation:
|
|
235
|
-
default:
|
|
236
|
-
throw CoreErrors_1.CoreErrors.general.notSupported();
|
|
237
|
-
}
|
|
317
|
+
return creationContentCipher;
|
|
238
318
|
}
|
|
239
|
-
async
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (change.response) {
|
|
252
|
-
// The request was revoked before we fetched the creation,
|
|
253
|
-
// thus the creation and revoke change is one
|
|
254
|
-
const relationshipDoc = await this.relationships.read(change.relationshipId);
|
|
255
|
-
return await this.updatePendingRelationshipWithPeerResponse(relationshipDoc, change);
|
|
256
|
-
}
|
|
257
|
-
return newRelationship;
|
|
319
|
+
async updateRelationshipWithPeerResponse(relationshipDoc) {
|
|
320
|
+
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
321
|
+
const backboneRelationship = (await this.client.getRelationship(relationship.id.toString())).value;
|
|
322
|
+
if (!(await this.secrets.hasCryptoRelationshipSecrets(relationship.relationshipSecretId)) && backboneRelationship.creationResponseContent) {
|
|
323
|
+
const creationResponseContent = backboneRelationship.creationResponseContent;
|
|
324
|
+
const cipher = RelationshipCreationResponseContentCipher_1.RelationshipCreationResponseContentCipher.fromBase64(creationResponseContent);
|
|
325
|
+
await this.secrets.convertSecrets(relationship.relationshipSecretId, cipher.publicCreationResponseContentCrypto);
|
|
326
|
+
}
|
|
327
|
+
relationship.cache.auditLog = RelationshipAuditLog_1.RelationshipAuditLog.fromBackboneAuditLog(backboneRelationship.auditLog);
|
|
328
|
+
relationship.status = backboneRelationship.status;
|
|
329
|
+
await this.relationships.update(relationshipDoc, relationship);
|
|
330
|
+
return relationship;
|
|
258
331
|
}
|
|
259
|
-
async
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
const hasRelationshipSecret = await this.secrets.hasCryptoRelationshipSecrets(relationshipSecretId);
|
|
265
|
-
if (change.response && hasRelationshipSecret) {
|
|
266
|
-
promises.push(this.decryptCreationChangeResponse(change, relationshipSecretId));
|
|
267
|
-
}
|
|
268
|
-
const [requestContent, responseContent] = await Promise.all(promises);
|
|
269
|
-
const creationChange = RelationshipChange_1.RelationshipChange.fromBackbone(change, requestContent.content, responseContent?.content);
|
|
270
|
-
return creationChange;
|
|
271
|
-
}
|
|
272
|
-
async decryptCreationChangeRequest(change, secretId, templateId) {
|
|
273
|
-
if (!change.content)
|
|
274
|
-
throw this.newEmptyOrInvalidContentError();
|
|
275
|
-
const isOwnChange = this.parent.identity.isMe(core_1.CoreAddress.from(change.createdBy));
|
|
276
|
-
const requestCipher = RelationshipCreationChangeRequestCipher_1.RelationshipCreationChangeRequestCipher.fromBase64(change.content);
|
|
277
|
-
const signedRequestBuffer = await this.secrets.decryptRequest(secretId, requestCipher.cipher);
|
|
278
|
-
const signedRequest = RelationshipCreationChangeRequestSigned_1.RelationshipCreationChangeRequestSigned.deserialize(signedRequestBuffer.toUtf8());
|
|
332
|
+
async decryptCreationContent(backboneCreationContent, creationContentCreator, secretId) {
|
|
333
|
+
const isOwnContent = this.parent.identity.isMe(creationContentCreator);
|
|
334
|
+
const creationContentCipher = RelationshipCreationContentCipher_1.RelationshipCreationContentCipher.fromBase64(backboneCreationContent);
|
|
335
|
+
const signedCreationContentBuffer = await this.secrets.decryptCreationContent(secretId, creationContentCipher.cipher);
|
|
336
|
+
const signedCreationContent = RelationshipCreationContentSigned_1.RelationshipCreationContentSigned.deserialize(signedCreationContentBuffer.toUtf8());
|
|
279
337
|
let relationshipSignatureValid;
|
|
280
|
-
if (
|
|
281
|
-
relationshipSignatureValid = await this.secrets.verifyOwn(secretId, crypto_1.CoreBuffer.fromUtf8(
|
|
338
|
+
if (isOwnContent) {
|
|
339
|
+
relationshipSignatureValid = await this.secrets.verifyOwn(secretId, crypto_1.CoreBuffer.fromUtf8(signedCreationContent.serializedCreationContent), signedCreationContent.relationshipSignature);
|
|
282
340
|
}
|
|
283
341
|
else {
|
|
284
|
-
relationshipSignatureValid = await this.secrets.verifyPeer(secretId, crypto_1.CoreBuffer.fromUtf8(
|
|
342
|
+
relationshipSignatureValid = await this.secrets.verifyPeer(secretId, crypto_1.CoreBuffer.fromUtf8(signedCreationContent.serializedCreationContent), signedCreationContent.relationshipSignature);
|
|
285
343
|
}
|
|
286
344
|
if (!relationshipSignatureValid) {
|
|
287
|
-
throw CoreErrors_1.CoreErrors.general.signatureNotValid("
|
|
288
|
-
}
|
|
289
|
-
const requestContent = RelationshipCreationChangeRequestContentWrapper_1.RelationshipCreationChangeRequestContentWrapper.deserialize(signedRequest.serializedRequest);
|
|
290
|
-
if (!requestContent.templateId.equals(templateId)) {
|
|
291
|
-
throw new core_1.TransportError("The relationship request contains a wrong template id.");
|
|
292
|
-
}
|
|
293
|
-
return requestContent;
|
|
294
|
-
}
|
|
295
|
-
async decryptCreationChangeResponse(change, relationshipSecretId) {
|
|
296
|
-
if (!change.response)
|
|
297
|
-
throw this.newChangeResponseMissingError(change.id);
|
|
298
|
-
if (change.type !== RelationshipChangeType_1.RelationshipChangeType.Creation)
|
|
299
|
-
this.throwWrongChangeType(change.type);
|
|
300
|
-
if (!change.response.content) {
|
|
301
|
-
throw this.newEmptyOrInvalidContentError(change);
|
|
302
|
-
}
|
|
303
|
-
const isOwnChange = this.parent.identity.isMe(core_1.CoreAddress.from(change.response.createdBy));
|
|
304
|
-
const cipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.fromBase64(change.response.content);
|
|
305
|
-
let signedResponseBuffer;
|
|
306
|
-
if (change.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked) {
|
|
307
|
-
if (isOwnChange) {
|
|
308
|
-
signedResponseBuffer = await this.secrets.decryptOwn(relationshipSecretId, cipher.cipher);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
signedResponseBuffer = await this.secrets.decryptPeer(relationshipSecretId, cipher.cipher, true);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
signedResponseBuffer = await this.secrets.decryptRequest(relationshipSecretId, cipher.cipher);
|
|
316
|
-
}
|
|
317
|
-
const signedResponse = RelationshipCreationChangeResponseSigned_1.RelationshipCreationChangeResponseSigned.deserialize(signedResponseBuffer.toUtf8());
|
|
318
|
-
let relationshipSignatureValid;
|
|
319
|
-
if (isOwnChange) {
|
|
320
|
-
relationshipSignatureValid = await this.secrets.verifyOwn(relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
relationshipSignatureValid = await this.secrets.verifyPeer(relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
|
|
324
|
-
}
|
|
325
|
-
if (!relationshipSignatureValid) {
|
|
326
|
-
throw CoreErrors_1.CoreErrors.general.signatureNotValid("relationshipResponse");
|
|
327
|
-
}
|
|
328
|
-
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.deserialize(signedResponse.serializedResponse);
|
|
329
|
-
if (!responseContent.relationshipId.equals(change.relationshipId)) {
|
|
330
|
-
throw new core_1.TransportError("The relationship response contains a wrong relationship id.");
|
|
331
|
-
}
|
|
332
|
-
return responseContent;
|
|
333
|
-
}
|
|
334
|
-
async updatePendingRelationshipWithPeerResponse(relationshipDoc, change) {
|
|
335
|
-
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
336
|
-
if (relationship.status !== RelationshipStatus_1.RelationshipStatus.Pending) {
|
|
337
|
-
this.log.debug("Trying to update non-pending relationship with creation change", change);
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
if (!relationship.cache) {
|
|
341
|
-
await this.updateCacheOfRelationship(relationship, undefined);
|
|
345
|
+
throw CoreErrors_1.CoreErrors.general.signatureNotValid("relationshipCreationContent");
|
|
342
346
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
if (!change.response.content) {
|
|
346
|
-
throw this.newEmptyOrInvalidContentError(change);
|
|
347
|
-
}
|
|
348
|
-
const cipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.fromBase64(change.response.content);
|
|
349
|
-
if (change.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked) {
|
|
350
|
-
if (!cipher.publicResponseCrypto) {
|
|
351
|
-
throw new core_1.TransportError("The response crypto is missing.");
|
|
352
|
-
}
|
|
353
|
-
await this.secrets.convertSecrets(relationship.relationshipSecretId, cipher.publicResponseCrypto);
|
|
354
|
-
}
|
|
355
|
-
const responseContent = await this.decryptCreationChangeResponse(change, relationship.relationshipSecretId);
|
|
356
|
-
const response = RelationshipChangeResponse_1.RelationshipChangeResponse.fromBackbone(change.response, responseContent.content);
|
|
357
|
-
if (!relationship.cache) {
|
|
358
|
-
throw this.newCacheEmptyError(Relationship_1.Relationship, relationship.id.toString());
|
|
359
|
-
}
|
|
360
|
-
relationship.cache.changes[0].status = change.status;
|
|
361
|
-
switch (change.status) {
|
|
362
|
-
case RelationshipChangeStatus_1.RelationshipChangeStatus.Accepted:
|
|
363
|
-
relationship.toActive(response);
|
|
364
|
-
break;
|
|
365
|
-
case RelationshipChangeStatus_1.RelationshipChangeStatus.Rejected:
|
|
366
|
-
relationship.toRejected(response);
|
|
367
|
-
break;
|
|
368
|
-
case RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked:
|
|
369
|
-
relationship.toRevoked(response);
|
|
370
|
-
break;
|
|
371
|
-
default:
|
|
372
|
-
throw CoreErrors_1.CoreErrors.general.notSupported();
|
|
373
|
-
}
|
|
374
|
-
await this.relationships.update(relationshipDoc, relationship);
|
|
375
|
-
return relationship;
|
|
347
|
+
const creationContent = RelationshipCreationContentWrapper_1.RelationshipCreationContentWrapper.deserialize(signedCreationContent.serializedCreationContent);
|
|
348
|
+
return creationContent;
|
|
376
349
|
}
|
|
377
|
-
async
|
|
378
|
-
const backboneRelationship = (await this.client.getRelationship(
|
|
350
|
+
async createNewRelationshipByIncomingCreation(relationshipId) {
|
|
351
|
+
const backboneRelationship = (await this.client.getRelationship(relationshipId)).value;
|
|
352
|
+
if (!backboneRelationship.creationContent)
|
|
353
|
+
throw new core_1.TransportError("Creation content is missing");
|
|
379
354
|
const templateId = core_1.CoreId.from(backboneRelationship.relationshipTemplateId);
|
|
380
355
|
const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId);
|
|
381
356
|
if (!template)
|
|
382
357
|
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
|
|
383
358
|
if (!template.cache)
|
|
384
359
|
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
385
|
-
if (!change.request.content)
|
|
386
|
-
throw this.newEmptyOrInvalidContentError(change);
|
|
387
360
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
388
|
-
const
|
|
389
|
-
await this.secrets.createTemplatorSecrets(secretId, template.cache,
|
|
390
|
-
const
|
|
391
|
-
const
|
|
392
|
-
const relationship = Relationship_1.Relationship.fromCreationChangeReceived(backboneRelationship, template, requestContent.identity, relationshipChange, secretId);
|
|
361
|
+
const creationContentCipher = RelationshipCreationContentCipher_1.RelationshipCreationContentCipher.fromBase64(backboneRelationship.creationContent);
|
|
362
|
+
await this.secrets.createTemplatorSecrets(secretId, template.cache, creationContentCipher.publicCreationContentCrypto);
|
|
363
|
+
const creationContent = await this.decryptCreationContent(backboneRelationship.creationContent, core_1.CoreAddress.from(backboneRelationship.from), secretId);
|
|
364
|
+
const relationship = Relationship_1.Relationship.fromBackboneAndCreationContent(backboneRelationship, template, creationContent.identity, creationContent.content, secretId);
|
|
393
365
|
await this.relationships.create(relationship);
|
|
394
366
|
return relationship;
|
|
395
367
|
}
|
|
396
|
-
async
|
|
397
|
-
|
|
368
|
+
async applyRelationshipChangedEvent(relationshipId) {
|
|
369
|
+
let relationshipDoc = await this.relationships.read(relationshipId);
|
|
398
370
|
if (!relationshipDoc) {
|
|
399
|
-
|
|
371
|
+
const newRelationship = await this.createNewRelationshipByIncomingCreation(relationshipId);
|
|
372
|
+
if (newRelationship.status === RelationshipStatus_1.RelationshipStatus.Pending) {
|
|
373
|
+
return newRelationship;
|
|
374
|
+
}
|
|
375
|
+
// this path is for a revocation that is processed before its corresponding creation
|
|
376
|
+
relationshipDoc = await this.relationships.read(relationshipId);
|
|
377
|
+
}
|
|
378
|
+
return await this.updateRelationshipWithPeerResponse(relationshipDoc);
|
|
379
|
+
}
|
|
380
|
+
async prepareCreationResponseContent(relationship) {
|
|
381
|
+
const publicCreationResponseContentCrypto = await this.secrets.getPublicCreationResponseContentCrypto(relationship.relationshipSecretId);
|
|
382
|
+
const creationResponseContent = RelationshipCreationResponseContentWrapper_1.RelationshipCreationResponseContentWrapper.from({ relationshipId: relationship.id });
|
|
383
|
+
const serializedCreationResponseContent = creationResponseContent.serialize();
|
|
384
|
+
const buffer = CoreUtil_1.CoreUtil.toBuffer(serializedCreationResponseContent);
|
|
385
|
+
const [deviceSignature, relationshipSignature] = await Promise.all([this.parent.activeDevice.sign(buffer), this.secrets.sign(relationship.relationshipSecretId, buffer)]);
|
|
386
|
+
const signedCreationResponseContent = RelationshipCreationResponseContentSigned_1.RelationshipCreationResponseContentSigned.from({
|
|
387
|
+
serializedCreationResponseContent,
|
|
388
|
+
deviceSignature,
|
|
389
|
+
relationshipSignature
|
|
390
|
+
});
|
|
391
|
+
const cipher = await this.secrets.encrypt(relationship.relationshipSecretId, signedCreationResponseContent);
|
|
392
|
+
const creationResponseContentCipher = RelationshipCreationResponseContentCipher_1.RelationshipCreationResponseContentCipher.from({
|
|
393
|
+
cipher,
|
|
394
|
+
publicCreationResponseContentCrypto
|
|
395
|
+
});
|
|
396
|
+
return creationResponseContentCipher.toBase64();
|
|
397
|
+
}
|
|
398
|
+
async completeOperationWithBackboneCall(operation, id) {
|
|
399
|
+
const relationshipDoc = await this.relationships.read(id.toString());
|
|
400
|
+
if (!relationshipDoc) {
|
|
401
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, id.toString());
|
|
400
402
|
}
|
|
401
403
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
402
404
|
if (!relationship.cache) {
|
|
403
405
|
await this.updateCacheOfRelationship(relationship);
|
|
404
406
|
}
|
|
405
407
|
if (!relationship.cache) {
|
|
406
|
-
throw this.newCacheEmptyError(Relationship_1.Relationship,
|
|
407
|
-
}
|
|
408
|
-
const queriedChange = relationship.cache.changes.find((r) => r.id.toString() === change.id.toString());
|
|
409
|
-
if (!queriedChange) {
|
|
410
|
-
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipChange_1.RelationshipChange, change.id.toString());
|
|
411
|
-
}
|
|
412
|
-
if (queriedChange.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Pending) {
|
|
413
|
-
throw CoreErrors_1.CoreErrors.relationships.wrongChangeStatus(queriedChange.status);
|
|
414
|
-
}
|
|
415
|
-
let encryptedContent;
|
|
416
|
-
if (content) {
|
|
417
|
-
encryptedContent =
|
|
418
|
-
targetStatus === RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked
|
|
419
|
-
? await this.encryptRevokeContent(relationship, content)
|
|
420
|
-
: await this.encryptAcceptRejectContent(relationship, content);
|
|
408
|
+
throw this.newCacheEmptyError(Relationship_1.Relationship, id.toString());
|
|
421
409
|
}
|
|
422
410
|
let backboneResponse;
|
|
423
|
-
switch (
|
|
424
|
-
case
|
|
425
|
-
|
|
411
|
+
switch (operation) {
|
|
412
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.AcceptanceOfCreation:
|
|
413
|
+
const encryptedContent = await this.prepareCreationResponseContent(relationship);
|
|
414
|
+
backboneResponse = (await this.client.acceptRelationship(id.toString(), { creationResponseContent: encryptedContent })).value;
|
|
415
|
+
break;
|
|
416
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RejectionOfCreation:
|
|
417
|
+
backboneResponse = (await this.client.rejectRelationship(id.toString())).value;
|
|
418
|
+
break;
|
|
419
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RevocationOfCreation:
|
|
420
|
+
backboneResponse = (await this.client.revokeRelationship(id.toString())).value;
|
|
421
|
+
break;
|
|
422
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.Termination:
|
|
423
|
+
backboneResponse = (await this.client.terminateRelationship(id.toString())).value;
|
|
426
424
|
break;
|
|
427
|
-
case
|
|
428
|
-
backboneResponse = (await this.client.
|
|
425
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.ReactivationRequested:
|
|
426
|
+
backboneResponse = (await this.client.reactivateRelationship(id.toString())).value;
|
|
429
427
|
break;
|
|
430
|
-
case
|
|
431
|
-
backboneResponse = (await this.client.
|
|
428
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.AcceptanceOfReactivation:
|
|
429
|
+
backboneResponse = (await this.client.acceptRelationshipReactivation(id.toString())).value;
|
|
430
|
+
break;
|
|
431
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RejectionOfReactivation:
|
|
432
|
+
backboneResponse = (await this.client.rejectRelationshipReactivation(id.toString())).value;
|
|
433
|
+
break;
|
|
434
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RevocationOfReactivation:
|
|
435
|
+
backboneResponse = (await this.client.revokeRelationshipReactivation(id.toString())).value;
|
|
432
436
|
break;
|
|
433
437
|
default:
|
|
434
|
-
throw new core_1.TransportError("
|
|
438
|
+
throw new core_1.TransportError("operation not supported");
|
|
435
439
|
}
|
|
436
|
-
const backboneChange = backboneResponse.changes[backboneResponse.changes.length - 1];
|
|
437
|
-
queriedChange.response = RelationshipChangeResponse_1.RelationshipChangeResponse.fromBackbone(backboneResponse.changes[backboneResponse.changes.length - 1].response, content);
|
|
438
|
-
queriedChange.status = backboneChange.status;
|
|
439
440
|
relationship.status = backboneResponse.status;
|
|
441
|
+
relationship.cache.auditLog = RelationshipAuditLog_1.RelationshipAuditLog.fromBackboneAuditLog(backboneResponse.auditLog);
|
|
440
442
|
await this.relationships.update(relationshipDoc, relationship);
|
|
441
|
-
this.
|
|
443
|
+
this.publishEventAfterCompletedOperation(operation, relationship);
|
|
442
444
|
return relationship;
|
|
443
445
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
const cipher = await this.secrets.encryptRequest(relationship.relationshipSecretId, signedResponse);
|
|
458
|
-
const responseCipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.from({
|
|
459
|
-
cipher: cipher
|
|
460
|
-
});
|
|
461
|
-
return responseCipher.toBase64();
|
|
462
|
-
}
|
|
463
|
-
async encryptAcceptRejectContent(relationship, content) {
|
|
464
|
-
const publicResponseCrypto = await this.secrets.getPublicResponse(relationship.relationshipSecretId);
|
|
465
|
-
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.from({
|
|
466
|
-
relationshipId: relationship.id,
|
|
467
|
-
content: content
|
|
468
|
-
});
|
|
469
|
-
const serializedResponse = responseContent.serialize();
|
|
470
|
-
const buffer = CoreUtil_1.CoreUtil.toBuffer(serializedResponse);
|
|
471
|
-
const [deviceSignature, relationshipSignature] = await Promise.all([this.parent.activeDevice.sign(buffer), this.secrets.sign(relationship.relationshipSecretId, buffer)]);
|
|
472
|
-
const signedResponse = RelationshipCreationChangeResponseSigned_1.RelationshipCreationChangeResponseSigned.from({
|
|
473
|
-
serializedResponse: serializedResponse,
|
|
474
|
-
deviceSignature: deviceSignature,
|
|
475
|
-
relationshipSignature: relationshipSignature
|
|
476
|
-
});
|
|
477
|
-
const cipher = await this.secrets.encrypt(relationship.relationshipSecretId, signedResponse);
|
|
478
|
-
const responseCipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.from({
|
|
479
|
-
cipher: cipher,
|
|
480
|
-
publicResponseCrypto: publicResponseCrypto
|
|
481
|
-
});
|
|
482
|
-
return responseCipher.toBase64();
|
|
483
|
-
}
|
|
484
|
-
throwWrongChangeType(type) {
|
|
485
|
-
throw new core_1.TransportError(`The relationship change has the wrong type (${type}) to run this operation`);
|
|
486
|
-
}
|
|
487
|
-
newChangeResponseMissingError(changeId) {
|
|
488
|
-
return new core_1.TransportError(`The response of the relationship change (${changeId}) is missing`);
|
|
489
|
-
}
|
|
490
|
-
newEmptyOrInvalidContentError(change) {
|
|
491
|
-
return new core_1.TransportError(`The content property of the relationship change ${change?.id} is missing or invalid`);
|
|
446
|
+
publishEventAfterCompletedOperation(operation, relationship) {
|
|
447
|
+
this.eventBus.publish(new events_1.RelationshipChangedEvent(this.parent.identity.address.toString(), relationship));
|
|
448
|
+
switch (operation) {
|
|
449
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.ReactivationRequested:
|
|
450
|
+
this.eventBus.publish(new events_1.RelationshipReactivationRequestedEvent(this.parent.identity.address.toString(), relationship));
|
|
451
|
+
break;
|
|
452
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RevocationOfReactivation:
|
|
453
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.AcceptanceOfReactivation:
|
|
454
|
+
case RelationshipAuditLog_2.RelationshipAuditLogEntryReason.RejectionOfReactivation:
|
|
455
|
+
this.eventBus.publish(new events_1.RelationshipReactivationCompletedEvent(this.parent.identity.address.toString(), relationship));
|
|
456
|
+
break;
|
|
457
|
+
default:
|
|
458
|
+
}
|
|
492
459
|
}
|
|
493
460
|
}
|
|
494
461
|
exports.RelationshipsController = RelationshipsController;
|
|
@@ -497,7 +464,7 @@ __decorate([
|
|
|
497
464
|
__metadata("design:type", Function),
|
|
498
465
|
__metadata("design:paramtypes", [String, Object]),
|
|
499
466
|
__metadata("design:returntype", Promise)
|
|
500
|
-
], RelationshipsController.prototype, "
|
|
467
|
+
], RelationshipsController.prototype, "updateExistingRelationshipInDb", null);
|
|
501
468
|
__decorate([
|
|
502
469
|
(0, ts_utils_1.log)(),
|
|
503
470
|
__metadata("design:type", Function),
|
|
@@ -509,42 +476,23 @@ __decorate([
|
|
|
509
476
|
__metadata("design:type", Function),
|
|
510
477
|
__metadata("design:paramtypes", [Object]),
|
|
511
478
|
__metadata("design:returntype", Promise)
|
|
512
|
-
], RelationshipsController.prototype, "
|
|
513
|
-
__decorate([
|
|
514
|
-
(0, ts_utils_1.log)(),
|
|
515
|
-
__metadata("design:type", Function),
|
|
516
|
-
__metadata("design:paramtypes", [Object, core_1.CoreId, core_1.CoreId]),
|
|
517
|
-
__metadata("design:returntype", Promise)
|
|
518
|
-
], RelationshipsController.prototype, "parseCreationChange", null);
|
|
479
|
+
], RelationshipsController.prototype, "updateRelationshipWithPeerResponse", null);
|
|
519
480
|
__decorate([
|
|
520
481
|
(0, ts_utils_1.log)(),
|
|
521
482
|
__metadata("design:type", Function),
|
|
522
|
-
__metadata("design:paramtypes", [
|
|
523
|
-
core_1.CoreId]),
|
|
483
|
+
__metadata("design:paramtypes", [String, core_1.CoreAddress, core_1.CoreId]),
|
|
524
484
|
__metadata("design:returntype", Promise)
|
|
525
|
-
], RelationshipsController.prototype, "
|
|
485
|
+
], RelationshipsController.prototype, "decryptCreationContent", null);
|
|
526
486
|
__decorate([
|
|
527
487
|
(0, ts_utils_1.log)(),
|
|
528
488
|
__metadata("design:type", Function),
|
|
529
|
-
__metadata("design:paramtypes", [
|
|
530
|
-
__metadata("design:returntype", Promise)
|
|
531
|
-
], RelationshipsController.prototype, "decryptCreationChangeResponse", null);
|
|
532
|
-
__decorate([
|
|
533
|
-
(0, ts_utils_1.log)(),
|
|
534
|
-
__metadata("design:type", Function),
|
|
535
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
536
|
-
__metadata("design:returntype", Promise)
|
|
537
|
-
], RelationshipsController.prototype, "updatePendingRelationshipWithPeerResponse", null);
|
|
538
|
-
__decorate([
|
|
539
|
-
(0, ts_utils_1.log)(),
|
|
540
|
-
__metadata("design:type", Function),
|
|
541
|
-
__metadata("design:paramtypes", [Object]),
|
|
489
|
+
__metadata("design:paramtypes", [String]),
|
|
542
490
|
__metadata("design:returntype", Promise)
|
|
543
|
-
], RelationshipsController.prototype, "
|
|
491
|
+
], RelationshipsController.prototype, "createNewRelationshipByIncomingCreation", null);
|
|
544
492
|
__decorate([
|
|
545
493
|
(0, ts_utils_1.log)(),
|
|
546
494
|
__metadata("design:type", Function),
|
|
547
|
-
__metadata("design:paramtypes", [String,
|
|
495
|
+
__metadata("design:paramtypes", [String, core_1.CoreId]),
|
|
548
496
|
__metadata("design:returntype", Promise)
|
|
549
|
-
], RelationshipsController.prototype, "
|
|
497
|
+
], RelationshipsController.prototype, "completeOperationWithBackboneCall", null);
|
|
550
498
|
//# sourceMappingURL=RelationshipsController.js.map
|