@ethora/chat-component-rn 26.8.1 → 26.8.2
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/CHANGELOG.md +96 -0
- package/README.md +43 -10
- package/lib/commonjs/assets/icons.js +7 -2
- package/lib/commonjs/assets/icons.js.map +1 -1
- package/lib/commonjs/components/AuthForms/Login.js +4 -4
- package/lib/commonjs/components/AuthForms/Login.js.map +1 -1
- package/lib/commonjs/components/Header/HeaderRoomList.js +29 -8
- package/lib/commonjs/components/Header/HeaderRoomList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatHeader.js +9 -3
- package/lib/commonjs/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatRoom.js +150 -14
- package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatWrapper.js +34 -13
- package/lib/commonjs/components/MainComponents/ChatWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/LoginWrapper.js +2 -1
- package/lib/commonjs/components/MainComponents/LoginWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MediaMessage.js +29 -9
- package/lib/commonjs/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MessageContainer.js +5 -1
- package/lib/commonjs/components/MainComponents/MessageContainer.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MessageList.js +13 -5
- package/lib/commonjs/components/MainComponents/MessageList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js +14 -13
- package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
- package/lib/commonjs/components/MainComponents/RoomList.js +208 -35
- package/lib/commonjs/components/MainComponents/RoomList.js.map +1 -1
- package/lib/commonjs/components/Menu/HeaderRoomListMenu.js +317 -98
- package/lib/commonjs/components/Menu/HeaderRoomListMenu.js.map +1 -1
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +322 -110
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +546 -203
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js +226 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +69 -27
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/PdfView.js +2 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/PdfView.js.map +1 -1
- package/lib/commonjs/components/Modals/Modal/Modal.js +8 -0
- package/lib/commonjs/components/Modals/Modal/Modal.js.map +1 -1
- package/lib/commonjs/components/Modals/NewChatModal/ModalContent.js +2 -1
- package/lib/commonjs/components/Modals/NewChatModal/ModalContent.js.map +1 -1
- package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js +202 -106
- package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/NewChatModal/UpdNewChatModal.js +8 -0
- package/lib/commonjs/components/Modals/NewChatModal/UpdNewChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js +563 -0
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -0
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js +210 -0
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js.map +1 -0
- package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js +4 -2
- package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/EditUserModal.js +7 -21
- package/lib/commonjs/components/Modals/UserProfileModal/EditUserModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +507 -244
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js +74 -46
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/commonjs/components/Modals/styledModalComponents.js +9 -2
- package/lib/commonjs/components/Modals/styledModalComponents.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +21 -7
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js +22 -3
- package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js +17 -3
- package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js +17 -3
- package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/VideoCallSession.js +6 -3
- package/lib/commonjs/components/VideoCalls/VideoCallSession.js.map +1 -1
- package/lib/commonjs/components/styled/AudioMessage.js +2 -1
- package/lib/commonjs/components/styled/AudioMessage.js.map +1 -1
- package/lib/commonjs/components/styled/MessageImage.js +37 -9
- package/lib/commonjs/components/styled/MessageImage.js.map +1 -1
- package/lib/commonjs/components/styled/SendInput.js +80 -11
- package/lib/commonjs/components/styled/SendInput.js.map +1 -1
- package/lib/commonjs/components/styled/StyledComponents.js +9 -3
- package/lib/commonjs/components/styled/StyledComponents.js.map +1 -1
- package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js +11 -4
- package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
- package/lib/commonjs/components/styled/UnsupportedType.js +14 -4
- package/lib/commonjs/components/styled/UnsupportedType.js.map +1 -1
- package/lib/commonjs/components/styled/VideoMessage.js +119 -61
- package/lib/commonjs/components/styled/VideoMessage.js.map +1 -1
- package/lib/commonjs/context/xmppProvider.js +184 -59
- package/lib/commonjs/context/xmppProvider.js.map +1 -1
- package/lib/commonjs/helpers/createMessageFromXml.js +19 -1
- package/lib/commonjs/helpers/createMessageFromXml.js.map +1 -1
- package/lib/commonjs/helpers/ensureScopedChatCache.js +2 -2
- package/lib/commonjs/helpers/ensureScopedChatCache.js.map +1 -1
- package/lib/commonjs/helpers/getChatBackground.js +23 -0
- package/lib/commonjs/helpers/getChatBackground.js.map +1 -0
- package/lib/commonjs/helpers/getDisplayFileName.js +79 -0
- package/lib/commonjs/helpers/getDisplayFileName.js.map +1 -0
- package/lib/commonjs/helpers/getServerReadTimestamp.js +188 -0
- package/lib/commonjs/helpers/getServerReadTimestamp.js.map +1 -0
- package/lib/commonjs/helpers/historyPreloadScheduler.js +65 -2
- package/lib/commonjs/helpers/historyPreloadScheduler.js.map +1 -1
- package/lib/commonjs/helpers/initXmppRooms.js +14 -8
- package/lib/commonjs/helpers/initXmppRooms.js.map +1 -1
- package/lib/commonjs/helpers/insertMessageWithDelimiter.js +51 -9
- package/lib/commonjs/helpers/insertMessageWithDelimiter.js.map +1 -1
- package/lib/commonjs/helpers/isOwnMessage.js +75 -0
- package/lib/commonjs/helpers/isOwnMessage.js.map +1 -0
- package/lib/commonjs/helpers/keyboardLayout.js +12 -2
- package/lib/commonjs/helpers/keyboardLayout.js.map +1 -1
- package/lib/commonjs/helpers/mediaLibraryRuntime.js +31 -0
- package/lib/commonjs/helpers/mediaLibraryRuntime.js.map +1 -0
- package/lib/commonjs/helpers/mimeToExtension.js +6 -14
- package/lib/commonjs/helpers/mimeToExtension.js.map +1 -1
- package/lib/commonjs/helpers/msgSortableMs.js +37 -0
- package/lib/commonjs/helpers/msgSortableMs.js.map +1 -0
- package/lib/commonjs/helpers/persistCrypto.js +122 -0
- package/lib/commonjs/helpers/persistCrypto.js.map +1 -0
- package/lib/commonjs/helpers/pickImageAsset.js +68 -0
- package/lib/commonjs/helpers/pickImageAsset.js.map +1 -0
- package/lib/commonjs/helpers/pushPayload.js +71 -0
- package/lib/commonjs/helpers/pushPayload.js.map +1 -0
- package/lib/commonjs/helpers/resolveInitBeforeLoadUser.js +130 -17
- package/lib/commonjs/helpers/resolveInitBeforeLoadUser.js.map +1 -1
- package/lib/commonjs/helpers/secureFileUrl.js +101 -0
- package/lib/commonjs/helpers/secureFileUrl.js.map +1 -0
- package/lib/commonjs/helpers/secureKeyValue.js +83 -0
- package/lib/commonjs/helpers/secureKeyValue.js.map +1 -0
- package/lib/commonjs/helpers/secureStoreRuntime.js +59 -0
- package/lib/commonjs/helpers/secureStoreRuntime.js.map +1 -0
- package/lib/commonjs/helpers/secureUserStorage.js +75 -0
- package/lib/commonjs/helpers/secureUserStorage.js.map +1 -0
- package/lib/commonjs/helpers/shallowEqual.js +36 -0
- package/lib/commonjs/helpers/shallowEqual.js.map +1 -0
- package/lib/commonjs/helpers/sheetGestures.js +32 -0
- package/lib/commonjs/helpers/sheetGestures.js.map +1 -0
- package/lib/commonjs/hooks/useChatRoomFocus.js +45 -12
- package/lib/commonjs/hooks/useChatRoomFocus.js.map +1 -1
- package/lib/commonjs/hooks/useChatWrapperInit.js +30 -10
- package/lib/commonjs/hooks/useChatWrapperInit.js.map +1 -1
- package/lib/commonjs/hooks/useComposing.js +27 -0
- package/lib/commonjs/hooks/useComposing.js.map +1 -1
- package/lib/commonjs/hooks/useFileToken.js +10 -0
- package/lib/commonjs/hooks/useFileToken.js.map +1 -0
- package/lib/commonjs/hooks/useLogout.js +23 -7
- package/lib/commonjs/hooks/useLogout.js.map +1 -1
- package/lib/commonjs/hooks/usePendingNotification.js +8 -11
- package/lib/commonjs/hooks/usePendingNotification.js.map +1 -1
- package/lib/commonjs/hooks/useSendMessage.js +50 -14
- package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
- package/lib/commonjs/hooks/useUnreadMessagesCounter.js +6 -1
- package/lib/commonjs/hooks/useUnreadMessagesCounter.js.map +1 -1
- package/lib/commonjs/i18n/strings.js +145 -37
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/main.js +44 -0
- package/lib/commonjs/main.js.map +1 -1
- package/lib/commonjs/networking/api-requests/auth.api.js +134 -60
- package/lib/commonjs/networking/api-requests/auth.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/roomMembers.api.js +1 -1
- package/lib/commonjs/networking/api-requests/roomMembers.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/rooms.api.js +9 -9
- package/lib/commonjs/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/user.api.js +68 -9
- package/lib/commonjs/networking/api-requests/user.api.js.map +1 -1
- package/lib/commonjs/networking/apiClient.js +62 -112
- package/lib/commonjs/networking/apiClient.js.map +1 -1
- package/lib/commonjs/networking/authRefresh.js +332 -0
- package/lib/commonjs/networking/authRefresh.js.map +1 -0
- package/lib/commonjs/networking/stanzaHandlers.js +41 -28
- package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
- package/lib/commonjs/networking/xmpp/flushLastViewedToPrivateStore.js +46 -8
- package/lib/commonjs/networking/xmpp/flushLastViewedToPrivateStore.js.map +1 -1
- package/lib/commonjs/networking/xmpp/presenceInRoom.xmpp.js +8 -1
- package/lib/commonjs/networking/xmpp/presenceInRoom.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/subscribeToRoomMessages.xmpp.js +5 -1
- package/lib/commonjs/networking/xmpp/subscribeToRoomMessages.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmppClient.js +124 -8
- package/lib/commonjs/networking/xmppClient.js.map +1 -1
- package/lib/commonjs/roomStore/chatSettingsSlice.js +26 -7
- package/lib/commonjs/roomStore/chatSettingsSlice.js.map +1 -1
- package/lib/commonjs/roomStore/index.js +35 -2
- package/lib/commonjs/roomStore/index.js.map +1 -1
- package/lib/commonjs/roomStore/persistence.js +226 -23
- package/lib/commonjs/roomStore/persistence.js.map +1 -1
- package/lib/commonjs/roomStore/roomsSlice.js +151 -38
- package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
- package/lib/commonjs/services/pushSubscriptionService.js +15 -13
- package/lib/commonjs/services/pushSubscriptionService.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/assets/icons.js +6 -1
- package/lib/module/assets/icons.js.map +1 -1
- package/lib/module/components/AuthForms/Login.js +4 -4
- package/lib/module/components/AuthForms/Login.js.map +1 -1
- package/lib/module/components/Header/HeaderRoomList.js +29 -8
- package/lib/module/components/Header/HeaderRoomList.js.map +1 -1
- package/lib/module/components/MainComponents/ChatHeader.js +9 -3
- package/lib/module/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/module/components/MainComponents/ChatRoom.js +152 -16
- package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/module/components/MainComponents/ChatWrapper.js +35 -14
- package/lib/module/components/MainComponents/ChatWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/LoginWrapper.js +2 -1
- package/lib/module/components/MainComponents/LoginWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/MediaMessage.js +30 -10
- package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/module/components/MainComponents/MessageContainer.js +5 -1
- package/lib/module/components/MainComponents/MessageContainer.js.map +1 -1
- package/lib/module/components/MainComponents/MessageList.js +13 -5
- package/lib/module/components/MainComponents/MessageList.js.map +1 -1
- package/lib/module/components/MainComponents/ProfileImagePlaceholder.js +14 -13
- package/lib/module/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
- package/lib/module/components/MainComponents/RoomList.js +207 -35
- package/lib/module/components/MainComponents/RoomList.js.map +1 -1
- package/lib/module/components/Menu/HeaderRoomListMenu.js +319 -101
- package/lib/module/components/Menu/HeaderRoomListMenu.js.map +1 -1
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js +313 -113
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +549 -207
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js +223 -0
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -0
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +70 -28
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/PdfView.js +2 -1
- package/lib/module/components/Modals/FilePreviewModal/PdfView.js.map +1 -1
- package/lib/module/components/Modals/Modal/Modal.js +9 -1
- package/lib/module/components/Modals/Modal/Modal.js.map +1 -1
- package/lib/module/components/Modals/NewChatModal/ModalContent.js +2 -1
- package/lib/module/components/Modals/NewChatModal/ModalContent.js.map +1 -1
- package/lib/module/components/Modals/NewChatModal/NewChatModal.js +205 -108
- package/lib/module/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
- package/lib/module/components/Modals/NewChatModal/UpdNewChatModal.js +8 -0
- package/lib/module/components/Modals/NewChatModal/UpdNewChatModal.js.map +1 -1
- package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js +555 -0
- package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -0
- package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js +205 -0
- package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js.map +1 -0
- package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js +4 -2
- package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/EditUserModal.js +9 -23
- package/lib/module/components/Modals/UserProfileModal/EditUserModal.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +509 -248
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js +76 -48
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/module/components/Modals/styledModalComponents.js +9 -2
- package/lib/module/components/Modals/styledModalComponents.js.map +1 -1
- package/lib/module/components/RoomComponents/ChatRoomItem.js +21 -7
- package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageFile.js +22 -3
- package/lib/module/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js +17 -3
- package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageVideo.js +17 -3
- package/lib/module/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
- package/lib/module/components/VideoCalls/VideoCallSession.js +6 -3
- package/lib/module/components/VideoCalls/VideoCallSession.js.map +1 -1
- package/lib/module/components/styled/AudioMessage.js +2 -1
- package/lib/module/components/styled/AudioMessage.js.map +1 -1
- package/lib/module/components/styled/MessageImage.js +37 -9
- package/lib/module/components/styled/MessageImage.js.map +1 -1
- package/lib/module/components/styled/SendInput.js +81 -12
- package/lib/module/components/styled/SendInput.js.map +1 -1
- package/lib/module/components/styled/StyledComponents.js +9 -3
- package/lib/module/components/styled/StyledComponents.js.map +1 -1
- package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js +11 -4
- package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
- package/lib/module/components/styled/UnsupportedType.js +14 -4
- package/lib/module/components/styled/UnsupportedType.js.map +1 -1
- package/lib/module/components/styled/VideoMessage.js +120 -62
- package/lib/module/components/styled/VideoMessage.js.map +1 -1
- package/lib/module/context/xmppProvider.js +184 -60
- package/lib/module/context/xmppProvider.js.map +1 -1
- package/lib/module/helpers/createMessageFromXml.js +19 -1
- package/lib/module/helpers/createMessageFromXml.js.map +1 -1
- package/lib/module/helpers/ensureScopedChatCache.js +2 -2
- package/lib/module/helpers/ensureScopedChatCache.js.map +1 -1
- package/lib/module/helpers/getChatBackground.js +18 -0
- package/lib/module/helpers/getChatBackground.js.map +1 -0
- package/lib/module/helpers/getDisplayFileName.js +73 -0
- package/lib/module/helpers/getDisplayFileName.js.map +1 -0
- package/lib/module/helpers/getServerReadTimestamp.js +181 -0
- package/lib/module/helpers/getServerReadTimestamp.js.map +1 -0
- package/lib/module/helpers/historyPreloadScheduler.js +66 -3
- package/lib/module/helpers/historyPreloadScheduler.js.map +1 -1
- package/lib/module/helpers/initXmppRooms.js +14 -8
- package/lib/module/helpers/initXmppRooms.js.map +1 -1
- package/lib/module/helpers/insertMessageWithDelimiter.js +52 -9
- package/lib/module/helpers/insertMessageWithDelimiter.js.map +1 -1
- package/lib/module/helpers/isOwnMessage.js +70 -0
- package/lib/module/helpers/isOwnMessage.js.map +1 -0
- package/lib/module/helpers/keyboardLayout.js +12 -2
- package/lib/module/helpers/keyboardLayout.js.map +1 -1
- package/lib/module/helpers/mediaLibraryRuntime.js +25 -0
- package/lib/module/helpers/mediaLibraryRuntime.js.map +1 -0
- package/lib/module/helpers/mimeToExtension.js +6 -13
- package/lib/module/helpers/mimeToExtension.js.map +1 -1
- package/lib/module/helpers/msgSortableMs.js +32 -0
- package/lib/module/helpers/msgSortableMs.js.map +1 -0
- package/lib/module/helpers/persistCrypto.js +115 -0
- package/lib/module/helpers/persistCrypto.js.map +1 -0
- package/lib/module/helpers/pickImageAsset.js +63 -0
- package/lib/module/helpers/pickImageAsset.js.map +1 -0
- package/lib/module/helpers/pushPayload.js +63 -0
- package/lib/module/helpers/pushPayload.js.map +1 -0
- package/lib/module/helpers/resolveInitBeforeLoadUser.js +130 -16
- package/lib/module/helpers/resolveInitBeforeLoadUser.js.map +1 -1
- package/lib/module/helpers/secureFileUrl.js +91 -0
- package/lib/module/helpers/secureFileUrl.js.map +1 -0
- package/lib/module/helpers/secureKeyValue.js +75 -0
- package/lib/module/helpers/secureKeyValue.js.map +1 -0
- package/lib/module/helpers/secureStoreRuntime.js +52 -0
- package/lib/module/helpers/secureStoreRuntime.js.map +1 -0
- package/lib/module/helpers/secureUserStorage.js +72 -0
- package/lib/module/helpers/secureUserStorage.js.map +1 -0
- package/lib/module/helpers/shallowEqual.js +31 -0
- package/lib/module/helpers/shallowEqual.js.map +1 -0
- package/lib/module/helpers/sheetGestures.js +26 -0
- package/lib/module/helpers/sheetGestures.js.map +1 -0
- package/lib/module/hooks/useChatRoomFocus.js +46 -13
- package/lib/module/hooks/useChatRoomFocus.js.map +1 -1
- package/lib/module/hooks/useChatWrapperInit.js +30 -10
- package/lib/module/hooks/useChatWrapperInit.js.map +1 -1
- package/lib/module/hooks/useComposing.js +28 -1
- package/lib/module/hooks/useComposing.js.map +1 -1
- package/lib/module/hooks/useFileToken.js +5 -0
- package/lib/module/hooks/useFileToken.js.map +1 -0
- package/lib/module/hooks/useLogout.js +23 -7
- package/lib/module/hooks/useLogout.js.map +1 -1
- package/lib/module/hooks/usePendingNotification.js +8 -11
- package/lib/module/hooks/usePendingNotification.js.map +1 -1
- package/lib/module/hooks/useSendMessage.js +52 -16
- package/lib/module/hooks/useSendMessage.js.map +1 -1
- package/lib/module/hooks/useUnreadMessagesCounter.js +6 -1
- package/lib/module/hooks/useUnreadMessagesCounter.js.map +1 -1
- package/lib/module/i18n/strings.js +145 -37
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/main.js +14 -2
- package/lib/module/main.js.map +1 -1
- package/lib/module/networking/api-requests/auth.api.js +131 -59
- package/lib/module/networking/api-requests/auth.api.js.map +1 -1
- package/lib/module/networking/api-requests/roomMembers.api.js +1 -1
- package/lib/module/networking/api-requests/roomMembers.api.js.map +1 -1
- package/lib/module/networking/api-requests/rooms.api.js +9 -9
- package/lib/module/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/module/networking/api-requests/user.api.js +64 -7
- package/lib/module/networking/api-requests/user.api.js.map +1 -1
- package/lib/module/networking/apiClient.js +61 -113
- package/lib/module/networking/apiClient.js.map +1 -1
- package/lib/module/networking/authRefresh.js +321 -0
- package/lib/module/networking/authRefresh.js.map +1 -0
- package/lib/module/networking/stanzaHandlers.js +41 -28
- package/lib/module/networking/stanzaHandlers.js.map +1 -1
- package/lib/module/networking/xmpp/flushLastViewedToPrivateStore.js +46 -8
- package/lib/module/networking/xmpp/flushLastViewedToPrivateStore.js.map +1 -1
- package/lib/module/networking/xmpp/presenceInRoom.xmpp.js +8 -1
- package/lib/module/networking/xmpp/presenceInRoom.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/subscribeToRoomMessages.xmpp.js +5 -1
- package/lib/module/networking/xmpp/subscribeToRoomMessages.xmpp.js.map +1 -1
- package/lib/module/networking/xmppClient.js +124 -8
- package/lib/module/networking/xmppClient.js.map +1 -1
- package/lib/module/roomStore/chatSettingsSlice.js +26 -7
- package/lib/module/roomStore/chatSettingsSlice.js.map +1 -1
- package/lib/module/roomStore/index.js +37 -4
- package/lib/module/roomStore/index.js.map +1 -1
- package/lib/module/roomStore/persistence.js +223 -22
- package/lib/module/roomStore/persistence.js.map +1 -1
- package/lib/module/roomStore/roomsSlice.js +139 -34
- package/lib/module/roomStore/roomsSlice.js.map +1 -1
- package/lib/module/services/pushSubscriptionService.js +15 -13
- package/lib/module/services/pushSubscriptionService.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/assets/icons.d.ts +16 -0
- package/lib/typescript/assets/icons.d.ts.map +1 -1
- package/lib/typescript/components/AuthForms/Login.d.ts.map +1 -1
- package/lib/typescript/components/Header/HeaderRoomList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatHeader.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/LoginWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MessageContainer.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MessageList.d.ts +10 -1
- package/lib/typescript/components/MainComponents/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ProfileImagePlaceholder.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/RoomList.d.ts +7 -0
- package/lib/typescript/components/MainComponents/RoomList.d.ts.map +1 -1
- package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts +3 -0
- package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts.map +1 -1
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts +9 -0
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts +10 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts +9 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts.map +1 -0
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/PdfView.d.ts.map +1 -1
- package/lib/typescript/components/Modals/Modal/Modal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/NewChatModal/ModalContent.d.ts +4 -2
- package/lib/typescript/components/Modals/NewChatModal/ModalContent.d.ts.map +1 -1
- package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts +1 -1
- package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/NewChatModal/UpdNewChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts +75 -0
- package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts.map +1 -0
- package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts +25 -0
- package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts.map +1 -0
- package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts +6 -1
- package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/EditUserModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts +16 -0
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts +1 -0
- package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/styledModalComponents.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/VideoCallSession.d.ts.map +1 -1
- package/lib/typescript/components/styled/AudioMessage.d.ts.map +1 -1
- package/lib/typescript/components/styled/MessageImage.d.ts +14 -0
- package/lib/typescript/components/styled/MessageImage.d.ts.map +1 -1
- package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
- package/lib/typescript/components/styled/StyledComponents.d.ts.map +1 -1
- package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts.map +1 -1
- package/lib/typescript/components/styled/UnsupportedType.d.ts.map +1 -1
- package/lib/typescript/components/styled/VideoMessage.d.ts +8 -0
- package/lib/typescript/components/styled/VideoMessage.d.ts.map +1 -1
- package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
- package/lib/typescript/helpers/createMessageFromXml.d.ts.map +1 -1
- package/lib/typescript/helpers/getChatBackground.d.ts +15 -0
- package/lib/typescript/helpers/getChatBackground.d.ts.map +1 -0
- package/lib/typescript/helpers/getDisplayFileName.d.ts +49 -0
- package/lib/typescript/helpers/getDisplayFileName.d.ts.map +1 -0
- package/lib/typescript/helpers/getServerReadTimestamp.d.ts +108 -0
- package/lib/typescript/helpers/getServerReadTimestamp.d.ts.map +1 -0
- package/lib/typescript/helpers/historyPreloadScheduler.d.ts.map +1 -1
- package/lib/typescript/helpers/initXmppRooms.d.ts.map +1 -1
- package/lib/typescript/helpers/insertMessageWithDelimiter.d.ts +1 -1
- package/lib/typescript/helpers/insertMessageWithDelimiter.d.ts.map +1 -1
- package/lib/typescript/helpers/isOwnMessage.d.ts +36 -0
- package/lib/typescript/helpers/isOwnMessage.d.ts.map +1 -0
- package/lib/typescript/helpers/keyboardLayout.d.ts +5 -1
- package/lib/typescript/helpers/keyboardLayout.d.ts.map +1 -1
- package/lib/typescript/helpers/mediaLibraryRuntime.d.ts +3 -0
- package/lib/typescript/helpers/mediaLibraryRuntime.d.ts.map +1 -0
- package/lib/typescript/helpers/mimeToExtension.d.ts +0 -15
- package/lib/typescript/helpers/mimeToExtension.d.ts.map +1 -1
- package/lib/typescript/helpers/msgSortableMs.d.ts +2 -0
- package/lib/typescript/helpers/msgSortableMs.d.ts.map +1 -0
- package/lib/typescript/helpers/persistCrypto.d.ts +13 -0
- package/lib/typescript/helpers/persistCrypto.d.ts.map +1 -0
- package/lib/typescript/helpers/pickImageAsset.d.ts +27 -0
- package/lib/typescript/helpers/pickImageAsset.d.ts.map +1 -0
- package/lib/typescript/helpers/pushPayload.d.ts +7 -0
- package/lib/typescript/helpers/pushPayload.d.ts.map +1 -0
- package/lib/typescript/helpers/resolveInitBeforeLoadUser.d.ts.map +1 -1
- package/lib/typescript/helpers/secureFileUrl.d.ts +7 -0
- package/lib/typescript/helpers/secureFileUrl.d.ts.map +1 -0
- package/lib/typescript/helpers/secureKeyValue.d.ts +13 -0
- package/lib/typescript/helpers/secureKeyValue.d.ts.map +1 -0
- package/lib/typescript/helpers/secureStoreRuntime.d.ts +29 -0
- package/lib/typescript/helpers/secureStoreRuntime.d.ts.map +1 -0
- package/lib/typescript/helpers/secureUserStorage.d.ts +23 -0
- package/lib/typescript/helpers/secureUserStorage.d.ts.map +1 -0
- package/lib/typescript/helpers/shallowEqual.d.ts +11 -0
- package/lib/typescript/helpers/shallowEqual.d.ts.map +1 -0
- package/lib/typescript/helpers/sheetGestures.d.ts +20 -0
- package/lib/typescript/helpers/sheetGestures.d.ts.map +1 -0
- package/lib/typescript/hooks/useChatRoomFocus.d.ts +4 -1
- package/lib/typescript/hooks/useChatRoomFocus.d.ts.map +1 -1
- package/lib/typescript/hooks/useChatWrapperInit.d.ts.map +1 -1
- package/lib/typescript/hooks/useComposing.d.ts.map +1 -1
- package/lib/typescript/hooks/useFileToken.d.ts +2 -0
- package/lib/typescript/hooks/useFileToken.d.ts.map +1 -0
- package/lib/typescript/hooks/useLogout.d.ts.map +1 -1
- package/lib/typescript/hooks/usePendingNotification.d.ts.map +1 -1
- package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/hooks/useUnreadMessagesCounter.d.ts +1 -0
- package/lib/typescript/hooks/useUnreadMessagesCounter.d.ts.map +1 -1
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/main.d.ts +9 -2
- package/lib/typescript/main.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/auth.api.d.ts +3 -1
- package/lib/typescript/networking/api-requests/auth.api.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/user.api.d.ts +27 -0
- package/lib/typescript/networking/api-requests/user.api.d.ts.map +1 -1
- package/lib/typescript/networking/apiClient.d.ts +12 -6
- package/lib/typescript/networking/apiClient.d.ts.map +1 -1
- package/lib/typescript/networking/authRefresh.d.ts +95 -0
- package/lib/typescript/networking/authRefresh.d.ts.map +1 -0
- package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/flushLastViewedToPrivateStore.d.ts +10 -2
- package/lib/typescript/networking/xmpp/flushLastViewedToPrivateStore.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/presenceInRoom.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/subscribeToRoomMessages.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmppClient.d.ts +14 -0
- package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
- package/lib/typescript/roomStore/chatSettingsSlice.d.ts +16 -0
- package/lib/typescript/roomStore/chatSettingsSlice.d.ts.map +1 -1
- package/lib/typescript/roomStore/index.d.ts.map +1 -1
- package/lib/typescript/roomStore/persistence.d.ts +18 -1
- package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
- package/lib/typescript/roomStore/roomsSlice.d.ts +43 -3
- package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
- package/lib/typescript/services/pushSubscriptionService.d.ts +1 -1
- package/lib/typescript/services/pushSubscriptionService.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +50 -5
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +41 -28
- package/src/assets/icons.tsx +48 -9
- package/src/components/AuthForms/Login.tsx +3 -3
- package/src/components/Header/HeaderRoomList.tsx +29 -7
- package/src/components/MainComponents/ChatHeader.tsx +9 -3
- package/src/components/MainComponents/ChatRoom.tsx +161 -15
- package/src/components/MainComponents/ChatWrapper.tsx +36 -20
- package/src/components/MainComponents/LoginWrapper.tsx +1 -0
- package/src/components/MainComponents/MediaMessage.tsx +26 -8
- package/src/components/MainComponents/MessageContainer.tsx +5 -1
- package/src/components/MainComponents/MessageList.tsx +23 -4
- package/src/components/MainComponents/ProfileImagePlaceholder.tsx +21 -14
- package/src/components/MainComponents/RoomList.tsx +236 -39
- package/src/components/Menu/HeaderRoomListMenu.tsx +328 -75
- package/src/components/Modals/AttachSheet/AttachSheet.tsx +333 -97
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +600 -282
- package/src/components/Modals/ChatProfileModal/ReportChatModal.tsx +244 -0
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +79 -38
- package/src/components/Modals/FilePreviewModal/PdfView.tsx +2 -1
- package/src/components/Modals/Modal/Modal.tsx +7 -0
- package/src/components/Modals/NewChatModal/ModalContent.tsx +6 -3
- package/src/components/Modals/NewChatModal/NewChatModal.tsx +219 -119
- package/src/components/Modals/NewChatModal/UpdNewChatModal.tsx +12 -1
- package/src/components/Modals/ProfileHeader/ProfileHeader.tsx +624 -0
- package/src/components/Modals/ProfileHeader/ProfileMenu.tsx +217 -0
- package/src/components/Modals/SelectUsersModal/SelectUsersModal.tsx +14 -4
- package/src/components/Modals/UserProfileModal/EditUserModal.tsx +9 -25
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +617 -307
- package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +75 -58
- package/src/components/Modals/styledModalComponents.tsx +9 -2
- package/src/components/RoomComponents/ChatRoomItem.tsx +18 -3
- package/src/components/RoomComponents/styled/LastMessageFile.tsx +28 -4
- package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +18 -3
- package/src/components/RoomComponents/styled/LastMessageVideo.tsx +18 -3
- package/src/components/VideoCalls/VideoCallSession.tsx +8 -3
- package/src/components/styled/AudioMessage.tsx +2 -1
- package/src/components/styled/MessageImage.tsx +53 -7
- package/src/components/styled/SendInput.tsx +83 -12
- package/src/components/styled/StyledComponents.ts +9 -3
- package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +11 -4
- package/src/components/styled/UnsupportedType.tsx +14 -4
- package/src/components/styled/VideoMessage.tsx +131 -54
- package/src/context/xmppProvider.tsx +216 -57
- package/src/helpers/createMessageFromXml.ts +20 -1
- package/src/helpers/ensureScopedChatCache.ts +2 -2
- package/src/helpers/getChatBackground.ts +18 -0
- package/src/helpers/getDisplayFileName.ts +87 -0
- package/src/helpers/getServerReadTimestamp.ts +197 -0
- package/src/helpers/historyPreloadScheduler.ts +80 -3
- package/src/helpers/initXmppRooms.tsx +14 -10
- package/src/helpers/insertMessageWithDelimiter.ts +55 -19
- package/src/helpers/isOwnMessage.ts +90 -0
- package/src/helpers/keyboardLayout.ts +23 -2
- package/src/helpers/mediaLibraryRuntime.ts +25 -0
- package/src/helpers/mimeToExtension.ts +6 -22
- package/src/helpers/msgSortableMs.ts +25 -0
- package/src/helpers/persistCrypto.ts +127 -0
- package/src/helpers/pickImageAsset.ts +68 -0
- package/src/helpers/pushPayload.ts +62 -0
- package/src/helpers/resolveInitBeforeLoadUser.ts +125 -18
- package/src/helpers/secureFileUrl.ts +103 -0
- package/src/helpers/secureKeyValue.ts +80 -0
- package/src/helpers/secureStoreRuntime.ts +62 -0
- package/src/helpers/secureUserStorage.ts +80 -0
- package/src/helpers/shallowEqual.ts +33 -0
- package/src/helpers/sheetGestures.ts +25 -0
- package/src/hooks/useChatRoomFocus.ts +49 -9
- package/src/hooks/useChatWrapperInit.ts +30 -10
- package/src/hooks/useComposing.tsx +37 -1
- package/src/hooks/useFileToken.ts +7 -0
- package/src/hooks/useLogout.tsx +29 -9
- package/src/hooks/usePendingNotification.ts +5 -11
- package/src/hooks/useSendMessage.tsx +60 -15
- package/src/hooks/useUnreadMessagesCounter.ts +11 -0
- package/src/i18n/strings.ts +145 -37
- package/src/main.ts +26 -2
- package/src/networking/api-requests/auth.api.ts +156 -48
- package/src/networking/api-requests/roomMembers.api.ts +1 -1
- package/src/networking/api-requests/rooms.api.ts +9 -9
- package/src/networking/api-requests/user.api.ts +79 -7
- package/src/networking/apiClient.ts +68 -123
- package/src/networking/authRefresh.ts +451 -0
- package/src/networking/stanzaHandlers.ts +44 -28
- package/src/networking/xmpp/flushLastViewedToPrivateStore.ts +71 -10
- package/src/networking/xmpp/presenceInRoom.xmpp.ts +6 -1
- package/src/networking/xmpp/subscribeToRoomMessages.xmpp.ts +12 -1
- package/src/networking/xmppClient.ts +141 -9
- package/src/roomStore/chatSettingsSlice.ts +34 -10
- package/src/roomStore/index.ts +40 -4
- package/src/roomStore/persistence.ts +234 -24
- package/src/roomStore/roomsSlice.ts +161 -29
- package/src/services/pushSubscriptionService.ts +18 -13
- package/src/types/types.ts +72 -5
- package/src/version.ts +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { setBaseURL } from '../networking/apiClient';
|
|
4
|
+
import { refreshAuthTokens, isRefreshFatalError } from '../networking/authRefresh';
|
|
4
5
|
import { loginViaJwt } from '../networking/api-requests/auth.api';
|
|
5
6
|
import { getMyUser } from '../networking/api-requests/user.api';
|
|
6
7
|
import { store } from '../roomStore';
|
|
7
8
|
import { setUser } from '../roomStore/chatSettingsSlice';
|
|
8
9
|
import { walletToUsername } from './walletUsername';
|
|
9
|
-
import {
|
|
10
|
-
import { localStorageConstants } from './constants/LOCAL_STORAGE';
|
|
10
|
+
import { secureUserStorage } from './secureUserStorage';
|
|
11
11
|
const getStatusCode = error => {
|
|
12
12
|
const status = error?.response?.status;
|
|
13
13
|
return typeof status === 'number' ? status : null;
|
|
@@ -31,15 +31,112 @@ const normalizeUserForXmpp = user => {
|
|
|
31
31
|
xmppUsername: normalizedXmppUsername
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
|
|
35
|
+
// Hermes has no atob/Buffer; hand-decode just enough base64url to read a
|
|
36
|
+
// JWT's `iat`. Claims are ASCII so the byte-per-char string is fine.
|
|
37
|
+
const B64_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
38
|
+
const readJwtIat = token => {
|
|
39
|
+
if (!token || typeof token !== 'string') {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
const part = token.split('.')[1];
|
|
43
|
+
if (!part) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const clean = part.replace(/-/g, '+').replace(/_/g, '/');
|
|
48
|
+
let out = '';
|
|
49
|
+
let buffer = 0;
|
|
50
|
+
let bits = 0;
|
|
51
|
+
for (let i = 0; i < clean.length; i++) {
|
|
52
|
+
const idx = B64_ALPHABET.indexOf(clean[i]);
|
|
53
|
+
if (idx === -1) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
buffer = buffer << 6 | idx;
|
|
57
|
+
bits += 6;
|
|
58
|
+
if (bits >= 8) {
|
|
59
|
+
bits -= 8;
|
|
60
|
+
out += String.fromCharCode(buffer >> bits & 0xff);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const iat = JSON.parse(out)?.iat;
|
|
64
|
+
return typeof iat === 'number' ? iat : 0;
|
|
65
|
+
} catch {
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A `userLogin.user` is typically a snapshot the host captured at ITS
|
|
72
|
+
* login time and re-presents verbatim on every mount, while this SDK
|
|
73
|
+
* keeps rotating the session and persisting the newest pair to
|
|
74
|
+
* `ETHORA_USER`. Taking the snapshot as-is therefore discards the live
|
|
75
|
+
* session in favour of an ever-aging copy: media goes blank the moment
|
|
76
|
+
* the snapshot has no `fileToken` (secure-files URLs 401 without it),
|
|
77
|
+
* and once the snapshot's refresh token ages out entirely the account
|
|
78
|
+
* looks dead even though the SDK held a working session all along.
|
|
79
|
+
*
|
|
80
|
+
* So, for the SAME account only, prefer whichever refresh pair was
|
|
81
|
+
* minted later (JWT `iat` decides — a host that genuinely re-logged-in
|
|
82
|
+
* hands us newer tokens and wins), and fill in a missing `fileToken`
|
|
83
|
+
* from the persisted copy either way.
|
|
84
|
+
*/
|
|
85
|
+
const adoptFresherPersistedSession = async candidate => {
|
|
86
|
+
try {
|
|
87
|
+
const stored = await secureUserStorage().get();
|
|
88
|
+
if (!stored) {
|
|
89
|
+
return candidate;
|
|
38
90
|
}
|
|
91
|
+
const sameUser = candidate._id && stored._id && candidate._id === stored._id || candidate.xmppUsername && stored.xmppUsername && candidate.xmppUsername === stored.xmppUsername;
|
|
92
|
+
if (!sameUser) {
|
|
93
|
+
return candidate;
|
|
94
|
+
}
|
|
95
|
+
const merged = {
|
|
96
|
+
...candidate
|
|
97
|
+
};
|
|
98
|
+
if (stored.refreshToken && readJwtIat(stored.refreshToken) > readJwtIat(candidate.refreshToken)) {
|
|
99
|
+
merged.refreshToken = stored.refreshToken;
|
|
100
|
+
if (stored.token) {
|
|
101
|
+
merged.token = stored.token;
|
|
102
|
+
}
|
|
103
|
+
if (stored.fileToken) {
|
|
104
|
+
merged.fileToken = stored.fileToken;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!merged.fileToken && stored.fileToken) {
|
|
108
|
+
merged.fileToken = stored.fileToken;
|
|
109
|
+
}
|
|
110
|
+
return merged;
|
|
111
|
+
} catch {
|
|
112
|
+
return candidate;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Bootstrap rotation.
|
|
118
|
+
*
|
|
119
|
+
* Was a second, independent `/users/login/refresh` caller that bypassed
|
|
120
|
+
* every lock in the SDK — and, worse, only wrote the rotated token to
|
|
121
|
+
* the store on the happy path, so several of the early-return branches
|
|
122
|
+
* below used to drop it. Under the backend's reuse detection a dropped
|
|
123
|
+
* rotation means the next launch presents a burned token and the
|
|
124
|
+
* session is killed.
|
|
125
|
+
*
|
|
126
|
+
* `refreshAuthTokens` persists the new pair before it resolves, so by
|
|
127
|
+
* the time this returns the rotation is safe no matter which branch the
|
|
128
|
+
* caller takes afterwards. The explicit token is required here: during
|
|
129
|
+
* bootstrap the candidate session isn't in the store yet.
|
|
130
|
+
*/
|
|
131
|
+
const refreshWithToken = async refreshToken => {
|
|
132
|
+
const result = await refreshAuthTokens({
|
|
133
|
+
refreshToken
|
|
39
134
|
});
|
|
40
135
|
return {
|
|
41
|
-
token:
|
|
42
|
-
refreshToken:
|
|
136
|
+
token: result.token,
|
|
137
|
+
refreshToken: result.refreshToken || refreshToken,
|
|
138
|
+
xmppPassword: result.xmppPassword || '',
|
|
139
|
+
fileToken: result.fileToken || ''
|
|
43
140
|
};
|
|
44
141
|
};
|
|
45
142
|
const mergeUsers = (base, patch) => {
|
|
@@ -64,10 +161,14 @@ const tryHydrateViaMy = async (candidate, myEndpoint, signal) => {
|
|
|
64
161
|
}
|
|
65
162
|
let workingToken = candidate?.token || '';
|
|
66
163
|
let workingRefresh = candidate?.refreshToken || '';
|
|
164
|
+
let rotatedXmppPassword = '';
|
|
165
|
+
let workingFileToken = candidate?.fileToken || '';
|
|
67
166
|
const candidateWithCurrentTokens = () => ({
|
|
68
167
|
...candidate,
|
|
69
168
|
token: workingToken || candidate.token,
|
|
70
|
-
refreshToken: workingRefresh || candidate.refreshToken
|
|
169
|
+
refreshToken: workingRefresh || candidate.refreshToken,
|
|
170
|
+
xmppPassword: rotatedXmppPassword || candidate.xmppPassword,
|
|
171
|
+
fileToken: workingFileToken || candidate.fileToken
|
|
71
172
|
});
|
|
72
173
|
const fallbackWithCreds = () => {
|
|
73
174
|
const normalized = normalizeUserForXmpp(candidateWithCurrentTokens());
|
|
@@ -86,6 +187,8 @@ const tryHydrateViaMy = async (candidate, myEndpoint, signal) => {
|
|
|
86
187
|
if (merged) {
|
|
87
188
|
merged.token = workingToken || merged.token;
|
|
88
189
|
merged.refreshToken = workingRefresh || merged.refreshToken;
|
|
190
|
+
merged.xmppPassword = rotatedXmppPassword || merged.xmppPassword;
|
|
191
|
+
merged.fileToken = workingFileToken || merged.fileToken;
|
|
89
192
|
}
|
|
90
193
|
return merged;
|
|
91
194
|
} catch (error) {
|
|
@@ -110,6 +213,8 @@ const tryHydrateViaMy = async (candidate, myEndpoint, signal) => {
|
|
|
110
213
|
const refreshed = await refreshWithToken(workingRefresh);
|
|
111
214
|
workingToken = refreshed.token;
|
|
112
215
|
workingRefresh = refreshed.refreshToken;
|
|
216
|
+
rotatedXmppPassword = refreshed.xmppPassword || rotatedXmppPassword;
|
|
217
|
+
workingFileToken = refreshed.fileToken || workingFileToken;
|
|
113
218
|
try {
|
|
114
219
|
const myUser = await getMyUser({
|
|
115
220
|
token: workingToken,
|
|
@@ -119,6 +224,8 @@ const tryHydrateViaMy = async (candidate, myEndpoint, signal) => {
|
|
|
119
224
|
if (merged) {
|
|
120
225
|
merged.token = workingToken || merged.token;
|
|
121
226
|
merged.refreshToken = workingRefresh || merged.refreshToken;
|
|
227
|
+
merged.xmppPassword = rotatedXmppPassword || merged.xmppPassword;
|
|
228
|
+
merged.fileToken = workingFileToken || merged.fileToken;
|
|
122
229
|
}
|
|
123
230
|
return merged;
|
|
124
231
|
} catch (myError) {
|
|
@@ -138,6 +245,13 @@ const tryHydrateViaMy = async (candidate, myEndpoint, signal) => {
|
|
|
138
245
|
if (signal?.aborted || isAbortError(error)) {
|
|
139
246
|
return null;
|
|
140
247
|
}
|
|
248
|
+
// A fatal refresh verdict (reuse detected / token not found / stale
|
|
249
|
+
// with nothing newer around) carries no HTTP response, so it would
|
|
250
|
+
// otherwise fall through to `throw` — the session is simply dead,
|
|
251
|
+
// which for bootstrap means "nothing to restore".
|
|
252
|
+
if (isRefreshFatalError(error)) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
141
255
|
if (isAuthError(error)) {
|
|
142
256
|
return null;
|
|
143
257
|
}
|
|
@@ -155,14 +269,14 @@ export const resolveInitBeforeLoadUser = async options => {
|
|
|
155
269
|
if (config?.baseUrl) {
|
|
156
270
|
setBaseURL(config.baseUrl, config.customAppToken);
|
|
157
271
|
}
|
|
158
|
-
const myEndpoint = config?.initBeforeLoadAuth?.myEndpoint || '/users/my';
|
|
272
|
+
const myEndpoint = config?.initBeforeLoadAuth?.myEndpoint || '/v1/users/my';
|
|
159
273
|
|
|
160
274
|
// Priority 1: explicit userLogin
|
|
161
275
|
const explicitUser = config?.userLogin?.enabled ? config?.userLogin?.user : null;
|
|
162
276
|
if (explicitUser) {
|
|
163
277
|
const candidate = normalizeUserForXmpp(explicitUser);
|
|
164
278
|
if (candidate && hasXmppCredentials(candidate)) {
|
|
165
|
-
return candidate;
|
|
279
|
+
return await adoptFresherPersistedSession(candidate);
|
|
166
280
|
}
|
|
167
281
|
const hydrated = await tryHydrateViaMy(explicitUser, myEndpoint, signal).catch(() => null);
|
|
168
282
|
if (hydrated && hasXmppCredentials(hydrated)) {
|
|
@@ -219,13 +333,13 @@ export const resolveInitBeforeLoadUser = async options => {
|
|
|
219
333
|
|
|
220
334
|
// Priority 5: persisted user in AsyncStorage
|
|
221
335
|
try {
|
|
222
|
-
const storedUser = await
|
|
336
|
+
const storedUser = await secureUserStorage().get();
|
|
223
337
|
if (storedUser && (storedUser.token || storedUser.refreshToken || storedUser.xmppPassword)) {
|
|
224
338
|
const hydrated = await tryHydrateViaMy(storedUser, myEndpoint, signal).catch(() => null);
|
|
225
339
|
if (hydrated && hasXmppCredentials(hydrated)) {
|
|
226
340
|
return hydrated;
|
|
227
341
|
}
|
|
228
|
-
await
|
|
342
|
+
await secureUserStorage().remove();
|
|
229
343
|
}
|
|
230
344
|
} catch {
|
|
231
345
|
// ignore storage errors
|
|
@@ -279,7 +393,7 @@ export const refreshUserCredentialsForXmpp = async (config, signal) => {
|
|
|
279
393
|
// fall through to /users/my path
|
|
280
394
|
}
|
|
281
395
|
}
|
|
282
|
-
const myEndpoint = config?.initBeforeLoadAuth?.myEndpoint || '/users/my';
|
|
396
|
+
const myEndpoint = config?.initBeforeLoadAuth?.myEndpoint || '/v1/users/my';
|
|
283
397
|
|
|
284
398
|
// Priority 2: redux store user (covers userLogin + customLogin +
|
|
285
399
|
// anything previously persisted into chatSettingStore.user). The
|
|
@@ -297,7 +411,7 @@ export const refreshUserCredentialsForXmpp = async (config, signal) => {
|
|
|
297
411
|
// should already mirror this, but if the redux state got cleared
|
|
298
412
|
// mid-session (logout race) this gives us one last shot.
|
|
299
413
|
try {
|
|
300
|
-
const storedUser = await
|
|
414
|
+
const storedUser = await secureUserStorage().get();
|
|
301
415
|
if (storedUser && (storedUser.token || storedUser.refreshToken || storedUser.xmppPassword)) {
|
|
302
416
|
const hydrated = await tryHydrateViaMy(storedUser, myEndpoint, signal).catch(() => null);
|
|
303
417
|
if (hydrated && hasXmppCredentials(hydrated)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["http","setBaseURL","loginViaJwt","getMyUser","store","setUser","walletToUsername","asyncLocalStorage","localStorageConstants","getStatusCode","error","status","response","isAuthError","code","isAbortError","message","toLowerCase","includes","hasXmppCredentials","user","Boolean","xmppPassword","xmppUsername","defaultWallet","walletAddress","normalizeUserForXmpp","normalizedXmppUsername","refreshWithToken","refreshToken","post","headers","Authorization","token","data","mergeUsers","base","patch","tryHydrateViaMy","candidate","myEndpoint","signal","aborted","mergedCandidate","workingToken","workingRefresh","candidateWithCurrentTokens","fallbackWithCreds","normalized","myUser","endpoint","merged","fallback","refreshed","myError","resolveInitBeforeLoadUser","options","config","baseUrl","customAppToken","initBeforeLoadAuth","explicitUser","userLogin","enabled","hydrated","catch","customLogin","loginFunction","customUser","jwtLogin","jwtUser","currentUser","getState","chatSettingStore","storedUser","ETHORA_USER","get","remove","applyResolvedUserToStore","dispatch","refreshUserCredentialsForXmpp","fresh"],"sourceRoot":"../../../src","sources":["helpers/resolveInitBeforeLoadUser.ts"],"mappings":";;AAAA,OAAOA,IAAI,IAAIC,UAAU,QAAQ,yBAAyB;AAC1D,SAASC,WAAW,QAAQ,qCAAqC;AACjE,SAASC,SAAS,QAAQ,qCAAqC;AAE/D,SAASC,KAAK,QAAQ,cAAc;AACpC,SAASC,OAAO,QAAQ,gCAAgC;AACxD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,qBAAqB,QAAQ,2BAA2B;AAYjE,MAAMC,aAAa,GAAIC,KAAc,IAA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,MAAM8B,UAAU,GAAGiB,MAAM,EAAEG,kBAAkB,EAAEpB,UAAU,IAAI,WAAW;;EAExE;EACA;EACA;EACA;EACA,MAAM+B,WAAW,GAAGnE,KAAK,CAACoE,QAAQ,CAAC,CAAC,CAACC,gBAAgB,CAACrD,IAAI;EAC1D,IAAImD,WAAW,EAAEtC,KAAK,IAAIsC,WAAW,EAAE1C,YAAY,EAAE;IACnD,MAAMmC,QAAQ,GAAG,MAAM1B,eAAe,CACpCiC,WAAW,EACX/B,UAAU,EACVC,MACF,CAAC,CAACwB,KAAK,CAAC,MAAM,IAAI,CAAC;IACnB,IAAID,QAAQ,IAAI7C,kBAAkB,CAAC6C,QAAQ,CAAC,EAAE;MAAC,OAAOA,QAAQ;IAAC;EACjE;;EAEA;EACA;EACA;EACA,IAAI;IACF,MAAMU,UAAU,GAAG,MAAMnE,iBAAiB,CACxCC,qBAAqB,CAACmE,WACxB,CAAC,CAACC,GAAG,CAAC,CAAC;IACP,IACEF,UAAU,KACTA,UAAU,CAACzC,KAAK,IAAIyC,UAAU,CAAC7C,YAAY,IAAI6C,UAAU,CAACpD,YAAY,CAAC,EACxE;MACA,MAAM0C,QAAQ,GAAG,MAAM1B,eAAe,CACpCoC,UAAU,EACVlC,UAAU,EACVC,MACF,CAAC,CAACwB,KAAK,CAAC,MAAM,IAAI,CAAC;MACnB,IAAID,QAAQ,IAAI7C,kBAAkB,CAAC6C,QAAQ,CAAC,EAAE;QAAC,OAAOA,QAAQ;MAAC;IACjE;EACF,CAAC,CAAC,MAAM;IACN;EAAA;EAGF,OAAO,IAAI;AACb,CAAC;AAED,eAAeT,yBAAyB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["setBaseURL","refreshAuthTokens","isRefreshFatalError","loginViaJwt","getMyUser","store","setUser","walletToUsername","secureUserStorage","getStatusCode","error","status","response","isAuthError","code","isAbortError","message","toLowerCase","includes","hasXmppCredentials","user","Boolean","xmppPassword","xmppUsername","defaultWallet","walletAddress","normalizeUserForXmpp","normalizedXmppUsername","B64_ALPHABET","readJwtIat","token","part","split","clean","replace","out","buffer","bits","i","length","idx","indexOf","String","fromCharCode","iat","JSON","parse","adoptFresherPersistedSession","candidate","stored","get","sameUser","_id","merged","refreshToken","fileToken","refreshWithToken","result","mergeUsers","base","patch","tryHydrateViaMy","myEndpoint","signal","aborted","mergedCandidate","workingToken","workingRefresh","rotatedXmppPassword","workingFileToken","candidateWithCurrentTokens","fallbackWithCreds","normalized","myUser","endpoint","fallback","refreshed","myError","resolveInitBeforeLoadUser","options","config","baseUrl","customAppToken","initBeforeLoadAuth","explicitUser","userLogin","enabled","hydrated","catch","customLogin","loginFunction","customUser","jwtLogin","jwtUser","currentUser","getState","chatSettingStore","storedUser","remove","applyResolvedUserToStore","dispatch","refreshUserCredentialsForXmpp","fresh"],"sourceRoot":"../../../src","sources":["helpers/resolveInitBeforeLoadUser.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,yBAAyB;AACpD,SAASC,iBAAiB,EAAEC,mBAAmB,QAAQ,2BAA2B;AAClF,SAASC,WAAW,QAAQ,qCAAqC;AACjE,SAASC,SAAS,QAAQ,qCAAqC;AAE/D,SAASC,KAAK,QAAQ,cAAc;AACpC,SAASC,OAAO,QAAQ,gCAAgC;AACxD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,iBAAiB,QAAQ,qBAAqB;AAYvD,MAAMC,aAAa,GAAIC,KAAc,IAAoB;EACvD,MAAMC,MAAM,GAAID,KAAK,EAAoBE,QAAQ,EAAED,MAAM;EACzD,OAAO,OAAOA,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAG,IAAI;AACnD,CAAC;AAED,MAAME,WAAW,GAAIH,KAAc,IAAc;EAC/C,MAAMI,IAAI,GAAGL,aAAa,CAACC,KAAK,CAAC;EACjC,OAAOI,IAAI,KAAK,GAAG,IAAIA,IAAI,KAAK,GAAG;AACrC,CAAC;AAED,MAAMC,YAAY,GAAIL,KAAc,IAAc;EAChD,MAAMM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AAE;QAAC,OAAOA,QAAQ;MAAC;IACjE;EACF,CAAC,CAAC,MAAM;IACN;EAAA;EAGF,OAAO,IAAI;AACb,CAAC;AAED,eAAeT,yBAAyB","ignoreList":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { store } from '../roomStore';
|
|
4
|
+
import { getCurrentBaseURL } from '../networking/apiClient';
|
|
5
|
+
import { refreshAuthTokens } from '../networking/authRefresh';
|
|
6
|
+
const SECURE_FILES_HOST_PREFIX = 'secure-files.';
|
|
7
|
+
const SECURE_MEDIA_PATH_PREFIX = '/secure-media/';
|
|
8
|
+
const FILE_TOKEN_PARAM = 'ft';
|
|
9
|
+
export const resolveFileUrl = url => {
|
|
10
|
+
if (!url) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
// Any scheme at all — http(s), data, file, content, blob.
|
|
14
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
|
|
15
|
+
return url;
|
|
16
|
+
}
|
|
17
|
+
if (!url.startsWith('/')) {
|
|
18
|
+
return url;
|
|
19
|
+
}
|
|
20
|
+
const base = getCurrentBaseURL().replace(/\/+$/, '');
|
|
21
|
+
return base ? `${base}${url}` : url;
|
|
22
|
+
};
|
|
23
|
+
export const isSecureFileUrl = url => {
|
|
24
|
+
if (!url) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const path = url.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*/i, '');
|
|
28
|
+
if (path.startsWith(SECURE_MEDIA_PATH_PREFIX)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const match = /^https?:\/\/(?:[^@/]+@)?([^:/?#]+)/i.exec(url);
|
|
32
|
+
if (!match) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return match[1].toLowerCase().startsWith(SECURE_FILES_HOST_PREFIX);
|
|
36
|
+
};
|
|
37
|
+
export const appendFileToken = (url, fileToken) => {
|
|
38
|
+
if (!url) {
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
const resolved = resolveFileUrl(url);
|
|
42
|
+
if (!fileToken || !isSecureFileUrl(resolved)) {
|
|
43
|
+
return resolved;
|
|
44
|
+
}
|
|
45
|
+
url = resolved;
|
|
46
|
+
const hashIndex = url.indexOf('#');
|
|
47
|
+
const hash = hashIndex === -1 ? '' : url.slice(hashIndex);
|
|
48
|
+
const withoutHash = hashIndex === -1 ? url : url.slice(0, hashIndex);
|
|
49
|
+
const queryIndex = withoutHash.indexOf('?');
|
|
50
|
+
const base = queryIndex === -1 ? withoutHash : withoutHash.slice(0, queryIndex);
|
|
51
|
+
const query = queryIndex === -1 ? '' : withoutHash.slice(queryIndex + 1);
|
|
52
|
+
const params = query.split('&').filter(Boolean).filter(pair => pair.split('=')[0] !== FILE_TOKEN_PARAM);
|
|
53
|
+
params.push(`${FILE_TOKEN_PARAM}=${encodeURIComponent(fileToken)}`);
|
|
54
|
+
return `${base}?${params.join('&')}${hash}`;
|
|
55
|
+
};
|
|
56
|
+
export const withFileToken = url => appendFileToken(url, store.getState().chatSettingStore?.user?.fileToken || '');
|
|
57
|
+
const RECOVERY_COOLDOWN_MS = 30_000;
|
|
58
|
+
let recoveryInFlight = null;
|
|
59
|
+
let lastRecoveryAt = 0;
|
|
60
|
+
export const requestFileTokenRecovery = () => {
|
|
61
|
+
if (recoveryInFlight) {
|
|
62
|
+
return recoveryInFlight;
|
|
63
|
+
}
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
if (now - lastRecoveryAt < RECOVERY_COOLDOWN_MS) {
|
|
66
|
+
return Promise.resolve(false);
|
|
67
|
+
}
|
|
68
|
+
lastRecoveryAt = now;
|
|
69
|
+
const state = store.getState();
|
|
70
|
+
const refreshConfig = state.chatSettingStore?.config?.refreshTokens;
|
|
71
|
+
const user = state.chatSettingStore?.user;
|
|
72
|
+
if (!refreshConfig?.enabled) {
|
|
73
|
+
return Promise.resolve(false);
|
|
74
|
+
}
|
|
75
|
+
const run = async () => {
|
|
76
|
+
if (!refreshConfig.refreshFunction && !user?.refreshToken) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const tokens = await refreshAuthTokens();
|
|
80
|
+
return Boolean(tokens.fileToken);
|
|
81
|
+
};
|
|
82
|
+
recoveryInFlight = run().catch(() => false).finally(() => {
|
|
83
|
+
recoveryInFlight = null;
|
|
84
|
+
});
|
|
85
|
+
return recoveryInFlight;
|
|
86
|
+
};
|
|
87
|
+
export const __resetFileTokenRecoveryForTests = () => {
|
|
88
|
+
recoveryInFlight = null;
|
|
89
|
+
lastRecoveryAt = 0;
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=secureFileUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["store","getCurrentBaseURL","refreshAuthTokens","SECURE_FILES_HOST_PREFIX","SECURE_MEDIA_PATH_PREFIX","FILE_TOKEN_PARAM","resolveFileUrl","url","test","startsWith","base","replace","isSecureFileUrl","path","match","exec","toLowerCase","appendFileToken","fileToken","resolved","hashIndex","indexOf","hash","slice","withoutHash","queryIndex","query","params","split","filter","Boolean","pair","push","encodeURIComponent","join","withFileToken","getState","chatSettingStore","user","RECOVERY_COOLDOWN_MS","recoveryInFlight","lastRecoveryAt","requestFileTokenRecovery","now","Date","Promise","resolve","state","refreshConfig","config","refreshTokens","enabled","run","refreshFunction","refreshToken","tokens","catch","finally","__resetFileTokenRecoveryForTests"],"sourceRoot":"../../../src","sources":["helpers/secureFileUrl.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,cAAc;AACpC,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,iBAAiB,QAAQ,2BAA2B;AAE7D,MAAMC,wBAAwB,GAAG,eAAe;AAChD,MAAMC,wBAAwB,GAAG,gBAAgB;AAEjD,MAAMC,gBAAgB,GAAG,IAAI;AAE7B,OAAO,MAAMC,cAAc,GAAIC,GAAmB,I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
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
+
import { loadSecureStore } from './secureStoreRuntime';
|
|
5
|
+
import { pushLog } from '../utils/devLogger';
|
|
6
|
+
|
|
7
|
+
// Fallback keys are prefixed and namespaced away from every other
|
|
8
|
+
// AsyncStorage key this SDK writes, so a host that never installs
|
|
9
|
+
// expo-secure-store can still be told apart from one that used to lack
|
|
10
|
+
// it and has since added it (see `secureSet`'s stale-fallback cleanup).
|
|
11
|
+
const FALLBACK_PREFIX = '@ethora/secure-fallback:';
|
|
12
|
+
let warnedFallback = false;
|
|
13
|
+
const warnFallbackOnce = () => {
|
|
14
|
+
if (warnedFallback) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
warnedFallback = true;
|
|
18
|
+
pushLog('warn', 'expo-secure-store is not installed — auth tokens, the XMPP ' + 'password, and the message-history cipher key are falling back ' + 'to plain AsyncStorage instead of the platform Keychain/Keystore. ' + 'Add the optional peer dependency `expo-secure-store` to your app ' + 'to store them securely.');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Small-value secure KV store: platform Keychain/Keystore via
|
|
23
|
+
* expo-secure-store when the host has it installed, plain (but still
|
|
24
|
+
* namespaced) AsyncStorage otherwise. NOT for bulk data — see
|
|
25
|
+
* `persistCrypto.ts`'s size note on why message history goes through
|
|
26
|
+
* AES instead of straight into this store.
|
|
27
|
+
*/
|
|
28
|
+
export async function secureGet(key) {
|
|
29
|
+
const store = loadSecureStore();
|
|
30
|
+
if (store) {
|
|
31
|
+
try {
|
|
32
|
+
return await store.getItemAsync(key);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
pushLog('warn', `secureStore: getItemAsync(${key}) failed`, e);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
warnFallbackOnce();
|
|
39
|
+
return AsyncStorage.getItem(FALLBACK_PREFIX + key);
|
|
40
|
+
}
|
|
41
|
+
export async function secureSet(key, value) {
|
|
42
|
+
const store = loadSecureStore();
|
|
43
|
+
if (store) {
|
|
44
|
+
try {
|
|
45
|
+
await store.setItemAsync(key, value);
|
|
46
|
+
// Clean up a stale plaintext fallback copy from before this host
|
|
47
|
+
// added expo-secure-store — otherwise it sits on disk forever.
|
|
48
|
+
AsyncStorage.removeItem(FALLBACK_PREFIX + key).catch(() => undefined);
|
|
49
|
+
return;
|
|
50
|
+
} catch (e) {
|
|
51
|
+
pushLog('warn', `secureStore: setItemAsync(${key}) failed`, e);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
warnFallbackOnce();
|
|
56
|
+
await AsyncStorage.setItem(FALLBACK_PREFIX + key, value);
|
|
57
|
+
}
|
|
58
|
+
export async function secureRemove(key) {
|
|
59
|
+
const store = loadSecureStore();
|
|
60
|
+
if (store) {
|
|
61
|
+
try {
|
|
62
|
+
await store.deleteItemAsync(key);
|
|
63
|
+
} catch {
|
|
64
|
+
// Key may simply not exist — deleteItemAsync throwing here isn't
|
|
65
|
+
// actionable either way.
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
await AsyncStorage.removeItem(FALLBACK_PREFIX + key).catch(() => undefined);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Test seam only. */
|
|
72
|
+
export const __resetSecureKeyValueWarningForTests = () => {
|
|
73
|
+
warnedFallback = false;
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=secureKeyValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AsyncStorage","loadSecureStore","pushLog","FALLBACK_PREFIX","warnedFallback","warnFallbackOnce","secureGet","key","store","getItemAsync","e","getItem","secureSet","value","setItemAsync","removeItem","catch","undefined","setItem","secureRemove","deleteItemAsync","__resetSecureKeyValueWarningForTests"],"sourceRoot":"../../../src","sources":["helpers/secureKeyValue.ts"],"mappings":";;AAAA,OAAOA,YAAY,MAAM,2CAA2C;AACpE,SAASC,eAAe,QAAQ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L,gBAAgB,CAAC,CAAC;EAClB,MAAML,YAAY,CAACkB,OAAO,CAACf,eAAe,GAAGI,GAAG,EAAEM,KAAK,CAAC;AAC1D;AAEA,OAAO,eAAeM,YAAYA,CAACZ,GAAW,EAAiB;EAC7D,MAAMC,KAAK,GAAGP,eAAe,CAAC,CAAC;EAC/B,IAAIO,KAAK,EAAE;IACT,IAAI;MACF,MAAMA,KAAK,CAACY,eAAe,CAACb,GAAG,CAAC;IAClC,CAAC,CAAC,MAAM;MACN;MACA;IAAA;EAEJ;EACA,MAAMP,YAAY,CAACe,UAAU,CAACZ,eAAe,GAAGI,GAAG,CAAC,CAACS,KAAK,CAAC,MAAMC,SAAS,CAAC;AAC7E;;AAEA;AACA,OAAO,MAAMI,oCAAoC,GAAGA,CAAA,KAAY;EAC9DjB,cAAc,GAAG,KAAK;AACxB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Optional-dependency bridge for `expo-secure-store` — the Keychain
|
|
5
|
+
* (iOS) / Keystore-backed EncryptedSharedPreferences (Android) API.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `components/VideoCalls/livekitRuntime.ts`: a plain top-level
|
|
8
|
+
* `import ... from 'expo-secure-store'` is not allowed anywhere in the
|
|
9
|
+
* SDK, since Metro resolves imports at bundle time and a host that
|
|
10
|
+
* hasn't added this optional peer dependency would fail to build over
|
|
11
|
+
* a feature it never opted into. Everything goes through
|
|
12
|
+
* `loadSecureStore()`, which requires the module lazily and returns
|
|
13
|
+
* null when it isn't installed — callers fall back to plain
|
|
14
|
+
* AsyncStorage rather than crash (see `secureKeyValue.ts`).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
let cached;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the SecureStore runtime, or null when the optional native
|
|
21
|
+
* package isn't installed in the host app. Result is memoised
|
|
22
|
+
* (including the failure) so a missing dependency doesn't re-throw on
|
|
23
|
+
* every read/write.
|
|
24
|
+
*/
|
|
25
|
+
export const loadSecureStore = () => {
|
|
26
|
+
if (cached !== undefined) {
|
|
27
|
+
return cached;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
31
|
+
const mod = require('expo-secure-store');
|
|
32
|
+
if (typeof mod?.getItemAsync !== 'function' || typeof mod?.setItemAsync !== 'function' || typeof mod?.deleteItemAsync !== 'function') {
|
|
33
|
+
cached = null;
|
|
34
|
+
} else {
|
|
35
|
+
cached = {
|
|
36
|
+
getItemAsync: mod.getItemAsync,
|
|
37
|
+
setItemAsync: mod.setItemAsync,
|
|
38
|
+
deleteItemAsync: mod.deleteItemAsync
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
cached = null;
|
|
43
|
+
}
|
|
44
|
+
return cached;
|
|
45
|
+
};
|
|
46
|
+
export const isSecureStoreAvailable = () => loadSecureStore() !== null;
|
|
47
|
+
|
|
48
|
+
/** Test seam only. */
|
|
49
|
+
export const __resetSecureStoreRuntimeForTests = () => {
|
|
50
|
+
cached = undefined;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=secureStoreRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cached","loadSecureStore","undefined","mod","require","getItemAsync","setItemAsync","deleteItemAsync","isSecureStoreAvailable","__resetSecureStoreRuntimeForTests"],"sourceRoot":"../../../src","sources":["helpers/secureStoreRuntime.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,IAAIA,MAA6C;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAiC;EAC9D,IAAID,MAAM,KAAKE,SAAS,EAAE;IACxB,OAAOF,MAAM;EACf;EAEA,IAAI;IACF;IACA,MAAMG,GAAG,GAAGC,OAAO,CAAC,mBAAmB,CAAC;IACxC,IACE,OAAOD,GAAG,EAAEE,YAAY,KAAK,UAAU,IACvC,OAAOF,GAAG,EAAEG,YAAY,KAAK,UAAU,IACvC,OAAOH,GAAG,EAAEI,eAAe,KAAK,UAAU,EAC1C;MACAP,MAAM,GAAG,IAAI;IACf,CAAC,MAAM;MACLA,MAAM,GAAG;QACPK,YAAY,EAAEF,GAAG,CAACE,YAAY;QAC9BC,YAAY,EAAEH,GAAG,CAACG,YAAY;QAC9BC,eAAe,EAAEJ,GAAG,CAACI;MACvB,CAAC;IACH;EACF,CAAC,CAAC,MAAM;IACNP,MAAM,GAAG,IAAI;EACf;EAEA,OAAOA,MAAM;AACf,CAAC;AAED,OAAO,MAAMQ,sBAAsB,GAAGA,CAAA,KAAeP,eAAe,CAAC,CAAC,KAAK,IAAI;;AAE/E;AACA,OAAO,MAAMQ,iCAAiC,GAAGA,CAAA,KAAY;EAC3DT,MAAM,GAAGE,SAAS;AACpB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { asyncLocalStorage } from '../hooks/useLocalStorage';
|
|
4
|
+
import { localStorageConstants } from './constants/LOCAL_STORAGE';
|
|
5
|
+
import { secureGet, secureSet, secureRemove } from './secureKeyValue';
|
|
6
|
+
|
|
7
|
+
// Keychain (iOS) / Keystore-backed EncryptedSharedPreferences (Android)
|
|
8
|
+
// keys for the four live bearer credentials on `User`. Deliberately one
|
|
9
|
+
// key per field rather than one JSON blob: expo-secure-store historically
|
|
10
|
+
// caps a single value's size on Android, and four short JWTs each stay
|
|
11
|
+
// comfortably under that ceiling where one combined blob might not.
|
|
12
|
+
const SECRET_KEYS = {
|
|
13
|
+
token: 'ethora_auth_token',
|
|
14
|
+
refreshToken: 'ethora_auth_refresh_token',
|
|
15
|
+
xmppPassword: 'ethora_auth_xmpp_password',
|
|
16
|
+
fileToken: 'ethora_auth_file_token'
|
|
17
|
+
};
|
|
18
|
+
const SECRET_FIELDS = Object.keys(SECRET_KEYS);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Persisted-user storage, split across two backends behind the exact
|
|
22
|
+
* same `{ get, set, remove }` shape `asyncLocalStorage<User>(...)`
|
|
23
|
+
* already exposed — every existing call site swaps in by changing only
|
|
24
|
+
* the constructor call, `get()`/`set()`/`remove()` keep returning/taking
|
|
25
|
+
* a complete `User`.
|
|
26
|
+
*
|
|
27
|
+
* The four live credentials (REST access + refresh token, XMPP
|
|
28
|
+
* password, secure-media fileToken) never touch plain AsyncStorage:
|
|
29
|
+
* they go through `secureGet`/`secureSet`/`secureRemove` (platform
|
|
30
|
+
* Keychain/Keystore, falling back to namespaced AsyncStorage only when
|
|
31
|
+
* the host hasn't installed the optional `expo-secure-store` peer dep).
|
|
32
|
+
* Everything else on `User` — name, avatar, ids, xmppUsername, wallet
|
|
33
|
+
* address, none of it a bearer credential — keeps living under the
|
|
34
|
+
* existing `ETHORA_USER` AsyncStorage key, unchanged.
|
|
35
|
+
*/
|
|
36
|
+
export function secureUserStorage() {
|
|
37
|
+
const get = async () => {
|
|
38
|
+
const profile = await asyncLocalStorage(localStorageConstants.ETHORA_USER).get();
|
|
39
|
+
if (!profile) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const secretValues = await Promise.all(SECRET_FIELDS.map(field => secureGet(SECRET_KEYS[field])));
|
|
43
|
+
const merged = {
|
|
44
|
+
...profile
|
|
45
|
+
};
|
|
46
|
+
SECRET_FIELDS.forEach((field, i) => {
|
|
47
|
+
merged[field] = secretValues[i] || '';
|
|
48
|
+
});
|
|
49
|
+
return merged;
|
|
50
|
+
};
|
|
51
|
+
const set = async user => {
|
|
52
|
+
const profile = {
|
|
53
|
+
...user
|
|
54
|
+
};
|
|
55
|
+
for (const field of SECRET_FIELDS) {
|
|
56
|
+
profile[field] = '';
|
|
57
|
+
}
|
|
58
|
+
await Promise.all([asyncLocalStorage(localStorageConstants.ETHORA_USER).set(profile), ...SECRET_FIELDS.map(field => {
|
|
59
|
+
const value = user?.[field];
|
|
60
|
+
return value ? secureSet(SECRET_KEYS[field], value) : secureRemove(SECRET_KEYS[field]);
|
|
61
|
+
})]);
|
|
62
|
+
};
|
|
63
|
+
const remove = async () => {
|
|
64
|
+
await Promise.all([asyncLocalStorage(localStorageConstants.ETHORA_USER).remove(), ...SECRET_FIELDS.map(field => secureRemove(SECRET_KEYS[field]))]);
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
get,
|
|
68
|
+
set,
|
|
69
|
+
remove
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=secureUserStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asyncLocalStorage","localStorageConstants","secureGet","secureSet","secureRemove","SECRET_KEYS","token","refreshToken","xmppPassword","fileToken","SECRET_FIELDS","Object","keys","secureUserStorage","get","profile","ETHORA_USER","secretValues","Promise","all","map","field","merged","forEach","i","set","user","value","remove"],"sourceRoot":"../../../src","sources":["helpers/secureUserStorage.ts"],"mappings":";;AACA,SAASA,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,qBAAqB,QAAQ,2BAA2B;AACjE,SAASC,SAAS,EAAEC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;;AAErE;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG;EAClBC,KAAK,EAAE,mBAAmB;EAC1BC,YAAY,EAAE,2BAA2B;EACzCC,YAAY,EAAE,2BAA2B;EACzCC,SAAS,EAAE;AACb,CAAU;AAGV,MAAMC,aAAa,GAAGC,MAAM,CAACC,IAAI,CAACP,WAAW,CAAkB;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,iBAAiBA,CAAA,EAAG;EAClC,MAAMC,GAAG,GAAG,MAAAA,CAA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AAiB,CAACC,qBAAqB,CAACe,WAAW,CAAC,CAACY,MAAM,CAAC,CAAC,EAC7D,GAAGlB,aAAa,CAACU,GAAG,CAAEC,KAAK,IAAKjB,YAAY,CAACC,WAAW,CAACgB,KAAK,CAAC,CAAC,CAAC,CAClE,CAAC;EACJ,CAAC;EAED,OAAO;IAAEP,GAAG;IAAEW,GAAG;IAAEG;EAAO,CAAC;AAC7B","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One-level shallow equality for plain objects. Used to avoid re-dispatching
|
|
5
|
+
* config into redux on every render just because the host passed a fresh
|
|
6
|
+
* object literal with the same values (e.g. `<Chat config={{...}} />`
|
|
7
|
+
* re-created inline) — reference equality alone would fire far too often,
|
|
8
|
+
* and a deep/JSON comparison risks throwing on non-serializable fields
|
|
9
|
+
* (functions, React elements) that configs legitimately carry.
|
|
10
|
+
*/
|
|
11
|
+
export function shallowEqual(a, b) {
|
|
12
|
+
if (a === b) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const aKeys = Object.keys(a);
|
|
19
|
+
const bKeys = Object.keys(b);
|
|
20
|
+
if (aKeys.length !== bKeys.length) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
for (const key of aKeys) {
|
|
24
|
+
if (a[key] !== b[key]) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
export default shallowEqual;
|
|
31
|
+
//# sourceMappingURL=shallowEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["shallowEqual","a","b","aKeys","Object","keys","bKeys","length","key"],"sourceRoot":"../../../src","sources":["helpers/shallowEqual.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAACC,CAAU,EAAEC,CAAU,EAAW;EAC5D,IAAID,CAAC,KAAKC,CAAC,EAAE;IAAC,OAAO,IAAI;EAAC;EAC1B,IACE,OAAOD,CAAC,KAAK,QAAQ,IACrB,OAAOC,CAAC,KAAK,QAAQ,IACrBD,CAAC,KAAK,IAAI,IACVC,CAAC,KAAK,IAAI,EACV;IACA,OAAO,KAAK;EACd;EACA,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACJ,CAA4B,CAAC;EACvD,MAAMK,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACH,CAA4B,CAAC;EACvD,IAAIC,KAAK,CAACI,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;IAAC,OAAO,KAAK;EAAC;EACjD,KAAK,MAAMC,GAAG,IAAIL,KAAK,EAAE;IACvB,IACGF,CAAC,CAA6BO,GAAG,CAAC,KAClCN,CAAC,CAA6BM,GAAG,CAAC,EACnC;MACA,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb;AAEA,eAAeR,YAAY","ignoreList":[]}
|