@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoragePaths.js","sourceRoot":"","sources":["../../src/utils/StoragePaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"StoragePaths.js","sourceRoot":"","sources":["../../src/utils/StoragePaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAE9B,4EAA4E;AAC5E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAA;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LogLevel } from
|
|
2
|
-
import type { Logger } from
|
|
1
|
+
import { LogLevel } from './LogLevel.js';
|
|
2
|
+
import type { Logger } from './Logger.js';
|
|
3
3
|
export declare class ConsoleLogger implements Logger {
|
|
4
4
|
private minLevel;
|
|
5
5
|
constructor(minLevel?: LogLevel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAEvC,qBAAa,aAAc,YAAW,MAAM;IAC9B,OAAO,CAAC,QAAQ;gBAAR,QAAQ,GAAE,QAAwB;IAEtD,OAAO,CAAC,SAAS;IAIjB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMhD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAKjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleLogger.js","sourceRoot":"","sources":["../../../src/utils/logger/ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"ConsoleLogger.js","sourceRoot":"","sources":["../../../src/utils/logger/ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AAGtC,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,WAAqB,QAAQ,CAAC,IAAI;QAAlC,aAAQ,GAAR,QAAQ,CAA0B;IAAG,CAAC;IAElD,SAAS,CAAC,KAAe;QAC/B,OAAO,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAe;QACtC,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAe;QACtC,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/Logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/Logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAEhD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAE/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAE/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;CACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerFactory.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/LoggerFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"LoggerFactory.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/LoggerFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAGvC,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAQ;IAEjC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI1C,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;CAgB5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConsoleLogger } from
|
|
1
|
+
import { ConsoleLogger } from './ConsoleLogger.js';
|
|
2
2
|
export class LoggerFactory {
|
|
3
3
|
static rootLogger;
|
|
4
4
|
static setRootLogger(logger) {
|
|
@@ -12,7 +12,7 @@ export class LoggerFactory {
|
|
|
12
12
|
debug: (message, ...meta) => LoggerFactory.rootLogger.debug(`[${namespace}] ${message}`, ...meta),
|
|
13
13
|
info: (message, ...meta) => LoggerFactory.rootLogger.info(`[${namespace}] ${message}`, ...meta),
|
|
14
14
|
warn: (message, ...meta) => LoggerFactory.rootLogger.warn(`[${namespace}] ${message}`, ...meta),
|
|
15
|
-
error: (message, ...meta) => LoggerFactory.rootLogger.error(`[${namespace}] ${message}`, ...meta)
|
|
15
|
+
error: (message, ...meta) => LoggerFactory.rootLogger.error(`[${namespace}] ${message}`, ...meta)
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerFactory.js","sourceRoot":"","sources":["../../../src/utils/logger/LoggerFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"LoggerFactory.js","sourceRoot":"","sources":["../../../src/utils/logger/LoggerFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAEhD,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,UAAU,CAAQ;IAEjC,MAAM,CAAC,aAAa,CAAC,MAAc;QACjC,aAAa,CAAC,UAAU,GAAG,MAAM,CAAA;IACnC,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,SAAiB;QAChC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;YAC9B,aAAa,CAAC,UAAU,GAAG,IAAI,aAAa,EAAE,CAAA;QAChD,CAAC;QAED,OAAO;YACL,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC7C,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;YACtE,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC5C,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;YACrE,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC5C,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;YACrE,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC7C,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;SACvE,CAAA;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wireapp/wire-apps-js-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-alpha",
|
|
4
4
|
"description": "SDK for Wire third-party applications written in Typescript.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"keywords": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"proto:generate": "npm run proto:mkdir && npm run proto:package && npm run proto:js && npm run proto:ts",
|
|
39
39
|
"build": "npm run proto:generate && tsc -p tsconfig.json && npm run proto:copy && npm run migrations:copy",
|
|
40
40
|
"prepack": "npm run build",
|
|
41
|
-
"release:check": "npm run lint && npm run build && npm run -w sample build && npm run test:coverage -- --no-cache && npm run test:pack && npm pack --dry-run --cache /tmp/wire-sdk-release-npm-cache",
|
|
41
|
+
"release:check": "npm run lint && npm run format:check && npm run build && npm run -w sample build && npm run test:coverage -- --no-cache && npm run test:pack && npm pack --dry-run --cache /tmp/wire-sdk-release-npm-cache",
|
|
42
42
|
"sample": "npm run -w sample dev",
|
|
43
43
|
"test": "npm run test:typecheck",
|
|
44
44
|
"test:pack": "node scripts/verify-packed-install.js",
|
|
@@ -46,7 +46,17 @@
|
|
|
46
46
|
"test:coverage": "vitest run --coverage --typecheck --typecheck.tsconfig tsconfig.test.json",
|
|
47
47
|
"clean": "rm -rf ./build ./sample/build ./sample/storage ./src/generated",
|
|
48
48
|
"clean:all": "npm run clean && rm -rf ./node_modules",
|
|
49
|
-
"lint": "eslint src
|
|
49
|
+
"lint": "eslint src test drizzle.config.ts vitest.config.ts",
|
|
50
|
+
"lint:fix": "eslint src test drizzle.config.ts vitest.config.ts --fix",
|
|
51
|
+
"format": "prettier --write .",
|
|
52
|
+
"format:check": "prettier --check .",
|
|
53
|
+
"prepare": "husky || true"
|
|
54
|
+
},
|
|
55
|
+
"lint-staged": {
|
|
56
|
+
"*.ts": "prettier --write",
|
|
57
|
+
"{src,test,scripts}/**/*.ts": "eslint --fix",
|
|
58
|
+
"drizzle.config.ts": "eslint --fix",
|
|
59
|
+
"vitest.config.ts": "eslint --fix"
|
|
50
60
|
},
|
|
51
61
|
"files": [
|
|
52
62
|
"build/**/*",
|
|
@@ -57,7 +67,7 @@
|
|
|
57
67
|
],
|
|
58
68
|
"type": "module",
|
|
59
69
|
"engines": {
|
|
60
|
-
"node": "
|
|
70
|
+
"node": "22.22.1"
|
|
61
71
|
},
|
|
62
72
|
"repository": {
|
|
63
73
|
"type": "git",
|
|
@@ -82,19 +92,23 @@
|
|
|
82
92
|
"dotenv": "^17.4.2",
|
|
83
93
|
"drizzle-kit": "^0.31.9",
|
|
84
94
|
"eslint": "^10.7.0",
|
|
95
|
+
"eslint-config-prettier": "^10.1.8",
|
|
85
96
|
"globals": "^17.7.0",
|
|
97
|
+
"husky": "^9.1.7",
|
|
98
|
+
"lint-staged": "^17.3.0",
|
|
86
99
|
"msw": "^2.14.6",
|
|
100
|
+
"prettier": "^3.9.6",
|
|
87
101
|
"protobufjs-cli": "^2.6.1",
|
|
88
102
|
"typescript": "^6.0.3",
|
|
89
103
|
"typescript-eslint": "^8.65.0",
|
|
90
104
|
"vitest": "^4.1.10"
|
|
91
105
|
},
|
|
92
106
|
"dependencies": {
|
|
93
|
-
"@ubjs/core": "
|
|
94
|
-
"@ubjs/node": "
|
|
95
|
-
"@wireapp/core-crypto": "^10.
|
|
107
|
+
"@ubjs/core": "0.31.0-3",
|
|
108
|
+
"@ubjs/node": "0.31.0-3",
|
|
109
|
+
"@wireapp/core-crypto": "^10.3.0",
|
|
96
110
|
"bazinga64": "^6.5.13",
|
|
97
|
-
"better-sqlite3": "^
|
|
111
|
+
"better-sqlite3": "^13.0.2",
|
|
98
112
|
"drizzle-orm": "^0.45.1",
|
|
99
113
|
"long": "^5.3.2",
|
|
100
114
|
"protobufjs": "^8.7.1",
|
package/src/WireAppSdk.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
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
|
-
*/
|
|
16
|
-
|
|
17
|
-
import
|
|
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
|
+
|
|
17
|
+
import 'reflect-metadata'
|
|
18
18
|
import './core/event/processors.index.js'
|
|
19
|
-
import {mkdirSync} from
|
|
20
|
-
import {CoreCryptoService} from
|
|
19
|
+
import {mkdirSync} from 'node:fs'
|
|
20
|
+
import {CoreCryptoService} from './core/CoreCryptoService.js'
|
|
21
21
|
import {
|
|
22
22
|
WIRE_API_HOST,
|
|
23
23
|
WIRE_CRYPTOGRAPHY_STORAGE_KEY,
|
|
24
24
|
WIRE_EVENTS_HANDLER,
|
|
25
|
-
WIRE_USER_DOMAIN,
|
|
26
|
-
WIRE_USER_ID,
|
|
27
25
|
WIRE_SDK_API_TOKEN
|
|
28
|
-
} from
|
|
29
|
-
import {WebSocketClient} from
|
|
30
|
-
import {WireEventsHandler} from
|
|
31
|
-
import {DatabaseService} from
|
|
32
|
-
import {container} from
|
|
33
|
-
import type {Logger} from
|
|
34
|
-
import {LoggerFactory} from
|
|
35
|
-
import {ConsoleLogger} from
|
|
36
|
-
import {ConversationService} from
|
|
37
|
-
import {AppProperties} from
|
|
38
|
-
import {CRYPTOGRAPHY_STORAGE_PATH, STORAGE_PATH} from
|
|
26
|
+
} from './utils/DependencyInjectionTokens.js'
|
|
27
|
+
import {WebSocketClient} from './core/WebSocketClient.js'
|
|
28
|
+
import {WireEventsHandler} from './core/WireEventsHandler.js'
|
|
29
|
+
import {DatabaseService} from './db/DatabaseService.js'
|
|
30
|
+
import {container} from 'tsyringe'
|
|
31
|
+
import type {Logger} from './utils/logger/Logger.js'
|
|
32
|
+
import {LoggerFactory} from './utils/logger/LoggerFactory.js'
|
|
33
|
+
import {ConsoleLogger} from './utils/logger/ConsoleLogger.js'
|
|
34
|
+
import {ConversationService} from './api/ConversationService.js'
|
|
35
|
+
import {AppProperties} from './service/AppProperties.js'
|
|
36
|
+
import {CRYPTOGRAPHY_STORAGE_PATH, STORAGE_PATH} from './utils/StoragePaths.js'
|
|
37
|
+
import type {BackendConnectionListener} from './core/BackendConnectionListener.js'
|
|
38
|
+
import {InvalidParameterError, UnknownError} from './exception/WireException.js'
|
|
39
|
+
import {SelfService} from './api/SelfService.js'
|
|
40
|
+
import {WireApplicationManager} from './core/WireApplicationManager.js'
|
|
39
41
|
|
|
40
42
|
export class WireAppSdk {
|
|
41
43
|
private readonly CRYPTOGRAPHY_STORAGE_KEY_BYTES = 32
|
|
42
|
-
private userId: string
|
|
43
44
|
private apiToken: string
|
|
44
|
-
private userDomain: string
|
|
45
45
|
private apiHost: string
|
|
46
46
|
private cryptographyStorageKey: Uint8Array
|
|
47
47
|
|
|
@@ -56,24 +56,19 @@ export class WireAppSdk {
|
|
|
56
56
|
private logger: Logger
|
|
57
57
|
|
|
58
58
|
private constructor(
|
|
59
|
-
userId: string,
|
|
60
59
|
apiToken: string,
|
|
61
|
-
userDomain: string,
|
|
62
60
|
apiHost: string,
|
|
63
61
|
cryptographyStorageKey: Uint8Array,
|
|
64
62
|
wireEventsHandler: WireEventsHandler,
|
|
65
63
|
logger?: Logger
|
|
66
64
|
) {
|
|
67
65
|
if (cryptographyStorageKey.length !== this.CRYPTOGRAPHY_STORAGE_KEY_BYTES) {
|
|
68
|
-
throw new
|
|
66
|
+
throw new InvalidParameterError(
|
|
69
67
|
`cryptographyStorageKey must be exactly ${this.CRYPTOGRAPHY_STORAGE_KEY_BYTES} bytes long`
|
|
70
|
-
)
|
|
68
|
+
)
|
|
71
69
|
}
|
|
72
|
-
|
|
73
70
|
|
|
74
|
-
this.userId = userId
|
|
75
71
|
this.apiToken = apiToken
|
|
76
|
-
this.userDomain = userDomain
|
|
77
72
|
this.apiHost = apiHost
|
|
78
73
|
this.cryptographyStorageKey = cryptographyStorageKey
|
|
79
74
|
this.wireEventsHandler = wireEventsHandler
|
|
@@ -82,23 +77,13 @@ export class WireAppSdk {
|
|
|
82
77
|
}
|
|
83
78
|
|
|
84
79
|
static async create(
|
|
85
|
-
userId: string,
|
|
86
80
|
apiToken: string,
|
|
87
|
-
userDomain: string,
|
|
88
81
|
apiHost: string,
|
|
89
82
|
cryptographyStorageKey: Uint8Array,
|
|
90
83
|
wireEventsHandler: WireEventsHandler,
|
|
91
|
-
logger?: Logger
|
|
84
|
+
logger?: Logger
|
|
92
85
|
): Promise<WireAppSdk> {
|
|
93
|
-
const wireAppSdk = new WireAppSdk(
|
|
94
|
-
userId,
|
|
95
|
-
apiToken,
|
|
96
|
-
userDomain,
|
|
97
|
-
apiHost,
|
|
98
|
-
cryptographyStorageKey,
|
|
99
|
-
wireEventsHandler,
|
|
100
|
-
logger
|
|
101
|
-
)
|
|
86
|
+
const wireAppSdk = new WireAppSdk(apiToken, apiHost, cryptographyStorageKey, wireEventsHandler, logger)
|
|
102
87
|
|
|
103
88
|
wireAppSdk.registerExitHandlers()
|
|
104
89
|
await wireAppSdk.init()
|
|
@@ -107,10 +92,15 @@ export class WireAppSdk {
|
|
|
107
92
|
|
|
108
93
|
private async init() {
|
|
109
94
|
this.prepareStorage()
|
|
110
|
-
this.
|
|
95
|
+
this.configureDependencyTokens()
|
|
96
|
+
|
|
111
97
|
// Save cookie from constructor parameter only at first application start.
|
|
112
98
|
// Once BE provides new token, the one stored in `apiToken` will be obsolete.
|
|
113
|
-
this.appProperties
|
|
99
|
+
this.appProperties = container.resolve(AppProperties)
|
|
100
|
+
this.appProperties.saveBackendCookieIfMissing(this.apiToken)
|
|
101
|
+
|
|
102
|
+
await this.configureApplicationIdentity()
|
|
103
|
+
this.resolveRuntimeDependencies()
|
|
114
104
|
|
|
115
105
|
await this.initCryptoClient()
|
|
116
106
|
}
|
|
@@ -120,18 +110,22 @@ export class WireAppSdk {
|
|
|
120
110
|
mkdirSync(CRYPTOGRAPHY_STORAGE_PATH, {recursive: true})
|
|
121
111
|
}
|
|
122
112
|
|
|
123
|
-
private
|
|
113
|
+
private configureDependencyTokens() {
|
|
124
114
|
container.registerInstance(WIRE_API_HOST, this.apiHost)
|
|
125
115
|
container.registerInstance(WIRE_SDK_API_TOKEN, this.apiToken)
|
|
126
|
-
container.registerInstance(WIRE_USER_ID, this.userId)
|
|
127
|
-
container.registerInstance(WIRE_USER_DOMAIN, this.userDomain)
|
|
128
116
|
container.registerInstance(WIRE_CRYPTOGRAPHY_STORAGE_KEY, this.cryptographyStorageKey)
|
|
129
117
|
|
|
130
118
|
container.registerInstance(WIRE_EVENTS_HANDLER, this.wireEventsHandler)
|
|
119
|
+
}
|
|
131
120
|
|
|
121
|
+
private resolveRuntimeDependencies() {
|
|
132
122
|
this.webSocketClient = container.resolve(WebSocketClient)
|
|
133
123
|
this.conversationService = container.resolve(ConversationService)
|
|
134
|
-
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private async configureApplicationIdentity() {
|
|
127
|
+
const selfService = container.resolve(SelfService)
|
|
128
|
+
await selfService.fetchAndSaveApplicationData()
|
|
135
129
|
}
|
|
136
130
|
|
|
137
131
|
private async initCryptoClient() {
|
|
@@ -144,13 +138,13 @@ export class WireAppSdk {
|
|
|
144
138
|
|
|
145
139
|
async startListening() {
|
|
146
140
|
if (this.isWebSocketRunning) {
|
|
147
|
-
this.logger.info(
|
|
141
|
+
this.logger.info('Wire Apps SDK is already running.')
|
|
148
142
|
return
|
|
149
143
|
}
|
|
150
144
|
this.isWebSocketRunning = true
|
|
151
145
|
|
|
152
146
|
if (!this.webSocketClient || !this.conversationService) {
|
|
153
|
-
throw new
|
|
147
|
+
throw new UnknownError('Wire Apps SDK dependencies are not initialized.')
|
|
154
148
|
}
|
|
155
149
|
|
|
156
150
|
this.webSocketClient.connect().finally(() => {
|
|
@@ -162,30 +156,49 @@ export class WireAppSdk {
|
|
|
162
156
|
|
|
163
157
|
stopListening() {
|
|
164
158
|
if (!this.isWebSocketRunning) {
|
|
165
|
-
this.logger.info(
|
|
159
|
+
this.logger.info('Wire Apps SDK is not running.')
|
|
166
160
|
}
|
|
167
|
-
this.logger.info(
|
|
161
|
+
this.logger.info('Wire Apps SDK shutting down.')
|
|
168
162
|
this.isWebSocketRunning = false
|
|
169
163
|
|
|
170
164
|
this.webSocketClient?.close()
|
|
171
165
|
}
|
|
172
166
|
|
|
173
167
|
async close() {
|
|
174
|
-
this.logger.debug(
|
|
168
|
+
this.logger.debug('Closing Websocket connections.')
|
|
175
169
|
this.stopListening()
|
|
176
170
|
|
|
177
|
-
this.logger.debug(
|
|
171
|
+
this.logger.debug('Closing Database connections.')
|
|
178
172
|
try {
|
|
179
173
|
const databaseService = container.resolve(DatabaseService)
|
|
180
174
|
databaseService.close()
|
|
181
175
|
} catch (exception) {
|
|
182
|
-
this.logger.debug(
|
|
176
|
+
this.logger.debug('Database service was not initialized or could not be closed.', exception)
|
|
183
177
|
}
|
|
184
178
|
|
|
185
179
|
// Clear container to prevent memory leaks
|
|
186
180
|
container.clearInstances()
|
|
187
181
|
}
|
|
188
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Registers a listener to be notified when the connection to the Wire backend
|
|
185
|
+
* is established or lost.
|
|
186
|
+
*/
|
|
187
|
+
setBackendConnectionListener(listener: BackendConnectionListener): void {
|
|
188
|
+
this.webSocketClient?.setBackendConnectionListener(listener)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Returns the WireApplicationManager used to interact with the Wire backend.
|
|
193
|
+
*
|
|
194
|
+
* Available as soon as create() resolves. Operations on MLS conversations require the app
|
|
195
|
+
* to have joined those conversations, which happens during startListening().
|
|
196
|
+
* Do not use the returned instance after close().
|
|
197
|
+
*/
|
|
198
|
+
getApplicationManager(): WireApplicationManager {
|
|
199
|
+
return container.resolve(WireApplicationManager)
|
|
200
|
+
}
|
|
201
|
+
|
|
189
202
|
private registerExitHandlers(): void {
|
|
190
203
|
// SIGINT: Ctrl+C in terminal
|
|
191
204
|
process.on('SIGINT', () => this.handleExit('SIGINT'))
|
|
@@ -14,41 +14,30 @@
|
|
|
14
14
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
20
|
-
import type {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import type {
|
|
17
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
18
|
+
import {singleton} from 'tsyringe'
|
|
19
|
+
import type {AssetUploadData} from './model/asset/AssetUploadData.js'
|
|
20
|
+
import type {AssetUploadResponse} from './model/asset/AssetUploadResponse.js'
|
|
21
|
+
import {randomUUID} from 'crypto'
|
|
22
|
+
import {concatToBuffer} from '../utils/BufferUtils.js'
|
|
23
|
+
import type {AssetData} from '../model/Asset.js'
|
|
24
24
|
|
|
25
25
|
@singleton()
|
|
26
26
|
export class AssetsApiClient {
|
|
27
|
-
constructor(private httpClient: HttpClient) {
|
|
28
|
-
}
|
|
27
|
+
constructor(private httpClient: HttpClient) {}
|
|
29
28
|
|
|
30
|
-
private static readonly BASE_PATH =
|
|
29
|
+
private static readonly BASE_PATH = 'assets'
|
|
31
30
|
|
|
32
|
-
async downloadAsset(
|
|
33
|
-
assetId: string,
|
|
34
|
-
assetDomain: string,
|
|
35
|
-
assetToken?: string | null
|
|
36
|
-
): Promise<AssetData> {
|
|
31
|
+
async downloadAsset(assetId: string, assetDomain: string, assetToken?: string | null): Promise<AssetData> {
|
|
37
32
|
const path = `${AssetsApiClient.BASE_PATH}/${assetDomain}/${assetId}`
|
|
38
|
-
const headerAssetToken: Record<string, string> = assetToken ? {
|
|
33
|
+
const headerAssetToken: Record<string, string> = assetToken ? {'Asset-Token': assetToken} : {}
|
|
39
34
|
|
|
40
|
-
return await this.httpClient.getRequest<Uint8Array>(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
additionalHeaders: headerAssetToken
|
|
44
|
-
}
|
|
45
|
-
)
|
|
35
|
+
return await this.httpClient.getRequest<Uint8Array>(path, {
|
|
36
|
+
additionalHeaders: headerAssetToken
|
|
37
|
+
})
|
|
46
38
|
}
|
|
47
39
|
|
|
48
|
-
async uploadAsset(
|
|
49
|
-
asset: AssetData,
|
|
50
|
-
assetUploadData: AssetUploadData
|
|
51
|
-
): Promise<AssetUploadResponse> {
|
|
40
|
+
async uploadAsset(asset: AssetData, assetUploadData: AssetUploadData): Promise<AssetUploadResponse> {
|
|
52
41
|
const boundary = `Frontier${randomUUID()}`
|
|
53
42
|
|
|
54
43
|
const metadata = JSON.stringify(assetUploadData)
|
|
@@ -62,16 +51,12 @@ export class AssetsApiClient {
|
|
|
62
51
|
`--${boundary}\r\n` +
|
|
63
52
|
'Content-Type: application/octet-stream\r\n' +
|
|
64
53
|
`Content-length: ${asset.length}\r\n` +
|
|
65
|
-
'\r\n'
|
|
54
|
+
'\r\n'
|
|
66
55
|
|
|
67
|
-
const footer = `\r\n--${boundary}--\r\n
|
|
56
|
+
const footer = `\r\n--${boundary}--\r\n`
|
|
68
57
|
|
|
69
|
-
return await this.httpClient.postRequest(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
headerContentType: `multipart/mixed; boundary=${boundary}`,
|
|
74
|
-
},
|
|
75
|
-
)
|
|
58
|
+
return await this.httpClient.postRequest(AssetsApiClient.BASE_PATH, concatToBuffer(body, asset, footer), {
|
|
59
|
+
headerContentType: `multipart/mixed; boundary=${boundary}`
|
|
60
|
+
})
|
|
76
61
|
}
|
|
77
62
|
}
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import type {
|
|
23
|
-
import {
|
|
24
|
-
import type {
|
|
25
|
-
import type {AssetData} from
|
|
17
|
+
import {singleton} from 'tsyringe'
|
|
18
|
+
import {AssetsApiClient} from './AssetsApiClient.js'
|
|
19
|
+
import type {AssetRemoteData} from '../model/WireMessage.js'
|
|
20
|
+
import {AESUtils} from '../utils/AESUtils.js'
|
|
21
|
+
import {HashUtils} from '../utils/HashUtils.js'
|
|
22
|
+
import type {AssetUploadData} from './model/asset/AssetUploadData.js'
|
|
23
|
+
import {obfuscateId} from '../utils/ObfuscateUtil.js'
|
|
24
|
+
import type {AssetUploadResponse} from './model/asset/AssetUploadResponse.js'
|
|
25
|
+
import type {AssetData} from '../model/Asset.js'
|
|
26
|
+
import {InvalidParameterError} from '../exception/WireException.js'
|
|
26
27
|
|
|
27
28
|
@singleton()
|
|
28
29
|
export class AssetsTransferService {
|
|
29
|
-
constructor(private assetsApiClient: AssetsApiClient) {
|
|
30
|
-
}
|
|
30
|
+
constructor(private assetsApiClient: AssetsApiClient) {}
|
|
31
31
|
|
|
32
32
|
private readonly MAX_DATA_SIZE = 100 * 1024 * 1024
|
|
33
33
|
|
|
@@ -40,16 +40,15 @@ export class AssetsTransferService {
|
|
|
40
40
|
|
|
41
41
|
const calculatedSha256 = HashUtils.calculateSha256Hash(encryptedAsset)
|
|
42
42
|
if (!HashUtils.isHashEqual(assetRemoteData.sha256, calculatedSha256)) {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
throw new InvalidParameterError(
|
|
44
|
+
`Asset download failed. Asset checksums do not match. assetId: ${obfuscateId(assetRemoteData.assetId)}`
|
|
45
|
+
)
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
return AESUtils.decryptData(encryptedAsset, assetRemoteData.otrKey)
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
async uploadAssetForSending(
|
|
51
|
-
asset: AssetData
|
|
52
|
-
): Promise<AssetRemoteData> {
|
|
51
|
+
async uploadAssetForSending(asset: AssetData): Promise<AssetRemoteData> {
|
|
53
52
|
const cryptoKeyInfo = AESUtils.generateRandomAES256Key()
|
|
54
53
|
const encryptedAsset = AESUtils.encryptData(asset, cryptoKeyInfo.keyMaterial)
|
|
55
54
|
const assetUploadData = {
|
|
@@ -57,10 +56,7 @@ export class AssetsTransferService {
|
|
|
57
56
|
public: false
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
const assetUploadResponse = await this.uploadAsset(
|
|
61
|
-
encryptedAsset,
|
|
62
|
-
assetUploadData
|
|
63
|
-
)
|
|
59
|
+
const assetUploadResponse = await this.uploadAsset(encryptedAsset, assetUploadData)
|
|
64
60
|
|
|
65
61
|
return {
|
|
66
62
|
otrKey: cryptoKeyInfo.keyMaterial,
|
|
@@ -72,19 +68,12 @@ export class AssetsTransferService {
|
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
private async uploadAsset(
|
|
76
|
-
asset: AssetData,
|
|
77
|
-
assetUploadData: AssetUploadData
|
|
78
|
-
): Promise<AssetUploadResponse> {
|
|
71
|
+
private async uploadAsset(asset: AssetData, assetUploadData: AssetUploadData): Promise<AssetUploadResponse> {
|
|
79
72
|
if (asset.length > this.MAX_DATA_SIZE) {
|
|
80
|
-
|
|
81
|
-
throw new Error("AssetData size exceeds the maximum limit of 100MB")
|
|
73
|
+
throw new InvalidParameterError(`AssetData size exceeds the maximum limit of 100MB. Size: ${asset.length} bytes`)
|
|
82
74
|
}
|
|
83
75
|
|
|
84
|
-
return await this.assetsApiClient.uploadAsset(
|
|
85
|
-
asset,
|
|
86
|
-
assetUploadData
|
|
87
|
-
)
|
|
76
|
+
return await this.assetsApiClient.uploadAsset(asset, assetUploadData)
|
|
88
77
|
}
|
|
89
78
|
}
|
|
90
79
|
|
|
@@ -92,5 +81,4 @@ export class AssetsTransferService {
|
|
|
92
81
|
* The asset is retained indefinitely, storage is optimized
|
|
93
82
|
* for infrequent access after 30 days of creation.
|
|
94
83
|
*/
|
|
95
|
-
const ETERNAL_INFREQUENT_ACCESS =
|
|
96
|
-
|
|
84
|
+
const ETERNAL_INFREQUENT_ACCESS = 'eternal-infrequent_access'
|
|
@@ -14,41 +14,32 @@
|
|
|
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 {RegisterClientResponse} from
|
|
19
|
-
import {RegisterClientRequest} from
|
|
20
|
-
import type {MlsPublicKeys} from
|
|
21
|
-
import type {ClientUpdateRequest} from
|
|
22
|
-
import {mapToPreKeyRequest} from
|
|
23
|
-
import type {PreKeyCrypto} from
|
|
24
|
-
import {singleton} from
|
|
25
|
-
import {AppProperties} from
|
|
17
|
+
import {HttpClient} from '../core/HttpClient.js'
|
|
18
|
+
import type {RegisterClientResponse} from './response/RegisterClientResponse.js'
|
|
19
|
+
import {RegisterClientRequest} from './request/RegisterClientRequest.js'
|
|
20
|
+
import type {MlsPublicKeys} from '../model/MlsPublicKeys.js'
|
|
21
|
+
import type {ClientUpdateRequest} from './request/ClientUpdateRequest.js'
|
|
22
|
+
import {mapToPreKeyRequest} from '../mappers/PreKeyMapper.js'
|
|
23
|
+
import type {PreKeyCrypto} from '../model/PreKeyCrypto.js'
|
|
24
|
+
import {singleton} from 'tsyringe'
|
|
25
|
+
import {AppProperties} from '../service/AppProperties.js'
|
|
26
26
|
|
|
27
27
|
@singleton()
|
|
28
28
|
export class ClientsApiClient {
|
|
29
29
|
constructor(
|
|
30
30
|
private httpClient: HttpClient,
|
|
31
31
|
private appProperties: AppProperties
|
|
32
|
-
) {
|
|
32
|
+
) {}
|
|
33
33
|
|
|
34
|
-
private readonly basePath =
|
|
35
|
-
|
|
36
|
-
async registerClient(
|
|
37
|
-
proteusPreKeys: PreKeyCrypto[],
|
|
38
|
-
proteusLastPreKey: PreKeyCrypto
|
|
39
|
-
): Promise<string> {
|
|
34
|
+
private readonly basePath = 'clients'
|
|
40
35
|
|
|
36
|
+
async registerClient(proteusPreKeys: PreKeyCrypto[], proteusLastPreKey: PreKeyCrypto): Promise<string> {
|
|
41
37
|
const requestPayload = new RegisterClientRequest(
|
|
42
38
|
mapToPreKeyRequest(proteusLastPreKey),
|
|
43
|
-
proteusPreKeys.map((preKey) =>
|
|
44
|
-
mapToPreKeyRequest(preKey)
|
|
45
|
-
)
|
|
39
|
+
proteusPreKeys.map((preKey) => mapToPreKeyRequest(preKey))
|
|
46
40
|
)
|
|
47
41
|
|
|
48
|
-
const response = await this.httpClient.postRequest<RegisterClientResponse>(
|
|
49
|
-
this.basePath,
|
|
50
|
-
requestPayload
|
|
51
|
-
)
|
|
42
|
+
const response = await this.httpClient.postRequest<RegisterClientResponse>(this.basePath, requestPayload)
|
|
52
43
|
|
|
53
44
|
// Register client is performed with an access_token having limited scope.
|
|
54
45
|
// Clear the token to force a refresh with the full-scope token for next requests.
|
|
@@ -59,13 +50,9 @@ export class ClientsApiClient {
|
|
|
59
50
|
|
|
60
51
|
async updateClientWithMlsPublicKey(mlsPublicKeys: MlsPublicKeys): Promise<void> {
|
|
61
52
|
const requestPayload: ClientUpdateRequest = {
|
|
62
|
-
mls_public_keys: mlsPublicKeys
|
|
53
|
+
mls_public_keys: mlsPublicKeys
|
|
63
54
|
}
|
|
64
55
|
|
|
65
|
-
await this.httpClient.putRequest<void>(
|
|
66
|
-
`${this.basePath}/${this.appProperties.getDeviceId()}`,
|
|
67
|
-
requestPayload
|
|
68
|
-
)
|
|
56
|
+
await this.httpClient.putRequest<void>(`${this.basePath}/${this.appProperties.getDeviceId()}`, requestPayload)
|
|
69
57
|
}
|
|
70
|
-
|
|
71
58
|
}
|