electron-cast 0.4.0 → 0.5.0-next.1

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 (626) hide show
  1. package/CHANGELOG.md +280 -0
  2. package/CONTRIBUTING.md +305 -0
  3. package/README.md +211 -165
  4. package/SECURITY.md +324 -0
  5. package/dist/cjs/client/auth/build-time.js +1 -1
  6. package/dist/cjs/client/auth/cast-auth.d.ts +2 -0
  7. package/dist/cjs/client/auth/cast-auth.js.map +1 -1
  8. package/dist/cjs/dial/dial-registry.d.ts +104 -0
  9. package/dist/cjs/dial/dial-registry.js +301 -0
  10. package/dist/cjs/dial/dial-registry.js.map +1 -0
  11. package/dist/cjs/dial/dial-sink-service.d.ts +108 -0
  12. package/dist/cjs/dial/dial-sink-service.js +314 -0
  13. package/dist/cjs/dial/dial-sink-service.js.map +1 -0
  14. package/dist/cjs/dial/http.d.ts +40 -0
  15. package/dist/cjs/dial/http.js +172 -0
  16. package/dist/cjs/dial/http.js.map +1 -0
  17. package/dist/cjs/dial/index.d.ts +63 -0
  18. package/dist/cjs/dial/index.js +134 -0
  19. package/dist/cjs/dial/index.js.map +1 -0
  20. package/dist/cjs/dial/origins.d.ts +4 -0
  21. package/dist/cjs/dial/origins.js +36 -0
  22. package/dist/cjs/dial/origins.js.map +1 -0
  23. package/dist/cjs/dial/parse.d.ts +101 -0
  24. package/dist/cjs/dial/parse.js +296 -0
  25. package/dist/cjs/dial/parse.js.map +1 -0
  26. package/dist/cjs/dial/route-provider.d.ts +96 -0
  27. package/dist/cjs/dial/route-provider.js +376 -0
  28. package/dist/cjs/dial/route-provider.js.map +1 -0
  29. package/dist/cjs/dial/ssdp-socket.d.ts +34 -0
  30. package/dist/cjs/dial/ssdp-socket.js +72 -0
  31. package/dist/cjs/dial/ssdp-socket.js.map +1 -0
  32. package/dist/cjs/dial/xml.d.ts +13 -0
  33. package/dist/cjs/dial/xml.js +208 -0
  34. package/dist/cjs/dial/xml.js.map +1 -0
  35. package/dist/cjs/discovery/cast-discovery.d.ts +2 -0
  36. package/dist/cjs/discovery/cast-discovery.js.map +1 -1
  37. package/dist/cjs/discovery/device-cache.d.ts +9 -0
  38. package/dist/cjs/discovery/device-cache.js.map +1 -1
  39. package/dist/cjs/discovery/index.d.ts +1 -0
  40. package/dist/cjs/discovery/index.js +1 -0
  41. package/dist/cjs/discovery/index.js.map +1 -1
  42. package/dist/cjs/discovery/ip-policy.d.ts +20 -0
  43. package/dist/cjs/discovery/ip-policy.js +109 -0
  44. package/dist/cjs/discovery/ip-policy.js.map +1 -0
  45. package/dist/cjs/discovery/udp-socket.d.ts +3 -0
  46. package/dist/cjs/discovery/udp-socket.js +3 -0
  47. package/dist/cjs/discovery/udp-socket.js.map +1 -1
  48. package/dist/cjs/electron/access-code.d.ts +221 -0
  49. package/dist/cjs/electron/access-code.js +586 -0
  50. package/dist/cjs/electron/access-code.js.map +1 -0
  51. package/dist/cjs/electron/app-discovery.d.ts +82 -0
  52. package/dist/cjs/electron/app-discovery.js +219 -0
  53. package/dist/cjs/electron/app-discovery.js.map +1 -0
  54. package/dist/cjs/electron/default-presentation.d.ts +38 -0
  55. package/dist/cjs/electron/default-presentation.js +88 -0
  56. package/dist/cjs/electron/default-presentation.js.map +1 -0
  57. package/dist/cjs/electron/main.d.ts +98 -11
  58. package/dist/cjs/electron/main.js +602 -20
  59. package/dist/cjs/electron/main.js.map +1 -1
  60. package/dist/cjs/electron/manager-api.d.ts +200 -18
  61. package/dist/cjs/electron/manager-api.js +199 -4
  62. package/dist/cjs/electron/manager-api.js.map +1 -1
  63. package/dist/cjs/electron/media-controller.d.ts +79 -0
  64. package/dist/cjs/electron/media-controller.js +251 -0
  65. package/dist/cjs/electron/media-controller.js.map +1 -0
  66. package/dist/cjs/electron/network-monitor.d.ts +61 -0
  67. package/dist/cjs/electron/network-monitor.js +124 -0
  68. package/dist/cjs/electron/network-monitor.js.map +1 -0
  69. package/dist/cjs/electron/preload.js.map +1 -1
  70. package/dist/cjs/electron/presentation-handler.d.ts +39 -4
  71. package/dist/cjs/electron/presentation-handler.js +191 -47
  72. package/dist/cjs/electron/presentation-handler.js.map +1 -1
  73. package/dist/cjs/electron/presentation-source.d.ts +76 -0
  74. package/dist/cjs/electron/presentation-source.js +132 -0
  75. package/dist/cjs/electron/presentation-source.js.map +1 -0
  76. package/dist/cjs/electron/session-service.d.ts +198 -24
  77. package/dist/cjs/electron/session-service.js +630 -248
  78. package/dist/cjs/electron/session-service.js.map +1 -1
  79. package/dist/cjs/electron/session-tracker.d.ts +82 -0
  80. package/dist/cjs/electron/session-tracker.js +225 -0
  81. package/dist/cjs/electron/session-tracker.js.map +1 -0
  82. package/dist/cjs/electron/sink-service.d.ts +246 -0
  83. package/dist/cjs/electron/sink-service.js +606 -0
  84. package/dist/cjs/electron/sink-service.js.map +1 -0
  85. package/dist/cjs/electron/wired-display/controller.d.ts +76 -0
  86. package/dist/cjs/electron/wired-display/controller.js +198 -0
  87. package/dist/cjs/electron/wired-display/controller.js.map +1 -0
  88. package/dist/cjs/electron/wired-display/displays.d.ts +44 -0
  89. package/dist/cjs/electron/wired-display/displays.js +98 -0
  90. package/dist/cjs/electron/wired-display/displays.js.map +1 -0
  91. package/dist/cjs/electron/wired-display/electron-windows.d.ts +111 -0
  92. package/dist/cjs/electron/wired-display/electron-windows.js +306 -0
  93. package/dist/cjs/electron/wired-display/electron-windows.js.map +1 -0
  94. package/dist/cjs/electron/wired-display/index.d.ts +90 -0
  95. package/dist/cjs/electron/wired-display/index.js +115 -0
  96. package/dist/cjs/electron/wired-display/index.js.map +1 -0
  97. package/dist/cjs/electron/wired-display/local-presentation.d.ts +98 -0
  98. package/dist/cjs/electron/wired-display/local-presentation.js +234 -0
  99. package/dist/cjs/electron/wired-display/local-presentation.js.map +1 -0
  100. package/dist/cjs/electron/wired-display/provider.d.ts +112 -0
  101. package/dist/cjs/electron/wired-display/provider.js +202 -0
  102. package/dist/cjs/electron/wired-display/provider.js.map +1 -0
  103. package/dist/cjs/index.d.ts +1 -0
  104. package/dist/cjs/index.js +1 -0
  105. package/dist/cjs/index.js.map +1 -1
  106. package/dist/cjs/mirroring/backend.d.ts +76 -0
  107. package/dist/cjs/mirroring/backend.js +21 -0
  108. package/dist/cjs/mirroring/backend.js.map +1 -0
  109. package/dist/cjs/mirroring/electron/agent-protocol.d.ts +158 -0
  110. package/dist/cjs/mirroring/electron/agent-protocol.js +11 -0
  111. package/dist/cjs/mirroring/electron/agent-protocol.js.map +1 -0
  112. package/dist/cjs/mirroring/electron/agent-source.d.ts +20 -0
  113. package/dist/cjs/mirroring/electron/agent-source.js +621 -0
  114. package/dist/cjs/mirroring/electron/agent-source.js.map +1 -0
  115. package/dist/cjs/mirroring/electron/engine-process.d.ts +87 -0
  116. package/dist/cjs/mirroring/electron/engine-process.js +81 -0
  117. package/dist/cjs/mirroring/electron/engine-process.js.map +1 -0
  118. package/dist/cjs/mirroring/electron/host.d.ts +89 -0
  119. package/dist/cjs/mirroring/electron/host.js +321 -0
  120. package/dist/cjs/mirroring/electron/host.js.map +1 -0
  121. package/dist/cjs/mirroring/electron/port-backend.d.ts +107 -0
  122. package/dist/cjs/mirroring/electron/port-backend.js +446 -0
  123. package/dist/cjs/mirroring/electron/port-backend.js.map +1 -0
  124. package/dist/cjs/mirroring/encoding-support.d.ts +66 -0
  125. package/dist/cjs/mirroring/encoding-support.js +89 -0
  126. package/dist/cjs/mirroring/encoding-support.js.map +1 -0
  127. package/dist/cjs/mirroring/engine.d.ts +16 -0
  128. package/dist/cjs/mirroring/engine.js +78 -0
  129. package/dist/cjs/mirroring/engine.js.map +1 -0
  130. package/dist/cjs/mirroring/mirror-settings.d.ts +101 -0
  131. package/dist/cjs/mirroring/mirror-settings.js +140 -0
  132. package/dist/cjs/mirroring/mirror-settings.js.map +1 -0
  133. package/dist/cjs/mirroring/mirroring-activity.d.ts +207 -0
  134. package/dist/cjs/mirroring/mirroring-activity.js +367 -0
  135. package/dist/cjs/mirroring/mirroring-activity.js.map +1 -0
  136. package/dist/cjs/mirroring/mirroring-manager.d.ts +134 -0
  137. package/dist/cjs/mirroring/mirroring-manager.js +286 -0
  138. package/dist/cjs/mirroring/mirroring-manager.js.map +1 -0
  139. package/dist/cjs/mirroring/protocol/answer.d.ts +87 -0
  140. package/dist/cjs/mirroring/protocol/answer.js +233 -0
  141. package/dist/cjs/mirroring/protocol/answer.js.map +1 -0
  142. package/dist/cjs/mirroring/protocol/constants.d.ts +64 -0
  143. package/dist/cjs/mirroring/protocol/constants.js +70 -0
  144. package/dist/cjs/mirroring/protocol/constants.js.map +1 -0
  145. package/dist/cjs/mirroring/protocol/errors.d.ts +25 -0
  146. package/dist/cjs/mirroring/protocol/errors.js +34 -0
  147. package/dist/cjs/mirroring/protocol/errors.js.map +1 -0
  148. package/dist/cjs/mirroring/protocol/frame-id.d.ts +9 -0
  149. package/dist/cjs/mirroring/protocol/frame-id.js +24 -0
  150. package/dist/cjs/mirroring/protocol/frame-id.js.map +1 -0
  151. package/dist/cjs/mirroring/protocol/messenger.d.ts +42 -0
  152. package/dist/cjs/mirroring/protocol/messenger.js +122 -0
  153. package/dist/cjs/mirroring/protocol/messenger.js.map +1 -0
  154. package/dist/cjs/mirroring/protocol/offer.d.ts +109 -0
  155. package/dist/cjs/mirroring/protocol/offer.js +192 -0
  156. package/dist/cjs/mirroring/protocol/offer.js.map +1 -0
  157. package/dist/cjs/mirroring/protocol/recommendations.d.ts +28 -0
  158. package/dist/cjs/mirroring/protocol/recommendations.js +103 -0
  159. package/dist/cjs/mirroring/protocol/recommendations.js.map +1 -0
  160. package/dist/cjs/mirroring/routing.d.ts +60 -0
  161. package/dist/cjs/mirroring/routing.js +147 -0
  162. package/dist/cjs/mirroring/routing.js.map +1 -0
  163. package/dist/cjs/mirroring/rtcp/ntp.d.ts +27 -0
  164. package/dist/cjs/mirroring/rtcp/ntp.js +62 -0
  165. package/dist/cjs/mirroring/rtcp/ntp.js.map +1 -0
  166. package/dist/cjs/mirroring/rtcp/parser.d.ts +50 -0
  167. package/dist/cjs/mirroring/rtcp/parser.js +270 -0
  168. package/dist/cjs/mirroring/rtcp/parser.js.map +1 -0
  169. package/dist/cjs/mirroring/rtcp/sender-report.d.ts +32 -0
  170. package/dist/cjs/mirroring/rtcp/sender-report.js +56 -0
  171. package/dist/cjs/mirroring/rtcp/sender-report.js.map +1 -0
  172. package/dist/cjs/mirroring/rtcp/wire.d.ts +54 -0
  173. package/dist/cjs/mirroring/rtcp/wire.js +73 -0
  174. package/dist/cjs/mirroring/rtcp/wire.js.map +1 -0
  175. package/dist/cjs/mirroring/rtp/frame-crypto.d.ts +11 -0
  176. package/dist/cjs/mirroring/rtp/frame-crypto.js +39 -0
  177. package/dist/cjs/mirroring/rtp/frame-crypto.js.map +1 -0
  178. package/dist/cjs/mirroring/rtp/frame.d.ts +23 -0
  179. package/dist/cjs/mirroring/rtp/frame.js +3 -0
  180. package/dist/cjs/mirroring/rtp/frame.js.map +1 -0
  181. package/dist/cjs/mirroring/rtp/packetizer.d.ts +27 -0
  182. package/dist/cjs/mirroring/rtp/packetizer.js +92 -0
  183. package/dist/cjs/mirroring/rtp/packetizer.js.map +1 -0
  184. package/dist/cjs/mirroring/sender/audio-sender.d.ts +23 -0
  185. package/dist/cjs/mirroring/sender/audio-sender.js +52 -0
  186. package/dist/cjs/mirroring/sender/audio-sender.js.map +1 -0
  187. package/dist/cjs/mirroring/sender/bandwidth-estimator.d.ts +26 -0
  188. package/dist/cjs/mirroring/sender/bandwidth-estimator.js +107 -0
  189. package/dist/cjs/mirroring/sender/bandwidth-estimator.js.map +1 -0
  190. package/dist/cjs/mirroring/sender/capture-size-oracle.d.ts +121 -0
  191. package/dist/cjs/mirroring/sender/capture-size-oracle.js +440 -0
  192. package/dist/cjs/mirroring/sender/capture-size-oracle.js.map +1 -0
  193. package/dist/cjs/mirroring/sender/frame-sender.d.ts +103 -0
  194. package/dist/cjs/mirroring/sender/frame-sender.js +217 -0
  195. package/dist/cjs/mirroring/sender/frame-sender.js.map +1 -0
  196. package/dist/cjs/mirroring/sender/packet-router.d.ts +74 -0
  197. package/dist/cjs/mirroring/sender/packet-router.js +196 -0
  198. package/dist/cjs/mirroring/sender/packet-router.js.map +1 -0
  199. package/dist/cjs/mirroring/sender/sender-session.d.ts +85 -0
  200. package/dist/cjs/mirroring/sender/sender-session.js +240 -0
  201. package/dist/cjs/mirroring/sender/sender-session.js.map +1 -0
  202. package/dist/cjs/mirroring/sender/sender.d.ts +120 -0
  203. package/dist/cjs/mirroring/sender/sender.js +457 -0
  204. package/dist/cjs/mirroring/sender/sender.js.map +1 -0
  205. package/dist/cjs/mirroring/sender/video-encoder-metrics.d.ts +29 -0
  206. package/dist/cjs/mirroring/sender/video-encoder-metrics.js +64 -0
  207. package/dist/cjs/mirroring/sender/video-encoder-metrics.js.map +1 -0
  208. package/dist/cjs/mirroring/sender/video-sender.d.ts +95 -0
  209. package/dist/cjs/mirroring/sender/video-sender.js +183 -0
  210. package/dist/cjs/mirroring/sender/video-sender.js.map +1 -0
  211. package/dist/cjs/mirroring/session-host.d.ts +185 -0
  212. package/dist/cjs/mirroring/session-host.js +630 -0
  213. package/dist/cjs/mirroring/session-host.js.map +1 -0
  214. package/dist/cjs/mirroring/stats/clock-offset-estimator.d.ts +11 -0
  215. package/dist/cjs/mirroring/stats/clock-offset-estimator.js +123 -0
  216. package/dist/cjs/mirroring/stats/clock-offset-estimator.js.map +1 -0
  217. package/dist/cjs/mirroring/stats/openscreen-stats-client.d.ts +12 -0
  218. package/dist/cjs/mirroring/stats/openscreen-stats-client.js +21 -0
  219. package/dist/cjs/mirroring/stats/openscreen-stats-client.js.map +1 -0
  220. package/dist/cjs/mirroring/stats/sorted-map.d.ts +23 -0
  221. package/dist/cjs/mirroring/stats/sorted-map.js +70 -0
  222. package/dist/cjs/mirroring/stats/sorted-map.js.map +1 -0
  223. package/dist/cjs/mirroring/stats/statistics-analyzer.d.ts +50 -0
  224. package/dist/cjs/mirroring/stats/statistics-analyzer.js +339 -0
  225. package/dist/cjs/mirroring/stats/statistics-analyzer.js.map +1 -0
  226. package/dist/cjs/mirroring/stats/statistics-collector.d.ts +29 -0
  227. package/dist/cjs/mirroring/stats/statistics-collector.js +53 -0
  228. package/dist/cjs/mirroring/stats/statistics-collector.js.map +1 -0
  229. package/dist/cjs/mirroring/stats/statistics-common.d.ts +61 -0
  230. package/dist/cjs/mirroring/stats/statistics-common.js +45 -0
  231. package/dist/cjs/mirroring/stats/statistics-common.js.map +1 -0
  232. package/dist/cjs/mirroring/stats/statistics-dispatcher.d.ts +28 -0
  233. package/dist/cjs/mirroring/stats/statistics-dispatcher.js +104 -0
  234. package/dist/cjs/mirroring/stats/statistics-dispatcher.js.map +1 -0
  235. package/dist/cjs/mirroring/stats/statistics.d.ts +84 -0
  236. package/dist/cjs/mirroring/stats/statistics.js +147 -0
  237. package/dist/cjs/mirroring/stats/statistics.js.map +1 -0
  238. package/dist/cjs/mirroring/transport/udp-environment.d.ts +40 -0
  239. package/dist/cjs/mirroring/transport/udp-environment.js +97 -0
  240. package/dist/cjs/mirroring/transport/udp-environment.js.map +1 -0
  241. package/dist/cjs/polyfill/bridge-types.d.ts +11 -0
  242. package/dist/cjs/polyfill/presentation-receiver.d.ts +12 -0
  243. package/dist/cjs/polyfill/presentation-receiver.js +369 -0
  244. package/dist/cjs/polyfill/presentation-receiver.js.map +1 -0
  245. package/dist/cjs/polyfill/presentation-standin.js +157 -15
  246. package/dist/cjs/polyfill/presentation-standin.js.map +1 -1
  247. package/dist/cjs/protocol/framing.d.ts +1 -1
  248. package/dist/cjs/protocol/framing.js +1 -1
  249. package/dist/cjs/protocol/framing.js.map +1 -1
  250. package/dist/cli.d.ts +2 -0
  251. package/dist/cli.js +56 -0
  252. package/dist/cli.js.map +1 -0
  253. package/dist/client/auth/build-time.js +1 -1
  254. package/dist/client/auth/cast-auth.d.ts +2 -0
  255. package/dist/client/auth/cast-auth.js.map +1 -1
  256. package/dist/dial/dial-registry.d.ts +104 -0
  257. package/dist/dial/dial-registry.js +297 -0
  258. package/dist/dial/dial-registry.js.map +1 -0
  259. package/dist/dial/dial-sink-service.d.ts +108 -0
  260. package/dist/dial/dial-sink-service.js +310 -0
  261. package/dist/dial/dial-sink-service.js.map +1 -0
  262. package/dist/dial/http.d.ts +40 -0
  263. package/dist/dial/http.js +165 -0
  264. package/dist/dial/http.js.map +1 -0
  265. package/dist/dial/index.d.ts +63 -0
  266. package/dist/dial/index.js +115 -0
  267. package/dist/dial/index.js.map +1 -0
  268. package/dist/dial/origins.d.ts +4 -0
  269. package/dist/dial/origins.js +32 -0
  270. package/dist/dial/origins.js.map +1 -0
  271. package/dist/dial/parse.d.ts +101 -0
  272. package/dist/dial/parse.js +281 -0
  273. package/dist/dial/parse.js.map +1 -0
  274. package/dist/dial/route-provider.d.ts +96 -0
  275. package/dist/dial/route-provider.js +369 -0
  276. package/dist/dial/route-provider.js.map +1 -0
  277. package/dist/dial/ssdp-socket.d.ts +34 -0
  278. package/dist/dial/ssdp-socket.js +65 -0
  279. package/dist/dial/ssdp-socket.js.map +1 -0
  280. package/dist/dial/xml.d.ts +13 -0
  281. package/dist/dial/xml.js +204 -0
  282. package/dist/dial/xml.js.map +1 -0
  283. package/dist/dial-test/cli-main.d.ts +17 -0
  284. package/dist/dial-test/cli-main.js +130 -0
  285. package/dist/dial-test/cli-main.js.map +1 -0
  286. package/dist/dial-test/report.d.ts +55 -0
  287. package/dist/dial-test/report.js +77 -0
  288. package/dist/dial-test/report.js.map +1 -0
  289. package/dist/dial-test/runner.d.ts +42 -0
  290. package/dist/dial-test/runner.js +566 -0
  291. package/dist/dial-test/runner.js.map +1 -0
  292. package/dist/dial-test/scrub.d.ts +14 -0
  293. package/dist/dial-test/scrub.js +73 -0
  294. package/dist/dial-test/scrub.js.map +1 -0
  295. package/dist/discovery/cast-discovery.d.ts +2 -0
  296. package/dist/discovery/cast-discovery.js.map +1 -1
  297. package/dist/discovery/device-cache.d.ts +9 -0
  298. package/dist/discovery/device-cache.js.map +1 -1
  299. package/dist/discovery/index.d.ts +1 -0
  300. package/dist/discovery/index.js +1 -0
  301. package/dist/discovery/index.js.map +1 -1
  302. package/dist/discovery/ip-policy.d.ts +20 -0
  303. package/dist/discovery/ip-policy.js +103 -0
  304. package/dist/discovery/ip-policy.js.map +1 -0
  305. package/dist/discovery/udp-socket.d.ts +3 -0
  306. package/dist/discovery/udp-socket.js +3 -0
  307. package/dist/discovery/udp-socket.js.map +1 -1
  308. package/dist/electron/access-code.d.ts +221 -0
  309. package/dist/electron/access-code.js +577 -0
  310. package/dist/electron/access-code.js.map +1 -0
  311. package/dist/electron/app-discovery.d.ts +82 -0
  312. package/dist/electron/app-discovery.js +215 -0
  313. package/dist/electron/app-discovery.js.map +1 -0
  314. package/dist/electron/default-presentation.d.ts +38 -0
  315. package/dist/electron/default-presentation.js +83 -0
  316. package/dist/electron/default-presentation.js.map +1 -0
  317. package/dist/electron/main.d.ts +98 -11
  318. package/dist/electron/main.js +597 -21
  319. package/dist/electron/main.js.map +1 -1
  320. package/dist/electron/manager-api.d.ts +200 -18
  321. package/dist/electron/manager-api.js +196 -4
  322. package/dist/electron/manager-api.js.map +1 -1
  323. package/dist/electron/media-controller.d.ts +79 -0
  324. package/dist/electron/media-controller.js +248 -0
  325. package/dist/electron/media-controller.js.map +1 -0
  326. package/dist/electron/network-monitor.d.ts +61 -0
  327. package/dist/electron/network-monitor.js +117 -0
  328. package/dist/electron/network-monitor.js.map +1 -0
  329. package/dist/electron/preload.js.map +1 -1
  330. package/dist/electron/presentation-handler.d.ts +39 -4
  331. package/dist/electron/presentation-handler.js +192 -48
  332. package/dist/electron/presentation-handler.js.map +1 -1
  333. package/dist/electron/presentation-source.d.ts +76 -0
  334. package/dist/electron/presentation-source.js +125 -0
  335. package/dist/electron/presentation-source.js.map +1 -0
  336. package/dist/electron/session-service.d.ts +198 -24
  337. package/dist/electron/session-service.js +629 -248
  338. package/dist/electron/session-service.js.map +1 -1
  339. package/dist/electron/session-tracker.d.ts +82 -0
  340. package/dist/electron/session-tracker.js +219 -0
  341. package/dist/electron/session-tracker.js.map +1 -0
  342. package/dist/electron/sink-service.d.ts +246 -0
  343. package/dist/electron/sink-service.js +602 -0
  344. package/dist/electron/sink-service.js.map +1 -0
  345. package/dist/electron/wired-display/controller.d.ts +76 -0
  346. package/dist/electron/wired-display/controller.js +194 -0
  347. package/dist/electron/wired-display/controller.js.map +1 -0
  348. package/dist/electron/wired-display/displays.d.ts +44 -0
  349. package/dist/electron/wired-display/displays.js +91 -0
  350. package/dist/electron/wired-display/displays.js.map +1 -0
  351. package/dist/electron/wired-display/electron-windows.d.ts +111 -0
  352. package/dist/electron/wired-display/electron-windows.js +301 -0
  353. package/dist/electron/wired-display/electron-windows.js.map +1 -0
  354. package/dist/electron/wired-display/index.d.ts +90 -0
  355. package/dist/electron/wired-display/index.js +99 -0
  356. package/dist/electron/wired-display/index.js.map +1 -0
  357. package/dist/electron/wired-display/local-presentation.d.ts +98 -0
  358. package/dist/electron/wired-display/local-presentation.js +228 -0
  359. package/dist/electron/wired-display/local-presentation.js.map +1 -0
  360. package/dist/electron/wired-display/provider.d.ts +112 -0
  361. package/dist/electron/wired-display/provider.js +197 -0
  362. package/dist/electron/wired-display/provider.js.map +1 -0
  363. package/dist/index.d.ts +1 -0
  364. package/dist/index.js +1 -0
  365. package/dist/index.js.map +1 -1
  366. package/dist/mirroring/backend.d.ts +76 -0
  367. package/dist/mirroring/backend.js +18 -0
  368. package/dist/mirroring/backend.js.map +1 -0
  369. package/dist/mirroring/electron/agent-protocol.d.ts +158 -0
  370. package/dist/mirroring/electron/agent-protocol.js +10 -0
  371. package/dist/mirroring/electron/agent-protocol.js.map +1 -0
  372. package/dist/mirroring/electron/agent-source.d.ts +20 -0
  373. package/dist/mirroring/electron/agent-source.js +618 -0
  374. package/dist/mirroring/electron/agent-source.js.map +1 -0
  375. package/dist/mirroring/electron/engine-process.d.ts +87 -0
  376. package/dist/mirroring/electron/engine-process.js +78 -0
  377. package/dist/mirroring/electron/engine-process.js.map +1 -0
  378. package/dist/mirroring/electron/host.d.ts +89 -0
  379. package/dist/mirroring/electron/host.js +318 -0
  380. package/dist/mirroring/electron/host.js.map +1 -0
  381. package/dist/mirroring/electron/port-backend.d.ts +107 -0
  382. package/dist/mirroring/electron/port-backend.js +441 -0
  383. package/dist/mirroring/electron/port-backend.js.map +1 -0
  384. package/dist/mirroring/encoding-support.d.ts +66 -0
  385. package/dist/mirroring/encoding-support.js +81 -0
  386. package/dist/mirroring/encoding-support.js.map +1 -0
  387. package/dist/mirroring/engine.d.ts +16 -0
  388. package/dist/mirroring/engine.js +75 -0
  389. package/dist/mirroring/engine.js.map +1 -0
  390. package/dist/mirroring/mirror-settings.d.ts +101 -0
  391. package/dist/mirroring/mirror-settings.js +134 -0
  392. package/dist/mirroring/mirror-settings.js.map +1 -0
  393. package/dist/mirroring/mirroring-activity.d.ts +207 -0
  394. package/dist/mirroring/mirroring-activity.js +362 -0
  395. package/dist/mirroring/mirroring-activity.js.map +1 -0
  396. package/dist/mirroring/mirroring-manager.d.ts +134 -0
  397. package/dist/mirroring/mirroring-manager.js +281 -0
  398. package/dist/mirroring/mirroring-manager.js.map +1 -0
  399. package/dist/mirroring/protocol/answer.d.ts +87 -0
  400. package/dist/mirroring/protocol/answer.js +226 -0
  401. package/dist/mirroring/protocol/answer.js.map +1 -0
  402. package/dist/mirroring/protocol/constants.d.ts +64 -0
  403. package/dist/mirroring/protocol/constants.js +66 -0
  404. package/dist/mirroring/protocol/constants.js.map +1 -0
  405. package/dist/mirroring/protocol/errors.d.ts +25 -0
  406. package/dist/mirroring/protocol/errors.js +29 -0
  407. package/dist/mirroring/protocol/errors.js.map +1 -0
  408. package/dist/mirroring/protocol/frame-id.d.ts +9 -0
  409. package/dist/mirroring/protocol/frame-id.js +20 -0
  410. package/dist/mirroring/protocol/frame-id.js.map +1 -0
  411. package/dist/mirroring/protocol/messenger.d.ts +42 -0
  412. package/dist/mirroring/protocol/messenger.js +118 -0
  413. package/dist/mirroring/protocol/messenger.js.map +1 -0
  414. package/dist/mirroring/protocol/offer.d.ts +109 -0
  415. package/dist/mirroring/protocol/offer.js +176 -0
  416. package/dist/mirroring/protocol/offer.js.map +1 -0
  417. package/dist/mirroring/protocol/recommendations.d.ts +28 -0
  418. package/dist/mirroring/protocol/recommendations.js +99 -0
  419. package/dist/mirroring/protocol/recommendations.js.map +1 -0
  420. package/dist/mirroring/routing.d.ts +60 -0
  421. package/dist/mirroring/routing.js +130 -0
  422. package/dist/mirroring/routing.js.map +1 -0
  423. package/dist/mirroring/rtcp/ntp.d.ts +27 -0
  424. package/dist/mirroring/rtcp/ntp.js +57 -0
  425. package/dist/mirroring/rtcp/ntp.js.map +1 -0
  426. package/dist/mirroring/rtcp/parser.d.ts +50 -0
  427. package/dist/mirroring/rtcp/parser.js +265 -0
  428. package/dist/mirroring/rtcp/parser.js.map +1 -0
  429. package/dist/mirroring/rtcp/sender-report.d.ts +32 -0
  430. package/dist/mirroring/rtcp/sender-report.js +51 -0
  431. package/dist/mirroring/rtcp/sender-report.js.map +1 -0
  432. package/dist/mirroring/rtcp/wire.d.ts +54 -0
  433. package/dist/mirroring/rtcp/wire.js +68 -0
  434. package/dist/mirroring/rtcp/wire.js.map +1 -0
  435. package/dist/mirroring/rtp/frame-crypto.d.ts +11 -0
  436. package/dist/mirroring/rtp/frame-crypto.js +35 -0
  437. package/dist/mirroring/rtp/frame-crypto.js.map +1 -0
  438. package/dist/mirroring/rtp/frame.d.ts +23 -0
  439. package/dist/mirroring/rtp/frame.js +2 -0
  440. package/dist/mirroring/rtp/frame.js.map +1 -0
  441. package/dist/mirroring/rtp/packetizer.d.ts +27 -0
  442. package/dist/mirroring/rtp/packetizer.js +88 -0
  443. package/dist/mirroring/rtp/packetizer.js.map +1 -0
  444. package/dist/mirroring/sender/audio-sender.d.ts +23 -0
  445. package/dist/mirroring/sender/audio-sender.js +54 -0
  446. package/dist/mirroring/sender/audio-sender.js.map +1 -0
  447. package/dist/mirroring/sender/bandwidth-estimator.d.ts +26 -0
  448. package/dist/mirroring/sender/bandwidth-estimator.js +103 -0
  449. package/dist/mirroring/sender/bandwidth-estimator.js.map +1 -0
  450. package/dist/mirroring/sender/capture-size-oracle.d.ts +121 -0
  451. package/dist/mirroring/sender/capture-size-oracle.js +433 -0
  452. package/dist/mirroring/sender/capture-size-oracle.js.map +1 -0
  453. package/dist/mirroring/sender/frame-sender.d.ts +103 -0
  454. package/dist/mirroring/sender/frame-sender.js +212 -0
  455. package/dist/mirroring/sender/frame-sender.js.map +1 -0
  456. package/dist/mirroring/sender/packet-router.d.ts +74 -0
  457. package/dist/mirroring/sender/packet-router.js +191 -0
  458. package/dist/mirroring/sender/packet-router.js.map +1 -0
  459. package/dist/mirroring/sender/sender-session.d.ts +85 -0
  460. package/dist/mirroring/sender/sender-session.js +235 -0
  461. package/dist/mirroring/sender/sender-session.js.map +1 -0
  462. package/dist/mirroring/sender/sender.d.ts +120 -0
  463. package/dist/mirroring/sender/sender.js +452 -0
  464. package/dist/mirroring/sender/sender.js.map +1 -0
  465. package/dist/mirroring/sender/video-encoder-metrics.d.ts +29 -0
  466. package/dist/mirroring/sender/video-encoder-metrics.js +58 -0
  467. package/dist/mirroring/sender/video-encoder-metrics.js.map +1 -0
  468. package/dist/mirroring/sender/video-sender.d.ts +95 -0
  469. package/dist/mirroring/sender/video-sender.js +190 -0
  470. package/dist/mirroring/sender/video-sender.js.map +1 -0
  471. package/dist/mirroring/session-host.d.ts +185 -0
  472. package/dist/mirroring/session-host.js +625 -0
  473. package/dist/mirroring/session-host.js.map +1 -0
  474. package/dist/mirroring/stats/clock-offset-estimator.d.ts +11 -0
  475. package/dist/mirroring/stats/clock-offset-estimator.js +120 -0
  476. package/dist/mirroring/stats/clock-offset-estimator.js.map +1 -0
  477. package/dist/mirroring/stats/openscreen-stats-client.d.ts +12 -0
  478. package/dist/mirroring/stats/openscreen-stats-client.js +17 -0
  479. package/dist/mirroring/stats/openscreen-stats-client.js.map +1 -0
  480. package/dist/mirroring/stats/sorted-map.d.ts +23 -0
  481. package/dist/mirroring/stats/sorted-map.js +66 -0
  482. package/dist/mirroring/stats/sorted-map.js.map +1 -0
  483. package/dist/mirroring/stats/statistics-analyzer.d.ts +50 -0
  484. package/dist/mirroring/stats/statistics-analyzer.js +335 -0
  485. package/dist/mirroring/stats/statistics-analyzer.js.map +1 -0
  486. package/dist/mirroring/stats/statistics-collector.d.ts +29 -0
  487. package/dist/mirroring/stats/statistics-collector.js +49 -0
  488. package/dist/mirroring/stats/statistics-collector.js.map +1 -0
  489. package/dist/mirroring/stats/statistics-common.d.ts +61 -0
  490. package/dist/mirroring/stats/statistics-common.js +39 -0
  491. package/dist/mirroring/stats/statistics-common.js.map +1 -0
  492. package/dist/mirroring/stats/statistics-dispatcher.d.ts +28 -0
  493. package/dist/mirroring/stats/statistics-dispatcher.js +100 -0
  494. package/dist/mirroring/stats/statistics-dispatcher.js.map +1 -0
  495. package/dist/mirroring/stats/statistics.d.ts +84 -0
  496. package/dist/mirroring/stats/statistics.js +141 -0
  497. package/dist/mirroring/stats/statistics.js.map +1 -0
  498. package/dist/mirroring/transport/udp-environment.d.ts +40 -0
  499. package/dist/mirroring/transport/udp-environment.js +93 -0
  500. package/dist/mirroring/transport/udp-environment.js.map +1 -0
  501. package/dist/polyfill/bridge-types.d.ts +11 -0
  502. package/dist/polyfill/presentation-receiver.d.ts +12 -0
  503. package/dist/polyfill/presentation-receiver.js +366 -0
  504. package/dist/polyfill/presentation-receiver.js.map +1 -0
  505. package/dist/polyfill/presentation-standin.js +157 -15
  506. package/dist/polyfill/presentation-standin.js.map +1 -1
  507. package/dist/protocol/framing.d.ts +1 -1
  508. package/dist/protocol/framing.js +1 -1
  509. package/dist/protocol/framing.js.map +1 -1
  510. package/docs/API.md +724 -0
  511. package/docs/ARCHITECTURE.md +242 -0
  512. package/docs/CHROMIUM-MAP.md +176 -0
  513. package/docs/DESIGN.md +1189 -0
  514. package/docs/FAQ.md +123 -0
  515. package/docs/GETTING-STARTED.md +248 -0
  516. package/docs/MAIN-API.md +524 -0
  517. package/docs/TROUBLESHOOTING.md +283 -0
  518. package/docs/guides/audio-and-groups.md +75 -0
  519. package/docs/guides/custom-receivers.md +109 -0
  520. package/docs/guides/device-authentication.md +145 -0
  521. package/docs/guides/device-picker.md +176 -0
  522. package/docs/guides/index.md +17 -0
  523. package/docs/guides/low-level-client.md +103 -0
  524. package/docs/guides/restart-rejoin.md +172 -0
  525. package/docs/guides/testing.md +162 -0
  526. package/docs/guides/windows-and-iframes.md +116 -0
  527. package/docs/readme/badges/dependencies.svg +1 -0
  528. package/docs/readme/badges/electron.svg +1 -0
  529. package/docs/readme/badges/license.svg +1 -0
  530. package/docs/readme/badges/node.svg +1 -0
  531. package/docs/readme/board.jpg +0 -0
  532. package/docs/readme/hero-dark.jpg +0 -0
  533. package/docs/readme/hero-light.jpg +0 -0
  534. package/docs/readme/nosignal.jpg +0 -0
  535. package/docs/readme/parity.jpg +0 -0
  536. package/docs/readme/trace.svg +22 -0
  537. package/package.json +21 -5
  538. package/src/cli.ts +57 -0
  539. package/src/client/auth/cast-auth.ts +2 -0
  540. package/src/dial/dial-registry.ts +316 -0
  541. package/src/dial/dial-sink-service.ts +343 -0
  542. package/src/dial/http.ts +200 -0
  543. package/src/dial/index.ts +135 -0
  544. package/src/dial/origins.ts +31 -0
  545. package/src/dial/parse.ts +319 -0
  546. package/src/dial/route-provider.ts +429 -0
  547. package/src/dial/ssdp-socket.ts +79 -0
  548. package/src/dial/xml.ts +180 -0
  549. package/src/dial-test/cli-main.ts +146 -0
  550. package/src/dial-test/report.ts +109 -0
  551. package/src/dial-test/runner.ts +615 -0
  552. package/src/dial-test/scrub.ts +74 -0
  553. package/src/discovery/cast-discovery.ts +2 -0
  554. package/src/discovery/device-cache.ts +5 -0
  555. package/src/discovery/index.ts +1 -0
  556. package/src/discovery/ip-policy.ts +97 -0
  557. package/src/discovery/udp-socket.ts +3 -0
  558. package/src/electron/access-code.ts +681 -0
  559. package/src/electron/app-discovery.ts +244 -0
  560. package/src/electron/default-presentation.ts +104 -0
  561. package/src/electron/main.ts +664 -29
  562. package/src/electron/manager-api.ts +367 -15
  563. package/src/electron/media-controller.ts +313 -0
  564. package/src/electron/network-monitor.ts +140 -0
  565. package/src/electron/preload.ts +1 -1
  566. package/src/electron/presentation-handler.ts +195 -48
  567. package/src/electron/presentation-source.ts +155 -0
  568. package/src/electron/session-service.ts +693 -238
  569. package/src/electron/session-tracker.ts +248 -0
  570. package/src/electron/sink-service.ts +726 -0
  571. package/src/electron/wired-display/controller.ts +212 -0
  572. package/src/electron/wired-display/displays.ts +107 -0
  573. package/src/electron/wired-display/electron-windows.ts +386 -0
  574. package/src/electron/wired-display/index.ts +181 -0
  575. package/src/electron/wired-display/local-presentation.ts +286 -0
  576. package/src/electron/wired-display/provider.ts +276 -0
  577. package/src/index.ts +1 -0
  578. package/src/mirroring/backend.ts +103 -0
  579. package/src/mirroring/electron/agent-protocol.ts +84 -0
  580. package/src/mirroring/electron/agent-source.ts +619 -0
  581. package/src/mirroring/electron/engine-process.ts +131 -0
  582. package/src/mirroring/electron/host.ts +361 -0
  583. package/src/mirroring/electron/port-backend.ts +466 -0
  584. package/src/mirroring/encoding-support.ts +146 -0
  585. package/src/mirroring/engine.ts +91 -0
  586. package/src/mirroring/mirror-settings.ts +174 -0
  587. package/src/mirroring/mirroring-activity.ts +466 -0
  588. package/src/mirroring/mirroring-manager.ts +342 -0
  589. package/src/mirroring/protocol/answer.ts +285 -0
  590. package/src/mirroring/protocol/constants.ts +75 -0
  591. package/src/mirroring/protocol/errors.ts +36 -0
  592. package/src/mirroring/protocol/frame-id.ts +20 -0
  593. package/src/mirroring/protocol/messenger.ts +128 -0
  594. package/src/mirroring/protocol/offer.ts +275 -0
  595. package/src/mirroring/protocol/recommendations.ts +135 -0
  596. package/src/mirroring/routing.ts +160 -0
  597. package/src/mirroring/rtcp/ntp.ts +61 -0
  598. package/src/mirroring/rtcp/parser.ts +292 -0
  599. package/src/mirroring/rtcp/sender-report.ts +88 -0
  600. package/src/mirroring/rtcp/wire.ts +76 -0
  601. package/src/mirroring/rtp/frame-crypto.ts +38 -0
  602. package/src/mirroring/rtp/frame.ts +25 -0
  603. package/src/mirroring/rtp/packetizer.ts +95 -0
  604. package/src/mirroring/sender/audio-sender.ts +59 -0
  605. package/src/mirroring/sender/bandwidth-estimator.ts +111 -0
  606. package/src/mirroring/sender/capture-size-oracle.ts +476 -0
  607. package/src/mirroring/sender/frame-sender.ts +293 -0
  608. package/src/mirroring/sender/packet-router.ts +228 -0
  609. package/src/mirroring/sender/sender-session.ts +306 -0
  610. package/src/mirroring/sender/sender.ts +497 -0
  611. package/src/mirroring/sender/video-encoder-metrics.ts +64 -0
  612. package/src/mirroring/sender/video-sender.ts +243 -0
  613. package/src/mirroring/session-host.ts +725 -0
  614. package/src/mirroring/stats/clock-offset-estimator.ts +139 -0
  615. package/src/mirroring/stats/openscreen-stats-client.ts +19 -0
  616. package/src/mirroring/stats/sorted-map.ts +68 -0
  617. package/src/mirroring/stats/statistics-analyzer.ts +388 -0
  618. package/src/mirroring/stats/statistics-collector.ts +69 -0
  619. package/src/mirroring/stats/statistics-common.ts +112 -0
  620. package/src/mirroring/stats/statistics-dispatcher.ts +133 -0
  621. package/src/mirroring/stats/statistics.ts +170 -0
  622. package/src/mirroring/transport/udp-environment.ts +100 -0
  623. package/src/polyfill/bridge-types.ts +11 -0
  624. package/src/polyfill/presentation-receiver.ts +350 -0
  625. package/src/polyfill/presentation-standin.ts +147 -15
  626. package/src/protocol/framing.ts +1 -1
