@kaleyra/video-react-native-module 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +292 -0
  3. package/android/build.gradle +100 -0
  4. package/android/gradle.properties +9 -0
  5. package/android/settings.gradle +6 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/assets/kaleyra_video_wrapper_info.txt +1 -0
  8. package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeAccessTokenProvider.kt +22 -0
  9. package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeContextContainer.kt +9 -0
  10. package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeVideoHybridBridge.kt +30 -0
  11. package/android/src/main/java/com/kaleyra/video_react_native_module/VideoNativeEmitter.kt +45 -0
  12. package/android/src/main/java/com/kaleyra/video_react_native_module/VideoNativeModule.kt +109 -0
  13. package/android/src/main/java/com/kaleyra/video_react_native_module/VideoReactPackage.kt +20 -0
  14. package/index.ts +47 -0
  15. package/ios/PluginInfo/_KaleyraVideoHybridVersionInfo.swift +31 -0
  16. package/ios/ReactEvents/ReactNativeEventEmitter.swift +31 -0
  17. package/ios/ReactEvents/VideoNativeEmitter.m +17 -0
  18. package/ios/ReactEvents/VideoNativeEmitter.swift +42 -0
  19. package/ios/ReactNativePlugin-Bridging-Header.h +5 -0
  20. package/ios/ReactNativePlugin.xcodeproj/project.pbxproj +301 -0
  21. package/ios/VideoNativeModule.m +45 -0
  22. package/ios/VideoNativeModule.swift +154 -0
  23. package/lib/commonjs/index.js +12 -0
  24. package/lib/commonjs/native-bridge/TypeScript/Environments.js +41 -0
  25. package/lib/commonjs/native-bridge/TypeScript/Events.js +46 -0
  26. package/lib/commonjs/native-bridge/TypeScript/Regions.js +47 -0
  27. package/lib/commonjs/native-bridge/TypeScript/UserDetailsFormatValidator.js +32 -0
  28. package/lib/commonjs/native-bridge/TypeScript/errors/IllegalArgumentError.js +12 -0
  29. package/lib/commonjs/native-bridge/TypeScript/types/AccessTokenRequest.js +4 -0
  30. package/lib/commonjs/native-bridge/TypeScript/types/AccessTokenResponse.js +36 -0
  31. package/lib/commonjs/native-bridge/TypeScript/types/AudioCallOptions.js +4 -0
  32. package/lib/commonjs/native-bridge/TypeScript/types/AudioCallType.js +19 -0
  33. package/lib/commonjs/native-bridge/TypeScript/types/CallDisplayMode.js +23 -0
  34. package/lib/commonjs/native-bridge/TypeScript/types/CallKitConfiguration.js +4 -0
  35. package/lib/commonjs/native-bridge/TypeScript/types/CallOptions.js +4 -0
  36. package/lib/commonjs/native-bridge/TypeScript/types/CallType.js +23 -0
  37. package/lib/commonjs/native-bridge/TypeScript/types/ChatToolConfiguration.js +4 -0
  38. package/lib/commonjs/native-bridge/TypeScript/types/CreateCallOptions.js +4 -0
  39. package/lib/commonjs/native-bridge/TypeScript/types/Environment.js +4 -0
  40. package/lib/commonjs/native-bridge/TypeScript/types/IosConfiguration.js +4 -0
  41. package/lib/commonjs/native-bridge/TypeScript/types/KaleyraVideoConfiguration.js +4 -0
  42. package/lib/commonjs/native-bridge/TypeScript/types/RecordingType.js +23 -0
  43. package/lib/commonjs/native-bridge/TypeScript/types/Region.js +4 -0
  44. package/lib/commonjs/native-bridge/TypeScript/types/ScreenShareToolConfiguration.js +4 -0
  45. package/lib/commonjs/native-bridge/TypeScript/types/Session.js +4 -0
  46. package/lib/commonjs/native-bridge/TypeScript/types/Tools.js +4 -0
  47. package/lib/commonjs/native-bridge/TypeScript/types/UserDetails.js +4 -0
  48. package/lib/commonjs/native-bridge/TypeScript/types/UserDetailsFormat.js +4 -0
  49. package/lib/commonjs/native-bridge/TypeScript/types/VoipHandlingStrategy.js +19 -0
  50. package/lib/commonjs/src/KaleyraVideo.js +259 -0
  51. package/lib/commonjs/src/ReactNativeEventEmitter.js +40 -0
  52. package/lib/commonjs/src/events/Events.js +4 -0
  53. package/lib/module/index.js +2 -0
  54. package/lib/module/native-bridge/TypeScript/Environments.js +37 -0
  55. package/lib/module/native-bridge/TypeScript/Events.js +43 -0
  56. package/lib/module/native-bridge/TypeScript/Regions.js +43 -0
  57. package/lib/module/native-bridge/TypeScript/UserDetailsFormatValidator.js +28 -0
  58. package/lib/module/native-bridge/TypeScript/errors/IllegalArgumentError.js +8 -0
  59. package/lib/module/native-bridge/TypeScript/types/AccessTokenRequest.js +3 -0
  60. package/lib/module/native-bridge/TypeScript/types/AccessTokenResponse.js +32 -0
  61. package/lib/module/native-bridge/TypeScript/types/AudioCallOptions.js +3 -0
  62. package/lib/module/native-bridge/TypeScript/types/AudioCallType.js +16 -0
  63. package/lib/module/native-bridge/TypeScript/types/CallDisplayMode.js +20 -0
  64. package/lib/module/native-bridge/TypeScript/types/CallKitConfiguration.js +3 -0
  65. package/lib/module/native-bridge/TypeScript/types/CallOptions.js +3 -0
  66. package/lib/module/native-bridge/TypeScript/types/CallType.js +20 -0
  67. package/lib/module/native-bridge/TypeScript/types/ChatToolConfiguration.js +3 -0
  68. package/lib/module/native-bridge/TypeScript/types/CreateCallOptions.js +3 -0
  69. package/lib/module/native-bridge/TypeScript/types/Environment.js +3 -0
  70. package/lib/module/native-bridge/TypeScript/types/IosConfiguration.js +3 -0
  71. package/lib/module/native-bridge/TypeScript/types/KaleyraVideoConfiguration.js +3 -0
  72. package/lib/module/native-bridge/TypeScript/types/RecordingType.js +20 -0
  73. package/lib/module/native-bridge/TypeScript/types/Region.js +3 -0
  74. package/lib/module/native-bridge/TypeScript/types/ScreenShareToolConfiguration.js +3 -0
  75. package/lib/module/native-bridge/TypeScript/types/Session.js +3 -0
  76. package/lib/module/native-bridge/TypeScript/types/Tools.js +3 -0
  77. package/lib/module/native-bridge/TypeScript/types/UserDetails.js +3 -0
  78. package/lib/module/native-bridge/TypeScript/types/UserDetailsFormat.js +3 -0
  79. package/lib/module/native-bridge/TypeScript/types/VoipHandlingStrategy.js +16 -0
  80. package/lib/module/src/KaleyraVideo.js +249 -0
  81. package/lib/module/src/ReactNativeEventEmitter.js +36 -0
  82. package/lib/module/src/events/Events.js +3 -0
  83. package/lib/typescript/index.d.ts +2 -0
  84. package/lib/typescript/native-bridge/TypeScript/Environments.d.ts +28 -0
  85. package/lib/typescript/native-bridge/TypeScript/Events.d.ts +40 -0
  86. package/lib/typescript/native-bridge/TypeScript/Regions.d.ts +32 -0
  87. package/lib/typescript/native-bridge/TypeScript/UserDetailsFormatValidator.d.ts +4 -0
  88. package/lib/typescript/native-bridge/TypeScript/errors/IllegalArgumentError.d.ts +6 -0
  89. package/lib/typescript/native-bridge/TypeScript/types/AccessTokenRequest.d.ts +4 -0
  90. package/lib/typescript/native-bridge/TypeScript/types/AccessTokenResponse.d.ts +12 -0
  91. package/lib/typescript/native-bridge/TypeScript/types/AudioCallOptions.d.ts +11 -0
  92. package/lib/typescript/native-bridge/TypeScript/types/AudioCallType.d.ts +13 -0
  93. package/lib/typescript/native-bridge/TypeScript/types/CallDisplayMode.d.ts +17 -0
  94. package/lib/typescript/native-bridge/TypeScript/types/CallKitConfiguration.d.ts +26 -0
  95. package/lib/typescript/native-bridge/TypeScript/types/CallOptions.d.ts +13 -0
  96. package/lib/typescript/native-bridge/TypeScript/types/CallType.d.ts +17 -0
  97. package/lib/typescript/native-bridge/TypeScript/types/ChatToolConfiguration.d.ts +15 -0
  98. package/lib/typescript/native-bridge/TypeScript/types/CreateCallOptions.d.ts +15 -0
  99. package/lib/typescript/native-bridge/TypeScript/types/Environment.d.ts +9 -0
  100. package/lib/typescript/native-bridge/TypeScript/types/IosConfiguration.d.ts +23 -0
  101. package/lib/typescript/native-bridge/TypeScript/types/KaleyraVideoConfiguration.d.ts +33 -0
  102. package/lib/typescript/native-bridge/TypeScript/types/RecordingType.d.ts +17 -0
  103. package/lib/typescript/native-bridge/TypeScript/types/Region.d.ts +9 -0
  104. package/lib/typescript/native-bridge/TypeScript/types/ScreenShareToolConfiguration.d.ts +19 -0
  105. package/lib/typescript/native-bridge/TypeScript/types/Session.d.ts +16 -0
  106. package/lib/typescript/native-bridge/TypeScript/types/Tools.d.ts +42 -0
  107. package/lib/typescript/native-bridge/TypeScript/types/UserDetails.d.ts +29 -0
  108. package/lib/typescript/native-bridge/TypeScript/types/UserDetailsFormat.d.ts +19 -0
  109. package/lib/typescript/native-bridge/TypeScript/types/VoipHandlingStrategy.d.ts +13 -0
  110. package/lib/typescript/src/KaleyraVideo.d.ts +125 -0
  111. package/lib/typescript/src/ReactNativeEventEmitter.d.ts +15 -0
  112. package/lib/typescript/src/events/Events.d.ts +37 -0
  113. package/native-bridge/LICENSE +165 -0
  114. package/native-bridge/TypeScript/Environments.ts +44 -0
  115. package/native-bridge/TypeScript/Events.ts +43 -0
  116. package/native-bridge/TypeScript/Regions.ts +51 -0
  117. package/native-bridge/TypeScript/UserDetailsFormatValidator.ts +35 -0
  118. package/native-bridge/TypeScript/errors/IllegalArgumentError.ts +9 -0
  119. package/native-bridge/TypeScript/types/AccessTokenRequest.ts +7 -0
  120. package/native-bridge/TypeScript/types/AccessTokenResponse.ts +41 -0
  121. package/native-bridge/TypeScript/types/AudioCallOptions.ts +15 -0
  122. package/native-bridge/TypeScript/types/AudioCallType.ts +17 -0
  123. package/native-bridge/TypeScript/types/CallDisplayMode.ts +22 -0
  124. package/native-bridge/TypeScript/types/CallKitConfiguration.ts +32 -0
  125. package/native-bridge/TypeScript/types/CallOptions.ts +18 -0
  126. package/native-bridge/TypeScript/types/CallType.ts +22 -0
  127. package/native-bridge/TypeScript/types/ChatToolConfiguration.ts +21 -0
  128. package/native-bridge/TypeScript/types/CreateCallOptions.ts +20 -0
  129. package/native-bridge/TypeScript/types/Environment.ts +12 -0
  130. package/native-bridge/TypeScript/types/IosConfiguration.ts +29 -0
  131. package/native-bridge/TypeScript/types/KaleyraVideoConfiguration.ts +42 -0
  132. package/native-bridge/TypeScript/types/RecordingType.ts +22 -0
  133. package/native-bridge/TypeScript/types/Region.ts +12 -0
  134. package/native-bridge/TypeScript/types/ScreenShareToolConfiguration.ts +24 -0
  135. package/native-bridge/TypeScript/types/Session.ts +20 -0
  136. package/native-bridge/TypeScript/types/Tools.ts +50 -0
  137. package/native-bridge/TypeScript/types/UserDetails.ts +37 -0
  138. package/native-bridge/TypeScript/types/UserDetailsFormat.ts +23 -0
  139. package/native-bridge/TypeScript/types/VoipHandlingStrategy.ts +17 -0
  140. package/native-bridge/android/build.gradle +72 -0
  141. package/native-bridge/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  142. package/native-bridge/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  143. package/native-bridge/android/gradle.properties +22 -0
  144. package/native-bridge/android/gradlew +234 -0
  145. package/native-bridge/android/gradlew.bat +89 -0
  146. package/native-bridge/android/settings.gradle +1 -0
  147. package/native-bridge/android/src/main/AndroidManifest.xml +1 -0
  148. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/AccessTokenProvider.kt +8 -0
  149. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/CallOptionsProxy.kt +9 -0
  150. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ContextContainer.kt +10 -0
  151. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/DTOs.kt +407 -0
  152. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/SDKAccessTokenProviderProxy.kt +16 -0
  153. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/VideoHybridBridge.kt +21 -0
  154. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/VideoSDKHybridBridge.kt +64 -0
  155. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/configurator/CachedSDKConfigurator.kt +15 -0
  156. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/configurator/VideoSDKConfigurator.kt +46 -0
  157. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/connector/CachedUserConnector.kt +15 -0
  158. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/connector/VideoSDKCachedUserConnector.kt +60 -0
  159. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/Events.kt +29 -0
  160. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/EventsEmitter.kt +8 -0
  161. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/EventsReporter.kt +9 -0
  162. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/CallEventsReporter.kt +54 -0
  163. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/ChatEventsReporter.kt +43 -0
  164. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/CrossPlatformModuleStatus.kt +29 -0
  165. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/ModuleEventsReporter.kt +34 -0
  166. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/SDKEventsReporter.kt +63 -0
  167. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/CallDisplayExtension.kt +15 -0
  168. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ConfigurationExtension.kt +39 -0
  169. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/EnvironmentExtension.kt +12 -0
  170. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/RecordingTypeExtension.kt +15 -0
  171. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/RegionExtension.kt +13 -0
  172. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ScreenShareToolConfigurationExtension.kt +15 -0
  173. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ToolsExtension.kt +95 -0
  174. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/UserExtensions.kt +35 -0
  175. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/notifications/KaleyraVideoNotificationReceiver.kt +139 -0
  176. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/notifications/KaleyraVideoNotificationService.kt +85 -0
  177. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/ConfigurationEntity.kt +27 -0
  178. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/ConnectedUserEntity.kt +30 -0
  179. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/Converters.kt +25 -0
  180. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/UserDetailsDao.kt +21 -0
  181. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/UserDetailsEntity.kt +22 -0
  182. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/VideoHybridBridgeRepository.kt +39 -0
  183. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ui/SDKUserInterfacePresenter.kt +49 -0
  184. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ui/UserInterfacePresenter.kt +14 -0
  185. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/CachedUserDetails.kt +18 -0
  186. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/CachedUserDetailsFormatter.kt +59 -0
  187. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/SDKCachedUserDetails.kt +74 -0
  188. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/utils/CaseInsensitiveEnumTypeAdapterFactory.kt +48 -0
  189. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/utils/TLSSocketFactoryCompat.kt +76 -0
  190. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.pbxproj +1399 -0
  191. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  192. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  193. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/xcshareddata/IDETemplateMacros.plist +9 -0
  194. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/xcshareddata/xcschemes/KaleyraVideoHybridNativeBridge.xcscheme +79 -0
  195. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcworkspace/contents.xcworkspacedata +10 -0
  196. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  197. package/native-bridge/iOS/Podfile +28 -0
  198. package/native-bridge/iOS/Podfile.lock +20 -0
  199. package/native-bridge/iOS/Source/Abstractions/BandyerSDKProtocol.swift +24 -0
  200. package/native-bridge/iOS/Source/Abstractions/CallWindowProtocol.swift +18 -0
  201. package/native-bridge/iOS/Source/AccessToken/AccessTokenRequester.swift +9 -0
  202. package/native-bridge/iOS/Source/AccessToken/TokenProvider.swift +78 -0
  203. package/native-bridge/iOS/Source/Broadcast/BroadcastConfigurationPlistReader.swift +49 -0
  204. package/native-bridge/iOS/Source/Concurrency/DispatchQueue+isMain.swift +19 -0
  205. package/native-bridge/iOS/Source/Concurrency/Lock.swift +21 -0
  206. package/native-bridge/iOS/Source/Concurrency/MainQueueDispatcher.swift +23 -0
  207. package/native-bridge/iOS/Source/Concurrency/MainQueueRelay.swift +18 -0
  208. package/native-bridge/iOS/Source/DTOs/AccessTokenRequest+Encodable.swift +27 -0
  209. package/native-bridge/iOS/Source/DTOs/AccessTokenResponse+Decodable.swift +24 -0
  210. package/native-bridge/iOS/Source/DTOs/Array+JSON.swift +6 -0
  211. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Bandyer.swift +14 -0
  212. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Decodable.swift +18 -0
  213. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Equatable.swift +12 -0
  214. package/native-bridge/iOS/Source/DTOs/AudioCallType+Bandyer.swift +18 -0
  215. package/native-bridge/iOS/Source/DTOs/AudioCallType+Decodable.swift +25 -0
  216. package/native-bridge/iOS/Source/DTOs/CallKitConfiguration+Decodable.swift +20 -0
  217. package/native-bridge/iOS/Source/DTOs/CallOptions+Bandyer.swift +14 -0
  218. package/native-bridge/iOS/Source/DTOs/CallOptions+Decodable.swift +16 -0
  219. package/native-bridge/iOS/Source/DTOs/CallOptions+Equatable.swift +12 -0
  220. package/native-bridge/iOS/Source/DTOs/CallType+Bandyer.swift +20 -0
  221. package/native-bridge/iOS/Source/DTOs/CallType+Decodable.swift +27 -0
  222. package/native-bridge/iOS/Source/DTOs/ChatToolConfiguration+Decodable.swift +18 -0
  223. package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Decodable.swift +22 -0
  224. package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Equatable.swift +13 -0
  225. package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Intent.swift +17 -0
  226. package/native-bridge/iOS/Source/DTOs/DTOs.swift +314 -0
  227. package/native-bridge/iOS/Source/DTOs/Environment+Bandyer.swift +20 -0
  228. package/native-bridge/iOS/Source/DTOs/Environment+Decodable.swift +16 -0
  229. package/native-bridge/iOS/Source/DTOs/IosConfiguration+Decodable.swift +18 -0
  230. package/native-bridge/iOS/Source/DTOs/JSONDecodable.swift +27 -0
  231. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+Bandyer.swift +158 -0
  232. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+Decodable.swift +28 -0
  233. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+UserInterfacePresenterConfiguration.swift +29 -0
  234. package/native-bridge/iOS/Source/DTOs/RecordingType+Bandyer.swift +33 -0
  235. package/native-bridge/iOS/Source/DTOs/RecordingType+Decodable.swift +27 -0
  236. package/native-bridge/iOS/Source/DTOs/Region+Bandyer.swift +22 -0
  237. package/native-bridge/iOS/Source/DTOs/Region+Decodable.swift +16 -0
  238. package/native-bridge/iOS/Source/DTOs/ScreenShareToolConfiguration+Decodable.swift +18 -0
  239. package/native-bridge/iOS/Source/DTOs/Tools+Decodable.swift +24 -0
  240. package/native-bridge/iOS/Source/DTOs/UserDetails+Bandyer.swift +18 -0
  241. package/native-bridge/iOS/Source/DTOs/UserDetails+Decodable.swift +28 -0
  242. package/native-bridge/iOS/Source/DTOs/UserDetailsFormat+Decodable.swift +19 -0
  243. package/native-bridge/iOS/Source/DTOs/VoipHandlingStrategy+Decodable.swift +25 -0
  244. package/native-bridge/iOS/Source/Events/Emitter/EventEmitter.swift +8 -0
  245. package/native-bridge/iOS/Source/Events/Events+CaseIterable.swift +18 -0
  246. package/native-bridge/iOS/Source/Events/Events+Description.swift +28 -0
  247. package/native-bridge/iOS/Source/Events/Events.swift +21 -0
  248. package/native-bridge/iOS/Source/Events/Reporters/CallClientEventsReporter.swift +46 -0
  249. package/native-bridge/iOS/Source/Events/Reporters/ChatClientEventsReporter.swift +46 -0
  250. package/native-bridge/iOS/Source/Events/Reporters/ClientState.swift +61 -0
  251. package/native-bridge/iOS/Source/Events/Reporters/EventsReporter.swift +69 -0
  252. package/native-bridge/iOS/Source/Events/Reporters/PushTokenEventsReporter.swift +34 -0
  253. package/native-bridge/iOS/Source/Extensions/URL+FromString.swift +26 -0
  254. package/native-bridge/iOS/Source/KaleyraVideoHybridNativeBridge.h +14 -0
  255. package/native-bridge/iOS/Source/NativeHybridBridge/VideoHybridNativeBridge.swift +173 -0
  256. package/native-bridge/iOS/Source/NativeHybridBridge/VideoHybridNativeBridgeError.swift +33 -0
  257. package/native-bridge/iOS/Source/UI/KaleyraVideoSDKUserInterfacePresenter.swift +249 -0
  258. package/native-bridge/iOS/Source/UI/Presenters/PresentingViewControllerViewControllerPresenter.swift +44 -0
  259. package/native-bridge/iOS/Source/UI/Presenters/ViewControllerPresenter.swift +17 -0
  260. package/native-bridge/iOS/Source/UI/Presenters/WindowViewControllerPresenter.swift +111 -0
  261. package/native-bridge/iOS/Source/UI/UserInterfacePresenter+MainQueueRelay.swift +30 -0
  262. package/native-bridge/iOS/Source/UI/UserInterfacePresenter.swift +14 -0
  263. package/native-bridge/iOS/Source/User Details/Cache/UsersDetailsCache.swift +36 -0
  264. package/native-bridge/iOS/Source/User Details/Formatter/FormatterProxy.swift +47 -0
  265. package/native-bridge/iOS/Source/User Details/Formatter/UserDetailsFormatter.swift +83 -0
  266. package/native-bridge/iOS/Source/User Details/Providers/UsersDetailsProvider.swift +39 -0
  267. package/package.json +147 -0
  268. package/src/KaleyraVideo.ts +343 -0
  269. package/src/ReactNativeEventEmitter.ts +51 -0
  270. package/src/events/Events.ts +46 -0
  271. package/video-react-native-module.podspec +36 -0
