@flashphoner/sfusdk 2.0.291 → 2.0.299

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.
Files changed (242) hide show
  1. package/dist/client.version +1 -1
  2. package/dist/sdk/attachments-transfer-client.d.ts +9 -0
  3. package/dist/sdk/attachments-transfer-client.js +130 -0
  4. package/dist/sdk/attachments-transfer-client.js.map +1 -0
  5. package/dist/sdk/attachments-transfer-manager.d.ts +8 -0
  6. package/dist/sdk/attachments-transfer-manager.js +29 -0
  7. package/dist/sdk/attachments-transfer-manager.js.map +1 -0
  8. package/dist/sdk/connection.d.ts +2 -0
  9. package/dist/sdk/connection.js +19 -6
  10. package/dist/sdk/connection.js.map +1 -1
  11. package/dist/sdk/constants.d.ts +38 -5
  12. package/dist/sdk/constants.js +17 -1
  13. package/dist/sdk/constants.js.map +1 -1
  14. package/dist/sdk/sfu-extended.d.ts +49 -5
  15. package/dist/sdk/sfu-extended.js +108 -58
  16. package/dist/sdk/sfu-extended.js.map +1 -1
  17. package/docs/assets/navigation.js +1 -1
  18. package/docs/assets/search.js +1 -1
  19. package/docs/classes/attachments_transfer_client.AttachmentsTransferClient.html +10 -0
  20. package/docs/classes/attachments_transfer_manager.AttachmentsTransferManager.html +4 -0
  21. package/docs/classes/connection.Connection.html +3 -1
  22. package/docs/classes/sfu_extended.SfuExtended.html +98 -81
  23. package/docs/enums/constants.AttachmentState.html +2 -2
  24. package/docs/enums/constants.AuthenticationStatus.html +2 -2
  25. package/docs/enums/constants.ChannelSendPolicy.html +2 -2
  26. package/docs/enums/constants.ChatError.html +3 -2
  27. package/docs/enums/constants.ChatReceivePolicy.html +2 -2
  28. package/docs/enums/constants.ChatSectionsError.html +2 -2
  29. package/docs/enums/constants.ChatType.html +2 -2
  30. package/docs/enums/constants.ConferenceType.html +2 -2
  31. package/docs/enums/constants.ConnectionError.html +3 -0
  32. package/docs/enums/constants.ConnectionType.html +2 -2
  33. package/docs/enums/constants.ContactError.html +2 -2
  34. package/docs/enums/constants.DeliveryStatus.html +2 -2
  35. package/docs/enums/constants.ExamplesError.html +2 -2
  36. package/docs/enums/constants.ExamplesEvent.html +2 -2
  37. package/docs/enums/constants.InternalApi.html +6 -2
  38. package/docs/enums/constants.MeetingSyncEvent.html +10 -10
  39. package/docs/enums/constants.MessageAttachmentMediaType.html +2 -2
  40. package/docs/enums/constants.MessageAttachmentType.html +2 -2
  41. package/docs/enums/constants.MessageState.html +2 -2
  42. package/docs/enums/constants.MessageTargetEntityType.html +2 -2
  43. package/docs/enums/constants.Operations.html +2 -2
  44. package/docs/enums/constants.ParticipantRole.html +2 -2
  45. package/docs/enums/constants.PresenceStatus.html +2 -2
  46. package/docs/enums/constants.RemoteSdpType.html +2 -2
  47. package/docs/enums/constants.RoomError.html +2 -2
  48. package/docs/enums/constants.RoomState.html +2 -2
  49. package/docs/enums/constants.SortOrder.html +2 -2
  50. package/docs/enums/constants.SpaceError.html +2 -2
  51. package/docs/enums/constants.SpaceEvent.html +20 -14
  52. package/docs/enums/constants.State.html +2 -2
  53. package/docs/enums/constants.StatsType.html +2 -2
  54. package/docs/enums/constants.TrackType.html +2 -2
  55. package/docs/enums/constants.UserInfoError.html +2 -2
  56. package/docs/enums/constants.UserManagementError.html +2 -2
  57. package/docs/modules/attachments_transfer_client.html +2 -0
  58. package/docs/modules/attachments_transfer_manager.html +2 -0
  59. package/docs/modules/constants.html +4 -0
  60. package/docs/modules/sfu_extended.html +2 -0
  61. package/docs/types/constants.AddRemoveTracks.html +1 -1
  62. package/docs/types/constants.AddRemoveTracksSync.html +1 -1
  63. package/docs/types/constants.AddedMembersToThread.html +1 -0
  64. package/docs/types/constants.AddedRemovedReactionOnMessage.html +1 -1
  65. package/docs/types/constants.AddedRoleToMember.html +1 -1
  66. package/docs/types/constants.Attachment.html +1 -1
  67. package/docs/types/constants.AttachmentInfo.html +1 -1
  68. package/docs/types/constants.AttachmentRequest.html +1 -1
  69. package/docs/types/constants.AttachmentRequestAck.html +1 -1
  70. package/docs/types/constants.AttachmentStatus.html +1 -1
  71. package/docs/types/constants.AttachmentStatusEvent.html +1 -1
  72. package/docs/types/constants.AuthenticationStatusEvent.html +1 -1
  73. package/docs/types/constants.BannedContact.html +1 -1
  74. package/docs/types/constants.BitrateTestStatus.html +1 -1
  75. package/docs/types/constants.BooleanEvent.html +1 -1
  76. package/docs/types/constants.Calendar.html +1 -1
  77. package/docs/types/constants.CalendarEvent.html +1 -1
  78. package/docs/types/constants.CalendarEventEvent.html +1 -1
  79. package/docs/types/constants.Chat.html +1 -1
  80. package/docs/types/constants.ChatLoadedEvent.html +1 -1
  81. package/docs/types/constants.ChatMap.html +1 -1
  82. package/docs/types/constants.ChatMessagesCount.html +1 -1
  83. package/docs/types/constants.ChatMessagesEvent.html +1 -1
  84. package/docs/types/constants.ChatSearchResultEvent.html +1 -1
  85. package/docs/types/constants.ChatsEvent.html +1 -1
  86. package/docs/types/constants.ConnectionDetails.html +1 -1
  87. package/docs/types/constants.ConnectionFailedEvent.html +1 -1
  88. package/docs/types/constants.Contact.html +1 -1
  89. package/docs/types/constants.ContactDeleted.html +1 -1
  90. package/docs/types/constants.ContactUpdated.html +1 -1
  91. package/docs/types/constants.ControlMessage.html +1 -1
  92. package/docs/types/constants.ControlMessageEvent.html +1 -1
  93. package/docs/types/constants.CreatedRoom.html +1 -1
  94. package/docs/types/constants.EvictedFromRoom.html +1 -1
  95. package/docs/types/constants.EvictedSync.html +1 -1
  96. package/docs/types/constants.ExamplesUser.html +1 -1
  97. package/docs/types/constants.ExamplesUserEvent.html +1 -1
  98. package/docs/types/constants.FirstAndLastChatMessage.html +1 -1
  99. package/docs/types/constants.FragmentedMessage.html +1 -1
  100. package/docs/types/constants.FriendInvite.html +1 -1
  101. package/docs/types/constants.FriendInviteDeleted.html +1 -1
  102. package/docs/types/constants.InternalMessage.html +1 -1
  103. package/docs/types/constants.JoinedRoom.html +1 -1
  104. package/docs/types/constants.JoinedRoomSync.html +1 -1
  105. package/docs/types/constants.LastReadMessageUpdate.html +1 -1
  106. package/docs/types/constants.LastReadMessageUpdated.html +1 -1
  107. package/docs/types/constants.LeftMeetingSync.html +1 -1
  108. package/docs/types/constants.LeftRoom.html +1 -1
  109. package/docs/types/constants.LoadMessagesWithMentionsResult.html +1 -1
  110. package/docs/types/constants.MeetingEndedSync.html +1 -1
  111. package/docs/types/constants.MeetingNameUpdatedSync.html +1 -1
  112. package/docs/types/constants.MeetingsPreviewEvent.html +1 -1
  113. package/docs/types/constants.Message.html +1 -1
  114. package/docs/types/constants.MessageAttachment.html +1 -1
  115. package/docs/types/constants.MessageAttachmentData.html +1 -1
  116. package/docs/types/constants.MessageAttachmentsSearchResult.html +1 -1
  117. package/docs/types/constants.MessageDeleted.html +1 -1
  118. package/docs/types/constants.MessageDeliveryStatus.html +1 -1
  119. package/docs/types/constants.MessageEdited.html +1 -1
  120. package/docs/types/constants.MessageInfo.html +1 -1
  121. package/docs/types/constants.MessageReaction.html +1 -1
  122. package/docs/types/constants.MessageStatus.html +1 -1
  123. package/docs/types/constants.MessageStatusEvent.html +1 -1
  124. package/docs/types/constants.MessageStatusUpdate.html +1 -1
  125. package/docs/types/constants.MessageTargetEntityId.html +1 -1
  126. package/docs/types/constants.MessageWithUploadingAttachments.html +1 -1
  127. package/docs/types/constants.NewChatEvent.html +1 -1
  128. package/docs/types/constants.NewContact.html +1 -1
  129. package/docs/types/constants.NewFriendInvite.html +1 -1
  130. package/docs/types/constants.NewMeeting.html +1 -1
  131. package/docs/types/constants.NewSpaceCategoryEvent.html +1 -1
  132. package/docs/types/constants.NewSpaceChannelEvent.html +1 -1
  133. package/docs/types/constants.NewSpaceEvent.html +1 -1
  134. package/docs/types/constants.NewSpaceRoleAdded.html +1 -1
  135. package/docs/types/constants.NewSpaceThreadEvent.html +1 -1
  136. package/docs/types/constants.OperationFailed.html +1 -1
  137. package/docs/types/constants.OperationFailedEvent.html +1 -1
  138. package/docs/types/constants.Participant.html +1 -1
  139. package/docs/types/constants.ParticipantAVSMutedEvent.html +1 -1
  140. package/docs/types/constants.ParticipantConfigEvent.html +1 -1
  141. package/docs/types/constants.ParticipantRenamed.html +1 -1
  142. package/docs/types/constants.ParticipantsListEvent.html +1 -1
  143. package/docs/types/constants.ParticipantsListSyncEvent.html +1 -1
  144. package/docs/types/constants.PlacedInLobbyEvent.html +1 -1
  145. package/docs/types/constants.PlacedInWaitingRoomEvent.html +1 -1
  146. package/docs/types/constants.PublicChannelsEvent.html +1 -1
  147. package/docs/types/constants.Quality.html +1 -1
  148. package/docs/types/constants.RemoteSdp.html +1 -1
  149. package/docs/types/constants.RemoteSdpInfo.html +1 -1
  150. package/docs/types/constants.RemovedChatEvent.html +1 -1
  151. package/docs/types/constants.RemovedMemberFromThread.html +1 -0
  152. package/docs/types/constants.RemovedRoleFromMember.html +1 -1
  153. package/docs/types/constants.ResetPasswordRequestStatus.html +1 -1
  154. package/docs/types/constants.RoleAssigned.html +1 -1
  155. package/docs/types/constants.RolePermissionSectionsEvent.html +1 -1
  156. package/docs/types/constants.RolesListEvent.html +1 -1
  157. package/docs/types/constants.RoomAvailable.html +1 -1
  158. package/docs/types/constants.RoomConfigEvent.html +1 -1
  159. package/docs/types/constants.RoomExtendedConfig.html +1 -1
  160. package/docs/types/constants.RoomExtendedParticipantConfig.html +1 -1
  161. package/docs/types/constants.RoomExtendedParticipantsConfig.html +1 -1
  162. package/docs/types/constants.RoomExtendedScreenSharingConfig.html +1 -1
  163. package/docs/types/constants.RoomInfo.html +1 -1
  164. package/docs/types/constants.RoomMessage.html +1 -1
  165. package/docs/types/constants.RoomNameUpdated.html +1 -1
  166. package/docs/types/constants.RoomScreenSharingConfigEvent.html +1 -1
  167. package/docs/types/constants.SFUMeetingParticipantPreview.html +1 -1
  168. package/docs/types/constants.SFUMeetingPreview.html +1 -1
  169. package/docs/types/constants.SfuMessageEvent.html +1 -1
  170. package/docs/types/constants.SfuSpace.html +1 -1
  171. package/docs/types/constants.SfuSpaceCategory.html +1 -1
  172. package/docs/types/constants.SfuSpaceChannel.html +1 -1
  173. package/docs/types/constants.SfuSpaceChannelAccessRights.html +1 -1
  174. package/docs/types/constants.SfuSpaceInvite.html +1 -1
  175. package/docs/types/constants.SfuSpaceMember.html +1 -1
  176. package/docs/types/constants.SfuSpaceRole.html +1 -1
  177. package/docs/types/constants.SfuSpaceRolePermission.html +1 -1
  178. package/docs/types/constants.SfuSpaceRolePermissionSection.html +1 -1
  179. package/docs/types/constants.SfuSpaceThread.html +1 -1
  180. package/docs/types/constants.SfuSpaceUserBan.html +1 -1
  181. package/docs/types/constants.SignUpStatus.html +1 -1
  182. package/docs/types/constants.SpaceCategoryDeleted.html +1 -1
  183. package/docs/types/constants.SpaceCategoryUpdated.html +1 -1
  184. package/docs/types/constants.SpaceChannelDeleted.html +1 -1
  185. package/docs/types/constants.SpaceChannelMoved.html +1 -1
  186. package/docs/types/constants.SpaceChannelUpdated.html +1 -1
  187. package/docs/types/constants.SpaceCreatedEvent.html +1 -1
  188. package/docs/types/constants.SpaceDeletedEvent.html +1 -1
  189. package/docs/types/constants.SpaceInviteCreated.html +1 -1
  190. package/docs/types/constants.SpaceInviteRevoked.html +1 -1
  191. package/docs/types/constants.SpaceOverviewUpdated.html +1 -1
  192. package/docs/types/constants.SpaceRoleDeleted.html +1 -1
  193. package/docs/types/constants.SpaceRoleUpdated.html +1 -1
  194. package/docs/types/constants.SpaceThreadDeleted.html +1 -1
  195. package/docs/types/constants.SpaceThreadUpdated.html +1 -1
  196. package/docs/types/constants.StopScreenSharingEvent.html +1 -1
  197. package/docs/types/constants.StopTrackEvent.html +1 -1
  198. package/docs/types/constants.TracksQualityState.html +1 -1
  199. package/docs/types/constants.UnreadMessagesCountEvent.html +1 -1
  200. package/docs/types/constants.UnreadMessagesCountUpdate.html +1 -1
  201. package/docs/types/constants.UpdateChatEvent.html +1 -1
  202. package/docs/types/constants.UpdateMessagesDeliveryStatusEvent.html +1 -1
  203. package/docs/types/constants.UploadingAttachmentInfo.html +1 -1
  204. package/docs/types/constants.UserCalendarEvent.html +1 -1
  205. package/docs/types/constants.UserChatEncryptedPassword.html +1 -1
  206. package/docs/types/constants.UserContacts.html +1 -1
  207. package/docs/types/constants.UserContactsEvent.html +1 -1
  208. package/docs/types/constants.UserEmail.html +1 -1
  209. package/docs/types/constants.UserEncryptionInfo.html +1 -1
  210. package/docs/types/constants.UserEncryptionInfoEvent.html +1 -1
  211. package/docs/types/constants.UserHostKey.html +1 -1
  212. package/docs/types/constants.UserHostKeyChangedEvent.html +1 -1
  213. package/docs/types/constants.UserId.html +1 -1
  214. package/docs/types/constants.UserInfo.html +1 -1
  215. package/docs/types/constants.UserInfoChangedEvent.html +1 -1
  216. package/docs/types/constants.UserInfoEvent.html +1 -1
  217. package/docs/types/constants.UserJoinedToSpaceEvent.html +1 -1
  218. package/docs/types/constants.UserLeftSpace.html +1 -1
  219. package/docs/types/constants.UserNickname.html +1 -1
  220. package/docs/types/constants.UserNicknameChangedEvent.html +1 -1
  221. package/docs/types/constants.UserPassword.html +1 -1
  222. package/docs/types/constants.UserPhoneNumber.html +1 -1
  223. package/docs/types/constants.UserPhoneNumberChangedEvent.html +1 -1
  224. package/docs/types/constants.UserPmiSettings.html +1 -1
  225. package/docs/types/constants.UserPresenceStatusUpdated.html +1 -1
  226. package/docs/types/constants.UserRoomsEvent.html +1 -1
  227. package/docs/types/constants.UserSpaceNicknameUpdated.html +1 -0
  228. package/docs/types/constants.UserSpacesEvent.html +1 -1
  229. package/docs/types/constants.UserSpecificChatInfo.html +1 -1
  230. package/docs/types/constants.UserTimezone.html +1 -1
  231. package/docs/types/constants.UserTimezoneChangedEvent.html +1 -1
  232. package/docs/types/constants.WaitingListEvent.html +1 -1
  233. package/docs/types/constants.WaitingParticipant.html +1 -1
  234. package/docs/types/constants.WaitingRoomUpdate.html +1 -1
  235. package/docs/types/sfu_extended.EventUnion.html +1 -0
  236. package/docs/types/sfu_extended.NotifyUnion.html +1 -0
  237. package/docs/variables/constants.ATTACHMENT_CHUNK_SIZE.html +1 -1
  238. package/docs/variables/constants.ATTACHMENT_ID_LENGTH.html +1 -1
  239. package/docs/variables/constants.WS_CONNECTION_TIMEOUT.html +1 -1
  240. package/docs/variables/constants.WS_PINGS_MISSING_THRESHOLD.html +1 -1
  241. package/docs/variables/constants.WS_PING_INTERVAL_MS.html +1 -1
  242. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