@@ -0,0 +1,283 @@
1
+ # Troubleshooting
2
+
3
+ What to check, in order, when casting does not work: no devices, a button that never appears, a refused device, a hang at
4
+ startup, a session that drops, and how to get logs. Each section has the commands to run.
5
+
6
+ Start with [List what discovery sees](#list-what-discovery-sees). It separates "the network is the problem" from "my app is".
7
+
8
+ ## List what discovery sees
9
+
10
+ This uses only the published package and Node, with no Electron, and it only **asks** (it sends mDNS queries and never
11
+ answers or advertises). Save it as `discover.mjs` in a project that has electron-cast installed:
12
+
13
+ ```js
14
+ import { CastDiscovery } from "electron-cast";
15
+
16
+ const seconds = Number(process.argv[2] ?? 10);
17
+ const discovery = new CastDiscovery();
18
+ discovery.on("deviceUp", (d) => console.log(`up ${d.name} ${d.model} ${d.host}:${d.port}`));
19
+ discovery.on("deviceDown", (d) => console.log(`down ${d.name}`));
20
+ discovery.on("socketError", (iface, error) => console.log(`socket error on ${iface.name} (${iface.address}): ${error.message}`));
21
+
22
+ await discovery.start();
23
+ for (const i of discovery.interfaces()) {
24
+ console.log(`listening on ${i.name} (${i.address}${i.family === "IPv6" ? `%${i.scopeId}` : ""})`);
25
+ }
26
+ setTimeout(() => {
27
+ console.log(`${discovery.devices().length} device(s) found`);
28
+ discovery.stop();
29
+ }, seconds * 1000);
30
+ ```
31
+
32
+ ```sh
33
+ node discover.mjs 15
34
+ ```
35
+
36
+ (In a clone of the repository, `node examples/discover.ts 15` does the same on a Node that runs TypeScript, 22.18 or 24.)
37
+
38
+ Read the output:
39
+
40
+ - **No `listening on` lines.** Node sees no usable network interface: the machine is offline, or only has loopback and
41
+ link-local addresses. Discovery uses every non-loopback, non-`169.254.` IPv4 address, plus one IPv6 link-local address per
42
+ adapter.
43
+ - **`listening on` lines, then `0 device(s) found`.** The sockets opened but no device answered. This is the network or a
44
+ firewall: continue with [No devices found](#no-devices-found).
45
+ - **`socket error on ...`.** One interface failed (the others carry on). The message says why: often a virtual adapter or an
46
+ adapter that went away.
47
+ - **Devices appear here but not in your app.** The network is fine; look at your app: `manager.start()` was never called,
48
+ `allowOrigin` refused the page, or the preload did not run. See [the button never appears](#the-cast-button-never-appears).
49
+
50
+ ## No devices found
51
+
52
+ mDNS is multicast on the local link. Anything that stops multicast between the PC and the device hides the device. The usual
53
+ causes, most common first:
54
+
55
+ 1. **The PC and the device are on different networks.** mDNS does not cross routers. A PC on a wired VLAN, a guest SSID or a
56
+ different subnet from the Cast device sees nothing. Put them on one network, or run an mDNS reflector on the router
57
+ (avahi's reflector, or the router's own "mDNS" or "Bonjour" setting).
58
+ 2. **Wi-Fi client isolation** (AP isolation, "guest mode") on the access point drops traffic between wireless clients. Turn it
59
+ off for the network the devices are on.
60
+ 3. **A firewall on the PC** blocks inbound UDP 5353 (Windows, Linux) or the app is denied local network access (macOS).
61
+ 4. **A VPN.** A full-tunnel VPN can route multicast away from the LAN. Disconnect it and run the script again. Adapters
62
+ from VPNs (Tailscale, for example) still get a socket and are harmless; they just hear nothing.
63
+ 5. **The wrong adapter is the active one.** Discovery listens on every non-internal IPv4 interface, so a PC with several
64
+ adapters is covered, but check the `listening on` lines include the LAN adapter's address.
65
+ 6. **Running in WSL2 in NAT mode.** See [WSL](#wsl2).
66
+
67
+ Confirm that mDNS traffic reaches the machine at all, independent of electron-cast.
68
+
69
+ ### Windows
70
+
71
+ ```powershell
72
+ # Which adapter is the LAN one, and is its network profile Public? (Public blocks more inbound traffic.)
73
+ Get-NetConnectionProfile
74
+ Get-NetAdapter | Where-Object Status -eq Up
75
+ # Is anything else holding UDP 5353?
76
+ netstat -ano -p UDP | findstr :5353
77
+ # Firewall rules that apply to your app (replace the name)
78
+ Get-NetFirewallApplicationFilter | Where-Object Program -like "*MyApp*"
79
+ ```
80
+
81
+ If the app is not allowed through Windows Defender Firewall for the active profile, allow it (Windows Security, Firewall
82
+ and network protection, Allow an app through firewall), or run the script with Node and allow `node.exe` for the test. To
83
+ see the packets, capture in Wireshark with the display filter `mdns`: responses from the Cast devices
84
+ (`_googlecast._tcp.local` PTR records) should arrive within a few seconds of the queries.
85
+
86
+ ### macOS
87
+
88
+ macOS was not tested by the author, so treat these as the general checks.
89
+
90
+ ```sh
91
+ # Browse Cast devices with the system's own Bonjour tool (press Ctrl-C to stop)
92
+ dns-sd -B _googlecast._tcp local.
93
+ # Watch mDNS on the LAN interface
94
+ sudo tcpdump -ni en0 udp port 5353
95
+ ```
96
+
97
+ If `dns-sd` finds devices and electron-cast does not, check System Settings, Privacy and Security, Local Network for your
98
+ app, and that a packaged app declares `NSLocalNetworkUsageDescription` and `NSBonjourServices` (see [Getting
99
+ started](GETTING-STARTED.md#macos)).
100
+
101
+ ### Linux
102
+
103
+ ```sh
104
+ ip -br addr # interfaces and addresses
105
+ ip maddr show # multicast groups joined (224.0.0.251 for mDNS)
106
+ ss -ulpn 'sport = :5353' # who holds UDP 5353 (avahi-daemon and systemd-resolved may; sharing is fine)
107
+ avahi-browse -rt _googlecast._tcp # what avahi sees (needs avahi-utils)
108
+ sudo tcpdump -ni any udp port 5353 # are mDNS packets arriving at all?
109
+ sudo ufw status verbose # a host firewall (or: sudo firewall-cmd --list-all)
110
+ ```
111
+
112
+ `avahi-browse` finding devices and electron-cast not means the multicast is arriving at the machine but the app's socket is
113
+ not getting it: check `socket error` lines from the script. If `tcpdump` shows nothing, the network or a firewall is
114
+ dropping it before the app.
115
+
116
+ ### WSL2
117
+
118
+ Discovery needs to see the LAN's multicast traffic. Under WSL2 that depends on the networking mode:
119
+
120
+ - **Mirrored networking** (`networkingMode=mirrored`): discovery and device authentication passed on all 8 test devices from
121
+ Ubuntu under WSL2 in this mode on 2026-11-25. In `%UserProfile%\.wslconfig`:
122
+
123
+ ```ini
124
+ [wsl2]
125
+ networkingMode=mirrored
126
+ ```
127
+
128
+ then run `wsl --shutdown` from Windows and start the distribution again. It needs Windows 11 22H2 or later with a current WSL
129
+ (`wsl --version` to check).
130
+ - **NAT mode** (the default): the distribution sits behind a virtual switch on its own subnet, so the LAN's mDNS multicast
131
+ typically does not reach it and discovery finds nothing. That is the network design and not something electron-cast can change; it was
132
+ not measured. Use mirrored mode, or run the app on the Windows side.
133
+
134
+ ### Everything checks out, still nothing
135
+
136
+ - Wait a minute, or reboot the Cast device: electron-cast queries at start, again after 1 s and 3 s, then every 60 s.
137
+ - Make sure the device is a Cast device that advertises `_googlecast._tcp` (the Linux and macOS commands above browse for it).
138
+ - Give it a few seconds: a device is listed only once its channel is open and authenticated, after a random delay of up
139
+ to 5 s and a 3 s quiet period. One that fails authentication is never listed (see below).
140
+ - Your picker may be filtering them out. In default mode `selectDevice` receives the devices that said they have the
141
+ page's receiver app; in `mode: "chromecast"` those with the capabilities the page asked for.
142
+
143
+ ## The cast button never appears
144
+
145
+ The SDK shows its launcher only after it learns that a receiver is available. Check from the outside in. In the window's
146
+ DevTools console:
147
+
148
+ ```js
149
+ typeof window.__electronCastPresentationBridge // "object" if the preload ran (default mode)
150
+ typeof navigator.presentation // "object"
151
+ await new PresentationRequest(["https://google.com/cast#__castAppId__=CC1AD845/__castClientId__=probe"])
152
+ .getAvailability().then((a) => a.value) // true once a device is known and allowOrigin admits this origin
153
+ ```
154
+
155
+ - `"undefined"` for the first line: the **preload did not run** in this frame. Check `webPreferences.preload`, that the path is
156
+ absolute and the file exists, that a sandboxed preload is bundled (an unbundled `import "electron-cast/preload"` cannot load in a
157
+ sandboxed preload; look for the preload error in the DevTools console), and for an iframe that
158
+ `nodeIntegrationInSubFrames: true` is set.
159
+ - `false` from the last line with devices found by the script: **`allowOrigin` refused** this frame's origin (it reads as no
160
+ receivers), or the manager was never started (`await cast.start()`), or the manager was disposed. In an iframe the check uses
161
+ the iframe's own origin.
162
+ - Google's SDK did not load: look for a blocked script in the console. Your **Content Security Policy** has to allow
163
+ `www.gstatic.com` ([Getting started](GETTING-STARTED.md#5-content-security-policy)).
164
+ - With `mode: "chromecast"`, the bridge is `window.__electronCastBridge`, and `chrome.cast.isAvailable` is true after install.
165
+
166
+ If starting a cast fails with `AbortError: PresentationRequest::start() requires user gesture.` the call did not come from a
167
+ click. Casting must start from a user gesture, as in Chrome; a call from the DevTools console or a timer does not count.
168
+
169
+ ## A device is refused, or casting fails after picking it
170
+
171
+ A device that fails device authentication is never listed, as in Chrome: the channel opened to it at discovery is refused,
172
+ retried with Chrome's backoff, and then given up, so it does not reach the picker and a page that asks finds no screen.
173
+
174
+ To see the real reason in your logs, wrap `createClient` and log the `CastAuthError`: the exact snippet is in [Device
175
+ authentication](guides/device-authentication.md#what-failure-looks-like). The `reason` values, and what each usually means,
176
+ are in the [API reference](API.md#errors) and the [guide](guides/device-authentication.md#diagnosing-a-refused-device).
177
+
178
+ Other reasons a device does not show or a cast fails, from the same `createClient` wrapper:
179
+
180
+ | What you see | Meaning |
181
+ |---|---|
182
+ | `CastTimeoutError` on `connect` | The TLS handshake did not finish within `connectTimeoutMs` (10 s): the device is asleep, off, or unreachable from this machine (a different subnet, a firewall on the PC blocking outbound TCP 8009) |
183
+ | `CastConnectionError` | The TCP or TLS connection failed or was refused |
184
+ | `CastRequestError` with `LAUNCH_ERROR` | The device could not launch the receiver app: an unpublished app on a device that is not registered as a test device, a wrong app id, or the device is busy |
185
+ | A pick that never finishes | Your `selectDevice` never resolved. The time the picker is open does not count against the launch timeout, so resolve `null` on cancel |
186
+
187
+ A device is connected over IPv4 when it has an address, else IPv6 (link-local ones with the interface's zone, `fe80::1%12`). IPv6
188
+ discovery, and TLS and device authentication over unique-local and link-local addresses, were verified on real devices.
189
+
190
+ ## The app hangs at top-level `await app.whenReady()` (Electron 45)
191
+
192
+ In an ES module main process (`"type": "module"`, or an `.mjs` main), a top-level `await app.whenReady()` never resolves on
193
+ Electron 45 (reproduced on 45.5.0 on Windows): the app logs the line before it and then hangs. It is Electron's ESM startup,
194
+ not electron-cast. Diagnose it with two log lines either side of the `await`:
195
+
196
+ ```js
197
+ console.log("before whenReady");
198
+ await app.whenReady(); // hangs here on Electron 45 in an ES module main
199
+ console.log("after whenReady"); // never printed
200
+ ```
201
+
202
+ Use `then` instead, or put the work in a function that is not awaited at the top level:
203
+
204
+ ```js
205
+ app.whenReady().then(async () => {
206
+ await cast.start();
207
+ // create windows
208
+ });
209
+ ```
210
+
211
+ Related report: [electron/electron#40719](https://github.com/electron/electron/issues/40719) (closed; a comment there describes the
212
+ top-level await form of the same hang). A CommonJS main is not affected.
213
+
214
+ ## Sessions that drop
215
+
216
+ A session is the app running on the device plus a TLS connection from your main process. The connection is kept alive by
217
+ heartbeat: the client pings every 5 s and fails the connection after 10 s with no traffic from the device. When it fails, the
218
+ session ends for the page: in the default mode the page's `PresentationConnection` closes after a `disconnect_session`
219
+ message; with `mode: "chromecast"` it gets `sessionEnded` with status `disconnected`.
220
+
221
+ What is behind a drop, and what each looks like:
222
+
223
+ | Cause | Looks like | What to do |
224
+ |---|---|---|
225
+ | The device slept, rebooted or lost Wi-Fi | `disconnected` after about 10 s of silence | Rejoin by id once it is back ([guide](guides/restart-rejoin.md)); the app may be gone |
226
+ | Someone stopped the cast on a phone or the device | `stopped`, not `disconnected` | Nothing to fix |
227
+ | Your PC slept or changed network | `disconnected`; discovery replaces its sockets after wake and removes devices of a vanished adapter at once | Reconnect after discovery finds the device again |
228
+ | The receiver app ended (a crash, or its own timeout) | `stopped` | Check the receiver |
229
+
230
+ A **navigation** of the page is not a drop: it parks the session and the next page rejoins by auto-join. Closing the page
231
+ leaves the session without stopping playback.
232
+
233
+ To watch it happen, log the client's lifecycle (next section).
234
+
235
+ ## Logging
236
+
237
+ electron-cast has **no logging switch**, no debug flag and no environment variable. It writes to the console only when a listener
238
+ you gave it throws (`electron-cast: a media router observer failed`, and similar). It leaves visibility to you, through the seams it
239
+ exposes:
240
+
241
+ ```ts
242
+ import { ipcMain } from "electron";
243
+ import { CastClient, type CastDevice } from "electron-cast";
244
+ import { createCastManager, type ChannelParams } from "electron-cast/main";
245
+
246
+ function createClient(device: CastDevice, params: ChannelParams): CastClient {
247
+ const client = new CastClient({
248
+ host: device.host,
249
+ port: device.port,
250
+ connectTimeoutMs: params.connectTimeoutMs,
251
+ heartbeatTimeoutMs: params.livenessTimeoutMs,
252
+ });
253
+ const tag = `cast[${device.name}]`;
254
+ client.on("message", (m) => console.log(tag, m.namespace, m.sourceId, "->", m.destinationId, typeof m.data === "string" ? m.data.slice(0, 200) : `<${m.data.length} bytes>`));
255
+ client.on("receiverStatus", (s) => console.log(tag, "status", s.applications.map((a) => a.displayName), s.volume));
256
+ client.on("transportClosed", (id) => console.log(tag, "transport closed", id));
257
+ client.on("close", (error) => console.log(tag, "closed", error?.message ?? "on purpose"));
258
+ return client;
259
+ }
260
+
261
+ export const cast = createCastManager({
262
+ ipcMain,
263
+ selectDevice: async () => null, // your picker
264
+ createClient,
265
+ });
266
+
267
+ cast.registerMediaRoutesObserver({ onRoutesUpdated: (routes) => console.log("routes", routes.map((r) => [r.id, r.description, r.parked])) });
268
+ cast.registerMediaSinksObserver({ onSinksUpdated: (sinks) => console.log("sinks", sinks.map((s) => s.name)) });
269
+ ```
270
+
271
+ Heartbeat PING and PONG are handled inside the client and not reported as messages. For the layers below that:
272
+
273
+ - **Discovery:** the script at the top of this page, with `deviceUp`, `deviceChanged`, `deviceDown` and `socketError`.
274
+ - **The network:** Wireshark with `mdns` (discovery) or `tcp.port == 8009` (the connection; it is TLS, so you see timing and sizes,
275
+ not content).
276
+ - **TLS and sockets:** Node's own `NODE_DEBUG=tls,net` prints handshakes and socket events to stderr.
277
+ - **The page:** the DevTools console of the window. The preload's `console.error` appears there when a bridge listener throws.
278
+
279
+ ## Still stuck
280
+
281
+ Open an issue at [github.com/adammpkins/electron-cast/issues](https://github.com/adammpkins/electron-cast/issues) with: the
282
+ electron-cast and Electron versions, the OS, whether `discover.mjs` finds devices, the `CastAuthError` reason or the page's error
283
+ name and message, and what you tried above. For a vulnerability, use [private reporting](../SECURITY.md#reporting-a-vulnerability).
@@ -0,0 +1,75 @@
1
+ # Audio-only devices and speaker groups
2
+
3
+ How to tell a TV, a speaker and a speaker group apart in your picker, and what to expect when casting to each.
4
+
5
+ ## Telling devices apart
6
+
7
+ Every `CastDevice` carries a capability bit mask (`capabilities`, from the mDNS TXT record `ca`) and an `isGroup` flag.
8
+
9
+ | Bit | Name | Meaning |
10
+ |---|---|---|
11
+ | 1 | `video_out` | Can show video: a Chromecast, a TV, a Nest Hub |
12
+ | 2 | `video_in` | Video input |
13
+ | 4 | `audio_out` | Can play audio |
14
+ | 8 | `audio_in` | Audio input |
15
+ | 32 | `multizone_group` | A speaker group |
16
+
17
+ `capabilityNames(bits)` turns a mask into those names. Devices set many more bits than these six (values like `464901`
18
+ and `199204` were seen on real devices), so test only the documented ones, as the library does.
19
+
20
+ - A **Chromecast or TV** has `video_out`.
21
+ - An **audio-only device**, such as a Google Home Mini, has `audio_out` and no `video_out`.
22
+ - A **group** has `multizone_group` (`isGroup` is `true`, `model` is `"Google Cast Group"`).
23
+
24
+ ```ts
25
+ import { capabilityNames, type CastDevice } from "electron-cast";
26
+
27
+ type Kind = "tv" | "speaker" | "group";
28
+
29
+ function kindOf(device: CastDevice): Kind {
30
+ if (device.isGroup) return "group";
31
+ return device.capabilities & 1 ? "tv" : "speaker";
32
+ }
33
+
34
+ console.log(capabilityNames(5)); // ["video_out", "audio_out"]
35
+ ```
36
+
37
+ The same decision is what Chrome makes for the icon (`GetCastSinkIconType`): `video_out` gives a Cast icon, else a multizone
38
+ group a group icon, else a speaker icon. A [`MediaSink`](../MAIN-API.md#sinks) from the sinks observer carries it already
39
+ as `iconType`: `"cast"`, `"cast_audio_group"` or `"cast_audio"`.
40
+
41
+ ## Groups
42
+
43
+ A group is one device to the user and several to the network. Its facts, seen on real devices:
44
+
45
+ - A group answers on the **leader's address** but has **its own port** (for example 32044 and 32200 for two groups a Nest
46
+ Hub Max leads) and its own id. electron-cast keys devices by their TXT `id`, never by address, so a group and its leader
47
+ do not collide.
48
+ - A group's `id` is a dashed UUID; a single device's is 32 hex digits. Treat the id as an opaque string.
49
+ - Casting to a group is the same call as casting to a device: resolve the group's `CastDevice` from `selectDevice`.
50
+
51
+ Sort groups after devices in your picker, as the example in [Building your own device picker](device-picker.md) does.
52
+ Devices are listed over several seconds after `start()`, so a picker that [updates live](device-picker.md#a-picker-window-with-live-updates)
53
+ is worth having.
54
+
55
+ ## Which devices a page can be shown
56
+
57
+ In the default mode the page asks for no capabilities, so `selectDevice` receives **every** device, audio-only and groups
58
+ included, and receiver availability is true as soon as one device is known. If your app only wants video devices, filter in
59
+ your picker (`devices.filter(d => d.capabilities & 1)`).
60
+
61
+ The page-side SDK can still ask for capabilities (`mode: "chromecast"`'s `requestSession` does); a device is offered only if
62
+ it has all of them, and `receiver_unavailable` comes back if none do.
63
+
64
+ ## Device authentication and audio-only devices
65
+
66
+ Authentication reports a **policy** for the device certificate: `"unrestricted"`, or `"audio_only"` when a certificate in
67
+ the chain is audio-only. A Google Home Mini passes with `audio_only`. electron-cast reports the policy in
68
+ `CastClient.deviceAuth.policy` and **does nothing else with it**: it does not stop you launching a video app on such a
69
+ device. See [Device authentication](device-authentication.md).
70
+
71
+ ## What was tested
72
+
73
+ Discovery and device authentication passed on a Chromecast, a Chromecast Ultra, a Google Home Mini (audio-only), a Nest Hub,
74
+ a Nest Hub Max and two Cast groups, from Windows, and again on all eight from Linux (Ubuntu under WSL2 with mirrored
75
+ networking). Casting end to end, from Windows, included speaker groups.
@@ -0,0 +1,109 @@
1
+ # Custom receivers and the Default Media Receiver
2
+
3
+ Choosing which receiver app a cast launches, sending media to the Default Media Receiver, and talking to your own receiver
4
+ on a custom namespace.
5
+
6
+ A **receiver** is the app that runs on the Cast device (the web page the TV shows). A page asks for one by its **app id**.
7
+ electron-cast launches whatever app id the page's SDK asks for on the device the user picked; it does not choose or
8
+ restrict receivers. That is the SDK's job, and your `allowOrigin` and `selectDevice` decide whether the page may cast at all.
9
+
10
+ ## The Default Media Receiver
11
+
12
+ App id `CC1AD845` (`chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID` in the SDK) is Google's generic media player. It needs
13
+ no registration, plays a media URL the device can fetch, and is what the [example app](../../examples/electron-app) uses:
14
+
15
+ ```ts
16
+ declare const chrome: any;
17
+ declare const cast: any;
18
+
19
+ window.__onGCastApiAvailable = (available: boolean) => {
20
+ if (!available) return;
21
+ const context = cast.framework.CastContext.getInstance();
22
+ context.setOptions({
23
+ receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,
24
+ autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
25
+ });
26
+ };
27
+
28
+ // After the user has started a session with the launcher button:
29
+ async function play(url: string, contentType: string): Promise<void> {
30
+ const session = cast.framework.CastContext.getInstance().getCurrentSession();
31
+ if (!session) return;
32
+ const mediaInfo = new chrome.cast.media.MediaInfo(url, contentType);
33
+ mediaInfo.metadata = new chrome.cast.media.GenericMediaMetadata();
34
+ mediaInfo.metadata.title = "My video";
35
+ const error = await session.loadMedia(new chrome.cast.media.LoadRequest(mediaInfo));
36
+ if (error) console.error("Load failed", error);
37
+ }
38
+ declare global {
39
+ interface Window { __onGCastApiAvailable?: (available: boolean) => void }
40
+ }
41
+ ```
42
+
43
+ Only **starting** the session needs a user gesture (the launcher click). Loading media afterwards does not.
44
+
45
+ The device, not your app, fetches the media, so the URL has to be reachable from the device's network, and for HLS or
46
+ DASH it needs the CORS headers a receiver requires (the example uses a public HLS sample for that reason). With
47
+ `cast.framework` on a Nest Hub, session start, volume, HLS load, play, pause, seek, resume and stop were tested.
48
+
49
+ ## Your own receiver
50
+
51
+ 1. Build and register a receiver app in Google's Cast SDK Developer Console to get an app id. An unpublished app launches
52
+ only on devices you registered as test devices there (Google's rule, not electron-cast's).
53
+ 2. Use that id as the page's `receiverApplicationId` (or `SessionRequest`).
54
+ 3. Talk to it on your own **namespace** (`urn:x-cast:com.example.chat`, say).
55
+
56
+ ```ts
57
+ declare const chrome: any;
58
+
59
+ const NAMESPACE = "urn:x-cast:com.example.chat";
60
+
61
+ function listen(session: any): void {
62
+ session.addMessageListener(NAMESPACE, (_namespace: string, message: string) => {
63
+ console.log("from the receiver:", message);
64
+ });
65
+ }
66
+
67
+ function say(session: any, text: string): void {
68
+ session.sendMessage(NAMESPACE, { text }, () => {}, (error: unknown) => console.error(error));
69
+ }
70
+ ```
71
+
72
+ How messages flow, and the limits:
73
+
74
+ - **Namespaces.** In the default mode the namespace must be one the receiver app lists in its status. A receiver declares
75
+ them in its own configuration. A message to anything else is refused with an `invalid_parameter` error ("Invalid namespace") and never sent. (`mode: "chromecast"` lets the page name any
76
+ namespace, but the destination is always the receiver app's own transport, never the platform receiver.)
77
+ - **Delivery.** Messages go to the receiver app's transport. What the device sends comes back only to the members of that
78
+ session, routed by the app's transport id, so a session sees only its own app's traffic.
79
+ - **Sizes.** A page-to-receiver message over 1,048,576 characters is dropped, and the Cast wire limit of 65,536 bytes per
80
+ message still applies below that: a larger message fails with an error instead of being sent.
81
+ - **Untrusted data.** Everything a device sends is untrusted data. The SDK may put a receiver's name into markup, so
82
+ electron-cast HTML-escapes the friendly name it passes on, as Chrome does.
83
+
84
+ ## Which app id the page used
85
+
86
+ `CastRequestInfo.appId` in `selectDevice` tells your picker which receiver the page wants. A page can launch any app on the
87
+ device the user picked, so if you only support one receiver, check it there and resolve `null` for anything else:
88
+
89
+ ```ts
90
+ import { ipcMain } from "electron";
91
+ import { createCastManager } from "electron-cast/main";
92
+
93
+ const SUPPORTED = new Set(["CC1AD845", "ABCD1234"]);
94
+
95
+ export const cast = createCastManager({
96
+ ipcMain,
97
+ selectDevice: async (_devices, request) => {
98
+ if (!SUPPORTED.has(request.appId)) return null;
99
+ return null; // show your picker for the supported ones
100
+ },
101
+ });
102
+ ```
103
+
104
+ An app id is validated to `[A-Za-z0-9._-]{1,64}` before it gets anywhere near a device.
105
+
106
+ ## Receivers that are not Google-certified
107
+
108
+ A receiver you wrote and run yourself on non-Google hardware has no Google certificate, so device authentication fails
109
+ for it. See [Device authentication](device-authentication.md#casting-to-a-receiver-that-is-not-google-certified).
@@ -0,0 +1,145 @@
1
+ # Device authentication
2
+
3
+ What electron-cast checks before it talks to a Cast device, what a failure looks like to the user and to you, and how to
4
+ cast to a receiver that is not Google-certified.
5
+
6
+ ## What it is
7
+
8
+ A Cast device on your network presents a self-signed TLS certificate, so ordinary certificate validation cannot tell a
9
+ genuine device from anyone who answers mDNS. Chrome therefore runs a second check, the **device authentication
10
+ challenge** on the `urn:x-cast:com.google.cast.tp.deviceauth` namespace, and electron-cast ports it. After the TLS
11
+ handshake and before CONNECT, `CastClient.connect()`:
12
+
13
+ 1. sends a challenge (a random 16-byte nonce, SHA-256);
14
+ 2. checks that the TLS certificate is currently valid and lives no more than four days;
15
+ 3. builds the device's certificate chain from what it sent and validates it to Google's built-in Cast root certificates;
16
+ 4. checks revocation against the CRL the device sent, or else a fallback CRL built into the package;
17
+ 5. verifies the device's signature over the nonce and **this connection's TLS certificate**, which ties the proof to the
18
+ connection so it cannot be replayed on another.
19
+
20
+ There are no dependencies and no network access: the root certificates and the fallback CRL ship in the package. The
21
+ steps, and where electron-cast differs from Chromium, are in [DESIGN.md](../DESIGN.md#device-authentication-srcclientauth). The
22
+ Chromium sources it ports are in the [Chromium map](../CHROMIUM-MAP.md#cast-v2-channel-and-device-authentication).
23
+
24
+ It happens **when the channel opens**, which the manager does for every device discovery finds, before listing it.
25
+
26
+ **Tested:** it passed on 8 real devices from Windows (a Chromecast, a Chromecast Ultra, a Google Home Mini, a Nest Hub, a
27
+ Nest Hub Max and two Cast groups), and again on all 8 from Linux on 2026-11-25. The Google Home Mini passed with the
28
+ `audio_only` policy.
29
+
30
+ ## The policy: on by default
31
+
32
+ | Where | Option | Default |
33
+ |---|---|---|
34
+ | `createCastManager` | `verifyDevices` | `true` |
35
+ | `CastClient` | `verifyDevice` | `true` |
36
+
37
+ With it on, a device that fails is never used. With it off, **nothing** is checked: the connection is encrypted but the
38
+ device is not authenticated, so anyone on the local network who can answer mDNS, or sit between you and the device, can
39
+ pose as a Cast device. If the user picks it, that party receives whatever the page sends (media URLs, app messages and
40
+ tokens). It does not get cookies or anything else from the page ([SECURITY.md](../../SECURITY.md#tls-and-device-authentication)).
41
+
42
+ ## What failure looks like
43
+
44
+ - **To the user.** The device is **never listed**, as in Chrome: a device is a sink only once its channel has passed
45
+ authentication, so it does not reach your picker. The attempt is retried with Chrome's backoff (15 s, 3 attempts), then
46
+ given up.
47
+ - **To the page.** The device is not there: availability does not count it and `start()` does not offer it. The page
48
+ learns nothing about why.
49
+ - **To you.** `CastClient.connect()` rejects with `CastAuthError`, which has a `reason` (`untrusted_chain`, `revoked`,
50
+ `bad_signature`, `timeout`, and so on; [the full list](../API.md#errors)) and the device's `host`. The manager treats it as
51
+ an unreachable device, so to log it, wrap the client you hand the manager. `createClient` gets the attempt's timeouts as
52
+ its second argument; pass them on:
53
+
54
+ ```ts
55
+ import { ipcMain } from "electron";
56
+ import { CastAuthError, CastClient, type CastDevice } from "electron-cast";
57
+ import { createCastManager, type ChannelParams } from "electron-cast/main";
58
+
59
+ function createClient(device: CastDevice, params: ChannelParams): CastClient {
60
+ const client = new CastClient({
61
+ host: device.host,
62
+ port: device.port,
63
+ connectTimeoutMs: params.connectTimeoutMs,
64
+ heartbeatTimeoutMs: params.livenessTimeoutMs,
65
+ });
66
+ const connect = client.connect.bind(client);
67
+ client.connect = async () => {
68
+ try {
69
+ await connect();
70
+ console.log(`cast: ${device.name} verified`, client.deviceAuth);
71
+ } catch (error) {
72
+ if (error instanceof CastAuthError) console.warn(`cast: ${device.name} refused (${error.reason})`, error.message);
73
+ throw error;
74
+ }
75
+ };
76
+ return client;
77
+ }
78
+
79
+ export const cast = createCastManager({
80
+ ipcMain,
81
+ selectDevice: async () => null, // your picker
82
+ createClient, // verifyDevices is ignored when you give createClient: pass verifyDevice to your own CastClient
83
+ });
84
+ ```
85
+
86
+ `client.deviceAuth` is a `DeviceAuthResult`: the `policy` (`"unrestricted"` or `"audio_only"`), the digest the device
87
+ signed with, whether it echoed the nonce, and whether the fallback CRL was used and whether revocation was checked.
88
+
89
+ ## Casting to a receiver that is not Google-certified
90
+
91
+ An open-source receiver, or one you built for your own hardware, carries no Google certificate. For those, turn the check
92
+ off. Prefer doing it for the receivers you mean, not for everything:
93
+
94
+ ```ts
95
+ import { ipcMain } from "electron";
96
+ import { CastClient, type CastDevice } from "electron-cast";
97
+ import { createCastManager, type ChannelParams } from "electron-cast/main";
98
+
99
+ // Ids of the receivers you run yourself (CastDevice.id, the mDNS TXT `id`).
100
+ const OWN_RECEIVERS = new Set(["0123456789abcdef0123456789abcdef"]);
101
+
102
+ export const cast = createCastManager({
103
+ ipcMain,
104
+ selectDevice: async () => null, // your picker
105
+ createClient: (device: CastDevice, params: ChannelParams) =>
106
+ new CastClient({
107
+ host: device.host,
108
+ port: device.port,
109
+ connectTimeoutMs: params.connectTimeoutMs,
110
+ heartbeatTimeoutMs: params.livenessTimeoutMs,
111
+ verifyDevice: !OWN_RECEIVERS.has(device.id),
112
+ }),
113
+ });
114
+ ```
115
+
116
+ An id from the network is not a secret and can be copied by an attacker on the same network. This narrows the exposure; it
117
+ does not remove it. If you need all of your receivers pinned, give `CastClient` a `tls` option that pins their certificates
118
+ (it is applied after the defaults, so it can override `rejectUnauthorized`), and see
119
+ [SECURITY.md](../../SECURITY.md#tls-and-device-authentication).
120
+
121
+ A private Cast deployment with its own certificate authority can keep verification on and replace the trust anchors with the
122
+ `deviceAuth` option (`roots`, `crlRoots`, `fallbackCrl`, `now`). That option exists for tests and such deployments: an app
123
+ that sets it decides what counts as genuine.
124
+
125
+ ## Old releases and the stale fallback CRL
126
+
127
+ Revocation uses the CRL the device sends. A device that sends none falls back to a CRL built into the package, which
128
+ counts for **20 weeks** from the package's build time. After that, and only for a device that sent no valid CRL, the
129
+ revocation check is skipped instead of refusing the device, and `deviceAuth.revocationChecked` is `false`. Chromium would
130
+ refuse here; Chrome updates itself and an Electron app might not, so it would start refusing every such device about 20 weeks
131
+ after your electron-cast release. Everything else is still enforced. Update electron-cast regularly, and treat
132
+ `revocationChecked: false` as a prompt to do so. Why this is the one deliberate difference from Chromium:
133
+ [DESIGN.md](../DESIGN.md#device-authentication-srcclientauth).
134
+
135
+ ## Diagnosing a refused device
136
+
137
+ | `reason` | Usually means |
138
+ |---|---|
139
+ | `timeout` | No reply to the challenge within `authTimeoutMs` (10 s) of the TLS handshake |
140
+ | `untrusted_chain`, `invalid_certificate` | Not a Google-certified device, or its certificate chain is outside its validity dates |
141
+ | `tls_certificate_invalid` | The TLS certificate is expired, not yet valid or valid longer than four days; a system clock that is far off does this |
142
+ | `revoked` | Google revoked the device certificate or a CA, by the device's CRL or the fallback |
143
+ | `bad_signature`, `malformed_reply`, `unsupported_algorithm`, `device_error`, `no_tls_certificate`, `crl_invalid` | See [the table](../API.md#errors) |
144
+
145
+ Commands for working through one: [Troubleshooting](../TROUBLESHOOTING.md#a-device-is-refused-or-casting-fails-after-picking-it).