agora-appbuilder-core 4.0.0-api.5 → 4.0.0-api.6
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/package.json +2 -2
- package/template/.bundle/config +2 -0
- package/template/Gemfile +4 -0
- package/template/Gulpfile.js +29 -29
- package/template/_eslintrc.js +3 -3
- package/template/_gitignore +12 -11
- package/template/_package-lock.json +26471 -22749
- package/template/_prettierrc.js +2 -2
- package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +30 -10
- package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +19 -0
- package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +1 -0
- package/template/agora-rn-uikit/src/Controls/Icons.ts +45 -0
- package/template/agora-rn-uikit/src/Controls/Local/EndCall.tsx +6 -4
- package/template/agora-rn-uikit/src/Controls/Local/FullScreen.tsx +3 -1
- package/template/agora-rn-uikit/src/Controls/Local/LocalAudioMute.tsx +1 -0
- package/template/agora-rn-uikit/src/Controls/Local/LocalVideoMute.tsx +1 -0
- package/template/agora-rn-uikit/src/Controls/Local/SwitchCamera.tsx +1 -0
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteAudioMute.tsx +1 -0
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteSwap.tsx +3 -1
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteVideoMute.tsx +1 -0
- package/template/agora-rn-uikit/src/Reducer/ActiveSpeaker.ts +30 -0
- package/template/agora-rn-uikit/src/Reducer/LocalMuteAudio.ts +3 -1
- package/template/agora-rn-uikit/src/Reducer/LocalMuteVideo.ts +3 -1
- package/template/agora-rn-uikit/src/Reducer/LocalPermissionState.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/RemoteAudioStateChanged.ts +3 -3
- package/template/agora-rn-uikit/src/Reducer/RemoteVideoStateChanged.ts +5 -4
- package/template/agora-rn-uikit/src/Reducer/UpdateDualStreamMode.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +8 -5
- package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteAudio.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteVideo.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/UserPin.ts +18 -1
- package/template/agora-rn-uikit/src/Reducer/UserSecondaryPin.ts +23 -0
- package/template/agora-rn-uikit/src/Reducer/index.ts +2 -0
- package/template/agora-rn-uikit/src/Rtc/Create.tsx +47 -21
- package/template/agora-rn-uikit/src/Rtc/Join.tsx +37 -15
- package/template/agora-rn-uikit/src/RtcConfigure.tsx +122 -12
- package/template/agora-rn-uikit/src/Views/MaxVideoView.native.tsx +32 -4
- package/template/agora-rn-uikit/src/Views/MaxVideoView.tsx +21 -2
- package/template/agora-rn-uikit/src/Views/MinVideoView.tsx +2 -0
- package/template/android/app/build.gradle +59 -156
- package/template/android/app/src/debug/AndroidManifest.xml +6 -1
- package/template/android/app/src/debug/java/com/helloworld/ReactNativeFlipper.java +7 -4
- package/template/android/app/src/main/AndroidManifest.xml +6 -19
- package/template/android/app/src/main/assets/fonts/icomoon.ttf +0 -0
- package/template/android/app/src/main/java/com/helloworld/MainActivity.java +17 -0
- package/template/android/app/src/main/java/com/helloworld/MainApplication.java +19 -36
- package/template/android/app/src/release/java/com/helloworld/ReactNativeFlipper.java +20 -0
- package/template/android/build.gradle +19 -33
- package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/template/android/gradle/wrapper/gradle-wrapper.properties +3 -2
- package/template/android/gradle.properties +18 -4
- package/template/android/gradlew +165 -104
- package/template/android/gradlew.bat +12 -23
- package/template/android/settings.gradle +1 -0
- package/template/bridge/rtc/webNg/RtcEngine.ts +131 -16
- package/template/bridge/rtc/webNg/index.ts +72 -1
- package/template/bridge/rtm/web/index.ts +5 -3
- package/template/configTransform.js +16 -1
- package/template/customization-api/action-library.ts +0 -8
- package/template/customization-api/app-state.ts +11 -2
- package/template/customization-api/customEvents.ts +6 -1
- package/template/customization-api/index.ts +4 -0
- package/template/customization-api/sub-components.ts +6 -3
- package/template/customization-api/temp.ts +50 -0
- package/template/customization-api/typeDefinition.ts +26 -14
- package/template/customization-api/types.ts +26 -0
- package/template/customization-api/utils.ts +2 -0
- package/template/customization-implementation/index.ts +0 -1
- package/template/defaultConfig.js +72 -0
- package/template/global.d.ts +13 -1
- package/template/index.js +0 -4
- package/template/index.web.js +0 -5
- package/template/index.wsdk.tsx +1 -19
- package/template/ios/.xcode.env +11 -0
- package/template/ios/HelloWorld/AppDelegate.h +2 -4
- package/template/ios/HelloWorld/AppDelegate.mm +42 -0
- package/template/ios/HelloWorld/Info.plist +1 -1
- package/template/ios/HelloWorld/main.m +2 -1
- package/template/ios/HelloWorld.xcodeproj/project.pbxproj +529 -17
- package/template/ios/HelloWorld.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/template/ios/HelloWorld.xcworkspace/contents.xcworkspacedata +10 -0
- package/template/ios/HelloWorld.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/template/ios/HelloWorldTests/HelloWorldTests.m +14 -13
- package/template/ios/HelloWorldTests/Info.plist +2 -2
- package/template/ios/Podfile +53 -20
- package/template/ios/Podfile.lock +873 -0
- package/template/ios/ScreenSharing/Info.plist +15 -0
- package/template/ios/ScreenSharing/SampleHandler.h +9 -0
- package/template/ios/ScreenSharing/SampleHandler.m +70 -0
- package/template/jest.config.js +4 -0
- package/template/metro.config.js +7 -32
- package/template/package.json +52 -39
- package/template/react-native-toast-message/index.d.ts +3 -1
- package/template/react-native-toast-message/index.js +1 -0
- package/template/react-native-toast-message/src/components/base/index.js +20 -32
- package/template/react-native-toast-message/src/components/base/styles.js +18 -21
- package/template/react-native-toast-message/src/components/checkbox.js +24 -19
- package/template/react-native-toast-message/src/index.js +3 -1
- package/template/react-native-toast-message/src/index.sdk.tsx +4 -1
- package/template/src/App.tsx +13 -85
- package/template/src/AppRoutes.tsx +77 -0
- package/template/src/AppWrapper.tsx +38 -33
- package/template/src/SDKAppWrapper.tsx +79 -43
- package/template/src/app-state/useNoiseSupression.native.tsx +67 -0
- package/template/src/app-state/useNoiseSupression.tsx +107 -0
- package/template/src/app-state/useVideoQuality.tsx +39 -0
- package/template/src/assets/font-styles.css +171 -3
- package/template/src/assets/fonts/icomoon.ttf +0 -0
- package/template/src/assets/selection.json +1 -1
- package/template/src/atoms/ActionMenu.tsx +50 -11
- package/template/src/atoms/Avatar.tsx +51 -0
- package/template/src/atoms/Card.tsx +21 -8
- package/template/src/atoms/Carousel.native.tsx +105 -0
- package/template/src/atoms/Carousel.tsx +103 -0
- package/template/src/atoms/Checkbox.tsx +98 -0
- package/template/src/atoms/CircularProgress.tsx +0 -1
- package/template/src/atoms/ClipboardIconButton.tsx +91 -0
- package/template/src/atoms/CustomIcon.tsx +45 -0
- package/template/src/atoms/DropDownMulti.tsx +349 -0
- package/template/src/atoms/Dropdown.tsx +3 -3
- package/template/src/atoms/IconButton.tsx +52 -9
- package/template/src/atoms/ImageIcon.tsx +6 -3
- package/template/src/atoms/InlineNotification.tsx +81 -0
- package/template/src/atoms/MeetingLink.tsx +160 -0
- package/template/src/atoms/ParticipantsCount.tsx +18 -7
- package/template/src/atoms/Popup.tsx +49 -27
- package/template/src/atoms/PrimaryButton.tsx +19 -5
- package/template/src/atoms/RecordingInfo.tsx +2 -2
- package/template/src/atoms/SecondaryButton.tsx +2 -0
- package/template/src/atoms/Spacer.tsx +1 -0
- package/template/src/atoms/TertiaryButton.tsx +35 -5
- package/template/src/atoms/TextInput.tsx +2 -1
- package/template/src/atoms/Toolbar.tsx +64 -30
- package/template/src/atoms/ToolbarItem.tsx +11 -5
- package/template/src/atoms/ToolbarPreset.tsx +13 -2
- package/template/src/atoms/Tooltip.tsx +26 -4
- package/template/src/auth/AuthProvider.tsx +500 -0
- package/template/src/auth/AuthRoute.tsx +94 -0
- package/template/src/auth/IDPAuth.electron.tsx +31 -0
- package/template/src/auth/IDPAuth.tsx +67 -0
- package/template/src/auth/IDPLogoutComponent.tsx +158 -0
- package/template/src/auth/UserCancelPopup.tsx +115 -0
- package/template/src/auth/config.ts +52 -0
- package/template/src/auth/openIDPURL.electron.tsx +39 -0
- package/template/src/auth/openIDPURL.native.tsx +51 -0
- package/template/src/auth/openIDPURL.tsx +20 -0
- package/template/src/auth/useIDPAuth.electron.tsx +65 -0
- package/template/src/auth/useIDPAuth.native.tsx +70 -0
- package/template/src/auth/useIDPAuth.tsx +63 -0
- package/template/src/auth/useTokenAuth.tsx +194 -0
- package/template/src/components/Chat.tsx +5 -8
- package/template/src/components/ChatContext.ts +4 -0
- package/template/src/components/ColorConfigure.tsx +0 -1
- package/template/src/components/CommonStyles.ts +9 -2
- package/template/src/components/Controls.tsx +659 -52
- package/template/src/components/DeviceConfigure.tsx +362 -156
- package/template/src/components/DeviceContext.tsx +2 -0
- package/template/src/components/EventsConfigure.tsx +713 -109
- package/template/src/components/GraphQLProvider.tsx +62 -36
- package/template/src/components/GridVideo.tsx +23 -13
- package/template/src/components/HostControlView.tsx +11 -14
- package/template/src/components/JoinPhrase.tsx +0 -1
- package/template/src/components/Leftbar.tsx +4 -3
- package/template/src/components/Navbar.tsx +110 -42
- package/template/src/components/NavbarMobile.tsx +47 -36
- package/template/src/components/Navigation.native.tsx +1 -15
- package/template/src/{subComponents/screenshare/ScreenshareButton.native.tsx → components/Navigation.sdk.tsx} +17 -3
- package/template/src/components/Navigation.tsx +1 -15
- package/template/src/components/ParticipantsView.tsx +56 -48
- package/template/src/components/PinnedVideo.tsx +188 -114
- package/template/src/components/Precall.native.tsx +169 -67
- package/template/src/components/Precall.tsx +237 -71
- package/template/src/components/RTMConfigure.tsx +167 -55
- package/template/src/components/Rightbar.tsx +4 -3
- package/template/src/components/Router.electron.ts +1 -0
- package/template/src/components/Router.native.ts +1 -0
- package/template/src/components/Router.sdk.ts +1 -0
- package/template/src/components/Router.ts +1 -0
- package/template/src/components/SdkApiContext.tsx +179 -27
- package/template/src/components/SdkMuteToggleListener.tsx +88 -0
- package/template/src/components/SessionContext.tsx +0 -1
- package/template/src/components/Settings.tsx +25 -3
- package/template/src/components/SettingsView.tsx +44 -9
- package/template/src/components/Share.tsx +149 -71
- package/template/src/components/StorageContext.tsx +19 -5
- package/template/src/components/ToastComponent.tsx +3 -0
- package/template/src/components/WhiteboardLayout.tsx +291 -0
- package/template/src/components/chat-messages/useChatMessages.tsx +420 -207
- package/template/src/components/common/Error.tsx +2 -0
- package/template/src/components/common/Logo.tsx +2 -2
- package/template/src/components/contexts/LiveStreamDataContext.tsx +5 -4
- package/template/src/components/contexts/ScreenShareContext.tsx +15 -1
- package/template/src/components/contexts/WaitingRoomContext.tsx +50 -0
- package/template/src/components/contexts/WhiteboardContext.tsx +54 -54
- package/template/src/components/disable-chat/useDisableChat.tsx +32 -0
- package/template/src/components/livestream/LiveStreamContext.tsx +262 -177
- package/template/src/components/livestream/Types.ts +34 -18
- package/template/src/components/livestream/views/LiveStreamAttendeeLandingTile.tsx +295 -0
- package/template/src/components/livestream/views/LiveStreamControls.tsx +2 -4
- package/template/src/components/meeting-info-invite/MeetingInfo.tsx +82 -0
- package/template/src/components/meeting-info-invite/MeetingInfoCardHeader.tsx +86 -0
- package/template/src/components/meeting-info-invite/MeetingInfoGridTile.tsx +218 -0
- package/template/src/components/meeting-info-invite/MeetingInfoLinks.tsx +122 -0
- package/template/src/components/participants/AllAudienceParticipants.tsx +4 -5
- package/template/src/components/participants/AllHostParticipants.tsx +5 -6
- package/template/src/components/participants/Participant.tsx +40 -9
- package/template/src/components/participants/ParticipantSectionTitle.tsx +5 -2
- package/template/src/components/participants/ScreenshareParticipants.tsx +15 -17
- package/template/src/components/participants/UserActionMenuOptions.tsx +157 -49
- package/template/src/components/participants/WaitingRoomParticipants.tsx +74 -0
- package/template/src/components/popups/InvitePopup.tsx +110 -45
- package/template/src/components/popups/StartScreenSharePopup.native.tsx +182 -0
- package/template/src/components/popups/StartScreenSharePopup.tsx +6 -0
- package/template/src/components/popups/StopRecordingPopup.tsx +11 -5
- package/template/src/components/popups/StopScreenSharePopup.native.tsx +135 -0
- package/template/src/components/popups/StopScreenSharePopup.tsx +6 -0
- package/template/src/components/popups/WhiteboardClearAllPopup.tsx +123 -0
- package/template/src/components/precall/LocalMute.tsx +69 -45
- package/template/src/components/precall/PermissionHelper.tsx +52 -24
- package/template/src/components/precall/PreCallSettings.tsx +1 -0
- package/template/src/components/precall/VideoFallback.tsx +173 -0
- package/template/src/components/precall/VideoPreview.native.tsx +16 -50
- package/template/src/components/precall/VideoPreview.tsx +27 -162
- package/template/src/components/precall/index.tsx +2 -0
- package/template/src/components/precall/joinCallBtn.native.tsx +10 -3
- package/template/src/components/precall/joinCallBtn.tsx +11 -2
- package/template/src/components/precall/joinWaitingRoomBtn.native.tsx +210 -0
- package/template/src/components/precall/joinWaitingRoomBtn.tsx +250 -0
- package/template/src/components/precall/meetingTitle.tsx +35 -9
- package/template/src/components/precall/selectDevice.tsx +5 -5
- package/template/src/components/precall/textInput.tsx +16 -18
- package/template/src/components/precall/usePreCall.tsx +14 -4
- package/template/src/components/room-info/useRoomInfo.tsx +34 -0
- package/template/src/components/useShareLink.tsx +24 -59
- package/template/src/components/useUserPreference.tsx +73 -10
- package/template/src/components/useVideoCall.tsx +76 -3
- package/template/src/components/virtual-background/VBButton.tsx +64 -0
- package/template/src/components/virtual-background/VBCard.native.tsx +282 -0
- package/template/src/components/virtual-background/VBCard.tsx +272 -0
- package/template/src/components/virtual-background/VBPanel.tsx +279 -0
- package/template/src/components/virtual-background/VButils.native.ts +37 -0
- package/template/src/components/virtual-background/VButils.ts +104 -0
- package/template/src/components/virtual-background/VideoPreview.native.tsx +43 -0
- package/template/src/components/virtual-background/VideoPreview.tsx +106 -0
- package/template/src/components/virtual-background/imagePaths.ts +87 -0
- package/template/src/components/virtual-background/images/beachImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/bedroomImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/bookImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/earthImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/index.ts +37 -0
- package/template/src/components/virtual-background/images/lampImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/mountainsImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/office1ImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/officeImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/plantsImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/skyImageBase64.ts +1 -0
- package/template/src/components/virtual-background/images/wallImageBase64.ts +1 -0
- package/template/src/components/virtual-background/useVB.native.tsx +188 -0
- package/template/src/components/virtual-background/useVB.tsx +267 -0
- package/template/src/components/whiteboard/StrokeWidthTool.tsx +137 -0
- package/template/src/components/whiteboard/WhiteboardButton.tsx +93 -0
- package/template/src/components/whiteboard/WhiteboardCanvas.tsx +99 -0
- package/template/src/components/whiteboard/WhiteboardConfigure.native.tsx +137 -0
- package/template/src/components/whiteboard/WhiteboardConfigure.tsx +441 -0
- package/template/src/components/whiteboard/WhiteboardCursor.tsx +152 -0
- package/template/src/components/whiteboard/WhiteboardToolBox.tsx +1246 -0
- package/template/src/components/whiteboard/WhiteboardView.native.tsx +109 -0
- package/template/src/components/whiteboard/WhiteboardView.tsx +81 -0
- package/template/src/components/whiteboard/WhiteboardWidget.tsx +674 -0
- package/template/src/components/whiteboard/WhiteboardWrapper.tsx +38 -0
- package/template/src/language/default-labels/commonLabels.ts +51 -14
- package/template/src/language/default-labels/createScreenLabels.ts +97 -17
- package/template/src/language/default-labels/joinScreenLabels.ts +45 -6
- package/template/src/language/default-labels/precallScreenLabels.ts +145 -23
- package/template/src/language/default-labels/shareLinkScreenLabels.ts +85 -37
- package/template/src/language/default-labels/videoCallScreenLabels.ts +1137 -158
- package/template/src/pages/Create.tsx +125 -80
- package/template/src/pages/Join.tsx +76 -34
- package/template/src/pages/Login.tsx +26 -0
- package/template/src/pages/VideoCall.tsx +229 -114
- package/template/src/pages/video-call/ActionSheet.native.tsx +54 -7
- package/template/src/pages/video-call/ActionSheet.tsx +55 -16
- package/template/src/pages/video-call/ActionSheetContent.tsx +366 -291
- package/template/src/pages/video-call/ActionSheetHandle.tsx +7 -1
- package/template/src/pages/video-call/DefaultLayouts.ts +11 -5
- package/template/src/pages/video-call/NameWithMicIcon.tsx +17 -9
- package/template/src/pages/video-call/PinchableView.tsx +119 -0
- package/template/src/pages/video-call/RenderComponent.tsx +12 -3
- package/template/src/pages/video-call/SidePanelHeader.tsx +208 -6
- package/template/src/pages/video-call/VideoCallMobileView.tsx +140 -106
- package/template/src/pages/video-call/VideoCallScreen.native.tsx +3 -2
- package/template/src/pages/video-call/VideoCallScreen.tsx +113 -66
- package/template/src/pages/video-call/VideoComponent.tsx +53 -5
- package/template/src/pages/video-call/VideoRenderer.tsx +309 -52
- package/template/src/pages/video-call/VisibilitySensor.tsx +104 -0
- package/template/src/pages/video-call/ZoomableWrapper.native.tsx +34 -0
- package/template/src/pages/video-call/ZoomableWrapper.tsx +5 -0
- package/template/src/pages/video-call/index.ts +2 -0
- package/template/src/rtm/RTMEngine.ts +9 -4
- package/template/src/rtm-events/constants.ts +20 -0
- package/template/src/rtm-events-api/Events.ts +2 -0
- package/template/src/rtm-events-api/LocalEvents.ts +8 -0
- package/template/src/selection.json +1 -0
- package/template/src/subComponents/ChatBubble.tsx +81 -64
- package/template/src/subComponents/ChatContainer.tsx +20 -13
- package/template/src/subComponents/ChatInput.ios.tsx +11 -2
- package/template/src/subComponents/ChatInput.tsx +12 -3
- package/template/src/subComponents/Checkbox.native.tsx +46 -46
- package/template/src/subComponents/Checkbox.tsx +7 -6
- package/template/src/subComponents/CopyJoinInfo.tsx +26 -11
- package/template/src/subComponents/EndcallPopup.tsx +83 -12
- package/template/src/subComponents/LanguageSelector.tsx +34 -30
- package/template/src/subComponents/LayoutIconButton.tsx +30 -8
- package/template/src/subComponents/LayoutIconDropdown.tsx +19 -3
- package/template/src/subComponents/Loading.tsx +60 -0
- package/template/src/subComponents/LocalAudioMute.tsx +106 -30
- package/template/src/subComponents/LocalEndCall.tsx +91 -15
- package/template/src/subComponents/LocalSwitchCamera.tsx +50 -11
- package/template/src/subComponents/LocalVideoMute.tsx +126 -32
- package/template/src/subComponents/LogoutButton.tsx +1 -1
- package/template/src/subComponents/NetworkQualityPill.tsx +14 -31
- package/template/src/subComponents/Recording.tsx +23 -6
- package/template/src/subComponents/RemoteAudioMute.tsx +3 -3
- package/template/src/subComponents/RemoteMutePopup.tsx +55 -14
- package/template/src/subComponents/RemoteVideoMute.tsx +3 -3
- package/template/src/subComponents/RemoveMeetingPopup.tsx +19 -6
- package/template/src/subComponents/RemoveScreensharePopup.tsx +20 -5
- package/template/src/subComponents/ScreenShareNotice.tsx +11 -6
- package/template/src/subComponents/SelectDevice.tsx +98 -32
- package/template/src/subComponents/SidePanelEnum.tsx +2 -0
- package/template/src/subComponents/SidePanelHeader.tsx +97 -63
- package/template/src/subComponents/ToastConfig.tsx +70 -61
- package/template/src/subComponents/caption/Caption.tsx +130 -0
- package/template/src/subComponents/caption/CaptionContainer.tsx +302 -0
- package/template/src/subComponents/caption/CaptionIcon.tsx +111 -0
- package/template/src/subComponents/caption/CaptionText.tsx +182 -0
- package/template/src/subComponents/caption/DownloadTranscriptBtn.tsx +65 -0
- package/template/src/subComponents/caption/LanguageSelectorPopup.tsx +192 -0
- package/template/src/subComponents/caption/Transcript.tsx +449 -0
- package/template/src/subComponents/caption/TranscriptIcon.tsx +123 -0
- package/template/src/subComponents/caption/TranscriptText.tsx +98 -0
- package/template/src/subComponents/caption/index.ts +3 -0
- package/template/src/subComponents/caption/proto/ptoto.js +91 -0
- package/template/src/subComponents/caption/proto/test.proto +23 -0
- package/template/src/subComponents/caption/useCaption.tsx +123 -0
- package/template/src/subComponents/caption/useCaptionWidth.ts +27 -0
- package/template/src/subComponents/caption/useSTTAPI.tsx +179 -0
- package/template/src/subComponents/caption/useStreamMessageUtils.native.ts +211 -0
- package/template/src/subComponents/caption/useStreamMessageUtils.ts +235 -0
- package/template/src/subComponents/caption/useTranscriptDownload.native.ts +68 -0
- package/template/src/subComponents/caption/useTranscriptDownload.ts +52 -0
- package/template/src/subComponents/caption/utils.ts +125 -0
- package/template/src/subComponents/chat/ChatParticipants.tsx +53 -17
- package/template/src/subComponents/livestream/CurrentLiveStreamRequestsView.tsx +11 -13
- package/template/src/subComponents/livestream/controls/LocalRaiseHand.tsx +33 -9
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamApprovedRequestRecall.tsx +1 -0
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestApprove.tsx +10 -6
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestReject.tsx +28 -19
- package/template/src/subComponents/recording/useRecording.tsx +49 -20
- package/template/src/subComponents/recording/useRecordingLayoutQuery.tsx +0 -1
- package/template/src/subComponents/screenshare/ScreenshareButton.tsx +29 -10
- package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +270 -66
- package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +182 -95
- package/template/src/subComponents/screenshare/useScreenshare.tsx +2 -0
- package/template/src/subComponents/waiting-rooms/WaitingRoomControls.tsx +85 -0
- package/template/src/subComponents/waiting-rooms/useWaitingRoomAPI.ts +75 -0
- package/template/src/theme/index.ts +9 -0
- package/template/src/utils/SdkEvents.ts +14 -0
- package/template/src/utils/SdkMethodEvents.ts +23 -3
- package/template/src/utils/axiomLogger.ts +117 -0
- package/template/src/utils/book.jpg +0 -0
- package/template/src/utils/common.tsx +118 -6
- package/template/src/utils/endCallEveryOne.ts +7 -0
- package/template/src/utils/getCustomRoute.ts +7 -0
- package/template/src/utils/index.tsx +23 -0
- package/template/src/utils/useActionSheet.tsx +50 -0
- package/template/src/utils/useActiveSpeaker.ts +3 -7
- package/template/src/utils/useAppState.ts +17 -0
- package/template/src/utils/useAsyncEffect.ts +138 -0
- package/template/src/utils/useCreateRoom.ts +8 -12
- package/template/src/utils/useDisableButton.tsx +37 -0
- package/template/src/utils/useFindActiveSpeaker.native.ts +4 -0
- package/template/src/utils/useFindActiveSpeaker.ts +335 -0
- package/template/src/utils/useIsLocalUserSpeaking.native.ts +4 -0
- package/template/src/utils/useIsLocalUserSpeaking.ts +98 -0
- package/template/src/utils/useJoinRoom.ts +97 -36
- package/template/src/utils/useMuteToggleLocal.ts +114 -96
- package/template/src/utils/useString.ts +13 -3
- package/template/static.d.ts +42 -0
- package/template/tsconfig_rsdk_index.json +3 -3
- package/template/tsconfig_wsdk_index.json +1 -1
- package/template/web/index.html +20 -0
- package/template/webpack.commons.js +21 -10
- package/template/webpack.web.config.js +7 -3
- package/template/_buckconfig +0 -6
- package/template/_gitattributes +0 -1
- package/template/android/app/_BUCK +0 -55
- package/template/android/app/build_defs.bzl +0 -19
- package/template/ios/HelloWorld/AppDelegate.m +0 -74
- package/template/src/components/OAuth.electron.tsx +0 -41
- package/template/src/components/OAuth.native.tsx +0 -55
- package/template/src/components/OAuth.tsx +0 -30
- package/template/src/components/OAuthConfig.ts +0 -77
- package/template/src/components/Settings.native.tsx +0 -21
- package/template/src/components/StoreToken.tsx +0 -39
|
@@ -14,10 +14,20 @@ export interface ToolbarCustomItem {
|
|
|
14
14
|
order?: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export interface
|
|
18
|
-
align: '
|
|
17
|
+
export interface ToolbarBottomPresetProps {
|
|
18
|
+
align: 'bottom';
|
|
19
19
|
customItems?: Array<ToolbarCustomItem>;
|
|
20
|
+
snapPointsMinMax: [number, number];
|
|
20
21
|
}
|
|
22
|
+
export interface ToolbarOtherPresetProps {
|
|
23
|
+
align: 'top' | 'left' | 'right';
|
|
24
|
+
customItems?: Array<ToolbarCustomItem>;
|
|
25
|
+
snapPointsMinMax?: never;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ToolbarPresetProps =
|
|
29
|
+
| ToolbarBottomPresetProps
|
|
30
|
+
| ToolbarOtherPresetProps;
|
|
21
31
|
|
|
22
32
|
const ToolbarPreset = (props: ToolbarPresetProps) => {
|
|
23
33
|
const {align} = props;
|
|
@@ -49,6 +59,7 @@ const ToolbarPreset = (props: ToolbarPresetProps) => {
|
|
|
49
59
|
<ActionSheet
|
|
50
60
|
customItems={props?.customItems}
|
|
51
61
|
includeDefaultItems={true}
|
|
62
|
+
snapPointsMinMax={props?.snapPointsMinMax}
|
|
52
63
|
/>
|
|
53
64
|
) : (
|
|
54
65
|
<Controls customItems={props?.customItems} includeDefaultItems={true} />
|
|
@@ -13,12 +13,18 @@ interface TooltipProps {
|
|
|
13
13
|
toolTipIcon?: React.ReactNode;
|
|
14
14
|
isClickable?: boolean;
|
|
15
15
|
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
16
|
+
showTooltipArrow?: boolean;
|
|
16
17
|
onPress?: () => void;
|
|
17
18
|
}
|
|
18
19
|
const Tooltip = (props: TooltipProps) => {
|
|
19
20
|
const [isToolTipVisible, setToolTipVisible] = useState(false);
|
|
20
|
-
const {
|
|
21
|
-
|
|
21
|
+
const {
|
|
22
|
+
isClickable = false,
|
|
23
|
+
placement = 'top',
|
|
24
|
+
showTooltipArrow = true,
|
|
25
|
+
} = props;
|
|
26
|
+
const css = showTooltipArrow
|
|
27
|
+
? `
|
|
22
28
|
.custom-tool-tip{
|
|
23
29
|
padding:12px;
|
|
24
30
|
border-radius: 8px;
|
|
@@ -37,7 +43,23 @@ const Tooltip = (props: TooltipProps) => {
|
|
|
37
43
|
border-top-right-radius: 5px !important;
|
|
38
44
|
bottom: -10px !important;
|
|
39
45
|
margin-left: -10px !important;
|
|
40
|
-
}
|
|
46
|
+
}`
|
|
47
|
+
: `.custom-tool-tip{
|
|
48
|
+
padding:12px;
|
|
49
|
+
border-radius: 8px;
|
|
50
|
+
}
|
|
51
|
+
.custom-tool-tip div{
|
|
52
|
+
font-family: "Source Sans Pro";
|
|
53
|
+
font-weight: 400;
|
|
54
|
+
font-size: 16px;
|
|
55
|
+
}
|
|
56
|
+
.__react_component_tooltip.show{
|
|
57
|
+
opacity:1;
|
|
58
|
+
}
|
|
59
|
+
.custom-tool-tip::after{
|
|
60
|
+
display:none
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
41
63
|
const randomString = (
|
|
42
64
|
length = 5,
|
|
43
65
|
chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
|
@@ -77,7 +99,7 @@ const Tooltip = (props: TooltipProps) => {
|
|
|
77
99
|
id={toolTipId}
|
|
78
100
|
backgroundColor={$config.CARD_LAYER_3_COLOR}
|
|
79
101
|
className="custom-tool-tip"
|
|
80
|
-
place={
|
|
102
|
+
place={placement}
|
|
81
103
|
type="dark"
|
|
82
104
|
effect="solid">
|
|
83
105
|
<style type="text/css">{css}</style>
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useState,
|
|
4
|
+
useEffect,
|
|
5
|
+
Dispatch,
|
|
6
|
+
SetStateAction,
|
|
7
|
+
useContext,
|
|
8
|
+
useRef,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import {useHistory, useLocation} from '../components/Router';
|
|
11
|
+
import {gql, useApolloClient} from '@apollo/client';
|
|
12
|
+
import {useIDPAuth} from './useIDPAuth';
|
|
13
|
+
import Loading from '../subComponents/Loading';
|
|
14
|
+
import useTokenAuth from './useTokenAuth';
|
|
15
|
+
import Toast from '../../react-native-toast-message';
|
|
16
|
+
import {
|
|
17
|
+
ENABLE_AUTH,
|
|
18
|
+
getPlatformId,
|
|
19
|
+
GET_UNAUTH_FLOW_API_ENDPOINT,
|
|
20
|
+
} from './config';
|
|
21
|
+
import isSDK from '../utils/isSDK';
|
|
22
|
+
import {Linking} from 'react-native';
|
|
23
|
+
import {
|
|
24
|
+
isAndroid,
|
|
25
|
+
isIOS,
|
|
26
|
+
isWeb,
|
|
27
|
+
isDesktop,
|
|
28
|
+
processDeepLinkURI,
|
|
29
|
+
getParamFromURL,
|
|
30
|
+
} from '../utils/common';
|
|
31
|
+
import SDKMethodEventsManager from '../utils/SdkMethodEvents';
|
|
32
|
+
import StorageContext from '../components/StorageContext';
|
|
33
|
+
import UserCancelPopup from './UserCancelPopup';
|
|
34
|
+
import {exitApp} from './openIDPURL';
|
|
35
|
+
import {useString} from '../utils/useString';
|
|
36
|
+
import {
|
|
37
|
+
authSessionTimeoutToastHeading,
|
|
38
|
+
loadingText,
|
|
39
|
+
} from '../language/default-labels/commonLabels';
|
|
40
|
+
|
|
41
|
+
export const GET_USER = gql`
|
|
42
|
+
query getUser {
|
|
43
|
+
getUser {
|
|
44
|
+
name
|
|
45
|
+
email
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
type AuthProviderProps = {
|
|
51
|
+
enableAuth?: boolean;
|
|
52
|
+
children: React.ReactNode;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
interface AuthContextInterface {
|
|
56
|
+
authenticated: boolean;
|
|
57
|
+
setIsAuthenticated: Dispatch<SetStateAction<boolean>>;
|
|
58
|
+
authLogin: () => void;
|
|
59
|
+
authLogout: () => void;
|
|
60
|
+
returnTo: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const AuthContext = createContext<AuthContextInterface | null>(null);
|
|
64
|
+
|
|
65
|
+
const AuthProvider = (props: AuthProviderProps) => {
|
|
66
|
+
const loadingLabel = useString(loadingText)();
|
|
67
|
+
const timeoutHeading = useString(authSessionTimeoutToastHeading)();
|
|
68
|
+
const regEvent = useRef(true);
|
|
69
|
+
const refreshTimeoutWeb = useRef(null);
|
|
70
|
+
const [showNativePopup, setShowNativePopup] = useState(false);
|
|
71
|
+
const {setStore, store} = useContext(StorageContext);
|
|
72
|
+
const [authenticated, setIsAuthenticated] = useState(false);
|
|
73
|
+
const [authError, setAuthError] = useState<string | null>(null);
|
|
74
|
+
const [loading, setLoading] = useState(true);
|
|
75
|
+
const [returnTo, setReturnTo] = useState('');
|
|
76
|
+
// auth hooks
|
|
77
|
+
const {enableIDPAuth, idpLogout} = useIDPAuth();
|
|
78
|
+
const {enableTokenAuth, tokenLogout} = useTokenAuth();
|
|
79
|
+
// routing
|
|
80
|
+
const history = useHistory();
|
|
81
|
+
const location = useLocation();
|
|
82
|
+
// client
|
|
83
|
+
const apolloClient = useApolloClient();
|
|
84
|
+
|
|
85
|
+
const indexesOf = (arr, item) =>
|
|
86
|
+
arr.reduce((acc, v, i) => (v === item && acc.push(i), acc), []);
|
|
87
|
+
const nonprodenv = ['dev', 'staging', 'preprod', 'test'];
|
|
88
|
+
const timeout = indexesOf(nonprodenv, $config.BACKEND_ENDPOINT)
|
|
89
|
+
? 240600
|
|
90
|
+
: 3540600;
|
|
91
|
+
|
|
92
|
+
//not needed since cookies authentication removed
|
|
93
|
+
const tokenRefreshWeb = () => {
|
|
94
|
+
//cookie token expiry in staging - 5min and production - 1hr
|
|
95
|
+
//since we can't read the cookies and its expiry details in the frontend
|
|
96
|
+
//manully calling refresh before 59 sec
|
|
97
|
+
//NOTE - IMP - if we call the refresh before or after 59 sec it won't work
|
|
98
|
+
//staging - 4min 1 sec
|
|
99
|
+
//production - 59min 1 sec
|
|
100
|
+
// if (authenticated && $config.ENABLE_IDP_AUTH && isWeb()) {
|
|
101
|
+
// refreshTimeoutWeb.current = setTimeout(() => {
|
|
102
|
+
// fetch(`${$config.BACKEND_ENDPOINT}/v1/token/refresh`, {
|
|
103
|
+
// method: 'POST',
|
|
104
|
+
// credentials: 'include',
|
|
105
|
+
// headers: {
|
|
106
|
+
// 'X-Platform-ID': getPlatformId(),
|
|
107
|
+
// },
|
|
108
|
+
// })
|
|
109
|
+
// .then((data) => {
|
|
110
|
+
// clearTimeout(refreshTimeoutWeb.current);
|
|
111
|
+
// tokenRefreshWeb();
|
|
112
|
+
// })
|
|
113
|
+
// .catch((error) => {
|
|
114
|
+
// });
|
|
115
|
+
// }, timeout);
|
|
116
|
+
// } else if (!authenticated && $config.ENABLE_IDP_AUTH && isWeb()) {
|
|
117
|
+
// //not authenticated
|
|
118
|
+
// if (refreshTimeoutWeb.current) {
|
|
119
|
+
// clearTimeout(refreshTimeoutWeb.current);
|
|
120
|
+
// } else {
|
|
121
|
+
// }
|
|
122
|
+
// }
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// useEffect(() => {
|
|
126
|
+
// tokenRefreshWeb();
|
|
127
|
+
// }, [authenticated]);
|
|
128
|
+
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (!ENABLE_AUTH && !authenticated && store.token) {
|
|
131
|
+
setIsAuthenticated(true);
|
|
132
|
+
if (isAndroid() || isIOS()) {
|
|
133
|
+
if (returnTo) {
|
|
134
|
+
history.push(returnTo);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, [store?.token]);
|
|
139
|
+
|
|
140
|
+
const deepLinkUrl = (link: string | null) => {
|
|
141
|
+
if (link !== null) {
|
|
142
|
+
//deeplinking handling with authentication enabled
|
|
143
|
+
if ($config.ENABLE_IDP_AUTH) {
|
|
144
|
+
const url = processDeepLinkURI(link);
|
|
145
|
+
try {
|
|
146
|
+
//login link expiry fix
|
|
147
|
+
if (url?.indexOf('msg') !== -1) {
|
|
148
|
+
//adding time delay to open in app browser
|
|
149
|
+
Toast.show({
|
|
150
|
+
leadingIconName: 'alert',
|
|
151
|
+
type: 'error',
|
|
152
|
+
text1: timeoutHeading,
|
|
153
|
+
visibilityTime: 3000,
|
|
154
|
+
});
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
authLogin();
|
|
157
|
+
}, 3000);
|
|
158
|
+
} else if (url?.indexOf('authorize') !== -1) {
|
|
159
|
+
const token = getParamFromURL(url, 'token');
|
|
160
|
+
if (token) {
|
|
161
|
+
enableTokenAuth(token)
|
|
162
|
+
.then(() => {
|
|
163
|
+
setIsAuthenticated(true);
|
|
164
|
+
if (returnTo) {
|
|
165
|
+
history.push(returnTo);
|
|
166
|
+
} else {
|
|
167
|
+
history.push('/');
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
.catch(() => {
|
|
171
|
+
setIsAuthenticated(false);
|
|
172
|
+
console.log('debugging error on IDP token setting');
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
console.log('debugging deep-linking token is empty');
|
|
176
|
+
history.push('/');
|
|
177
|
+
}
|
|
178
|
+
} else if (url?.indexOf('authorize') === -1) {
|
|
179
|
+
console.log('debugging deep-linking setting return to');
|
|
180
|
+
setReturnTo(url);
|
|
181
|
+
} else {
|
|
182
|
+
history.push(url);
|
|
183
|
+
}
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.log('debugging deep-linking error catch');
|
|
186
|
+
history.push('/');
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
//deeplinking handling with authentication enabled
|
|
190
|
+
const url = processDeepLinkURI(link);
|
|
191
|
+
setReturnTo(url);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
//handling the deeplink for native
|
|
198
|
+
if (isIOS() || isAndroid()) {
|
|
199
|
+
const deepLink = async () => {
|
|
200
|
+
const initialUrl = await Linking.getInitialURL();
|
|
201
|
+
Linking.addEventListener('url', e => {
|
|
202
|
+
deepLinkUrl(e.url);
|
|
203
|
+
});
|
|
204
|
+
deepLinkUrl(initialUrl);
|
|
205
|
+
};
|
|
206
|
+
deepLink();
|
|
207
|
+
}
|
|
208
|
+
}, [history]);
|
|
209
|
+
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
if (isSDK() && regEvent.current) {
|
|
212
|
+
regEvent.current = false;
|
|
213
|
+
SDKMethodEventsManager.on('login', async (res, rej, token) => {
|
|
214
|
+
try {
|
|
215
|
+
setStore(prevState => {
|
|
216
|
+
return {...prevState, token};
|
|
217
|
+
});
|
|
218
|
+
setTimeout(async () => {
|
|
219
|
+
enableTokenAuth(token)
|
|
220
|
+
.then(() => {
|
|
221
|
+
res();
|
|
222
|
+
})
|
|
223
|
+
.catch(error => {
|
|
224
|
+
rej('SDK Login failed' + JSON.stringify(error));
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
} catch (error) {
|
|
228
|
+
rej('SDK Login failed' + JSON.stringify(error));
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
SDKMethodEventsManager.on('logout', async (res, rej) => {
|
|
232
|
+
try {
|
|
233
|
+
await tokenLogout();
|
|
234
|
+
res();
|
|
235
|
+
} catch (error) {
|
|
236
|
+
rej('SDK Logout failed' + JSON.stringify(error));
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (!isSDK() && $config.ENABLE_TOKEN_AUTH) {
|
|
242
|
+
Toast.show({
|
|
243
|
+
leadingIconName: 'alert',
|
|
244
|
+
type: 'error',
|
|
245
|
+
text1: 'Token Server Authentication only supports SDK integration',
|
|
246
|
+
text2: 'Please use Auth0 Authentication.',
|
|
247
|
+
visibilityTime: 1000 * 60,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (isSDK() && $config.ENABLE_IDP_AUTH) {
|
|
251
|
+
Toast.show({
|
|
252
|
+
leadingIconName: 'alert',
|
|
253
|
+
type: 'error',
|
|
254
|
+
text1: 'Auth0 Authentication does not support SDK integration',
|
|
255
|
+
text2: 'Please use Token Server Authentication.',
|
|
256
|
+
visibilityTime: 1000 * 60,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}, []);
|
|
260
|
+
|
|
261
|
+
useEffect(() => {
|
|
262
|
+
if (!authenticated && authError) {
|
|
263
|
+
Toast.show({
|
|
264
|
+
leadingIconName: 'alert',
|
|
265
|
+
type: 'error',
|
|
266
|
+
text1: authError,
|
|
267
|
+
visibilityTime: 3000,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}, [authenticated, authError]);
|
|
271
|
+
|
|
272
|
+
async function getUserDetails() {
|
|
273
|
+
try {
|
|
274
|
+
await apolloClient.query({
|
|
275
|
+
query: GET_USER,
|
|
276
|
+
fetchPolicy: 'network-only',
|
|
277
|
+
});
|
|
278
|
+
} catch (error) {
|
|
279
|
+
throw new Error(error);
|
|
280
|
+
} finally {
|
|
281
|
+
setLoading(false);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
// Ignore if on sdk since IDP flow is not supported
|
|
287
|
+
// For unauthenticated flow authLogin should be called to get the token
|
|
288
|
+
if (isSDK() && ENABLE_AUTH) {
|
|
289
|
+
setIsAuthenticated(true);
|
|
290
|
+
setLoading(false);
|
|
291
|
+
return () => {};
|
|
292
|
+
}
|
|
293
|
+
//if application in authorization state then don't call authlogin
|
|
294
|
+
if (
|
|
295
|
+
//to check authoriztion
|
|
296
|
+
location?.pathname?.indexOf('authorize') === -1 &&
|
|
297
|
+
//to check login link expiry
|
|
298
|
+
//login link expiry fix
|
|
299
|
+
location?.search?.indexOf('msg') === -1
|
|
300
|
+
) {
|
|
301
|
+
//fetch user details
|
|
302
|
+
getUserDetails()
|
|
303
|
+
.then(_ => {
|
|
304
|
+
//Each time user refresh the page we have to redirect the user to IDP login.then only we can able to refresh the token
|
|
305
|
+
//because we can't read the cookie so we don't know expirytime.
|
|
306
|
+
//so each time page refresh will get new token
|
|
307
|
+
//then only
|
|
308
|
+
if (isWeb() && $config.ENABLE_IDP_AUTH) {
|
|
309
|
+
//authLogin();this is for cookie based authentication
|
|
310
|
+
setIsAuthenticated(true);
|
|
311
|
+
} else {
|
|
312
|
+
setIsAuthenticated(true);
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
.catch(() => {
|
|
316
|
+
setIsAuthenticated(false);
|
|
317
|
+
authLogin();
|
|
318
|
+
});
|
|
319
|
+
} else {
|
|
320
|
+
if (location?.search?.indexOf('msg') !== -1) {
|
|
321
|
+
Toast.show({
|
|
322
|
+
leadingIconName: 'alert',
|
|
323
|
+
type: 'error',
|
|
324
|
+
text1: timeoutHeading,
|
|
325
|
+
visibilityTime: 3000,
|
|
326
|
+
});
|
|
327
|
+
setTimeout(() => {
|
|
328
|
+
authLogin();
|
|
329
|
+
}, 3000);
|
|
330
|
+
//new code
|
|
331
|
+
//authLogin();
|
|
332
|
+
} else {
|
|
333
|
+
//it will render the children
|
|
334
|
+
setLoading(false);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}, []);
|
|
338
|
+
|
|
339
|
+
const authLogin = () => {
|
|
340
|
+
// Authenticated login flow
|
|
341
|
+
if (ENABLE_AUTH) {
|
|
342
|
+
//AUTH -> IDP -> NATIVE and WEB and DESKTOP
|
|
343
|
+
if ($config.ENABLE_IDP_AUTH && !isSDK()) {
|
|
344
|
+
//it will open external web link and post authentication it will redirect to application
|
|
345
|
+
//@ts-ignore
|
|
346
|
+
enableIDPAuth(
|
|
347
|
+
isWeb()
|
|
348
|
+
? location.pathname
|
|
349
|
+
: isDesktop()
|
|
350
|
+
? history
|
|
351
|
+
: isIOS() || isAndroid()
|
|
352
|
+
? deepLinkUrl
|
|
353
|
+
: '',
|
|
354
|
+
timeoutHeading,
|
|
355
|
+
)?.then((response: any) => {
|
|
356
|
+
if (isAndroid() || isIOS()) {
|
|
357
|
+
if (response && response?.showNativePopup) {
|
|
358
|
+
setShowNativePopup(true);
|
|
359
|
+
} else {
|
|
360
|
+
setShowNativePopup(false);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
//AUTH -> IDP -> SDK ONLY
|
|
366
|
+
else if ($config.ENABLE_TOKEN_AUTH && isSDK()) {
|
|
367
|
+
enableTokenAuth()
|
|
368
|
+
.then(res => {
|
|
369
|
+
setIsAuthenticated(true);
|
|
370
|
+
history.push('/create');
|
|
371
|
+
})
|
|
372
|
+
.catch(error => {
|
|
373
|
+
//don't show token expire/not found toast in the sdk
|
|
374
|
+
//we have event emitter to inform the customer application
|
|
375
|
+
//they have to listen for those events
|
|
376
|
+
if (!isSDK()) {
|
|
377
|
+
if (error instanceof Error) {
|
|
378
|
+
setAuthError(error.message);
|
|
379
|
+
} else {
|
|
380
|
+
setAuthError(error);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
setIsAuthenticated(false);
|
|
384
|
+
//sdk there is no fallback page
|
|
385
|
+
history.push('/create');
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// Unauthenticated login flow
|
|
390
|
+
else {
|
|
391
|
+
fetch(GET_UNAUTH_FLOW_API_ENDPOINT(), {
|
|
392
|
+
credentials: 'include',
|
|
393
|
+
})
|
|
394
|
+
.then(response => response.json())
|
|
395
|
+
.then(response => {
|
|
396
|
+
// unauthenticated flow all platform we will have to handle the token manually
|
|
397
|
+
// we need to store token manually
|
|
398
|
+
if (!response.token) {
|
|
399
|
+
throw new Error('Token not received');
|
|
400
|
+
} else {
|
|
401
|
+
enableTokenAuth(response.token)
|
|
402
|
+
.then(() => {
|
|
403
|
+
//set auth enabled on useEffect
|
|
404
|
+
})
|
|
405
|
+
.catch(error => {
|
|
406
|
+
//we don't need to show token expire/not found toast in the sdk
|
|
407
|
+
//we have event emitter to inform the customer application
|
|
408
|
+
//they have to listen for those events
|
|
409
|
+
if (!isSDK()) {
|
|
410
|
+
if (error instanceof Error) {
|
|
411
|
+
setAuthError(error.message);
|
|
412
|
+
} else {
|
|
413
|
+
setAuthError(error);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
setIsAuthenticated(false);
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
})
|
|
420
|
+
.catch(error => {
|
|
421
|
+
if (error instanceof Error) {
|
|
422
|
+
setAuthError(error.message);
|
|
423
|
+
} else {
|
|
424
|
+
setAuthError(error);
|
|
425
|
+
}
|
|
426
|
+
setIsAuthenticated(false);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
const authLogout = () => {
|
|
432
|
+
if (ENABLE_AUTH && $config.ENABLE_IDP_AUTH && !isSDK()) {
|
|
433
|
+
idpLogout(isAndroid() || isIOS() ? setShowNativePopup : {})
|
|
434
|
+
.then(res => {
|
|
435
|
+
setIsAuthenticated(false);
|
|
436
|
+
})
|
|
437
|
+
.catch(() => {
|
|
438
|
+
setIsAuthenticated(false);
|
|
439
|
+
console.error('user logout failed');
|
|
440
|
+
setAuthError('Error occured on Logout, please try again.');
|
|
441
|
+
setTimeout(() => {
|
|
442
|
+
authLogin();
|
|
443
|
+
}, 3000);
|
|
444
|
+
});
|
|
445
|
+
} else {
|
|
446
|
+
if (!ENABLE_AUTH || isSDK()) {
|
|
447
|
+
//no need to logout because we need token to see the create screen
|
|
448
|
+
//unauth flow no logout
|
|
449
|
+
//sdk with auth flow will use sdk api for logout
|
|
450
|
+
history.push('/create');
|
|
451
|
+
} else {
|
|
452
|
+
tokenLogout()
|
|
453
|
+
.then(res => {})
|
|
454
|
+
.catch(() => {
|
|
455
|
+
console.error('user logout failed');
|
|
456
|
+
setAuthError('Error occured on Logout, please try again.');
|
|
457
|
+
})
|
|
458
|
+
.finally(() => {
|
|
459
|
+
setIsAuthenticated(false);
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
return (
|
|
466
|
+
<AuthContext.Provider
|
|
467
|
+
value={{
|
|
468
|
+
setIsAuthenticated,
|
|
469
|
+
authenticated,
|
|
470
|
+
authLogin,
|
|
471
|
+
authLogout,
|
|
472
|
+
returnTo,
|
|
473
|
+
}}>
|
|
474
|
+
{showNativePopup ? (
|
|
475
|
+
<UserCancelPopup
|
|
476
|
+
login={() => {
|
|
477
|
+
setShowNativePopup(false);
|
|
478
|
+
authLogin();
|
|
479
|
+
}}
|
|
480
|
+
exitApp={() => {
|
|
481
|
+
setShowNativePopup(false);
|
|
482
|
+
exitApp();
|
|
483
|
+
}}
|
|
484
|
+
modalVisible={showNativePopup}
|
|
485
|
+
setModalVisible={setShowNativePopup}
|
|
486
|
+
/>
|
|
487
|
+
) : (
|
|
488
|
+
<></>
|
|
489
|
+
)}
|
|
490
|
+
{(!authenticated && !ENABLE_AUTH) || (ENABLE_AUTH && loading) ? (
|
|
491
|
+
<Loading text={loadingLabel} />
|
|
492
|
+
) : (
|
|
493
|
+
props.children
|
|
494
|
+
)}
|
|
495
|
+
</AuthContext.Provider>
|
|
496
|
+
);
|
|
497
|
+
};
|
|
498
|
+
const useAuth = () => React.useContext(AuthContext);
|
|
499
|
+
|
|
500
|
+
export {AuthProvider, useAuth};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
********************************************
|
|
3
|
+
Copyright © 2021 Agora Lab, Inc., all rights reserved.
|
|
4
|
+
AppBuilder and all associated components, source code, APIs, services, and documentation
|
|
5
|
+
(the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
|
|
6
|
+
accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
|
|
7
|
+
Use without a license or in violation of any license terms and conditions (including use for
|
|
8
|
+
any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
|
|
9
|
+
information visit https://appbuilder.agora.io.
|
|
10
|
+
*********************************************
|
|
11
|
+
*/
|
|
12
|
+
import React, {useEffect, useRef} from 'react';
|
|
13
|
+
import {Route, Redirect} from '../components/Router';
|
|
14
|
+
import Toast from '../../react-native-toast-message';
|
|
15
|
+
import type {RouteProps} from 'react-router';
|
|
16
|
+
import {useAuth} from './AuthProvider';
|
|
17
|
+
import isSDK from '../utils/isSDK';
|
|
18
|
+
import Loading from '../subComponents/Loading';
|
|
19
|
+
import Login from '../pages/Login';
|
|
20
|
+
import {isAndroid, isIOS} from '../utils/common';
|
|
21
|
+
import {useString} from '../utils/useString';
|
|
22
|
+
import {
|
|
23
|
+
authAuthenticationFailedText,
|
|
24
|
+
loadingText,
|
|
25
|
+
} from '../language/default-labels/commonLabels';
|
|
26
|
+
|
|
27
|
+
interface PrivateRouteProps extends RouteProps {
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const AuthRoute: React.FC<PrivateRouteProps> = props => {
|
|
32
|
+
const didMountRef = useRef(false);
|
|
33
|
+
const {authenticated} = useAuth();
|
|
34
|
+
const loadingLabel = useString(loadingText)();
|
|
35
|
+
const failedtext = useString(authAuthenticationFailedText)();
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!didMountRef.current) return;
|
|
39
|
+
if (!authenticated) {
|
|
40
|
+
Toast.show({
|
|
41
|
+
leadingIconName: 'alert',
|
|
42
|
+
type: 'error',
|
|
43
|
+
text1: failedtext,
|
|
44
|
+
visibilityTime: 1000,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
didMountRef.current = true;
|
|
48
|
+
}, [authenticated]);
|
|
49
|
+
|
|
50
|
+
//on SDK no fallback so even though authentication failed we will still show the routes
|
|
51
|
+
//when user try to perform any operation it will get failed and throw regular error message
|
|
52
|
+
if (isSDK()) {
|
|
53
|
+
return <Route {...props} />;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return authenticated ? (
|
|
57
|
+
<>
|
|
58
|
+
<Route {...props} />
|
|
59
|
+
</>
|
|
60
|
+
) : (
|
|
61
|
+
//if user closes the inapp browser then we are showing the loginpopup
|
|
62
|
+
//: isAndroid() || isIOS() ? (
|
|
63
|
+
//if user closes inapp browser then show login/signup button
|
|
64
|
+
// <Login />
|
|
65
|
+
//)
|
|
66
|
+
<Loading text={loadingLabel} />
|
|
67
|
+
);
|
|
68
|
+
// <Redirect
|
|
69
|
+
// to={{
|
|
70
|
+
// pathname: '/login',
|
|
71
|
+
// }}
|
|
72
|
+
// />
|
|
73
|
+
// return (
|
|
74
|
+
// <Route
|
|
75
|
+
// {...props}
|
|
76
|
+
// render={({location}) => {
|
|
77
|
+
// return authenticated ? (
|
|
78
|
+
// props.children
|
|
79
|
+
// ) : (
|
|
80
|
+
// <Redirect
|
|
81
|
+
// to={{
|
|
82
|
+
// pathname: '/login',
|
|
83
|
+
// state: {
|
|
84
|
+
// from: location,
|
|
85
|
+
// },
|
|
86
|
+
// }}
|
|
87
|
+
// />
|
|
88
|
+
// );
|
|
89
|
+
// }}
|
|
90
|
+
// />
|
|
91
|
+
// );
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default AuthRoute;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, {useEffect} from 'react';
|
|
2
|
+
import {useAuth} from './AuthProvider';
|
|
3
|
+
import {useHistory, useParams} from '../components/Router';
|
|
4
|
+
import Loading from '../subComponents/Loading';
|
|
5
|
+
import useTokenAuth from './useTokenAuth';
|
|
6
|
+
import {useString} from '../utils/useString';
|
|
7
|
+
import {authAuthorizingApplicationText} from '../language/default-labels/commonLabels';
|
|
8
|
+
|
|
9
|
+
export const IDPAuth = () => {
|
|
10
|
+
const {setIsAuthenticated} = useAuth();
|
|
11
|
+
const {enableTokenAuth} = useTokenAuth();
|
|
12
|
+
const history = useHistory();
|
|
13
|
+
const {token}: {token: string} = useParams();
|
|
14
|
+
const text = useString(authAuthorizingApplicationText)();
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (token) {
|
|
18
|
+
enableTokenAuth(token)
|
|
19
|
+
.then(() => {
|
|
20
|
+
setIsAuthenticated(true);
|
|
21
|
+
history.push('/');
|
|
22
|
+
})
|
|
23
|
+
.catch(() => {
|
|
24
|
+
setIsAuthenticated(false);
|
|
25
|
+
console.log('debugging electron login failed');
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
return <Loading text={text} />;
|
|
31
|
+
};
|