@@ -0,0 +1,85 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.notifications
5
+
6
+ import android.content.ComponentName
7
+ import android.content.Context
8
+ import android.content.Intent
9
+ import android.util.Log
10
+ import androidx.core.app.JobIntentService
11
+ import com.kaleyra.video_hybrid_native_bridge.VideoSDKHybridBridge
12
+ import com.kaleyra.video_hybrid_native_bridge.ContextContainer
13
+ import com.kaleyra.video_hybrid_native_bridge.CrossPlatformAccessTokenProvider
14
+ import com.kaleyra.video_hybrid_native_bridge.events.Events
15
+ import com.kaleyra.video_hybrid_native_bridge.events.EventsEmitter
16
+ import com.kaleyra.video_hybrid_native_bridge.events.EventsReporter
17
+ import kotlinx.coroutines.CoroutineScope
18
+ import kotlinx.coroutines.asCoroutineDispatcher
19
+ import kotlinx.coroutines.launch
20
+ import org.json.JSONObject
21
+ import java.util.concurrent.Executors
22
+
23
+ /**
24
+ * @author kristiyan
25
+ */
26
+ class KaleyraVideoNotificationService : JobIntentService() {
27
+
28
+ companion object {
29
+ fun enqueueWork(
30
+ context: Context,
31
+ componentName: ComponentName,
32
+ intent: Intent
33
+ ) = enqueueWork(
34
+ context,
35
+ componentName,
36
+ KaleyraVideoNotificationReceiver::class.java.simpleName.hashCode(),
37
+ intent
38
+ )
39
+ }
40
+
41
+ override fun onHandleWork(intent: Intent) {
42
+ val extras = intent.extras ?: return
43
+ val payload = extras.getString("payload") ?: return
44
+ try {
45
+ val bandyerPayload = JSONObject(payload).get("payload").toString()
46
+ val bandyerToken = JSONObject(payload).getString("user_token")
47
+
48
+ val scope = CoroutineScope(Executors.newSingleThreadExecutor().asCoroutineDispatcher())
49
+ val plugin = VideoSDKHybridBridge(
50
+ contextContainer = ServiceContextContainer(),
51
+ tokenProvider = SingleTokenProvider(bandyerToken),
52
+ backgroundScope = scope,
53
+ eventsReporter = NoOpEventsReporter(),
54
+ eventsEmitter = NoOpEventsEmitter(),
55
+ )
56
+ scope.launch {
57
+ val savedConfiguration = plugin.lastConfiguration!!
58
+ val savedUsed = plugin.lastConnectedUserId!!
59
+ plugin.addUsersDetails(plugin.cachedUserDetails.toTypedArray())
60
+ plugin.configureBridge(savedConfiguration)
61
+ plugin.connect(savedUsed)
62
+ plugin.handlePushNotificationPayload(bandyerPayload)
63
+ }
64
+ } catch (exception: Throwable) {
65
+ Log.e("BandyerNotService", "" + exception.message)
66
+ }
67
+ }
68
+
69
+ private inner class ServiceContextContainer : ContextContainer {
70
+ override val context: Context = applicationContext
71
+ }
72
+
73
+ private class SingleTokenProvider(private val token: String) : CrossPlatformAccessTokenProvider {
74
+ override fun provideAccessToken(userId: String, completion: (Result<String>) -> Unit) = completion(Result.success(token))
75
+ }
76
+
77
+ private class NoOpEventsEmitter : EventsEmitter {
78
+ override fun sendEvent(event: Events, args: Any?) = Unit
79
+ }
80
+
81
+ private class NoOpEventsReporter : EventsReporter {
82
+ override fun start() = Unit
83
+ override fun stop() = Unit
84
+ }
85
+ }
@@ -0,0 +1,27 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.repository
5
+
6
+ import androidx.room.Dao
7
+ import androidx.room.Entity
8
+ import androidx.room.Insert
9
+ import androidx.room.OnConflictStrategy
10
+ import androidx.room.PrimaryKey
11
+ import androidx.room.Query
12
+ import com.kaleyra.video_hybrid_native_bridge.KaleyraVideoConfiguration
13
+
14
+ @Entity
15
+ data class ConfigurationEntity(
16
+ val plugin: KaleyraVideoConfiguration,
17
+ @PrimaryKey
18
+ val id: Int = 1,
19
+ )
20
+ @Dao
21
+ interface ConfigurationDao {
22
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
23
+ fun insert(configurationEntity: ConfigurationEntity)
24
+
25
+ @get:Query("SELECT * FROM configurationentity LIMIT 1")
26
+ val configuration: ConfigurationEntity?
27
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.repository
5
+
6
+ import androidx.room.Dao
7
+ import androidx.room.Entity
8
+ import androidx.room.Insert
9
+ import androidx.room.OnConflictStrategy
10
+ import androidx.room.PrimaryKey
11
+ import androidx.room.Query
12
+
13
+ @Entity
14
+ data class ConnectedUserEntity(
15
+ @PrimaryKey
16
+ val user: String
17
+ )
18
+
19
+ @Dao
20
+ interface ConnectedUserDao {
21
+
22
+ @get:Query("SELECT * FROM connecteduserentity LIMIT 1")
23
+ val user: ConnectedUserEntity?
24
+
25
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
26
+ fun insert(connectedUserEntity: ConnectedUserEntity)
27
+
28
+ @Query("DELETE FROM connecteduserentity")
29
+ fun clear()
30
+ }
@@ -0,0 +1,25 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.repository
5
+
6
+ import androidx.room.TypeConverter
7
+ import com.kaleyra.video_hybrid_native_bridge.KaleyraVideoConfiguration
8
+ import com.google.gson.Gson
9
+
10
+ internal class Converters {
11
+
12
+ private val gson by lazy { Gson() }
13
+
14
+ @TypeConverter
15
+ fun fromString(value: String?): KaleyraVideoConfiguration? {
16
+ value ?: return null
17
+ return gson.fromJson(value, KaleyraVideoConfiguration::class.java)
18
+ }
19
+
20
+ @TypeConverter
21
+ fun toString(config: KaleyraVideoConfiguration?): String? {
22
+ config ?: return null
23
+ return gson.toJson(config)
24
+ }
25
+ }
@@ -0,0 +1,21 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.repository
5
+
6
+ import androidx.room.*
7
+
8
+ @Dao
9
+ interface UserDetailsDao {
10
+ @get:Query("SELECT * FROM userdetailsentity")
11
+ val all: List<UserDetailsEntity>
12
+
13
+ @Query("SELECT * FROM userdetailsentity WHERE userAlias = :userAlias LIMIT 1")
14
+ fun getUserDetailsEntity(userAlias: String): UserDetailsEntity?
15
+
16
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
17
+ fun insert(userDetailsEntities: List<UserDetailsEntity>)
18
+
19
+ @Query("DELETE FROM userdetailsentity")
20
+ fun clear()
21
+ }
@@ -0,0 +1,22 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.repository
5
+
6
+ import androidx.room.Entity
7
+ import androidx.room.PrimaryKey
8
+
9
+
10
+ /**
11
+ * @suppress
12
+ * @author kristiyan
13
+ */
14
+ @Entity
15
+ data class UserDetailsEntity(
16
+ @PrimaryKey val userAlias: String,
17
+ var firstName: String? = null,
18
+ var lastName: String? = null,
19
+ var nickName: String? = null,
20
+ var email: String? = null,
21
+ var imageUrl: String? = null
22
+ )
@@ -0,0 +1,39 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.repository
5
+
6
+ import android.content.Context
7
+ import androidx.room.Database
8
+ import androidx.room.Room
9
+ import androidx.room.RoomDatabase
10
+ import androidx.room.TypeConverters
11
+
12
+
13
+ /**
14
+ *
15
+ * @author kristiyan
16
+ */
17
+ @Database(entities = [UserDetailsEntity::class, ConfigurationEntity::class, ConnectedUserEntity::class], version = 2, exportSchema = false)
18
+ @TypeConverters(Converters::class)
19
+ abstract class VideoHybridBridgeRepository : RoomDatabase() {
20
+
21
+ companion object {
22
+
23
+ private var instance: VideoHybridBridgeRepository? = null
24
+
25
+ fun getInstance(context: Context): VideoHybridBridgeRepository = synchronized(VideoHybridBridgeRepository::class) {
26
+ return instance ?: Room.databaseBuilder(
27
+ context.applicationContext,
28
+ VideoHybridBridgeRepository::class.java, "kaleyra_video_hybrid_bridge_repository.db"
29
+ )
30
+ .fallbackToDestructiveMigration()
31
+ .build()
32
+ .apply { instance = this }
33
+ }
34
+ }
35
+
36
+ abstract fun userDao(): UserDetailsDao
37
+ abstract fun configurationDao(): ConfigurationDao
38
+ abstract fun connectedUserDao(): ConnectedUserDao
39
+ }
@@ -0,0 +1,49 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.ui
5
+
6
+ import com.bandyer.android_sdk.client.BandyerSDKInstance
7
+ import com.bandyer.android_sdk.intent.BandyerIntent
8
+ import com.kaleyra.video_hybrid_native_bridge.CallDisplayMode
9
+ import com.kaleyra.video_hybrid_native_bridge.CallType.Audio
10
+ import com.kaleyra.video_hybrid_native_bridge.CallType.AudioUpgradable
11
+ import com.kaleyra.video_hybrid_native_bridge.CallType.AudioVideo
12
+ import com.kaleyra.video_hybrid_native_bridge.ContextContainer
13
+ import com.kaleyra.video_hybrid_native_bridge.CreateCallOptions
14
+ import com.kaleyra.video_hybrid_native_bridge.extensions.toSDK
15
+
16
+ internal class SDKUserInterfacePresenter(
17
+ private val sdk: BandyerSDKInstance,
18
+ private val contextContainer: ContextContainer
19
+ ) : UserInterfacePresenter {
20
+
21
+ private val context
22
+ get() = contextContainer.context
23
+
24
+ override fun startCall(callOptions: CreateCallOptions) {
25
+ val bandyerCallIntent = BandyerIntent.Builder().let {
26
+ when (callOptions.callType) {
27
+ Audio -> it.startWithAudioCall(context)
28
+ AudioUpgradable -> it.startWithAudioUpgradableCall(context)
29
+ AudioVideo -> it.startWithAudioVideoCall(context)
30
+ }.with(ArrayList(callOptions.callees)).build()
31
+ }
32
+ context.startActivity(bandyerCallIntent)
33
+ }
34
+
35
+ override fun startCallUrl(url: String) {
36
+ val bandyerCallIntent = BandyerIntent.Builder().startFromJoinCallUrl(context, url).build()
37
+ context.startActivity(bandyerCallIntent)
38
+ }
39
+
40
+ override fun startChat(userId: String) {
41
+ val bandyerCallIntent = BandyerIntent.Builder().startWithChat(context).with(userId).build()
42
+ context.startActivity(bandyerCallIntent)
43
+ }
44
+
45
+ override fun setDisplayModeForCurrentCall(mode: CallDisplayMode) {
46
+ val ongoingCall = sdk.callModule?.ongoingCall ?: return
47
+ sdk.callModule?.setDisplayMode(ongoingCall, mode.toSDK())
48
+ }
49
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.ui
5
+
6
+ import com.kaleyra.video_hybrid_native_bridge.CallDisplayMode
7
+ import com.kaleyra.video_hybrid_native_bridge.CreateCallOptions
8
+
9
+ interface UserInterfacePresenter {
10
+ fun startCall(callOptions: CreateCallOptions)
11
+ fun startCallUrl(url: String)
12
+ fun startChat(userId: String)
13
+ fun setDisplayModeForCurrentCall(mode: CallDisplayMode)
14
+ }
@@ -0,0 +1,18 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.user_details
5
+
6
+ import com.kaleyra.video_hybrid_native_bridge.UserDetails
7
+ import com.kaleyra.video_hybrid_native_bridge.UserDetailsFormat
8
+
9
+ interface CachedUserDetails {
10
+
11
+ val cachedUserDetails: androidx.collection.ArraySet<UserDetails>
12
+
13
+ fun setUserDetailsFormat(format: UserDetailsFormat)
14
+
15
+ fun addUsersDetails(userDetails: Array<UserDetails>)
16
+
17
+ fun removeUserDetails()
18
+ }
@@ -0,0 +1,59 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.user_details
5
+
6
+ import android.annotation.SuppressLint
7
+ import android.content.Context
8
+ import com.bandyer.android_sdk.notification.FormatContext
9
+ import com.bandyer.android_sdk.utils.provider.UserDetails
10
+ import com.bandyer.android_sdk.utils.provider.UserDetailsFormatter
11
+ import com.kaleyra.video_hybrid_native_bridge.UserDetailsFormat
12
+ import com.google.gson.Gson
13
+ import java.util.regex.Pattern
14
+ import kotlin.reflect.full.declaredMemberProperties
15
+
16
+ internal class CachedUserDetailsFormatter private constructor() : UserDetailsFormatter {
17
+
18
+ private lateinit var context: Context
19
+ private lateinit var userDetailsFormat: UserDetailsFormat
20
+
21
+ private val preferences by lazy { context.getSharedPreferences(KALEYRA_VIDEO_CACHED_USER_DETAILS_FORMATTER_PREFS, Context.MODE_PRIVATE) }
22
+ private val gson by lazy { Gson() }
23
+
24
+ constructor(context: Context) : this() {
25
+ this.context = context
26
+ userDetailsFormat = gson.fromJson(preferences.getString(KALEYRA_VIDEO_CACHED_USER_DETAILS_FORMAT, ""), UserDetailsFormat::class.java)
27
+ }
28
+
29
+ @SuppressLint("ApplySharedPref")
30
+ constructor(context: Context, userDetailsFormat: UserDetailsFormat) : this() {
31
+ this.context = context
32
+ this.userDetailsFormat = userDetailsFormat
33
+ preferences.edit().putString(KALEYRA_VIDEO_CACHED_USER_DETAILS_FORMAT, gson.toJson(userDetailsFormat)).commit()
34
+ }
35
+
36
+ override fun format(userDetails: UserDetails, context: FormatContext): String = with(userDetails) {
37
+ if (context.isNotification) userDetailsFormat.androidNotification?.let { formatBy(it) } ?: formatBy(userDetailsFormat.default)
38
+ else formatBy(userDetailsFormat.default)
39
+ }
40
+
41
+ private fun UserDetails.formatBy(textToFormat: String): String {
42
+ var output = textToFormat
43
+ val regex = "(?<=\\$\\{)(.*?)(?=\\})";
44
+ val p = Pattern.compile(regex);
45
+ val m = p.matcher(textToFormat);
46
+ while (m.find()) {
47
+ val keyword = m.group()
48
+ val value = UserDetails::class::declaredMemberProperties.get().firstOrNull { it.name == keyword }
49
+ output = output.replace("\${$keyword}", value?.call(this)?.toString() ?: "\${$keyword}")
50
+ }
51
+ return output
52
+ }
53
+
54
+ companion object {
55
+ private const val KALEYRA_VIDEO_CACHED_USER_DETAILS_FORMATTER_PREFS = "KALEYRA_VIDEO_CACHED_USER_DETAILS_FORMATTER_PREFS"
56
+ private const val KALEYRA_VIDEO_CACHED_USER_DETAILS_FORMAT = "KALEYRA_VIDEO_CACHED_USER_DETAILS_FORMAT"
57
+ }
58
+
59
+ }
@@ -0,0 +1,74 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.user_details
5
+
6
+ import com.bandyer.android_sdk.client.BandyerSDKInstance
7
+ import com.bandyer.android_sdk.client.Completion
8
+ import com.bandyer.android_sdk.utils.provider.UserDetailsProvider
9
+ import com.kaleyra.video_hybrid_native_bridge.ContextContainer
10
+ import com.kaleyra.video_hybrid_native_bridge.UserDetails
11
+ import com.kaleyra.video_hybrid_native_bridge.UserDetailsFormat
12
+ import com.kaleyra.video_hybrid_native_bridge.extensions.toSDK
13
+ import com.kaleyra.video_hybrid_native_bridge.extensions.toUserDetails
14
+ import com.kaleyra.video_hybrid_native_bridge.extensions.toUserDetailsEntity
15
+ import com.kaleyra.video_hybrid_native_bridge.repository.VideoHybridBridgeRepository
16
+ import kotlinx.coroutines.CoroutineScope
17
+ import kotlinx.coroutines.launch
18
+ import kotlin.collections.forEach
19
+
20
+ internal class SDKCachedUserDetails(
21
+ private val sdk: BandyerSDKInstance,
22
+ private val contextContainer: ContextContainer,
23
+ private val repository: VideoHybridBridgeRepository,
24
+ private val coroutineScope: CoroutineScope
25
+ ) : CachedUserDetails {
26
+ override fun setUserDetailsFormat(format: UserDetailsFormat) = sdk.setUserDetailsFormatter(CachedUserDetailsFormatter(contextContainer.context.applicationContext, format))
27
+
28
+ override val cachedUserDetails = androidx.collection.ArraySet<UserDetails>()
29
+ override fun addUsersDetails(userDetails: Array<UserDetails>) {
30
+ coroutineScope.launch {
31
+ val usersDao = userDetails.filter { it.userID.isNotBlank() }.map {
32
+ com.bandyer.android_sdk.utils.provider.UserDetails.Builder(it.userID).build().copy(
33
+ nickName = it.nickName,
34
+ firstName = it.firstName,
35
+ lastName = it.lastName,
36
+ email = it.email,
37
+ imageUrl = it.profileImageURL
38
+ ).toUserDetailsEntity()
39
+ }
40
+ if (usersDao.isEmpty()) return@launch
41
+ repository.userDao().insert(usersDao)
42
+ cachedUserDetails.addAll(userDetails)
43
+ }
44
+ setDetailsProvider()
45
+ }
46
+
47
+ private fun setDetailsProvider() {
48
+ sdk.setUserDetailsProvider(object : UserDetailsProvider {
49
+ override fun onUserDetailsRequested(userAliases: List<String>, completion: Completion<Iterable<com.bandyer.android_sdk.utils.provider.UserDetails>>) {
50
+ coroutineScope.launch {
51
+ val details = userAliases.map { userAlias ->
52
+ repository.userDao().getUserDetailsEntity(userAlias)?.toSDK() ?: com.bandyer.android_sdk.utils.provider.UserDetails.Builder(userAlias).build()
53
+ }
54
+ completion.success(details)
55
+ }
56
+ }
57
+ })
58
+ }
59
+
60
+ override fun removeUserDetails() {
61
+ coroutineScope.launch {
62
+ repository.userDao().clear()
63
+ cachedUserDetails.clear()
64
+ }
65
+ }
66
+
67
+ init {
68
+ coroutineScope.launch {
69
+ repository.userDao().all.forEach {
70
+ cachedUserDetails.add(it.toUserDetails())
71
+ }
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,48 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.utils
5
+
6
+ import com.google.gson.Gson
7
+ import com.google.gson.TypeAdapter
8
+ import com.google.gson.TypeAdapterFactory
9
+ import com.google.gson.reflect.TypeToken
10
+ import com.google.gson.stream.JsonReader
11
+ import com.google.gson.stream.JsonToken.NULL
12
+ import com.google.gson.stream.JsonWriter
13
+ import java.io.IOException
14
+
15
+ class CaseInsensitiveEnumTypeAdapterFactory : TypeAdapterFactory {
16
+ override fun <T> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
17
+ val rawType = type.rawType as Class<T>
18
+ if (!rawType.isEnum) {
19
+ return null
20
+ }
21
+ val lowercaseToConstant: MutableMap<String, T> = HashMap()
22
+ for (constant in rawType.enumConstants) lowercaseToConstant[toLowercase(constant!!)] = constant
23
+ return object : TypeAdapter<T>() {
24
+ @Throws(IOException::class)
25
+ override fun write(out: JsonWriter, value: T?) {
26
+ if (value == null) {
27
+ out.nullValue()
28
+ } else {
29
+ out.value(value.toString())
30
+ }
31
+ }
32
+
33
+ @Throws(IOException::class)
34
+ override fun read(reader: JsonReader): T? {
35
+ return if (reader.peek() == NULL) {
36
+ reader.nextNull()
37
+ null
38
+ } else {
39
+ lowercaseToConstant[toLowercase(reader.nextString())]
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ private fun toLowercase(o: Any): String {
46
+ return o.toString().lowercase()
47
+ }
48
+ }
@@ -0,0 +1,76 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.utils
5
+
6
+ import java.io.IOException
7
+ import java.net.InetAddress
8
+ import java.net.Socket
9
+ import java.net.UnknownHostException
10
+ import java.security.SecureRandom
11
+ import java.util.*
12
+ import javax.net.ssl.SSLContext
13
+ import javax.net.ssl.SSLSocket
14
+ import javax.net.ssl.SSLSocketFactory
15
+ import javax.net.ssl.TrustManager
16
+
17
+ internal class TLSSocketFactoryCompat : SSLSocketFactory {
18
+
19
+ private var internalSSLSocketFactory: SSLSocketFactory
20
+
21
+ constructor() {
22
+ val context = SSLContext.getInstance("TLS")
23
+ context.init(null, null, null)
24
+ internalSSLSocketFactory = context.socketFactory
25
+ }
26
+
27
+ constructor(tm: Array<TrustManager?>?) {
28
+ val context = SSLContext.getInstance("TLS")
29
+ context.init(null, tm, SecureRandom())
30
+ internalSSLSocketFactory = context.socketFactory
31
+ }
32
+
33
+ override fun getDefaultCipherSuites(): Array<String> = internalSSLSocketFactory.defaultCipherSuites
34
+
35
+ override fun getSupportedCipherSuites(): Array<String> = internalSSLSocketFactory.supportedCipherSuites
36
+
37
+ @Throws(IOException::class)
38
+ override fun createSocket(): Socket? = enableTLSOnSocket(internalSSLSocketFactory.createSocket())
39
+
40
+ @Throws(IOException::class)
41
+ override fun createSocket(s: Socket, host: String, port: Int, autoClose: Boolean): Socket? = enableTLSOnSocket(internalSSLSocketFactory.createSocket(s, host, port, autoClose))
42
+
43
+ @Throws(IOException::class, UnknownHostException::class)
44
+ override fun createSocket(host: String, port: Int): Socket? =
45
+ enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port))
46
+
47
+ @Throws(IOException::class, UnknownHostException::class)
48
+ override fun createSocket(host: String, port: Int, localHost: InetAddress, localPort: Int): Socket? =
49
+ enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port, localHost, localPort))
50
+
51
+ @Throws(IOException::class)
52
+ override fun createSocket(host: InetAddress, port: Int): Socket? =
53
+ enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port))
54
+
55
+ @Throws(IOException::class)
56
+ override fun createSocket(address: InetAddress, port: Int, localAddress: InetAddress, localPort: Int): Socket? =
57
+ enableTLSOnSocket(internalSSLSocketFactory.createSocket(address, port, localAddress, localPort))
58
+
59
+ private fun enableTLSOnSocket(socket: Socket?): Socket? {
60
+ if (socket !is SSLSocket) return null
61
+ //Create list of supported protocols
62
+ val supportedProtocols = ArrayList<String>()
63
+ for (protocol in socket.enabledProtocols) {
64
+ //Only add TLS protocols (don't want ot support older SSL versions)
65
+ if (protocol.toUpperCase().contains("TLS")) supportedProtocols.add(protocol)
66
+ }
67
+ //Force add TLSv1.1 and 1.2 if not already added
68
+ if (!supportedProtocols.contains("TLSv1.1")) supportedProtocols.add("TLSv1.1")
69
+ if (!supportedProtocols.contains("TLSv1.2")) supportedProtocols.add("TLSv1.2")
70
+ val protocolArray = supportedProtocols.toTypedArray()
71
+
72
+ //enable protocols in our list
73
+ socket.enabledProtocols = protocolArray
74
+ return socket
75
+ }
76
+ }