- import { AddedRoleToMember, Attachment, AttachmentRequest, AttachmentStatus, Calendar, CalendarEvent, SfuSpaceCategory, ChannelSendPolicy, Chat, ChatMap, ChatMessagesCount, ChatReceivePolicy, ChatType, ConnectionDetails, FirstAndLastChatMessage, InternalMessage, LastReadMessageUpdated, LoadMessagesWithMentionsResult, Message, MessageAttachment, MessageAttachmentData, MessageAttachmentMediaType, MessageAttachmentsSearchResult, MessageStatus, RoomInfo, SfuEvent, SignUpStatus, SortOrder, SfuSpace, SfuSpaceRole, State, UserEmail, UserHostKey, UserId, UserInfo, UserNickname, UserPassword, UserPhoneNumber, UserPmiSettings, UserSpecificChatInfo, UserTimezone, SfuSpaceInvite, SfuSpaceChannel, SpaceRoleDeleted, RemovedRoleFromMember, SfuSpaceThread, SpaceChannelUpdated, SfuSpaceRolePermissionSection, SpaceRoleUpdated, SpaceChannelMoved, SpaceEvent, MessageTargetEntityType, MessageTargetEntityId, MeetingSyncEvent, UnreadMessagesCountEvent, FriendInviteDeleted, UserContacts, PresenceStatus, Contact, ExamplesUser, UserEncryptionInfo, UserChatEncryptedPassword, AddedRemovedReactionOnMessage } from "./constants";
1
+ import { AddedRoleToMember, Attachment, AttachmentRequest, AttachmentStatus, Calendar, CalendarEvent, SfuSpaceCategory, ChannelSendPolicy, Chat, ChatMap, ChatMessagesCount, ChatReceivePolicy, ChatType, ConnectionDetails, FirstAndLastChatMessage, InternalMessage, LastReadMessageUpdated, LoadMessagesWithMentionsResult, Message, MessageAttachment, MessageAttachmentData, MessageAttachmentMediaType, MessageAttachmentsSearchResult, MessageStatus, RoomInfo, SfuEvent, SignUpStatus, SortOrder, SfuSpace, SfuSpaceRole, State, UserEmail, UserHostKey, UserId, UserInfo, UserNickname, UserPassword, UserPhoneNumber, UserPmiSettings, UserSpecificChatInfo, UserTimezone, SfuSpaceInvite, SfuSpaceChannel, SpaceRoleDeleted, RemovedRoleFromMember, SfuSpaceThread, SpaceChannelUpdated, SfuSpaceRolePermissionSection, SpaceRoleUpdated, SpaceChannelMoved, SpaceEvent, MessageTargetEntityType, MessageTargetEntityId, MeetingSyncEvent, UnreadMessagesCountEvent, FriendInviteDeleted, UserContacts, PresenceStatus, Contact, ExamplesUser, UserEncryptionInfo, UserChatEncryptedPassword, AddedRemovedReactionOnMessage, AddedMembersToThread, RemovedMemberFromThread } from "./constants";
2
2
  import { RoomExtended } from "./room-extended";
