@wireapp/wire-apps-js-sdk 0.0.1-alpha → 0.0.2-alpha
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/README.md +23 -8
- package/build/WireAppSdk.d.ts +22 -7
- package/build/WireAppSdk.d.ts.map +1 -1
- package/build/WireAppSdk.js +69 -47
- package/build/WireAppSdk.js.map +1 -1
- package/build/api/AssetsApiClient.d.ts +4 -4
- package/build/api/AssetsApiClient.d.ts.map +1 -1
- package/build/api/AssetsApiClient.js +7 -7
- package/build/api/AssetsApiClient.js.map +1 -1
- package/build/api/AssetsTransferService.d.ts +3 -3
- package/build/api/AssetsTransferService.d.ts.map +1 -1
- package/build/api/AssetsTransferService.js +9 -10
- package/build/api/AssetsTransferService.js.map +1 -1
- package/build/api/ClientsApiClient.d.ts +4 -4
- package/build/api/ClientsApiClient.d.ts.map +1 -1
- package/build/api/ClientsApiClient.js +7 -7
- package/build/api/ClientsApiClient.js.map +1 -1
- package/build/api/ClientsService.d.ts +3 -3
- package/build/api/ClientsService.d.ts.map +1 -1
- package/build/api/ClientsService.js +3 -3
- package/build/api/ClientsService.js.map +1 -1
- package/build/api/ConversationService.d.ts +34 -22
- package/build/api/ConversationService.d.ts.map +1 -1
- package/build/api/ConversationService.js +91 -84
- package/build/api/ConversationService.js.map +1 -1
- package/build/api/ConversationsApiClient.d.ts +7 -9
- package/build/api/ConversationsApiClient.d.ts.map +1 -1
- package/build/api/ConversationsApiClient.js +10 -20
- package/build/api/ConversationsApiClient.js.map +1 -1
- package/build/api/FeatureConfigsApiClient.d.ts +2 -2
- package/build/api/FeatureConfigsApiClient.d.ts.map +1 -1
- package/build/api/FeatureConfigsApiClient.js +3 -3
- package/build/api/FeatureConfigsApiClient.js.map +1 -1
- package/build/api/FeatureConfigsService.d.ts +1 -1
- package/build/api/FeatureConfigsService.d.ts.map +1 -1
- package/build/api/FeatureConfigsService.js +16 -16
- package/build/api/FeatureConfigsService.js.map +1 -1
- package/build/api/MlsApiClient.d.ts +4 -4
- package/build/api/MlsApiClient.d.ts.map +1 -1
- package/build/api/MlsApiClient.js +12 -12
- package/build/api/MlsApiClient.js.map +1 -1
- package/build/api/MlsService.d.ts +5 -5
- package/build/api/MlsService.d.ts.map +1 -1
- package/build/api/MlsService.js +23 -23
- package/build/api/MlsService.js.map +1 -1
- package/build/api/NotificationsApiClient.d.ts +4 -4
- package/build/api/NotificationsApiClient.d.ts.map +1 -1
- package/build/api/NotificationsApiClient.js +22 -22
- package/build/api/NotificationsApiClient.js.map +1 -1
- package/build/api/OneToOneConversationsApiClient.d.ts +3 -3
- package/build/api/OneToOneConversationsApiClient.d.ts.map +1 -1
- package/build/api/OneToOneConversationsApiClient.js +4 -4
- package/build/api/OneToOneConversationsApiClient.js.map +1 -1
- package/build/api/SearchApiClient.d.ts +2 -2
- package/build/api/SearchApiClient.d.ts.map +1 -1
- package/build/api/SearchApiClient.js +9 -8
- package/build/api/SearchApiClient.js.map +1 -1
- package/build/api/SelfApiClient.d.ts +9 -0
- package/build/api/SelfApiClient.d.ts.map +1 -0
- package/build/api/SelfApiClient.js +42 -0
- package/build/api/SelfApiClient.js.map +1 -0
- package/build/api/SelfService.d.ts +12 -0
- package/build/api/SelfService.d.ts.map +1 -0
- package/build/api/SelfService.js +81 -0
- package/build/api/SelfService.js.map +1 -0
- package/build/api/TeamsApiClient.d.ts +3 -3
- package/build/api/TeamsApiClient.d.ts.map +1 -1
- package/build/api/TeamsApiClient.js +4 -4
- package/build/api/TeamsApiClient.js.map +1 -1
- package/build/api/UserService.d.ts +6 -5
- package/build/api/UserService.d.ts.map +1 -1
- package/build/api/UserService.js +20 -11
- package/build/api/UserService.js.map +1 -1
- package/build/api/UsersApiClient.d.ts +8 -5
- package/build/api/UsersApiClient.d.ts.map +1 -1
- package/build/api/UsersApiClient.js +13 -8
- package/build/api/UsersApiClient.js.map +1 -1
- package/build/api/model/AddMembersToConversationResult.d.ts +1 -1
- package/build/api/model/AddMembersToConversationResult.d.ts.map +1 -1
- package/build/api/model/AddMembersToConversationResult.js +14 -14
- package/build/api/model/AddMembersToConversationResult.js.map +1 -1
- package/build/api/model/ConversationIdsPaginationConfig.js +14 -14
- package/build/api/model/ConversationIdsPaginationConfig.js.map +1 -1
- package/build/api/model/ConversationMemberOtherResponse.d.ts +2 -2
- package/build/api/model/ConversationMemberOtherResponse.d.ts.map +1 -1
- package/build/api/model/ConversationMemberOtherResponse.js +14 -14
- package/build/api/model/ConversationMemberOtherResponse.js.map +1 -1
- package/build/api/model/ConversationMemberSelfResponse.d.ts +2 -2
- package/build/api/model/ConversationMemberSelfResponse.d.ts.map +1 -1
- package/build/api/model/ConversationMemberSelfResponse.js +14 -14
- package/build/api/model/ConversationMemberSelfResponse.js.map +1 -1
- package/build/api/model/ConversationMembersResponse.d.ts +2 -2
- package/build/api/model/ConversationMembersResponse.d.ts.map +1 -1
- package/build/api/model/ConversationMembersResponse.js +14 -14
- package/build/api/model/ConversationMembersResponse.js.map +1 -1
- package/build/api/model/RemoveMembersFromConversationResult.d.ts +1 -1
- package/build/api/model/RemoveMembersFromConversationResult.d.ts.map +1 -1
- package/build/api/model/RemoveMembersFromConversationResult.js +14 -14
- package/build/api/model/RemoveMembersFromConversationResult.js.map +1 -1
- package/build/api/model/UserClientResponse.js +14 -14
- package/build/api/model/UserClientResponse.js.map +1 -1
- package/build/api/model/UserResponse.d.ts +4 -2
- package/build/api/model/UserResponse.d.ts.map +1 -1
- package/build/api/model/UserResponse.js +14 -14
- package/build/api/model/UserResponse.js.map +1 -1
- package/build/api/model/asset/AssetUploadData.d.ts.map +1 -1
- package/build/api/model/asset/AssetUploadResponse.d.ts.map +1 -1
- package/build/api/request/CapabilitiesRequest.js +14 -14
- package/build/api/request/CapabilitiesRequest.js.map +1 -1
- package/build/api/request/ClientUpdateRequest.d.ts +1 -1
- package/build/api/request/ClientUpdateRequest.d.ts.map +1 -1
- package/build/api/request/ClientUpdateRequest.js +14 -14
- package/build/api/request/ClientUpdateRequest.js.map +1 -1
- package/build/api/request/ConversationIdsRequest.d.ts +1 -1
- package/build/api/request/ConversationIdsRequest.js +14 -14
- package/build/api/request/ConversationIdsRequest.js.map +1 -1
- package/build/api/request/CreateConversationRequest.d.ts +9 -9
- package/build/api/request/CreateConversationRequest.d.ts.map +1 -1
- package/build/api/request/CreateConversationRequest.js +8 -11
- package/build/api/request/CreateConversationRequest.js.map +1 -1
- package/build/api/request/MlsKeyPackagesRequest.js +14 -14
- package/build/api/request/MlsKeyPackagesRequest.js.map +1 -1
- package/build/api/request/PreKeyRequest.d.ts.map +1 -1
- package/build/api/request/PreKeyRequest.js +14 -14
- package/build/api/request/PreKeyRequest.js.map +1 -1
- package/build/api/request/RegisterClientRequest.d.ts +2 -2
- package/build/api/request/RegisterClientRequest.d.ts.map +1 -1
- package/build/api/request/RegisterClientRequest.js +18 -20
- package/build/api/request/RegisterClientRequest.js.map +1 -1
- package/build/api/response/ClaimedKeyPackageList.d.ts.map +1 -1
- package/build/api/response/ClaimedKeyPackageList.js +14 -14
- package/build/api/response/ClaimedKeyPackageList.js.map +1 -1
- package/build/api/response/ConversationIdsResponse.d.ts +1 -1
- package/build/api/response/ConversationIdsResponse.js +14 -14
- package/build/api/response/ConversationIdsResponse.js.map +1 -1
- package/build/api/response/ConversationResponse.d.ts +4 -4
- package/build/api/response/ConversationResponse.d.ts.map +1 -1
- package/build/api/response/ConversationResponse.js +14 -14
- package/build/api/response/ConversationResponse.js.map +1 -1
- package/build/api/response/ConversationsResponse.d.ts +2 -2
- package/build/api/response/ConversationsResponse.js +14 -14
- package/build/api/response/ConversationsResponse.js.map +1 -1
- package/build/api/response/EventResponse.d.ts +1 -1
- package/build/api/response/EventResponse.d.ts.map +1 -1
- package/build/api/response/EventResponse.js +14 -14
- package/build/api/response/EventResponse.js.map +1 -1
- package/build/api/response/FeatureConfigsResponse.d.ts +1 -1
- package/build/api/response/FeatureConfigsResponse.d.ts.map +1 -1
- package/build/api/response/FeatureConfigsResponse.js +14 -14
- package/build/api/response/FeatureConfigsResponse.js.map +1 -1
- package/build/api/response/ListUsersResponse.d.ts +7 -0
- package/build/api/response/ListUsersResponse.d.ts.map +1 -0
- package/build/api/response/ListUsersResponse.js +17 -0
- package/build/api/response/ListUsersResponse.js.map +1 -0
- package/build/api/response/MlsPublicKeysResponse.d.ts +2 -2
- package/build/api/response/MlsPublicKeysResponse.d.ts.map +1 -1
- package/build/api/response/MlsPublicKeysResponse.js +18 -17
- package/build/api/response/MlsPublicKeysResponse.js.map +1 -1
- package/build/api/response/NotificationsResponse.d.ts +1 -1
- package/build/api/response/NotificationsResponse.js +14 -14
- package/build/api/response/NotificationsResponse.js.map +1 -1
- package/build/api/response/OneToOneConversationResponse.d.ts +2 -2
- package/build/api/response/OneToOneConversationResponse.d.ts.map +1 -1
- package/build/api/response/OneToOneConversationResponse.js +14 -14
- package/build/api/response/OneToOneConversationResponse.js.map +1 -1
- package/build/api/response/RegisterClientResponse.js +14 -14
- package/build/api/response/RegisterClientResponse.js.map +1 -1
- package/build/api/response/SearchContactsResponse.d.ts +1 -1
- package/build/api/response/SearchContactsResponse.d.ts.map +1 -1
- package/build/api/response/SelfResponse.d.ts +6 -0
- package/build/api/response/SelfResponse.d.ts.map +1 -0
- package/build/api/response/SelfResponse.js +17 -0
- package/build/api/response/SelfResponse.js.map +1 -0
- package/build/core/BackendConnectionListener.d.ts +31 -0
- package/build/core/BackendConnectionListener.d.ts.map +1 -0
- package/build/core/BackendConnectionListener.js +17 -0
- package/build/core/BackendConnectionListener.js.map +1 -0
- package/build/core/CoreCryptoClient.d.ts +10 -7
- package/build/core/CoreCryptoClient.d.ts.map +1 -1
- package/build/core/CoreCryptoClient.js +49 -32
- package/build/core/CoreCryptoClient.js.map +1 -1
- package/build/core/CoreCryptoMlsTransport.d.ts +2 -2
- package/build/core/CoreCryptoMlsTransport.d.ts.map +1 -1
- package/build/core/CoreCryptoMlsTransport.js +18 -17
- package/build/core/CoreCryptoMlsTransport.js.map +1 -1
- package/build/core/CoreCryptoService.d.ts +15 -14
- package/build/core/CoreCryptoService.d.ts.map +1 -1
- package/build/core/CoreCryptoService.js +67 -55
- package/build/core/CoreCryptoService.js.map +1 -1
- package/build/core/HttpClient.d.ts +1 -1
- package/build/core/HttpClient.d.ts.map +1 -1
- package/build/core/HttpClient.js +66 -76
- package/build/core/HttpClient.js.map +1 -1
- package/build/core/HttpRetryHelper.d.ts +1 -1
- package/build/core/HttpRetryHelper.d.ts.map +1 -1
- package/build/core/HttpRetryHelper.js +4 -4
- package/build/core/HttpRetryHelper.js.map +1 -1
- package/build/core/HttpRetryPolicy.js.map +1 -1
- package/build/core/WebSocketClient.d.ts +9 -4
- package/build/core/WebSocketClient.d.ts.map +1 -1
- package/build/core/WebSocketClient.js +66 -35
- package/build/core/WebSocketClient.js.map +1 -1
- package/build/core/WireApplicationManager.d.ts +24 -15
- package/build/core/WireApplicationManager.d.ts.map +1 -1
- package/build/core/WireApplicationManager.js +67 -32
- package/build/core/WireApplicationManager.js.map +1 -1
- package/build/core/WireEventsHandler.d.ts +7 -8
- package/build/core/WireEventsHandler.d.ts.map +1 -1
- package/build/core/WireEventsHandler.js +9 -13
- package/build/core/WireEventsHandler.js.map +1 -1
- package/build/core/event/DeleteConversationEventProcessor.d.ts +4 -4
- package/build/core/event/DeleteConversationEventProcessor.d.ts.map +1 -1
- package/build/core/event/DeleteConversationEventProcessor.js +7 -7
- package/build/core/event/DeleteConversationEventProcessor.js.map +1 -1
- package/build/core/event/EventProcessor.d.ts +2 -2
- package/build/core/event/EventProcessor.d.ts.map +1 -1
- package/build/core/event/EventRouter.d.ts +3 -3
- package/build/core/event/EventRouter.d.ts.map +1 -1
- package/build/core/event/EventRouter.js +18 -18
- package/build/core/event/EventRouter.js.map +1 -1
- package/build/core/event/MemberJoinEventProcessor.d.ts +4 -4
- package/build/core/event/MemberJoinEventProcessor.d.ts.map +1 -1
- package/build/core/event/MemberJoinEventProcessor.js +14 -11
- package/build/core/event/MemberJoinEventProcessor.js.map +1 -1
- package/build/core/event/MemberLeaveEventProcessor.d.ts +4 -4
- package/build/core/event/MemberLeaveEventProcessor.d.ts.map +1 -1
- package/build/core/event/MemberLeaveEventProcessor.js +12 -9
- package/build/core/event/MemberLeaveEventProcessor.js.map +1 -1
- package/build/core/event/MemberUpdateEventProcessor.d.ts +3 -3
- package/build/core/event/MemberUpdateEventProcessor.d.ts.map +1 -1
- package/build/core/event/MemberUpdateEventProcessor.js +6 -6
- package/build/core/event/MemberUpdateEventProcessor.js.map +1 -1
- package/build/core/event/MessageTimerUpdateEventProcessor.d.ts +11 -0
- package/build/core/event/MessageTimerUpdateEventProcessor.d.ts.map +1 -0
- package/build/core/event/MessageTimerUpdateEventProcessor.js +49 -0
- package/build/core/event/MessageTimerUpdateEventProcessor.js.map +1 -0
- package/build/core/event/MlsMessageEventProcessor.d.ts +6 -6
- package/build/core/event/MlsMessageEventProcessor.d.ts.map +1 -1
- package/build/core/event/MlsMessageEventProcessor.js +31 -26
- package/build/core/event/MlsMessageEventProcessor.js.map +1 -1
- package/build/core/event/MlsResetEventProcessor.d.ts +3 -3
- package/build/core/event/MlsResetEventProcessor.d.ts.map +1 -1
- package/build/core/event/MlsResetEventProcessor.js +6 -6
- package/build/core/event/MlsResetEventProcessor.js.map +1 -1
- package/build/core/event/MlsWelcomeEventProcessor.d.ts +7 -7
- package/build/core/event/MlsWelcomeEventProcessor.d.ts.map +1 -1
- package/build/core/event/MlsWelcomeEventProcessor.js +12 -12
- package/build/core/event/MlsWelcomeEventProcessor.js.map +1 -1
- package/build/core/event/NewConversationEventProcessor.d.ts +3 -3
- package/build/core/event/NewConversationEventProcessor.d.ts.map +1 -1
- package/build/core/event/NewConversationEventProcessor.js +6 -6
- package/build/core/event/NewConversationEventProcessor.js.map +1 -1
- package/build/core/event/processors.index.d.ts +9 -8
- package/build/core/event/processors.index.d.ts.map +1 -1
- package/build/core/event/processors.index.js +9 -8
- package/build/core/event/processors.index.js.map +1 -1
- package/build/db/AppPropertiesRepository.d.ts +2 -2
- package/build/db/AppPropertiesRepository.d.ts.map +1 -1
- package/build/db/AppPropertiesRepository.js +34 -23
- package/build/db/AppPropertiesRepository.js.map +1 -1
- package/build/db/ConversationMemberRepository.d.ts +3 -3
- package/build/db/ConversationMemberRepository.d.ts.map +1 -1
- package/build/db/ConversationMemberRepository.js +40 -26
- package/build/db/ConversationMemberRepository.js.map +1 -1
- package/build/db/ConversationRepository.d.ts +7 -2
- package/build/db/ConversationRepository.d.ts.map +1 -1
- package/build/db/ConversationRepository.js +72 -46
- package/build/db/ConversationRepository.js.map +1 -1
- package/build/db/DatabaseService.d.ts.map +1 -1
- package/build/db/DatabaseService.js +29 -27
- package/build/db/DatabaseService.js.map +1 -1
- package/build/db/migrations/0002_perfect_karnak.sql +1 -0
- package/build/db/migrations/meta/0002_snapshot.json +204 -0
- package/build/db/migrations/meta/_journal.json +7 -0
- package/build/db/model/AppEntity.js +14 -14
- package/build/db/model/AppEntity.js.map +1 -1
- package/build/db/model/ConversationEntity.d.ts +2 -1
- package/build/db/model/ConversationEntity.d.ts.map +1 -1
- package/build/db/model/ConversationEntity.js +14 -14
- package/build/db/model/ConversationEntity.js.map +1 -1
- package/build/db/model/ConversationMemberEntity.js +14 -14
- package/build/db/model/ConversationMemberEntity.js.map +1 -1
- package/build/db/relations.d.ts.map +1 -1
- package/build/db/relations.js +4 -4
- package/build/db/relations.js.map +1 -1
- package/build/db/schema.d.ts +17 -0
- package/build/db/schema.d.ts.map +1 -1
- package/build/db/schema.js +27 -19
- package/build/db/schema.js.map +1 -1
- package/build/exception/CoreCryptoMlsException.d.ts.map +1 -0
- package/build/exception/CoreCryptoMlsException.js +25 -0
- package/build/exception/CoreCryptoMlsException.js.map +1 -0
- package/build/exception/MlsException.d.ts.map +1 -0
- package/build/exception/MlsException.js +25 -0
- package/build/exception/MlsException.js.map +1 -0
- package/build/exception/WireApiError.d.ts.map +1 -0
- package/build/exception/WireApiError.js +17 -0
- package/build/exception/WireApiError.js.map +1 -0
- package/build/{model/exception → exception}/WireApiException.d.ts +1 -1
- package/build/exception/WireApiException.d.ts.map +1 -0
- package/build/{model/exception → exception}/WireApiException.js +2 -2
- package/build/exception/WireApiException.js.map +1 -0
- package/build/exception/WireException.d.ts +41 -0
- package/build/exception/WireException.d.ts.map +1 -0
- package/build/exception/WireException.js +81 -0
- package/build/exception/WireException.js.map +1 -0
- package/build/index.d.ts +18 -12
- package/build/index.d.ts.map +1 -1
- package/build/index.js +27 -22
- package/build/index.js.map +1 -1
- package/build/mappers/PreKeyMapper.d.ts +2 -2
- package/build/mappers/PreKeyMapper.d.ts.map +1 -1
- package/build/mappers/PreKeyMapper.js +14 -14
- package/build/mappers/PreKeyMapper.js.map +1 -1
- package/build/mappers/conversation/ConversationMapper.d.ts +2 -2
- package/build/mappers/conversation/ConversationMapper.d.ts.map +1 -1
- package/build/mappers/conversation/ConversationMapper.js +16 -15
- package/build/mappers/conversation/ConversationMapper.js.map +1 -1
- package/build/mappers/conversation/ConversationMemberMapper.d.ts +2 -2
- package/build/mappers/conversation/ConversationMemberMapper.d.ts.map +1 -1
- package/build/mappers/conversation/ConversationMemberMapper.js +15 -15
- package/build/mappers/conversation/ConversationMemberMapper.js.map +1 -1
- package/build/mappers/protobuf/EncryptionAlgorithmMapper.d.ts +4 -4
- package/build/mappers/protobuf/EncryptionAlgorithmMapper.d.ts.map +1 -1
- package/build/mappers/protobuf/EncryptionAlgorithmMapper.js +28 -23
- package/build/mappers/protobuf/EncryptionAlgorithmMapper.js.map +1 -1
- package/build/mappers/protobuf/MessageContentEncoder.d.ts +1 -1
- package/build/mappers/protobuf/MessageContentEncoder.d.ts.map +1 -1
- package/build/mappers/protobuf/MessageContentEncoder.js +4 -4
- package/build/mappers/protobuf/MessageContentEncoder.js.map +1 -1
- package/build/mappers/protobuf/MessageLinkPreviewMapper.d.ts +4 -4
- package/build/mappers/protobuf/MessageLinkPreviewMapper.d.ts.map +1 -1
- package/build/mappers/protobuf/MessageLinkPreviewMapper.js +18 -17
- package/build/mappers/protobuf/MessageLinkPreviewMapper.js.map +1 -1
- package/build/mappers/protobuf/MessageMentionMapper.d.ts +4 -4
- package/build/mappers/protobuf/MessageMentionMapper.d.ts.map +1 -1
- package/build/mappers/protobuf/MessageMentionMapper.js +16 -16
- package/build/mappers/protobuf/MessageMentionMapper.js.map +1 -1
- package/build/mappers/protobuf/ProtobufDeserializer.d.ts +2 -2
- package/build/mappers/protobuf/ProtobufDeserializer.d.ts.map +1 -1
- package/build/mappers/protobuf/ProtobufDeserializer.js +44 -40
- package/build/mappers/protobuf/ProtobufDeserializer.js.map +1 -1
- package/build/mappers/protobuf/ProtobufSerializer.d.ts.map +1 -1
- package/build/mappers/protobuf/ProtobufSerializer.js +51 -47
- package/build/mappers/protobuf/ProtobufSerializer.js.map +1 -1
- package/build/model/Asset.d.ts +1 -1
- package/build/model/Asset.d.ts.map +1 -1
- package/build/model/Asset.js +14 -14
- package/build/model/Asset.js.map +1 -1
- package/build/model/ClaimedKeyPackagesResult.d.ts +1 -1
- package/build/model/ClaimedKeyPackagesResult.d.ts.map +1 -1
- package/build/model/ClaimedKeyPackagesResult.js +14 -14
- package/build/model/ClaimedKeyPackagesResult.js.map +1 -1
- package/build/model/CryptoClientId.d.ts.map +1 -1
- package/build/model/CryptoClientId.js +14 -14
- package/build/model/CryptoClientId.js.map +1 -1
- package/build/model/CryptoProtocol.js +14 -14
- package/build/model/CryptoProtocol.js.map +1 -1
- package/build/model/DecryptedMlsMessage.d.ts +6 -0
- package/build/model/DecryptedMlsMessage.d.ts.map +1 -0
- package/build/model/DecryptedMlsMessage.js +17 -0
- package/build/model/DecryptedMlsMessage.js.map +1 -0
- package/build/model/EventContentDTO.d.ts +14 -4
- package/build/model/EventContentDTO.d.ts.map +1 -1
- package/build/model/EventContentDTO.js +14 -14
- package/build/model/EventContentDTO.js.map +1 -1
- package/build/model/PreKeyCrypto.js +14 -14
- package/build/model/PreKeyCrypto.js.map +1 -1
- package/build/model/QualifiedId.d.ts +4 -0
- package/build/model/QualifiedId.d.ts.map +1 -1
- package/build/model/QualifiedId.js +21 -15
- package/build/model/QualifiedId.js.map +1 -1
- package/build/model/TeamId.js +15 -15
- package/build/model/TeamId.js.map +1 -1
- package/build/model/UserType.d.ts +6 -0
- package/build/model/UserType.d.ts.map +1 -0
- package/build/model/UserType.js +22 -0
- package/build/model/UserType.js.map +1 -0
- package/build/model/WireMessage.d.ts +5 -5
- package/build/model/WireMessage.d.ts.map +1 -1
- package/build/model/WireMessage.js +43 -45
- package/build/model/WireMessage.js.map +1 -1
- package/build/model/WireUser.d.ts +5 -3
- package/build/model/WireUser.d.ts.map +1 -1
- package/build/model/WireUser.js +3 -1
- package/build/model/WireUser.js.map +1 -1
- package/build/model/conversation/Conversation.d.ts +2 -1
- package/build/model/conversation/Conversation.d.ts.map +1 -1
- package/build/model/conversation/Conversation.js +15 -15
- package/build/model/conversation/Conversation.js.map +1 -1
- package/build/model/conversation/ConversationMember.d.ts +2 -2
- package/build/model/conversation/ConversationMember.d.ts.map +1 -1
- package/build/model/conversation/ConversationMember.js +14 -14
- package/build/model/conversation/ConversationMember.js.map +1 -1
- package/build/model/conversation/ConversationRole.d.ts.map +1 -1
- package/build/model/conversation/ConversationRole.js +14 -14
- package/build/model/conversation/ConversationRole.js.map +1 -1
- package/build/model/conversation/ConversationType.js +14 -14
- package/build/model/conversation/ConversationType.js.map +1 -1
- package/build/model/protobuf/MessageEncryptionAlgorithm.d.ts.map +1 -1
- package/build/model/protobuf/MessageEncryptionAlgorithm.js +14 -14
- package/build/model/protobuf/MessageEncryptionAlgorithm.js.map +1 -1
- package/build/service/AppProperties.d.ts +12 -1
- package/build/service/AppProperties.d.ts.map +1 -1
- package/build/service/AppProperties.js +60 -26
- package/build/service/AppProperties.js.map +1 -1
- package/build/service/MlsFallbackStrategy.d.ts +3 -3
- package/build/service/MlsFallbackStrategy.d.ts.map +1 -1
- package/build/service/MlsFallbackStrategy.js +18 -18
- package/build/service/MlsFallbackStrategy.js.map +1 -1
- package/build/service/NotificationsService.d.ts +3 -3
- package/build/service/NotificationsService.d.ts.map +1 -1
- package/build/service/NotificationsService.js +19 -19
- package/build/service/NotificationsService.js.map +1 -1
- package/build/utils/AESUtils.d.ts +1 -1
- package/build/utils/AESUtils.d.ts.map +1 -1
- package/build/utils/AESUtils.js +15 -15
- package/build/utils/AESUtils.js.map +1 -1
- package/build/utils/BufferUtils.d.ts.map +1 -1
- package/build/utils/BufferUtils.js +15 -15
- package/build/utils/BufferUtils.js.map +1 -1
- package/build/utils/DependencyInjectionTokens.d.ts +0 -2
- package/build/utils/DependencyInjectionTokens.d.ts.map +1 -1
- package/build/utils/DependencyInjectionTokens.js +19 -21
- package/build/utils/DependencyInjectionTokens.js.map +1 -1
- package/build/utils/HashUtils.js +14 -14
- package/build/utils/HashUtils.js.map +1 -1
- package/build/utils/ObfuscateUtil.js +15 -15
- package/build/utils/ObfuscateUtil.js.map +1 -1
- package/build/utils/StoragePaths.js +18 -18
- package/build/utils/StoragePaths.js.map +1 -1
- package/build/utils/logger/ConsoleLogger.d.ts +2 -2
- package/build/utils/logger/ConsoleLogger.d.ts.map +1 -1
- package/build/utils/logger/ConsoleLogger.js +1 -1
- package/build/utils/logger/ConsoleLogger.js.map +1 -1
- package/build/utils/logger/Logger.d.ts.map +1 -1
- package/build/utils/logger/LoggerFactory.d.ts +1 -1
- package/build/utils/logger/LoggerFactory.d.ts.map +1 -1
- package/build/utils/logger/LoggerFactory.js +2 -2
- package/build/utils/logger/LoggerFactory.js.map +1 -1
- package/package.json +22 -8
- package/src/WireAppSdk.ts +78 -65
- package/src/api/AssetsApiClient.ts +20 -35
- package/src/api/AssetsTransferService.ts +20 -32
- package/src/api/ClientsApiClient.ts +16 -29
- package/src/api/ClientsService.ts +7 -14
- package/src/api/ConversationService.ts +221 -154
- package/src/api/ConversationsApiClient.ts +25 -29
- package/src/api/FeatureConfigsApiClient.ts +4 -4
- package/src/api/FeatureConfigsService.ts +17 -17
- package/src/api/MlsApiClient.ts +23 -31
- package/src/api/MlsService.ts +31 -41
- package/src/api/NotificationsApiClient.ts +27 -32
- package/src/api/OneToOneConversationsApiClient.ts +7 -10
- package/src/api/SearchApiClient.ts +20 -22
- package/src/api/SelfApiClient.ts +30 -0
- package/src/api/SelfService.ts +81 -0
- package/src/api/TeamsApiClient.ts +10 -10
- package/src/api/UserService.ts +43 -38
- package/src/api/UsersApiClient.ts +27 -23
- package/src/api/model/AddMembersToConversationResult.ts +15 -15
- package/src/api/model/ConversationIdsPaginationConfig.ts +14 -14
- package/src/api/model/ConversationMemberOtherResponse.ts +16 -16
- package/src/api/model/ConversationMemberSelfResponse.ts +16 -16
- package/src/api/model/ConversationMembersResponse.ts +17 -17
- package/src/api/model/RemoveMembersFromConversationResult.ts +15 -15
- package/src/api/model/UserClientResponse.ts +14 -14
- package/src/api/model/UserResponse.ts +18 -16
- package/src/api/model/asset/AssetUploadData.ts +2 -2
- package/src/api/model/asset/AssetUploadResponse.ts +3 -3
- package/src/api/request/CapabilitiesRequest.ts +15 -15
- package/src/api/request/ClientUpdateRequest.ts +15 -15
- package/src/api/request/ConversationIdsRequest.ts +15 -15
- package/src/api/request/CreateConversationRequest.ts +11 -14
- package/src/api/request/MlsKeyPackagesRequest.ts +14 -14
- package/src/api/request/PreKeyRequest.ts +15 -18
- package/src/api/request/RegisterClientRequest.ts +19 -21
- package/src/api/response/ClaimedKeyPackageList.ts +18 -18
- package/src/api/response/ConversationIdsResponse.ts +15 -15
- package/src/api/response/ConversationResponse.ts +18 -18
- package/src/api/response/ConversationsResponse.ts +16 -16
- package/src/api/response/EventResponse.ts +17 -17
- package/src/api/response/FeatureConfigsResponse.ts +15 -15
- package/src/api/response/ListUsersResponse.ts +23 -0
- package/src/api/response/MlsPublicKeysResponse.ts +24 -23
- package/src/api/response/NotificationsResponse.ts +15 -15
- package/src/api/response/OneToOneConversationResponse.ts +16 -17
- package/src/api/response/RegisterClientResponse.ts +14 -14
- package/src/api/response/SearchContactsResponse.ts +10 -10
- package/src/api/response/SelfResponse.ts +22 -0
- package/src/core/BackendConnectionListener.ts +47 -0
- package/src/core/CoreCryptoClient.ts +93 -117
- package/src/core/CoreCryptoMlsTransport.ts +24 -25
- package/src/core/CoreCryptoService.ts +93 -98
- package/src/core/HttpClient.ts +106 -125
- package/src/core/HttpRetryHelper.ts +6 -9
- package/src/core/HttpRetryPolicy.ts +5 -5
- package/src/core/WebSocketClient.ts +87 -47
- package/src/core/WireApplicationManager.ts +120 -68
- package/src/core/WireEventsHandler.ts +26 -35
- package/src/core/event/DeleteConversationEventProcessor.ts +16 -17
- package/src/core/event/EventProcessor.ts +3 -3
- package/src/core/event/EventRouter.ts +31 -35
- package/src/core/event/MemberJoinEventProcessor.ts +24 -21
- package/src/core/event/MemberLeaveEventProcessor.ts +23 -17
- package/src/core/event/MemberUpdateEventProcessor.ts +15 -16
- package/src/core/event/MessageTimerUpdateEventProcessor.ts +41 -0
- package/src/core/event/MlsMessageEventProcessor.ts +48 -38
- package/src/core/event/MlsResetEventProcessor.ts +13 -16
- package/src/core/event/MlsWelcomeEventProcessor.ts +24 -29
- package/src/core/event/NewConversationEventProcessor.ts +14 -15
- package/src/core/event/processors.index.ts +9 -8
- package/src/db/AppPropertiesRepository.ts +45 -39
- package/src/db/ConversationMemberRepository.ts +85 -77
- package/src/db/ConversationRepository.ts +86 -71
- package/src/db/DatabaseService.ts +34 -32
- package/src/db/migrations/0002_perfect_karnak.sql +1 -0
- package/src/db/migrations/meta/0002_snapshot.json +204 -0
- package/src/db/migrations/meta/_journal.json +7 -0
- package/src/db/model/AppEntity.ts +14 -14
- package/src/db/model/ConversationEntity.ts +16 -15
- package/src/db/model/ConversationMemberEntity.ts +14 -14
- package/src/db/relations.ts +6 -6
- package/src/db/schema.ts +47 -33
- package/src/exception/CoreCryptoMlsException.ts +26 -0
- package/src/exception/MlsException.ts +26 -0
- package/src/exception/WireApiError.ts +21 -0
- package/src/{model/exception → exception}/WireApiException.ts +9 -9
- package/src/exception/WireException.ts +94 -0
- package/src/index.ts +43 -27
- package/src/mappers/PreKeyMapper.ts +16 -16
- package/src/mappers/conversation/ConversationMapper.ts +18 -17
- package/src/mappers/conversation/ConversationMemberMapper.ts +18 -19
- package/src/mappers/protobuf/EncryptionAlgorithmMapper.ts +32 -27
- package/src/mappers/protobuf/MessageContentEncoder.ts +34 -50
- package/src/mappers/protobuf/MessageLinkPreviewMapper.ts +38 -37
- package/src/mappers/protobuf/MessageMentionMapper.ts +22 -22
- package/src/mappers/protobuf/ProtobufDeserializer.ts +78 -72
- package/src/mappers/protobuf/ProtobufSerializer.ts +137 -155
- package/src/model/Asset.ts +18 -18
- package/src/model/ClaimedKeyPackagesResult.ts +17 -17
- package/src/model/CryptoClientId.ts +16 -25
- package/src/model/CryptoProtocol.ts +17 -17
- package/src/model/DecryptedMlsMessage.ts +22 -0
- package/src/model/EventContentDTO.ts +36 -24
- package/src/model/PreKeyCrypto.ts +14 -14
- package/src/model/QualifiedId.ts +25 -18
- package/src/model/TeamId.ts +15 -15
- package/src/model/UserType.ts +21 -0
- package/src/model/WireMessage.ts +164 -196
- package/src/model/WireUser.ts +4 -3
- package/src/model/conversation/ChannelAddPermissionType.ts +2 -3
- package/src/model/conversation/Conversation.ts +16 -15
- package/src/model/conversation/ConversationAccess.ts +5 -6
- package/src/model/conversation/ConversationAccessRole.ts +5 -6
- package/src/model/conversation/ConversationMember.ts +16 -16
- package/src/model/conversation/ConversationRole.ts +17 -18
- package/src/model/conversation/ConversationType.ts +14 -14
- package/src/model/conversation/GroupConversationType.ts +2 -3
- package/src/model/conversation/ReceiptMode.ts +0 -1
- package/src/model/protobuf/MessageEncryptionAlgorithm.ts +18 -15
- package/src/service/AppProperties.ts +76 -40
- package/src/service/MlsFallbackStrategy.ts +21 -24
- package/src/service/NotificationsService.ts +22 -22
- package/src/utils/AESUtils.ts +25 -28
- package/src/utils/BufferUtils.ts +16 -16
- package/src/utils/DependencyInjectionTokens.ts +19 -21
- package/src/utils/HashUtils.ts +15 -15
- package/src/utils/ObfuscateUtil.ts +15 -15
- package/src/utils/StoragePaths.ts +18 -18
- package/src/utils/logger/ConsoleLogger.ts +8 -9
- package/src/utils/logger/LogLevel.ts +1 -1
- package/src/utils/logger/Logger.ts +4 -4
- package/src/utils/logger/LoggerFactory.ts +6 -6
- package/build/model/exception/CoreCryptoMlsException.d.ts.map +0 -1
- package/build/model/exception/CoreCryptoMlsException.js +0 -25
- package/build/model/exception/CoreCryptoMlsException.js.map +0 -1
- package/build/model/exception/MlsException.d.ts.map +0 -1
- package/build/model/exception/MlsException.js +0 -25
- package/build/model/exception/MlsException.js.map +0 -1
- package/build/model/exception/WireApiError.d.ts.map +0 -1
- package/build/model/exception/WireApiError.js +0 -17
- package/build/model/exception/WireApiError.js.map +0 -1
- package/build/model/exception/WireApiException.d.ts.map +0 -1
- package/build/model/exception/WireApiException.js.map +0 -1
- package/src/model/exception/CoreCryptoMlsException.ts +0 -26
- package/src/model/exception/MlsException.ts +0 -26
- package/src/model/exception/WireApiError.ts +0 -21
- /package/build/{model/exception → exception}/CoreCryptoMlsException.d.ts +0 -0
- /package/build/{model/exception → exception}/MlsException.d.ts +0 -0
- /package/build/{model/exception → exception}/WireApiError.d.ts +0 -0
|
@@ -14,32 +14,27 @@
|
|
|
14
14
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {HttpClient} from
|
|
18
|
-
import type {ConversationResponse} from
|
|
19
|
-
import type {QualifiedId} from
|
|
20
|
-
import {
|
|
21
|
-
import type {ConversationIdsPaginationConfig} from
|
|
22
|
-
import type {ConversationIdsResponse} from
|
|
23
|
-
import type {ConversationIdsRequest} from
|
|
24
|
-
import type {ConversationsResponse} from
|
|
25
|
-
import {LoggerFactory} from
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import type {
|
|
29
|
-
import type {CreateConversationRequest} from "./request/CreateConversationRequest.js";
|
|
17
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
18
|
+
import type {ConversationResponse} from './response/ConversationResponse.js'
|
|
19
|
+
import type {QualifiedId} from '../model/QualifiedId.js'
|
|
20
|
+
import {singleton} from 'tsyringe'
|
|
21
|
+
import type {ConversationIdsPaginationConfig} from './model/ConversationIdsPaginationConfig.js'
|
|
22
|
+
import type {ConversationIdsResponse} from './response/ConversationIdsResponse.js'
|
|
23
|
+
import type {ConversationIdsRequest} from './request/ConversationIdsRequest.js'
|
|
24
|
+
import type {ConversationsResponse} from './response/ConversationsResponse.js'
|
|
25
|
+
import {LoggerFactory} from '../utils/logger/LoggerFactory.js'
|
|
26
|
+
import {obfuscateId} from '../utils/ObfuscateUtil.js'
|
|
27
|
+
import type {ConversationRole} from '../model/conversation/ConversationRole.js'
|
|
28
|
+
import type {CreateConversationRequest} from './request/CreateConversationRequest.js'
|
|
30
29
|
|
|
31
30
|
@singleton()
|
|
32
31
|
export class ConversationsApiClient {
|
|
33
|
-
constructor(
|
|
34
|
-
@inject(WIRE_USER_ID) private wireUserId: string,
|
|
35
|
-
@inject(WIRE_USER_DOMAIN) private wireUserDomain: string,
|
|
36
|
-
private httpClient: HttpClient) {
|
|
37
|
-
}
|
|
32
|
+
constructor(private httpClient: HttpClient) {}
|
|
38
33
|
|
|
39
34
|
private logger = LoggerFactory.getLogger(this.constructor.name)
|
|
40
35
|
|
|
41
|
-
private readonly basePath =
|
|
42
|
-
private readonly HEADER_MLS_ACCEPT =
|
|
36
|
+
private readonly basePath = 'conversations'
|
|
37
|
+
private readonly HEADER_MLS_ACCEPT = 'message/mls'
|
|
43
38
|
private readonly CONVERSATION_LIST_IDS_PAGING_SIZE = 100
|
|
44
39
|
|
|
45
40
|
//TODO: Baris: In all ApiClient classes, we should use "fetch" word instead of "get" to be consistent in terms of naming.
|
|
@@ -56,7 +51,7 @@ export class ConversationsApiClient {
|
|
|
56
51
|
async getConversationGroupInfo(conversationQualifiedId: QualifiedId): Promise<Uint8Array> {
|
|
57
52
|
return await this.httpClient.getRequest<Uint8Array>(
|
|
58
53
|
`${this.basePath}/${conversationQualifiedId.domain}/${conversationQualifiedId.id}/groupinfo`,
|
|
59
|
-
{
|
|
54
|
+
{headerAccept: this.HEADER_MLS_ACCEPT}
|
|
60
55
|
)
|
|
61
56
|
}
|
|
62
57
|
|
|
@@ -113,27 +108,28 @@ export class ConversationsApiClient {
|
|
|
113
108
|
userId: QualifiedId,
|
|
114
109
|
newRole: ConversationRole
|
|
115
110
|
): Promise<void> {
|
|
116
|
-
this.logger.debug(
|
|
111
|
+
this.logger.debug(
|
|
112
|
+
`Updating conversation member role. conversationId: ${obfuscateId(conversationId.id)}, userId: ${obfuscateId(userId.id)}, newRole: ${newRole}`
|
|
113
|
+
)
|
|
117
114
|
|
|
118
115
|
const path = `${this.basePath}/${conversationId.domain}/${conversationId.id}/members/${userId.domain}/${userId.id}`
|
|
119
116
|
await this.httpClient.putRequest(path, {conversation_role: newRole})
|
|
120
117
|
|
|
121
|
-
this.logger.debug(
|
|
118
|
+
this.logger.debug(
|
|
119
|
+
`Updated conversation member role. conversationId: ${obfuscateId(conversationId.id)}, userId: ${obfuscateId(userId.id)}, newRole: ${newRole}`
|
|
120
|
+
)
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
// This method is used to create both GROUP and CHANNEL type conversations
|
|
125
124
|
async createGroupConversation(createConversationRequest: CreateConversationRequest): Promise<ConversationResponse> {
|
|
126
125
|
this.logger.info(`Creating group conversation with name: ${createConversationRequest.name}`)
|
|
127
|
-
return await this.httpClient.postRequest<ConversationResponse>(
|
|
128
|
-
this.basePath,
|
|
129
|
-
createConversationRequest
|
|
130
|
-
)
|
|
126
|
+
return await this.httpClient.postRequest<ConversationResponse>(this.basePath, createConversationRequest)
|
|
131
127
|
}
|
|
132
128
|
|
|
133
|
-
async leaveConversation(conversationQualifiedId: QualifiedId): Promise<void> {
|
|
129
|
+
async leaveConversation(conversationQualifiedId: QualifiedId, appQualifiedId: QualifiedId): Promise<void> {
|
|
134
130
|
this.logger.debug(`Leaving the conversation. conversationId: ${obfuscateId(conversationQualifiedId.id)}`)
|
|
135
131
|
|
|
136
|
-
const path = `${this.basePath}/${conversationQualifiedId.domain}/${conversationQualifiedId.id}/members/${
|
|
132
|
+
const path = `${this.basePath}/${conversationQualifiedId.domain}/${conversationQualifiedId.id}/members/${appQualifiedId.domain}/${appQualifiedId.id}`
|
|
137
133
|
await this.httpClient.deleteRequest(path)
|
|
138
134
|
|
|
139
135
|
this.logger.info(`Left the conversation. conversationId: ${obfuscateId(conversationQualifiedId.id)}`)
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {HttpClient} from
|
|
18
|
-
import type {FeatureConfigsResponse} from
|
|
19
|
-
import {
|
|
17
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
18
|
+
import type {FeatureConfigsResponse} from './response/FeatureConfigsResponse.js'
|
|
19
|
+
import {singleton} from 'tsyringe'
|
|
20
20
|
|
|
21
21
|
@singleton()
|
|
22
22
|
export class FeatureConfigsApiClient {
|
|
23
23
|
constructor(private httpClient: HttpClient) {}
|
|
24
24
|
|
|
25
|
-
private readonly basePath =
|
|
25
|
+
private readonly basePath = 'feature-configs'
|
|
26
26
|
|
|
27
27
|
async getFeatureConfigs(): Promise<FeatureConfigsResponse> {
|
|
28
28
|
await this.httpClient.refreshAccessToken()
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2025 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
* You should have received a copy of the GNU General Public License
|
|
14
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
|
-
*/
|
|
2
|
+
* Wire
|
|
3
|
+
* Copyright (C) 2025 Wire Swiss GmbH
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
* You should have received a copy of the GNU General Public License
|
|
14
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
|
+
*/
|
|
16
16
|
|
|
17
|
-
import type {FeatureConfigsResponse} from
|
|
18
|
-
import {FeatureConfigsApiClient} from
|
|
19
|
-
import {
|
|
17
|
+
import type {FeatureConfigsResponse} from './response/FeatureConfigsResponse.js'
|
|
18
|
+
import {FeatureConfigsApiClient} from './FeatureConfigsApiClient.js'
|
|
19
|
+
import {singleton} from 'tsyringe'
|
|
20
20
|
|
|
21
21
|
@singleton()
|
|
22
22
|
export class FeatureConfigsService {
|
package/src/api/MlsApiClient.ts
CHANGED
|
@@ -14,44 +14,40 @@
|
|
|
14
14
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {HttpClient} from
|
|
18
|
-
import {Encoder} from
|
|
19
|
-
import type {MlsKeyPackagesRequest} from
|
|
20
|
-
import {singleton} from
|
|
21
|
-
import type {MlsPublicKeysResponse} from
|
|
22
|
-
import type {ClaimedKeyPackageList} from
|
|
23
|
-
import {AppProperties} from
|
|
17
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
18
|
+
import {Encoder} from 'bazinga64'
|
|
19
|
+
import type {MlsKeyPackagesRequest} from './request/MlsKeyPackagesRequest.js'
|
|
20
|
+
import {singleton} from 'tsyringe'
|
|
21
|
+
import type {MlsPublicKeysResponse} from './response/MlsPublicKeysResponse.js'
|
|
22
|
+
import type {ClaimedKeyPackageList} from './response/ClaimedKeyPackageList.js'
|
|
23
|
+
import {AppProperties} from '../service/AppProperties.js'
|
|
24
24
|
|
|
25
25
|
@singleton()
|
|
26
26
|
export class MlsApiClient {
|
|
27
27
|
constructor(
|
|
28
28
|
private httpClient: HttpClient,
|
|
29
29
|
private appProperties: AppProperties
|
|
30
|
-
) {
|
|
30
|
+
) {}
|
|
31
31
|
|
|
32
|
-
private readonly HEADER_MLS_CONTENT_TYPE =
|
|
33
|
-
private readonly basePath =
|
|
34
|
-
private readonly commitBundlesPath = this.basePath +
|
|
35
|
-
private readonly sendMessagePath = this.basePath +
|
|
36
|
-
private readonly uploadMlsKeyPackagesPath = this.basePath +
|
|
37
|
-
private readonly claimKeyPackagesPath = this.basePath +
|
|
38
|
-
private readonly getPublicKeysPath = this.basePath +
|
|
39
|
-
private readonly CIPHERSUITE_QUERY_PARAM =
|
|
32
|
+
private readonly HEADER_MLS_CONTENT_TYPE = 'message/mls'
|
|
33
|
+
private readonly basePath = 'mls'
|
|
34
|
+
private readonly commitBundlesPath = this.basePath + '/commit-bundles'
|
|
35
|
+
private readonly sendMessagePath = this.basePath + '/messages'
|
|
36
|
+
private readonly uploadMlsKeyPackagesPath = this.basePath + '/key-packages/self/'
|
|
37
|
+
private readonly claimKeyPackagesPath = this.basePath + '/key-packages/claim'
|
|
38
|
+
private readonly getPublicKeysPath = this.basePath + '/public-keys'
|
|
39
|
+
private readonly CIPHERSUITE_QUERY_PARAM = 'ciphersuite'
|
|
40
40
|
|
|
41
41
|
async uploadCommitBundle(commitBundle: Uint8Array): Promise<void> {
|
|
42
|
-
await this.httpClient.postRequest<void>(
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
)
|
|
42
|
+
await this.httpClient.postRequest<void>(this.commitBundlesPath, commitBundle, {
|
|
43
|
+
headerContentType: this.HEADER_MLS_CONTENT_TYPE
|
|
44
|
+
})
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
async sendMessage(message: Uint8Array): Promise<void> {
|
|
50
|
-
await this.httpClient.postRequest<void>(
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
)
|
|
48
|
+
await this.httpClient.postRequest<void>(this.sendMessagePath, message, {
|
|
49
|
+
headerContentType: this.HEADER_MLS_CONTENT_TYPE
|
|
50
|
+
})
|
|
55
51
|
}
|
|
56
52
|
|
|
57
53
|
async uploadMlsKeyPackages(mlsKeyPackages: Uint8Array[]): Promise<void> {
|
|
@@ -70,11 +66,7 @@ export class MlsApiClient {
|
|
|
70
66
|
return await this.httpClient.getRequest<MlsPublicKeysResponse>(this.getPublicKeysPath)
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
async claimKeyPackages(
|
|
74
|
-
userId: string,
|
|
75
|
-
userDomain: string,
|
|
76
|
-
ciphersuite: string
|
|
77
|
-
): Promise<ClaimedKeyPackageList> {
|
|
69
|
+
async claimKeyPackages(userId: string, userDomain: string, ciphersuite: string): Promise<ClaimedKeyPackageList> {
|
|
78
70
|
const path = `${this.claimKeyPackagesPath}/${userDomain}/${userId}?${this.CIPHERSUITE_QUERY_PARAM}=${ciphersuite}`
|
|
79
71
|
return await this.httpClient.postRequest<ClaimedKeyPackageList>(path)
|
|
80
72
|
}
|
package/src/api/MlsService.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2025 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
* You should have received a copy of the GNU General Public License
|
|
14
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
|
-
*/
|
|
2
|
+
* Wire
|
|
3
|
+
* Copyright (C) 2025 Wire Swiss GmbH
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
* You should have received a copy of the GNU General Public License
|
|
14
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
|
+
*/
|
|
16
16
|
|
|
17
|
-
import {singleton} from
|
|
18
|
-
import {MlsApiClient} from
|
|
19
|
-
import type {CipherSuite} from
|
|
20
|
-
import {getRemovalKeyFromPublicKeysResponse, type MlsPublicKeysResponse} from
|
|
21
|
-
import type {ClaimedKeyPackagesResult} from
|
|
22
|
-
import type {QualifiedId} from
|
|
23
|
-
import type {KeyPackage} from
|
|
24
|
-
import {LoggerFactory} from
|
|
25
|
-
import {obfuscateId} from
|
|
26
|
-
import {Decoder} from
|
|
17
|
+
import {singleton} from 'tsyringe'
|
|
18
|
+
import {MlsApiClient} from './MlsApiClient.js'
|
|
19
|
+
import type {CipherSuite} from '@wireapp/core-crypto/native'
|
|
20
|
+
import {getRemovalKeyFromPublicKeysResponse, type MlsPublicKeysResponse} from './response/MlsPublicKeysResponse.js'
|
|
21
|
+
import type {ClaimedKeyPackagesResult} from '../model/ClaimedKeyPackagesResult.js'
|
|
22
|
+
import type {QualifiedId} from '../model/QualifiedId.js'
|
|
23
|
+
import type {KeyPackage} from './response/ClaimedKeyPackageList.js'
|
|
24
|
+
import {LoggerFactory} from '../utils/logger/LoggerFactory.js'
|
|
25
|
+
import {obfuscateId} from '../utils/ObfuscateUtil.js'
|
|
26
|
+
import {Decoder} from 'bazinga64'
|
|
27
27
|
|
|
28
28
|
@singleton()
|
|
29
29
|
export class MlsService {
|
|
30
30
|
private logger = LoggerFactory.getLogger(this.constructor.name)
|
|
31
31
|
|
|
32
|
-
constructor(private mlsApiClient: MlsApiClient) {
|
|
32
|
+
constructor(private mlsApiClient: MlsApiClient) {}
|
|
33
33
|
|
|
34
34
|
async uploadCommitBundle(commitBundle: Uint8Array): Promise<void> {
|
|
35
35
|
await this.mlsApiClient.uploadCommitBundle(commitBundle)
|
|
@@ -47,15 +47,11 @@ export class MlsService {
|
|
|
47
47
|
cipherSuite: CipherSuite,
|
|
48
48
|
existingPublicKeysResponse?: MlsPublicKeysResponse
|
|
49
49
|
): Promise<Uint8Array | null> {
|
|
50
|
-
const publicKeysResponse = existingPublicKeysResponse ?? await this.mlsApiClient.getPublicKeys()
|
|
50
|
+
const publicKeysResponse = existingPublicKeysResponse ?? (await this.mlsApiClient.getPublicKeys())
|
|
51
51
|
return getRemovalKeyFromPublicKeysResponse(publicKeysResponse, cipherSuite)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
async claimKeyPackages(
|
|
55
|
-
users: QualifiedId[],
|
|
56
|
-
ciphersuite: number
|
|
57
|
-
): Promise<ClaimedKeyPackagesResult> {
|
|
58
|
-
|
|
54
|
+
async claimKeyPackages(users: QualifiedId[], ciphersuite: number): Promise<ClaimedKeyPackagesResult> {
|
|
59
55
|
const claimedKeyPackages: KeyPackage[] = []
|
|
60
56
|
const successUsers: QualifiedId[] = []
|
|
61
57
|
const failedUsers: QualifiedId[] = []
|
|
@@ -64,11 +60,7 @@ export class MlsService {
|
|
|
64
60
|
|
|
65
61
|
for (const user of users) {
|
|
66
62
|
try {
|
|
67
|
-
const result = await this.mlsApiClient.claimKeyPackages(
|
|
68
|
-
user.id,
|
|
69
|
-
user.domain,
|
|
70
|
-
ciphersuiteHex
|
|
71
|
-
)
|
|
63
|
+
const result = await this.mlsApiClient.claimKeyPackages(user.id, user.domain, ciphersuiteHex)
|
|
72
64
|
|
|
73
65
|
if (result.key_packages.length > 0) {
|
|
74
66
|
successUsers.push(user)
|
|
@@ -78,14 +70,12 @@ export class MlsService {
|
|
|
78
70
|
// Ignoring when claiming key packages fails for a user
|
|
79
71
|
// as for now there is no retry
|
|
80
72
|
failedUsers.push(user)
|
|
81
|
-
this.logger.error(
|
|
82
|
-
`Error when claiming key packages for userId: ${obfuscateId(user.id)}: ${exception}`
|
|
83
|
-
)
|
|
73
|
+
this.logger.error(`Error when claiming key packages for userId: ${obfuscateId(user.id)}: ${exception}`)
|
|
84
74
|
}
|
|
85
75
|
}
|
|
86
76
|
|
|
87
77
|
return {
|
|
88
|
-
keyPackages: claimedKeyPackages.map(claimedKeyPackage => {
|
|
78
|
+
keyPackages: claimedKeyPackages.map((claimedKeyPackage) => {
|
|
89
79
|
return Decoder.fromBase64(claimedKeyPackage.key_package).asBytes
|
|
90
80
|
}),
|
|
91
81
|
successUsers: successUsers,
|
|
@@ -94,6 +84,6 @@ export class MlsService {
|
|
|
94
84
|
}
|
|
95
85
|
|
|
96
86
|
private toHexString(value: number, minDigits: number = 4): string {
|
|
97
|
-
return
|
|
87
|
+
return '0x' + value.toString(16).padStart(minDigits, '0')
|
|
98
88
|
}
|
|
99
89
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2026 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
* You should have received a copy of the GNU General Public License
|
|
14
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import {singleton} from
|
|
18
|
-
import {HttpClient} from
|
|
19
|
-
import type {EventResponse} from
|
|
20
|
-
import type {NotificationsResponse} from
|
|
21
|
-
import {AppProperties} from
|
|
2
|
+
* Wire
|
|
3
|
+
* Copyright (C) 2026 Wire Swiss GmbH
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
* You should have received a copy of the GNU General Public License
|
|
14
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {singleton} from 'tsyringe'
|
|
18
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
19
|
+
import type {EventResponse} from './response/EventResponse.js'
|
|
20
|
+
import type {NotificationsResponse} from './response/NotificationsResponse.js'
|
|
21
|
+
import {AppProperties} from '../service/AppProperties.js'
|
|
22
22
|
|
|
23
23
|
@singleton()
|
|
24
24
|
export class NotificationsApiClient {
|
|
@@ -27,25 +27,20 @@ export class NotificationsApiClient {
|
|
|
27
27
|
private appProperties: AppProperties
|
|
28
28
|
) {}
|
|
29
29
|
|
|
30
|
-
private readonly basePath =
|
|
31
|
-
private readonly lastNotificationPath = this.basePath +
|
|
32
|
-
private readonly CLIENT_QUERY_KEY =
|
|
33
|
-
private readonly SINCE_QUERY_KEY =
|
|
34
|
-
private readonly SIZE_QUERY_KEY =
|
|
30
|
+
private readonly basePath = 'notifications'
|
|
31
|
+
private readonly lastNotificationPath = this.basePath + '/last'
|
|
32
|
+
private readonly CLIENT_QUERY_KEY = 'client'
|
|
33
|
+
private readonly SINCE_QUERY_KEY = 'since'
|
|
34
|
+
private readonly SIZE_QUERY_KEY = 'size'
|
|
35
35
|
|
|
36
36
|
async getLastNotification(): Promise<EventResponse> {
|
|
37
37
|
const storedDeviceId = this.appProperties.getDeviceId()
|
|
38
38
|
const path = `${this.lastNotificationPath}?${this.CLIENT_QUERY_KEY}=${storedDeviceId}`
|
|
39
39
|
|
|
40
|
-
return await this.httpClient.getRequest<EventResponse>(
|
|
41
|
-
path
|
|
42
|
-
)
|
|
40
|
+
return await this.httpClient.getRequest<EventResponse>(path)
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
async getPaginatedNotifications(
|
|
46
|
-
querySize: number,
|
|
47
|
-
querySince?: string
|
|
48
|
-
): Promise<NotificationsResponse> {
|
|
43
|
+
async getPaginatedNotifications(querySize: number, querySince?: string): Promise<NotificationsResponse> {
|
|
49
44
|
const storedDeviceId = this.appProperties.getDeviceId()
|
|
50
45
|
|
|
51
46
|
let path = `${this.basePath}?${this.SIZE_QUERY_KEY}=${querySize}&${this.CLIENT_QUERY_KEY}=${storedDeviceId}`
|
|
@@ -14,20 +14,18 @@
|
|
|
14
14
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {HttpClient} from
|
|
18
|
-
import type {QualifiedId} from
|
|
19
|
-
import {singleton} from
|
|
20
|
-
import {LoggerFactory} from
|
|
21
|
-
import type {OneToOneConversationResponse} from
|
|
17
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
18
|
+
import type {QualifiedId} from '../model/QualifiedId.js'
|
|
19
|
+
import {singleton} from 'tsyringe'
|
|
20
|
+
import {LoggerFactory} from '../utils/logger/LoggerFactory.js'
|
|
21
|
+
import type {OneToOneConversationResponse} from './response/OneToOneConversationResponse.js'
|
|
22
22
|
|
|
23
23
|
@singleton()
|
|
24
24
|
export class OneToOneConversationsApiClient {
|
|
25
|
-
constructor(
|
|
26
|
-
private httpClient: HttpClient) {
|
|
27
|
-
}
|
|
25
|
+
constructor(private httpClient: HttpClient) {}
|
|
28
26
|
|
|
29
27
|
private logger = LoggerFactory.getLogger(this.constructor.name)
|
|
30
|
-
private readonly basePath =
|
|
28
|
+
private readonly basePath = 'one2one-conversations'
|
|
31
29
|
|
|
32
30
|
async getOneToOneConversation(userId: QualifiedId): Promise<OneToOneConversationResponse> {
|
|
33
31
|
this.logger.debug(`Getting OneToOne conversation. userId: ${userId}`)
|
|
@@ -35,5 +33,4 @@ export class OneToOneConversationsApiClient {
|
|
|
35
33
|
`${this.basePath}/${userId.domain}/${userId.id}`
|
|
36
34
|
)
|
|
37
35
|
}
|
|
38
|
-
|
|
39
36
|
}
|
|
@@ -14,45 +14,43 @@
|
|
|
14
14
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {HttpClient} from
|
|
18
|
-
import {singleton} from
|
|
19
|
-
import type {SearchContactsResponse} from
|
|
17
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
18
|
+
import {singleton} from 'tsyringe'
|
|
19
|
+
import type {SearchContactsResponse} from './response/SearchContactsResponse.js'
|
|
20
|
+
import {InvalidParameterError} from '../exception/WireException.js'
|
|
20
21
|
|
|
21
|
-
const DEFAULT_RESULT_SIZE = 15
|
|
22
|
-
const MIN_RESULT_SIZE = 1
|
|
23
|
-
const MAX_RESULT_SIZE = 500
|
|
22
|
+
const DEFAULT_RESULT_SIZE = 15
|
|
23
|
+
const MIN_RESULT_SIZE = 1
|
|
24
|
+
const MAX_RESULT_SIZE = 500
|
|
24
25
|
|
|
25
26
|
@singleton()
|
|
26
27
|
export class SearchApiClient {
|
|
27
|
-
constructor(private httpClient: HttpClient) {
|
|
28
|
-
}
|
|
28
|
+
constructor(private httpClient: HttpClient) {}
|
|
29
29
|
|
|
30
|
-
private readonly basePath =
|
|
30
|
+
private readonly basePath = 'search'
|
|
31
31
|
|
|
32
|
-
async searchUsers(
|
|
33
|
-
|
|
34
|
-
domain: string,
|
|
35
|
-
numberOfResults?: number
|
|
36
|
-
): Promise<SearchContactsResponse> {
|
|
37
|
-
const size = numberOfResults ?? DEFAULT_RESULT_SIZE;
|
|
32
|
+
async searchUsers(query: string, domain: string, numberOfResults?: number): Promise<SearchContactsResponse> {
|
|
33
|
+
const size = numberOfResults ?? DEFAULT_RESULT_SIZE
|
|
38
34
|
|
|
39
35
|
if (size < MIN_RESULT_SIZE || size > MAX_RESULT_SIZE) {
|
|
40
|
-
throw new
|
|
36
|
+
throw new InvalidParameterError(
|
|
37
|
+
`Number of results value must be between ${MIN_RESULT_SIZE} and ${MAX_RESULT_SIZE}. Value provided: ${size}`
|
|
38
|
+
)
|
|
41
39
|
}
|
|
42
40
|
if (!query.trim()) {
|
|
43
|
-
throw new
|
|
41
|
+
throw new InvalidParameterError('Search query must not be blank.')
|
|
44
42
|
}
|
|
45
43
|
if (!domain.trim()) {
|
|
46
|
-
throw new
|
|
44
|
+
throw new InvalidParameterError('Domain must not be blank.')
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
const params = new URLSearchParams({
|
|
50
48
|
q: query,
|
|
51
49
|
domain,
|
|
52
|
-
type:
|
|
53
|
-
size: String(size)
|
|
54
|
-
})
|
|
50
|
+
type: 'regular',
|
|
51
|
+
size: String(size)
|
|
52
|
+
})
|
|
55
53
|
|
|
56
|
-
return await this.httpClient.getRequest<SearchContactsResponse>(`${this.basePath}/contacts?${params}`)
|
|
54
|
+
return await this.httpClient.getRequest<SearchContactsResponse>(`${this.basePath}/contacts?${params}`)
|
|
57
55
|
}
|
|
58
56
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Wire
|
|
3
|
+
* Copyright (C) 2026 Wire Swiss GmbH
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
* You should have received a copy of the GNU General Public License
|
|
14
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {singleton} from 'tsyringe'
|
|
18
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
19
|
+
import type {SelfResponse} from './response/SelfResponse.js'
|
|
20
|
+
|
|
21
|
+
@singleton()
|
|
22
|
+
export class SelfApiClient {
|
|
23
|
+
constructor(private httpClient: HttpClient) {}
|
|
24
|
+
|
|
25
|
+
private readonly basePath = 'self'
|
|
26
|
+
|
|
27
|
+
async getSelf(): Promise<SelfResponse> {
|
|
28
|
+
return await this.httpClient.getRequest<SelfResponse>(this.basePath)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Wire
|
|
3
|
+
* Copyright (C) 2026 Wire Swiss GmbH
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
* You should have received a copy of the GNU General Public License
|
|
14
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {singleton} from 'tsyringe'
|
|
18
|
+
import {SelfApiClient} from './SelfApiClient.js'
|
|
19
|
+
import {AppProperties} from '../service/AppProperties.js'
|
|
20
|
+
import {QualifiedId} from '../model/QualifiedId.js'
|
|
21
|
+
import {LoggerFactory} from '../utils/logger/LoggerFactory.js'
|
|
22
|
+
import {InvalidParameterError, UnknownError} from '../exception/WireException.js'
|
|
23
|
+
import {TeamId} from '../model/TeamId.js'
|
|
24
|
+
|
|
25
|
+
@singleton()
|
|
26
|
+
export class SelfService {
|
|
27
|
+
private logger = LoggerFactory.getLogger(this.constructor.name)
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
private selfApiClient: SelfApiClient,
|
|
31
|
+
private appProperties: AppProperties
|
|
32
|
+
) {}
|
|
33
|
+
|
|
34
|
+
async fetchAndSaveApplicationData(): Promise<void> {
|
|
35
|
+
const response = await this.selfApiClient.getSelf()
|
|
36
|
+
const appUserId = new QualifiedId(response.qualified_id.id, response.qualified_id.domain)
|
|
37
|
+
|
|
38
|
+
this.saveApplicationQualifiedId(appUserId)
|
|
39
|
+
this.saveApplicationTeamId(response.team)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private saveApplicationQualifiedId(appUserId: QualifiedId): void {
|
|
43
|
+
if (!this.appProperties.hasApplicationQualifiedId()) {
|
|
44
|
+
this.logger.info(`Saving application QualifiedId: ${appUserId}`)
|
|
45
|
+
this.appProperties.saveApplicationQualifiedId(appUserId)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const storedApplicationQualifiedId = this.appProperties.getApplicationQualifiedId()
|
|
50
|
+
if (!QualifiedId.equals(storedApplicationQualifiedId, appUserId)) {
|
|
51
|
+
throw new UnknownError(
|
|
52
|
+
`Stored application QualifiedId ${storedApplicationQualifiedId} does not match fetched self QualifiedId ${appUserId}. Clear SDK storage before using a token for another app.`
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.logger.info(`Application QualifiedId already stored: ${storedApplicationQualifiedId}`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private saveApplicationTeamId(teamId?: string): void {
|
|
60
|
+
if (!teamId) {
|
|
61
|
+
throw new InvalidParameterError('The Application does not belong to a team')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const applicationTeamId = new TeamId(teamId)
|
|
65
|
+
|
|
66
|
+
if (!this.appProperties.hasApplicationTeamId()) {
|
|
67
|
+
this.logger.info(`Saving application TeamId: ${applicationTeamId}`)
|
|
68
|
+
this.appProperties.saveApplicationTeamId(applicationTeamId.value)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const storedApplicationTeamId = this.appProperties.getApplicationTeamId()
|
|
73
|
+
if (storedApplicationTeamId.value !== applicationTeamId.value) {
|
|
74
|
+
throw new UnknownError(
|
|
75
|
+
`Stored application TeamId ${storedApplicationTeamId} does not match fetched self TeamId ${applicationTeamId}. Clear SDK storage before using a token for another app.`
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this.logger.info(`Application TeamId already stored: ${applicationTeamId}`)
|
|
80
|
+
}
|
|
81
|
+
}
|