3
3
  import { SendingAttachmentsHandler } from "./sending-attachments-handler";
4
4
  import { PrefixFunction, Verbosity } from "./logger";
5
5
  import { ResetPasswordHandler } from "./reset-password-handler";
6
- declare type NotifyUnion = InternalMessage | Message | MessageStatus | AttachmentStatus | Calendar | UserSpecificChatInfo | ChatMap | Chat | ArrayBuffer | CalendarEvent | Attachment | UserInfo | Array<SfuSpace> | Contact;
7
- declare type EventUnion = SfuEvent | SpaceEvent | MeetingSyncEvent;
6
+ export declare type NotifyUnion = InternalMessage | Message | MessageStatus | AttachmentStatus | Calendar | UserSpecificChatInfo | ChatMap | Chat | ArrayBuffer | CalendarEvent | Attachment | UserInfo | Array<SfuSpace> | Contact;
7
+ export declare type EventUnion = SfuEvent | SpaceEvent | MeetingSyncEvent;
8
8
  export declare class SfuExtended {
9
9
  #private;
10
10
  constructor(logLevel?: Verbosity, prefix?: PrefixFunction, log?: any);
@@ -96,7 +96,7 @@ export declare class SfuExtended {
96
96
  /**
97
97
  * Logout from app
98
98
  */
99
- logout(): Promise<LastReadMessageUpdated>;
99
+ logout(): Promise<void>;
100
100
  /**
101
101
  * Load messages for Direct chat | Channel | Thread
102
102
  *
@@ -255,6 +255,7 @@ export declare class SfuExtended {
255
255
  * On client side should receive {@link SfuEvent.MESSAGE_ATTACHMENT_STATE} with {@link AttachmentStatus} to show progress
256
256
  */
257
257
  getMessageAttachment(attachment: AttachmentRequest): Promise<Attachment>;
258
+ private downloadAttachment;
258
259
  /**
259
260
  * Get user contacts.
260
261
  *
@@ -521,6 +522,7 @@ export declare class SfuExtended {
521
522
  * @param chat.publicKey - the public key of the chat used to encrypt messages
522
523
  * @param chat.encryptedPrivateKey - the private key of the chat, encrypted with a chat password, used to decrypt messages
523
524
  * @param chat.encryptedChatPasswords - an array of chat passwords for each member encrypted with the member's public keys, which must be decrypted using the user's private key.
525
+ * @param chat.encryptedAttachmentsSecretKey - encrypted key for encrypting attachments.
524
526
  */
525
527
  createChat(chat: {
526
528
  id?: string;
@@ -536,6 +538,7 @@ export declare class SfuExtended {
536
538
  encryptedPrivateKey?: string;
537
539
  publicKey?: string;
538
540
  encryptedChatPasswords?: Array<UserChatEncryptedPassword>;
541
+ encryptedAttachmentsSecretKey?: string;
539
542
  }): Promise<UserSpecificChatInfo>;
540
543
  /**
541
544
  * Delete chat
@@ -906,6 +909,35 @@ export declare class SfuExtended {
906
909
  threadId: string;
907
910
  name: string;
908
911
  }): Promise<void>;
912
+ /**
913
+ * Add members to thread
914
+ *
915
+ * Thread members will receive {@link SpaceEvent.ADDED_MEMBERS_TO_THREAD} with {@link AddedMembersToThread}
916
+ *
917
+ * New members will receive {@link NEW_SPACE_THREAD} with {@link NewSpaceThreadEvent}
918
+ *
919
+ */
920
+ addMembersToThread(options: {
921
+ spaceId: string;
922
+ channelId: string;
923
+ threadId: string;
924
+ members: Array<string>;
925
+ }): Promise<AddedMembersToThread>;
926
+ /**
927
+ * Remove member from thread
928
+ *
929
+ * For space owner/thread creator only
930
+ *
931
+ * Thread members will receive {@link SpaceEvent.REMOVED_MEMBER_FROM_THREAD} with {@link RemovedMemberFromThread}
932
+ *
933
+ * The removed member will receive {@link SpaceEvent.SPACE_THREAD_DELETED} with {@link SpaceThreadDeleted}
934
+ */
935
+ removeMemberFromThread(options: {
936
+ spaceId: string;
937
+ channelId: string;
938
+ threadId: string;
939
+ member: string;
940
+ }): Promise<RemovedMemberFromThread>;
909
941
  /**
910
942
  * Delete space thread
911
943
  *
@@ -1002,6 +1034,19 @@ export declare class SfuExtended {
1002
1034
  memberId: string;
1003
1035
  }): Promise<RemovedRoleFromMember>;
1004
1036
  getRolePermissions(): Promise<SfuSpaceRolePermissionSection[]>;
1037
+ /**
1038
+ * Update nickname in the space
1039
+ *
1040
+ * A custom nickname takes higher priority over the global one in a space. The nickname is updated for the {@link SfuSpaceMember}.
1041
+ * If a custom nickname is not set, it will be an empty string, and in this case, the display global nickname will be taken from the contacts.
1042
+ * To remove a custom nickname and use the global one, provide an empty string.
1043
+ *
1044
+ * Space members will receive {@link SpaceEvent.USER_SPACE_NICKNAME_UPDATED} with {@link UserSpaceNicknameUpdated}
1045
+ */
1046
+ updateSpaceNickname(options: {
1047
+ spaceId: string;
1048
+ nickname: string;
1049
+ }): Promise<void>;
1005
1050
  user(): {
1006
1051
  username: string;
1007
1052
  email: string;
@@ -1021,4 +1066,3 @@ export declare class SfuExtended {
1021
1066
  static fromUTF8ArrayToStr(data: Uint8Array): string;
1022
1067
  private closePcAndFireEvent;
1023
1068
  }
1024
- export {};
@@ -45,7 +45,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
45
45
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
47
  };
48
- var _SfuExtended_instances, _SfuExtended_connection, _SfuExtended__user, _SfuExtended__server, _SfuExtended__state, _SfuExtended_rooms, _SfuExtended_notifier, _SfuExtended_uploadingAttachmentState, _SfuExtended_downloadingAttachmentState, _SfuExtended_binaryChunkSize, _SfuExtended_logger, _SfuExtended_loggerPrefix, _SfuExtended_signUpId, _SfuExtended_resetPasswordId, _SfuExtended_emmitAction, _SfuExtended_emmitBinaryAction, _SfuExtended_checkAuthenticated, _SfuExtended_createConnection, _SfuExtended_getConnectionConfigForAnonymousUser, _SfuExtended_notifyMessageAttachmentState, _SfuExtended_getConnectionConfigForExamples;
48
+ var _SfuExtended_instances, _SfuExtended_connection, _SfuExtended__user, _SfuExtended__server, _SfuExtended__url, _SfuExtended__state, _SfuExtended_rooms, _SfuExtended_notifier, _SfuExtended_uploadingAttachmentState, _SfuExtended_attachmentsTransferManager, _SfuExtended_binaryChunkSize, _SfuExtended_logger, _SfuExtended_loggerPrefix, _SfuExtended_signUpId, _SfuExtended_resetPasswordId, _SfuExtended_emmitAction, _SfuExtended_emmitBinaryAction, _SfuExtended_checkAuthenticated, _SfuExtended_createConnection, _SfuExtended_getConnectionConfigForAnonymousUser, _SfuExtended_getConnectionConfigForExamples;
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.SfuExtended = void 0;
51
51
  const uuid_1 = require("uuid");
@@ -57,18 +57,20 @@ const room_extended_1 = require("./room-extended");
57
57
  const sending_attachments_handler_1 = require("./sending-attachments-handler");
58
58
  const logger_1 = __importStar(require("./logger"));
59
59
  const reset_password_handler_1 = require("./reset-password-handler");
60
+ const attachments_transfer_manager_1 = require("./attachments-transfer-manager");
60
61
  class SfuExtended {
61
62
  constructor(logLevel, prefix, log) {
62
63
  _SfuExtended_instances.add(this);
63
64
  _SfuExtended_connection.set(this, void 0);
64
65
  _SfuExtended__user.set(this, void 0);
65
66
  _SfuExtended__server.set(this, void 0);
67
+ _SfuExtended__url.set(this, void 0);
66
68
  _SfuExtended__state.set(this, constants_1.State.NEW);
67
69
  _SfuExtended_rooms.set(this, {});
68
70
  //TODO(naz): Provide union instead of InternalMessage
69
71
  _SfuExtended_notifier.set(this, new notifier_1.Notifier());
70
72
  _SfuExtended_uploadingAttachmentState.set(this, {});
71
- _SfuExtended_downloadingAttachmentState.set(this, []);
73
+ _SfuExtended_attachmentsTransferManager.set(this, new attachments_transfer_manager_1.AttachmentsTransferManager(__classPrivateFieldGet(this, _SfuExtended_notifier, "f")));
72
74
  _SfuExtended_binaryChunkSize.set(this, void 0);
73
75
  _SfuExtended_logger.set(this, new logger_1.default());
74
76
  _SfuExtended_loggerPrefix.set(this, void 0);
@@ -102,6 +104,13 @@ class SfuExtended {
102
104
  if (!options) {
103
105
  throw new TypeError("No options provided");
104
106
  }
107
+ if (__classPrivateFieldGet(this, _SfuExtended__state, "f") === constants_1.State.PENDING) {
108
+ return Promise.reject(new Error(constants_1.ConnectionError.CONNECTION_ALREADY_IN_PROGRESS));
109
+ }
110
+ if (__classPrivateFieldGet(this, _SfuExtended__state, "f") === constants_1.State.AUTHENTICATED) {
111
+ return Promise.reject(new Error(constants_1.ConnectionError.CONNECTION_ALREADY_ESTABLISHED));
112
+ }
113
+ __classPrivateFieldSet(this, _SfuExtended__state, constants_1.State.PENDING, "f");
105
114
  const connectionConfig = {
106
115
  url: options.url,
107
116
  appName: constants_1.InternalApi.Z_APP,
@@ -120,6 +129,7 @@ class SfuExtended {
120
129
  const self = this;
121
130
  __classPrivateFieldGet(this, _SfuExtended_instances, "m", _SfuExtended_createConnection).call(this);
122
131
  __classPrivateFieldSet(this, _SfuExtended__server, new URL(options.url).hostname, "f");
132
+ __classPrivateFieldSet(this, _SfuExtended__url, options.url, "f");
123
133
  __classPrivateFieldSet(this, _SfuExtended_binaryChunkSize, options.binaryChunkSize ? options.binaryChunkSize : constants_1.ATTACHMENT_CHUNK_SIZE, "f");
124
134
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
125
135
  try {
@@ -816,6 +826,18 @@ class SfuExtended {
816
826
  * On client side should receive {@link SfuEvent.MESSAGE_ATTACHMENT_STATE} with {@link AttachmentStatus} to show progress
817
827
  */
818
828
  getMessageAttachment(attachment) {
829
+ return __awaiter(this, void 0, void 0, function* () {
830
+ let result;
831
+ try {
832
+ result = yield this.downloadAttachment(attachment);
833
+ }
834
+ catch (e) {
835
+ throw e;
836
+ }
837
+ return yield __classPrivateFieldGet(this, _SfuExtended_attachmentsTransferManager, "f").download(result, __classPrivateFieldGet(this, _SfuExtended__url, "f"));
838
+ });
839
+ }
840
+ downloadAttachment(attachment) {
819
841
  __classPrivateFieldGet(this, _SfuExtended_instances, "m", _SfuExtended_checkAuthenticated).call(this);
820
842
  const self = this;
821
843
  const { targetEntityType, targetEntityId, messageId, attachmentId, name } = attachment;
@@ -1261,6 +1283,7 @@ class SfuExtended {
1261
1283
  * @param chat.publicKey - the public key of the chat used to encrypt messages
1262
1284
  * @param chat.encryptedPrivateKey - the private key of the chat, encrypted with a chat password, used to decrypt messages
1263
1285
  * @param chat.encryptedChatPasswords - an array of chat passwords for each member encrypted with the member's public keys, which must be decrypted using the user's private key.
1286
+ * @param chat.encryptedAttachmentsSecretKey - encrypted key for encrypting attachments.
1264
1287
  */
1265
1288
  createChat(chat) {
1266
1289
  __classPrivateFieldGet(this, _SfuExtended_instances, "m", _SfuExtended_checkAuthenticated).call(this);
@@ -1279,7 +1302,8 @@ class SfuExtended {
1279
1302
  encryptionEnabled: chat.isEncryptionEnabled,
1280
1303
  encryptedPrivateKey: chat.encryptedPrivateKey,
1281
1304
  publicKey: chat.publicKey,
1282
- encryptedChatPasswords: chat.encryptedChatPasswords
1305
+ encryptedChatPasswords: chat.encryptedChatPasswords,
1306
+ encryptedAttachmentsSecretKey: chat.encryptedAttachmentsSecretKey
1283
1307
  }, resolve, reject);
1284
1308
  });
1285
1309
  }
@@ -1843,6 +1867,47 @@ class SfuExtended {
1843
1867
  }, resolve, reject);
1844
1868
  });
1845
1869
  }
1870
+ /**
1871
+ * Add members to thread
1872
+ *
1873
+ * Thread members will receive {@link SpaceEvent.ADDED_MEMBERS_TO_THREAD} with {@link AddedMembersToThread}
1874
+ *
1875
+ * New members will receive {@link NEW_SPACE_THREAD} with {@link NewSpaceThreadEvent}
1876
+ *
1877
+ */
1878
+ addMembersToThread(options) {
1879
+ __classPrivateFieldGet(this, _SfuExtended_instances, "m", _SfuExtended_checkAuthenticated).call(this);
1880
+ const self = this;
1881
+ return new Promise(function (resolve, reject) {
1882
+ __classPrivateFieldGet(self, _SfuExtended_instances, "m", _SfuExtended_emmitAction).call(self, constants_1.InternalApi.ADD_MEMBERS_TO_THREAD, {
1883
+ spaceId: options.spaceId,
1884
+ channelId: options.channelId,
1885
+ threadId: options.threadId,
1886
+ members: options.members
1887
+ }, resolve, reject);
1888
+ });
1889
+ }
1890
+ /**
1891
+ * Remove member from thread
1892
+ *
1893
+ * For space owner/thread creator only
1894
+ *
1895
+ * Thread members will receive {@link SpaceEvent.REMOVED_MEMBER_FROM_THREAD} with {@link RemovedMemberFromThread}
1896
+ *
1897
+ * The removed member will receive {@link SpaceEvent.SPACE_THREAD_DELETED} with {@link SpaceThreadDeleted}
1898
+ */
1899
+ removeMemberFromThread(options) {
1900
+ __classPrivateFieldGet(this, _SfuExtended_instances, "m", _SfuExtended_checkAuthenticated).call(this);
1901
+ const self = this;
1902
+ return new Promise(function (resolve, reject) {
1903
+ __classPrivateFieldGet(self, _SfuExtended_instances, "m", _SfuExtended_emmitAction).call(self, constants_1.InternalApi.REMOVE_MEMBER_FROM_THREAD, {
1904
+ spaceId: options.spaceId,
1905
+ channelId: options.channelId,
1906
+ threadId: options.threadId,
1907
+ member: options.member
1908
+ }, resolve, reject);
1909
+ });
1910
+ }
1846
1911
  /**
1847
1912
  * Delete space thread
1848
1913
  *
@@ -1981,6 +2046,25 @@ class SfuExtended {
1981
2046
  __classPrivateFieldGet(self, _SfuExtended_instances, "m", _SfuExtended_emmitAction).call(self, constants_1.InternalApi.GET_ROLE_PERMISSIONS, {}, resolve, reject);
1982
2047
  });
1983
2048
  }
2049
+ /**
2050
+ * Update nickname in the space
2051
+ *
2052
+ * A custom nickname takes higher priority over the global one in a space. The nickname is updated for the {@link SfuSpaceMember}.
2053
+ * If a custom nickname is not set, it will be an empty string, and in this case, the display global nickname will be taken from the contacts.
2054
+ * To remove a custom nickname and use the global one, provide an empty string.
2055
+ *
2056
+ * Space members will receive {@link SpaceEvent.USER_SPACE_NICKNAME_UPDATED} with {@link UserSpaceNicknameUpdated}
2057
+ */
2058
+ updateSpaceNickname(options) {
2059
+ __classPrivateFieldGet(this, _SfuExtended_instances, "m", _SfuExtended_checkAuthenticated).call(this);
2060
+ const self = this;
2061
+ return new Promise(function (resolve, reject) {
2062
+ __classPrivateFieldGet(self, _SfuExtended_instances, "m", _SfuExtended_emmitAction).call(self, constants_1.InternalApi.UPDATE_SPACE_NICKNAME, {
2063
+ spaceId: options.spaceId,
2064
+ nickname: options.nickname
2065
+ }, resolve, reject);
2066
+ });
2067
+ }
1984
2068
  user() {
1985
2069
  return __classPrivateFieldGet(this, _SfuExtended__user, "f");
1986
2070
  }
@@ -2099,7 +2183,7 @@ class SfuExtended {
2099
2183
  }
2100
2184
  }
2101
2185
  exports.SfuExtended = SfuExtended;
2102
- _SfuExtended_connection = new WeakMap(), _SfuExtended__user = new WeakMap(), _SfuExtended__server = new WeakMap(), _SfuExtended__state = new WeakMap(), _SfuExtended_rooms = new WeakMap(), _SfuExtended_notifier = new WeakMap(), _SfuExtended_uploadingAttachmentState = new WeakMap(), _SfuExtended_downloadingAttachmentState = new WeakMap(), _SfuExtended_binaryChunkSize = new WeakMap(), _SfuExtended_logger = new WeakMap(), _SfuExtended_loggerPrefix = new WeakMap(), _SfuExtended_signUpId = new WeakMap(), _SfuExtended_resetPasswordId = new WeakMap(), _SfuExtended_instances = new WeakSet(), _SfuExtended_emmitAction = function _SfuExtended_emmitAction(action, data, resolve, reject) {
2186
+ _SfuExtended_connection = new WeakMap(), _SfuExtended__user = new WeakMap(), _SfuExtended__server = new WeakMap(), _SfuExtended__url = new WeakMap(), _SfuExtended__state = new WeakMap(), _SfuExtended_rooms = new WeakMap(), _SfuExtended_notifier = new WeakMap(), _SfuExtended_uploadingAttachmentState = new WeakMap(), _SfuExtended_attachmentsTransferManager = new WeakMap(), _SfuExtended_binaryChunkSize = new WeakMap(), _SfuExtended_logger = new WeakMap(), _SfuExtended_loggerPrefix = new WeakMap(), _SfuExtended_signUpId = new WeakMap(), _SfuExtended_resetPasswordId = new WeakMap(), _SfuExtended_instances = new WeakSet(), _SfuExtended_emmitAction = function _SfuExtended_emmitAction(action, data, resolve, reject) {
2103
2187
  const id = (0, uuid_1.v4)();
2104
2188
  promises_1.default.add(id, resolve, reject);
2105
2189
  __classPrivateFieldGet(this, _SfuExtended_connection, "f").send(action, Object.assign(Object.assign({}, data), { internalMessageId: id }));
@@ -2150,10 +2234,7 @@ _SfuExtended_connection = new WeakMap(), _SfuExtended__user = new WeakMap(), _Sf
2150
2234
  else if (data[0].type === constants_1.InternalApi.SFU_ATTACHMENT_REQUEST_ACK) {
2151
2235
  const ack = data[0];
2152
2236
  const request = ack.attachmentRequest;
2153
- const state = __classPrivateFieldGet(this, _SfuExtended_downloadingAttachmentState, "f").find(s => s.messageId === ack.attachmentRequest.messageId);
2154
- if (!state) {
2155
- __classPrivateFieldGet(this, _SfuExtended_downloadingAttachmentState, "f").push(Object.assign(Object.assign({}, request), { payload: null, internalMessageId: ack.internalMessageId }));
2156
- }
2237
+ promises_1.default.resolve(data[0].internalMessageId, Object.assign(Object.assign({}, request), { payload: null, sessionId: ack.sessionId, internalMessageId: ack.internalMessageId }));
2157
2238
  }
2158
2239
  else if (data[0].type === constants_1.InternalApi.USER_CALENDAR) {
2159
2240
  const calendar = data[0];
@@ -2500,6 +2581,18 @@ _SfuExtended_connection = new WeakMap(), _SfuExtended__user = new WeakMap(), _Sf
2500
2581
  __classPrivateFieldGet(this, _SfuExtended_notifier, "f").notify(constants_1.SpaceEvent.SPACE_THREAD_UPDATED, event);
2501
2582
  }
2502
2583
  }
2584
+ else if (data[0].type === constants_1.SpaceEvent.ADDED_MEMBERS_TO_THREAD) {
2585
+ const event = data[0];
2586
+ if (!promises_1.default.resolve(data[0].internalMessageId, event)) {
2587
+ __classPrivateFieldGet(this, _SfuExtended_notifier, "f").notify(constants_1.SpaceEvent.ADDED_MEMBERS_TO_THREAD, event);
2588
+ }
2589
+ }
2590
+ else if (data[0].type === constants_1.SpaceEvent.REMOVED_MEMBER_FROM_THREAD) {
2591
+ const event = data[0];
2592
+ if (!promises_1.default.resolve(data[0].internalMessageId, event)) {
2593
+ __classPrivateFieldGet(this, _SfuExtended_notifier, "f").notify(constants_1.SpaceEvent.REMOVED_MEMBER_FROM_THREAD, event);
2594
+ }
2595
+ }
2503
2596
  else if (data[0].type === constants_1.SpaceEvent.SPACE_THREAD_DELETED) {
2504
2597
  const event = data[0];
2505
2598
  if (!promises_1.default.resolve(data[0].internalMessageId, event)) {
@@ -2571,6 +2664,12 @@ _SfuExtended_connection = new WeakMap(), _SfuExtended__user = new WeakMap(), _Sf
2571
2664
  __classPrivateFieldGet(this, _SfuExtended_notifier, "f").notify(constants_1.SpaceEvent.ROLE_PERMISSION_SECTIONS, event);
2572
2665
  }
2573
2666
  }
2667
+ else if (data[0].type === constants_1.SpaceEvent.USER_SPACE_NICKNAME_UPDATED) {
2668
+ const event = data[0];
2669
+ if (!promises_1.default.resolve(data[0].internalMessageId, event)) {
2670
+ __classPrivateFieldGet(this, _SfuExtended_notifier, "f").notify(constants_1.SpaceEvent.USER_SPACE_NICKNAME_UPDATED, event);
2671
+ }
2672
+ }
2574
2673
  else if (data[0].type === constants_1.SfuEvent.USER_MEETINGS) {
2575
2674
  const event = data[0];
2576
2675
  __classPrivateFieldGet(this, _SfuExtended_notifier, "f").notify(constants_1.SfuEvent.USER_MEETINGS, event);
@@ -2687,51 +2786,13 @@ _SfuExtended_connection = new WeakMap(), _SfuExtended__user = new WeakMap(), _Sf
2687
2786
  __classPrivateFieldGet(this, _SfuExtended_notifier, "f").notify(constants_1.SfuEvent.FAILED, data[0]);
2688
2787
  break;
2689
2788
  }
2690
- }, (name, data) => {
2691
- switch (name) {
2692
- case constants_1.InternalApi.BINARY_DATA:
2693
- const headerSize = 4;
2694
- const buffer = new Uint8Array(data);
2695
- const messageTransferId = buffer[1];
2696
- const attachmentTransferId = buffer[2];
2697
- const eof = buffer[headerSize - 1];
2698
- const attachment = __classPrivateFieldGet(this, _SfuExtended_downloadingAttachmentState, "f").find((attachment) => attachment.attachmentTransferId === attachmentTransferId && attachment.messageTransferId === messageTransferId);
2699
- if (attachment) {
2700
- if (!attachment.payload) {
2701
- attachment.payload = data.slice(headerSize, data.byteLength);
2702
- }
2703
- else {
2704
- //ToDo (igor): optimize ArrayBuffer merging
2705
- const newData = new Uint8Array(attachment.payload.byteLength + (data.byteLength - headerSize));
2706
- newData.set(new Uint8Array(attachment.payload), 0);
2707
- newData.set(new Uint8Array(data.slice(headerSize, data.byteLength)), attachment.payload.byteLength);
2708
- attachment.payload = newData.buffer;
2709
- }
2710
- if (eof === 1) {
2711
- __classPrivateFieldGet(this, _SfuExtended_instances, "m", _SfuExtended_notifyMessageAttachmentState).call(this, attachment, constants_1.AttachmentState.DOWNLOADED);
2712
- const index = __classPrivateFieldGet(this, _SfuExtended_downloadingAttachmentState, "f").indexOf(attachment);
2713
- __classPrivateFieldGet(this, _SfuExtended_downloadingAttachmentState, "f").splice(index, 1);
2714
- // ToDo (igor): need to resolve or reject in any case
2715
- promises_1.default.resolve(attachment.internalMessageId, attachment);
2716
- }
2717
- else {
2718
- __classPrivateFieldGet(this, _SfuExtended_instances, "m", _SfuExtended_notifyMessageAttachmentState).call(this, attachment, constants_1.AttachmentState.PENDING);
2719
- }
2720
- }
2721
- else {
2722
- __classPrivateFieldGet(this, _SfuExtended_logger, "f").info("Unable to find attachment with messageTransferId " + messageTransferId + " attachmentTransferId " + attachmentTransferId);
2723
- }
2724
- break;
2725
- default:
2726
- console.error("Unknown binary data type " + name);
2727
- }
2789
+ }, () => {
2728
2790
  }, (e) => {
2729
2791
  __classPrivateFieldSet(self, _SfuExtended__state, constants_1.State.FAILED, "f");
2730
2792
  __classPrivateFieldGet(self, _SfuExtended_notifier, "f").notify(constants_1.SfuEvent.CONNECTION_FAILED, e);
2731
2793
  }, (e) => {
2732
2794
  __classPrivateFieldSet(self, _SfuExtended__state, constants_1.State.DISCONNECTED, "f");
2733
2795
  self.disconnect();
2734
- __classPrivateFieldGet(self, _SfuExtended_downloadingAttachmentState, "f").length = 0;
2735
2796
  __classPrivateFieldSet(self, _SfuExtended_uploadingAttachmentState, {}, "f");
2736
2797
  const event = {
2737
2798
  reason: e.reason,
@@ -2759,17 +2820,6 @@ _SfuExtended_connection = new WeakMap(), _SfuExtended__user = new WeakMap(), _Sf
2759
2820
  nickname: ""
2760
2821
  }
2761
2822
  };
2762
- }, _SfuExtended_notifyMessageAttachmentState = function _SfuExtended_notifyMessageAttachmentState(attachment, state) {
2763
- const status = {
2764
- targetEntityType: attachment.targetEntityType,
2765
- targetEntityId: attachment.targetEntityId,
2766
- messageId: attachment.messageId,
2767
- id: attachment.attachmentId,
2768
- name: attachment.name,
2769
- state: state,
2770
- downloadedSize: attachment.payload.byteLength
2771
- };
2772
- __classPrivateFieldGet(this, _SfuExtended_notifier, "f").notify(constants_1.SfuEvent.MESSAGE_ATTACHMENT_STATE, status);
2773
2823
  }, _SfuExtended_getConnectionConfigForExamples = function _SfuExtended_getConnectionConfigForExamples(url, timeout) {
2774
2824
  return {
2775
2825
  url: url,