librats 1.0.2 → 2.2.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 (319) hide show
  1. package/README.md +145 -331
  2. package/binding.gyp +16 -3
  3. package/lib/index.d.ts +288 -696
  4. package/lib/index.js +407 -44
  5. package/native-src/3rdparty/android/ifaddrs-android.c +1 -0
  6. package/native-src/3rdparty/android/ifaddrs-android.h +1 -0
  7. package/native-src/CMakeLists.txt +404 -179
  8. package/native-src/LICENSE +1 -1
  9. package/native-src/src/librats/bindings/rats.cpp +762 -0
  10. package/native-src/src/librats/bindings/rats.h +380 -0
  11. package/native-src/src/librats/bittorrent/bencode.cpp +437 -0
  12. package/native-src/src/librats/bittorrent/bencode.h +176 -0
  13. package/native-src/src/librats/bittorrent/bitfield.cpp +97 -0
  14. package/native-src/src/librats/bittorrent/bitfield.h +76 -0
  15. package/native-src/src/librats/bittorrent/byte_io.h +58 -0
  16. package/native-src/src/librats/bittorrent/choker.cpp +25 -0
  17. package/native-src/src/librats/bittorrent/choker.h +46 -0
  18. package/native-src/src/librats/bittorrent/client.cpp +413 -0
  19. package/native-src/src/librats/bittorrent/client.h +227 -0
  20. package/native-src/src/librats/bittorrent/disk_io.cpp +209 -0
  21. package/native-src/src/librats/bittorrent/disk_io.h +150 -0
  22. package/native-src/src/librats/bittorrent/extensions.cpp +191 -0
  23. package/native-src/src/librats/bittorrent/extensions.h +94 -0
  24. package/native-src/src/librats/bittorrent/file_storage.cpp +77 -0
  25. package/native-src/src/librats/bittorrent/file_storage.h +79 -0
  26. package/native-src/src/librats/bittorrent/log.h +42 -0
  27. package/native-src/src/librats/bittorrent/magnet_uri.cpp +98 -0
  28. package/native-src/src/librats/bittorrent/magnet_uri.h +35 -0
  29. package/native-src/src/librats/bittorrent/peer_connection.cpp +502 -0
  30. package/native-src/src/librats/bittorrent/peer_connection.h +194 -0
  31. package/native-src/src/librats/bittorrent/peer_list.cpp +68 -0
  32. package/native-src/src/librats/bittorrent/peer_list.h +75 -0
  33. package/native-src/src/librats/bittorrent/piece_picker.cpp +352 -0
  34. package/native-src/src/librats/bittorrent/piece_picker.h +201 -0
  35. package/native-src/src/librats/bittorrent/reactor.cpp +97 -0
  36. package/native-src/src/librats/bittorrent/reactor.h +89 -0
  37. package/native-src/src/librats/bittorrent/resume_data.cpp +72 -0
  38. package/native-src/src/librats/bittorrent/resume_data.h +41 -0
  39. package/native-src/src/librats/bittorrent/store_buffer.cpp +48 -0
  40. package/native-src/src/librats/bittorrent/store_buffer.h +47 -0
  41. package/native-src/src/librats/bittorrent/torrent.cpp +870 -0
  42. package/native-src/src/librats/bittorrent/torrent.h +260 -0
  43. package/native-src/src/librats/bittorrent/torrent_creator.cpp +129 -0
  44. package/native-src/src/librats/bittorrent/torrent_creator.h +58 -0
  45. package/native-src/src/librats/bittorrent/torrent_info.cpp +314 -0
  46. package/native-src/src/librats/bittorrent/torrent_info.h +118 -0
  47. package/native-src/src/librats/bittorrent/tracker.cpp +374 -0
  48. package/native-src/src/librats/bittorrent/tracker.h +108 -0
  49. package/native-src/src/librats/bittorrent/types.cpp +206 -0
  50. package/native-src/src/librats/bittorrent/types.h +86 -0
  51. package/native-src/src/librats/core/address.cpp +35 -0
  52. package/native-src/src/librats/core/address.h +78 -0
  53. package/native-src/src/librats/core/bytes.h +69 -0
  54. package/native-src/src/librats/core/chained_send_buffer.cpp +172 -0
  55. package/native-src/src/librats/core/chained_send_buffer.h +183 -0
  56. package/native-src/src/librats/core/endpoint_parse.cpp +41 -0
  57. package/native-src/src/librats/core/endpoint_parse.h +31 -0
  58. package/native-src/src/librats/core/event_bus.h +70 -0
  59. package/native-src/src/librats/core/host_endpoint.h +56 -0
  60. package/native-src/src/{io_poller.cpp → librats/core/io_poller.cpp} +520 -65
  61. package/native-src/src/{io_poller.h → librats/core/io_poller.h} +12 -6
  62. package/native-src/src/librats/core/ip_address.cpp +120 -0
  63. package/native-src/src/librats/core/ip_address.h +109 -0
  64. package/native-src/src/librats/core/mpsc_queue.h +47 -0
  65. package/native-src/src/librats/core/notifier.h +74 -0
  66. package/native-src/src/librats/core/receive_buffer.cpp +219 -0
  67. package/native-src/src/librats/core/receive_buffer.h +171 -0
  68. package/native-src/src/librats/core/service_registry.h +58 -0
  69. package/native-src/src/{socket.cpp → librats/core/socket.cpp} +625 -118
  70. package/native-src/src/librats/core/socket.h +496 -0
  71. package/native-src/src/librats/core/timer_queue.h +105 -0
  72. package/native-src/src/librats/core/types.cpp +43 -0
  73. package/native-src/src/librats/core/types.h +103 -0
  74. package/native-src/src/librats/core/wakeup_pipe.h +83 -0
  75. package/native-src/src/{crypto → librats/crypto}/blake2_endian.h +21 -23
  76. package/native-src/src/{crypto → librats/crypto}/blake2b.c +34 -33
  77. package/native-src/src/{crypto → librats/crypto}/blake2b.h +7 -6
  78. package/native-src/src/{crypto → librats/crypto}/blake2s.c +55 -54
  79. package/native-src/src/{crypto → librats/crypto}/blake2s.h +13 -12
  80. package/native-src/src/{crypto → librats/crypto}/chacha.c +22 -21
  81. package/native-src/src/{crypto → librats/crypto}/chacha.h +14 -13
  82. package/native-src/src/{crypto → librats/crypto}/chachapoly.c +56 -56
  83. package/native-src/src/{crypto → librats/crypto}/chachapoly.h +24 -17
  84. package/native-src/src/{crc32.cpp → librats/crypto/crc32.cpp} +1 -1
  85. package/native-src/src/{crc32.h → librats/crypto/crc32.h} +3 -1
  86. package/native-src/src/{crypto → librats/crypto}/curve25519.c +6 -4
  87. package/native-src/src/{crypto → librats/crypto}/curve25519.h +6 -3
  88. package/native-src/src/librats/crypto/hkdf.c +266 -0
  89. package/native-src/src/{crypto → librats/crypto}/hkdf.h +19 -19
  90. package/native-src/src/{noise.cpp → librats/crypto/noise.cpp} +84 -73
  91. package/native-src/src/{noise.h → librats/crypto/noise.h} +18 -8
  92. package/native-src/src/{crypto → librats/crypto}/poly1305.c +47 -46
  93. package/native-src/src/librats/crypto/poly1305.h +37 -0
  94. package/native-src/src/{sha1.cpp → librats/crypto/sha1.cpp} +33 -1
  95. package/native-src/src/{sha1.h → librats/crypto/sha1.h} +14 -6
  96. package/native-src/src/{crypto → librats/crypto}/sha256.c +15 -14
  97. package/native-src/src/{crypto → librats/crypto}/sha256.h +8 -7
  98. package/native-src/src/{crypto → librats/crypto}/sha512.c +15 -14
  99. package/native-src/src/{crypto → librats/crypto}/sha512.h +8 -7
  100. package/native-src/src/librats/dht/announce.cpp +37 -0
  101. package/native-src/src/librats/dht/announce.h +41 -0
  102. package/native-src/src/librats/dht/bep42.cpp +109 -0
  103. package/native-src/src/librats/dht/bep42.h +48 -0
  104. package/native-src/src/librats/dht/dht.cpp +501 -0
  105. package/native-src/src/librats/dht/dht.h +119 -0
  106. package/native-src/src/librats/dht/dht_runner.cpp +103 -0
  107. package/native-src/src/librats/dht/dht_runner.h +71 -0
  108. package/native-src/src/librats/dht/dos_blocker.cpp +42 -0
  109. package/native-src/src/librats/dht/dos_blocker.h +47 -0
  110. package/native-src/src/librats/dht/find_peers.cpp +52 -0
  111. package/native-src/src/librats/dht/find_peers.h +73 -0
  112. package/native-src/src/librats/dht/id.h +167 -0
  113. package/native-src/src/{krpc.cpp → librats/dht/krpc.cpp} +32 -81
  114. package/native-src/src/{krpc.h → librats/dht/krpc.h} +19 -23
  115. package/native-src/src/librats/dht/log.h +38 -0
  116. package/native-src/src/librats/dht/node.cpp +473 -0
  117. package/native-src/src/librats/dht/node.h +164 -0
  118. package/native-src/src/librats/dht/node_entry.h +81 -0
  119. package/native-src/src/librats/dht/observer.h +72 -0
  120. package/native-src/src/librats/dht/persistence.cpp +90 -0
  121. package/native-src/src/librats/dht/persistence.h +32 -0
  122. package/native-src/src/librats/dht/routing_table.cpp +559 -0
  123. package/native-src/src/librats/dht/routing_table.h +185 -0
  124. package/native-src/src/librats/dht/rpc_manager.cpp +127 -0
  125. package/native-src/src/librats/dht/rpc_manager.h +77 -0
  126. package/native-src/src/librats/dht/storage.cpp +92 -0
  127. package/native-src/src/librats/dht/storage.h +74 -0
  128. package/native-src/src/librats/dht/transport.h +27 -0
  129. package/native-src/src/librats/dht/traversal.cpp +326 -0
  130. package/native-src/src/librats/dht/traversal.h +120 -0
  131. package/native-src/src/librats/dht/udp_transport.cpp +49 -0
  132. package/native-src/src/librats/dht/udp_transport.h +51 -0
  133. package/native-src/src/librats/mdns/log.h +22 -0
  134. package/native-src/src/{mdns.cpp → librats/mdns/mdns.cpp} +75 -40
  135. package/native-src/src/{mdns.h → librats/mdns/mdns.h} +9 -8
  136. package/native-src/src/{natpmp.cpp → librats/nat/natpmp.cpp} +12 -9
  137. package/native-src/src/{natpmp.h → librats/nat/natpmp.h} +3 -3
  138. package/native-src/src/{port_mapping.h → librats/nat/port_mapping.h} +3 -2
  139. package/native-src/src/{stun.cpp → librats/nat/stun.cpp} +4 -4
  140. package/native-src/src/{stun.h → librats/nat/stun.h} +1 -1
  141. package/native-src/src/{upnp.cpp → librats/nat/upnp.cpp} +6 -6
  142. package/native-src/src/{upnp.h → librats/nat/upnp.h} +2 -2
  143. package/native-src/src/librats/node/circuit_service.h +84 -0
  144. package/native-src/src/librats/node/config.h +110 -0
  145. package/native-src/src/librats/node/dial_service.h +54 -0
  146. package/native-src/src/librats/node/dialer.cpp +264 -0
  147. package/native-src/src/librats/node/dialer.h +188 -0
  148. package/native-src/src/librats/node/host_events.h +26 -0
  149. package/native-src/src/librats/node/identify.cpp +130 -0
  150. package/native-src/src/librats/node/identify.h +71 -0
  151. package/native-src/src/librats/node/nat_status.cpp +103 -0
  152. package/native-src/src/librats/node/nat_status.h +118 -0
  153. package/native-src/src/librats/node/node.cpp +865 -0
  154. package/native-src/src/librats/node/node.h +344 -0
  155. package/native-src/src/librats/node/node_context.h +33 -0
  156. package/native-src/src/librats/node/peer_network.h +91 -0
  157. package/native-src/src/librats/peer/peer.h +49 -0
  158. package/native-src/src/librats/peer/peer_book.cpp +181 -0
  159. package/native-src/src/librats/peer/peer_book.h +88 -0
  160. package/native-src/src/librats/peer/peer_id.cpp +72 -0
  161. package/native-src/src/librats/peer/peer_id.h +62 -0
  162. package/native-src/src/librats/peer/peer_info.h +37 -0
  163. package/native-src/src/librats/peer/peer_table.cpp +170 -0
  164. package/native-src/src/librats/peer/peer_table.h +148 -0
  165. package/native-src/src/librats/security/handshaker.h +66 -0
  166. package/native-src/src/librats/security/identity.h +43 -0
  167. package/native-src/src/librats/security/noise_security.cpp +122 -0
  168. package/native-src/src/librats/security/noise_security.h +37 -0
  169. package/native-src/src/librats/security/plaintext_security.h +106 -0
  170. package/native-src/src/librats/security/session.h +37 -0
  171. package/native-src/src/{storage.cpp → librats/storage/storage.cpp} +369 -522
  172. package/native-src/src/{storage.h → librats/storage/storage.h} +135 -299
  173. package/native-src/src/librats/subsystems/bittorrent.cpp +211 -0
  174. package/native-src/src/librats/subsystems/bittorrent.h +136 -0
  175. package/native-src/src/librats/subsystems/dht_discovery.cpp +202 -0
  176. package/native-src/src/librats/subsystems/dht_discovery.h +123 -0
  177. package/native-src/src/librats/subsystems/dht_service.h +36 -0
  178. package/native-src/src/librats/subsystems/file_transfer.cpp +972 -0
  179. package/native-src/src/librats/subsystems/file_transfer.h +367 -0
  180. package/native-src/src/librats/subsystems/hole_punch.cpp +605 -0
  181. package/native-src/src/librats/subsystems/hole_punch.h +290 -0
  182. package/native-src/src/librats/subsystems/hole_punch_service.h +38 -0
  183. package/native-src/src/librats/subsystems/mdns_discovery.cpp +66 -0
  184. package/native-src/src/librats/subsystems/mdns_discovery.h +55 -0
  185. package/native-src/src/librats/subsystems/message_json.cpp +112 -0
  186. package/native-src/src/librats/subsystems/message_json.h +88 -0
  187. package/native-src/src/librats/subsystems/peer_exchange.cpp +241 -0
  188. package/native-src/src/librats/subsystems/peer_exchange.h +136 -0
  189. package/native-src/src/librats/subsystems/ping_service.cpp +98 -0
  190. package/native-src/src/librats/subsystems/ping_service.h +66 -0
  191. package/native-src/src/librats/subsystems/port_mapping_service.cpp +192 -0
  192. package/native-src/src/librats/subsystems/port_mapping_service.h +84 -0
  193. package/native-src/src/librats/subsystems/pubsub.cpp +567 -0
  194. package/native-src/src/librats/subsystems/pubsub.h +175 -0
  195. package/native-src/src/librats/subsystems/reconnection.cpp +239 -0
  196. package/native-src/src/librats/subsystems/reconnection.h +126 -0
  197. package/native-src/src/librats/subsystems/relay.cpp +1142 -0
  198. package/native-src/src/librats/subsystems/relay.h +211 -0
  199. package/native-src/src/librats/subsystems/relay_service.h +46 -0
  200. package/native-src/src/librats/transport/connection.cpp +343 -0
  201. package/native-src/src/librats/transport/connection.h +283 -0
  202. package/native-src/src/librats/transport/link.h +96 -0
  203. package/native-src/src/librats/transport/reactor.cpp +588 -0
  204. package/native-src/src/librats/transport/reactor.h +262 -0
  205. package/native-src/src/librats/transport/reactor_pool.h +81 -0
  206. package/native-src/src/librats/transport/relay_link.cpp +208 -0
  207. package/native-src/src/librats/transport/relay_link.h +303 -0
  208. package/native-src/src/librats/transport/tcp_link.cpp +49 -0
  209. package/native-src/src/librats/transport/tcp_link.h +43 -0
  210. package/native-src/src/librats/transport/udp_mux.cpp +617 -0
  211. package/native-src/src/librats/transport/udp_mux.h +363 -0
  212. package/native-src/src/librats/transport/udp_packet.cpp +121 -0
  213. package/native-src/src/librats/transport/udp_packet.h +190 -0
  214. package/native-src/src/librats/transport/udp_stream.cpp +1194 -0
  215. package/native-src/src/librats/transport/udp_stream.h +614 -0
  216. package/native-src/src/librats/util/features.h.in +51 -0
  217. package/native-src/src/{fs.cpp → librats/util/fs.cpp} +51 -3
  218. package/native-src/src/librats/util/fs.h +136 -0
  219. package/native-src/src/librats/util/json.cpp +1002 -0
  220. package/native-src/src/librats/util/json.h +444 -0
  221. package/native-src/src/{logger.cpp → librats/util/logger.cpp} +1 -1
  222. package/native-src/src/{logger.h → librats/util/logger.h} +43 -31
  223. package/native-src/src/{network_monitor.cpp → librats/util/network_monitor.cpp} +12 -4
  224. package/native-src/src/{network_monitor.h → librats/util/network_monitor.h} +2 -1
  225. package/native-src/src/{network_utils.cpp → librats/util/network_utils.cpp} +38 -23
  226. package/native-src/src/{network_utils.h → librats/util/network_utils.h} +15 -8
  227. package/native-src/src/{os.cpp → librats/util/os.cpp} +48 -18
  228. package/native-src/src/librats/util/rats_export.h +69 -0
  229. package/native-src/src/{version.cpp → librats/util/version.cpp} +2 -2
  230. package/native-src/src/{version.h.in → librats/util/version.h.in} +1 -1
  231. package/native-src/src/librats/wire/frame.cpp +76 -0
  232. package/native-src/src/librats/wire/frame.h +111 -0
  233. package/native-src/src/librats/wire/message_router.cpp +45 -0
  234. package/native-src/src/librats/wire/message_router.h +47 -0
  235. package/package.json +5 -4
  236. package/scripts/build-librats.js +1 -0
  237. package/scripts/postinstall.js +3 -3
  238. package/scripts/prepare-package.js +4 -4
  239. package/scripts/verify-installation.js +63 -105
  240. package/src/librats_node.cpp +1067 -1323
  241. package/native-src/src/bencode.cpp +0 -485
  242. package/native-src/src/bencode.h +0 -145
  243. package/native-src/src/bittorrent.cpp +0 -14
  244. package/native-src/src/bittorrent.h +0 -74
  245. package/native-src/src/bt_bitfield.cpp +0 -372
  246. package/native-src/src/bt_bitfield.h +0 -316
  247. package/native-src/src/bt_choker.cpp +0 -228
  248. package/native-src/src/bt_choker.h +0 -147
  249. package/native-src/src/bt_client.cpp +0 -1047
  250. package/native-src/src/bt_client.h +0 -445
  251. package/native-src/src/bt_create_torrent.cpp +0 -677
  252. package/native-src/src/bt_create_torrent.h +0 -473
  253. package/native-src/src/bt_extension.cpp +0 -469
  254. package/native-src/src/bt_extension.h +0 -309
  255. package/native-src/src/bt_file_storage.cpp +0 -261
  256. package/native-src/src/bt_file_storage.h +0 -298
  257. package/native-src/src/bt_handshake.cpp +0 -134
  258. package/native-src/src/bt_handshake.h +0 -157
  259. package/native-src/src/bt_messages.cpp +0 -364
  260. package/native-src/src/bt_messages.h +0 -324
  261. package/native-src/src/bt_network.cpp +0 -1007
  262. package/native-src/src/bt_network.h +0 -417
  263. package/native-src/src/bt_peer_connection.cpp +0 -742
  264. package/native-src/src/bt_peer_connection.h +0 -592
  265. package/native-src/src/bt_piece_picker.cpp +0 -786
  266. package/native-src/src/bt_piece_picker.h +0 -473
  267. package/native-src/src/bt_resume_data.cpp +0 -410
  268. package/native-src/src/bt_resume_data.h +0 -249
  269. package/native-src/src/bt_torrent.cpp +0 -2120
  270. package/native-src/src/bt_torrent.h +0 -641
  271. package/native-src/src/bt_torrent_info.cpp +0 -659
  272. package/native-src/src/bt_torrent_info.h +0 -418
  273. package/native-src/src/bt_types.h +0 -621
  274. package/native-src/src/chained_send_buffer.cpp +0 -75
  275. package/native-src/src/chained_send_buffer.h +0 -137
  276. package/native-src/src/crypto/hkdf.c +0 -266
  277. package/native-src/src/crypto/poly1305.h +0 -36
  278. package/native-src/src/dht.cpp +0 -3311
  279. package/native-src/src/dht.h +0 -717
  280. package/native-src/src/disk_io.cpp +0 -632
  281. package/native-src/src/disk_io.h +0 -315
  282. package/native-src/src/file_transfer.cpp +0 -1415
  283. package/native-src/src/file_transfer.h +0 -286
  284. package/native-src/src/fs.h +0 -108
  285. package/native-src/src/gossipsub.cpp +0 -1139
  286. package/native-src/src/gossipsub.h +0 -403
  287. package/native-src/src/ice.cpp +0 -893
  288. package/native-src/src/ice.h +0 -559
  289. package/native-src/src/json.hpp +0 -25526
  290. package/native-src/src/librats.cpp +0 -2378
  291. package/native-src/src/librats.h +0 -2324
  292. package/native-src/src/librats_bittorrent.cpp +0 -601
  293. package/native-src/src/librats_c.cpp +0 -1557
  294. package/native-src/src/librats_c.h +0 -323
  295. package/native-src/src/librats_discovery.cpp +0 -402
  296. package/native-src/src/librats_encryption.cpp +0 -275
  297. package/native-src/src/librats_file_transfer.cpp +0 -144
  298. package/native-src/src/librats_gossipsub.cpp +0 -289
  299. package/native-src/src/librats_ice.cpp +0 -213
  300. package/native-src/src/librats_log_macros.h +0 -36
  301. package/native-src/src/librats_logging.cpp +0 -173
  302. package/native-src/src/librats_mdns.cpp +0 -166
  303. package/native-src/src/librats_persistence.cpp +0 -796
  304. package/native-src/src/librats_portmap.cpp +0 -419
  305. package/native-src/src/librats_reconnection.cpp +0 -218
  306. package/native-src/src/librats_statistic.cpp +0 -105
  307. package/native-src/src/librats_storage.cpp +0 -189
  308. package/native-src/src/rats_export.h +0 -17
  309. package/native-src/src/receive_buffer.cpp +0 -82
  310. package/native-src/src/receive_buffer.h +0 -127
  311. package/native-src/src/socket.h +0 -228
  312. package/native-src/src/threadmanager.cpp +0 -105
  313. package/native-src/src/threadmanager.h +0 -53
  314. package/native-src/src/tracker.cpp +0 -1264
  315. package/native-src/src/tracker.h +0 -319
  316. package/native-src/src/turn.cpp +0 -762
  317. package/native-src/src/turn.h +0 -460
  318. package/native-src/src/wakeup_pipe.h +0 -60
  319. /package/native-src/src/{os.h → librats/util/os.h} +0 -0
package/README.md CHANGED
@@ -1,410 +1,224 @@
1
- # LibRats Node.js Bindings
1
+ # librats Node.js bindings
2
2
 
3
- Node.js bindings for librats - A high-performance peer-to-peer networking library with support for DHT, GossipSub, file transfer, NAT traversal, and more.
3
+ Node.js bindings for [librats](../README.md), a C++17 peer-to-peer networking
4
+ library: encrypted transport, DHT/mDNS discovery, NAT traversal, pub/sub, typed
5
+ JSON messaging and file transfer.
4
6
 
5
- ## Features
7
+ ## The model
6
8
 
7
- - **Peer-to-peer networking** - Direct connections between peers
8
- - **DHT (Distributed Hash Table)** - Decentralized peer discovery
9
- - **GossipSub** - Topic-based publish/subscribe messaging
10
- - **File Transfer** - Send and receive files and directories
11
- - **mDNS Discovery** - Local network peer discovery
12
- - **NAT Traversal** - STUN/ICE support for connecting through firewalls
13
- - **Encryption** - End-to-end encryption using Noise protocol
14
- - **Message Exchange** - String, binary, and JSON message types
15
- - **Configuration Persistence** - Save and restore client settings
9
+ A `RatsNode` is one librats node. On its own it gives you secure transport
10
+ (Noise XX over TCP **or** the library's reliable stream over UDP, both on the
11
+ same port), a self-certifying peer id, manual dialing, and raw messaging on named
12
+ channels nothing else. Discovery, pub/sub, JSON messaging, file transfer, NAT
13
+ port mapping, hole punching, RTT probing and reconnection are **opt-in
14
+ subsystems**: you pay only for what you turn on.
16
15
 
17
- ## Installation
16
+ Two rules follow from that:
17
+
18
+ - **Enable subsystems and register callbacks before `start()`.** Enabling after
19
+ start throws `RATS_ERR_ALREADY_STARTED`; using a subsystem before its enable
20
+ throws `RATS_ERR_NOT_ENABLED`.
21
+ - **Callbacks are marshalled onto the JS thread** from a librats reactor thread.
22
+ Keep them short anyway — a slow handler backs up the reactor's queue.
18
23
 
19
- ### Quick Install
24
+ Fallible calls **throw** an `Error` whose message is `librats: <CODE>`; pure
25
+ getters are properties.
20
26
 
21
- Install directly from npm:
27
+ ## Installation
22
28
 
23
29
  ```bash
24
30
  npm install librats
25
31
  ```
26
32
 
27
- The installation process will automatically:
28
- 1. Download all necessary source files
29
- 2. Build the native librats library using CMake
30
- 3. Build the Node.js native addon
31
- 4. Set up the bindings
32
-
33
- **No additional build steps required!**
33
+ The install builds the native librats library with CMake, then compiles the
34
+ Node.js addon against it. You need:
34
35
 
35
- ### Prerequisites
36
+ - **Node.js** 20+
37
+ - **CMake** 3.14+ ([download](https://cmake.org/download/))
38
+ - a **C++17 toolchain** — Visual Studio Build Tools 2017+ (Windows),
39
+ `build-essential` (Linux), `xcode-select --install` (macOS)
36
40
 
37
- The following build tools are required and will be used automatically during installation:
41
+ See [INSTALLATION.md](INSTALLATION.md) for what runs during install and how to
42
+ troubleshoot it.
38
43
 
39
- - **Node.js**: 20.0.0 or higher
40
- - **CMake**: Version 3.10 or higher ([download here](https://cmake.org/download/))
41
- - **C++ Compiler and Build Tools**:
42
- - **Windows**: Visual Studio Build Tools 2017 or later ([download here](https://visualstudio.microsoft.com/downloads/))
43
- - **Linux**: `build-essential` and `cmake` packages
44
- ```bash
45
- sudo apt install build-essential cmake
46
- ```
47
- - **macOS**: Xcode Command Line Tools
48
- ```bash
49
- xcode-select --install
50
- ```
51
-
52
- ### Verifying Installation
53
-
54
- After installation, you can verify everything is working:
55
-
56
- ```bash
57
- npm run verify
58
- ```
59
-
60
- This will check that the native addon is built correctly and all features are available.
61
-
62
- ### Building from Source
63
-
64
- If you're developing or need to rebuild:
65
-
66
- ```bash
67
- # Clone the repository
68
- git clone https://github.com/librats/librats.git
69
- cd librats/nodejs
70
-
71
- # Install (builds everything automatically)
72
- npm install
73
-
74
- # Verify the installation
75
- npm run verify
76
-
77
- # Or build manually
78
- npm run build
79
- ```
80
-
81
- ## Quick Start
82
-
83
- ### Basic Example
44
+ ## Quick start
84
45
 
85
46
  ```javascript
86
- const { RatsClient, ConnectionStrategy } = require('librats');
47
+ const { RatsNode } = require('librats');
87
48
 
88
- // Create a client listening on port 8080
89
- const client = new RatsClient(8080);
49
+ const node = new RatsNode({ listenPort: 8080, dataDir: './state' });
90
50
 
91
- // Set up event handlers
92
- client.onConnection((peerId) => {
93
- console.log(`Peer connected: ${peerId}`);
94
- client.sendString(peerId, 'Hello from Node.js!');
51
+ // Everything below happens before start().
52
+ node.onPeerConnected((peerId) => {
53
+ console.log(`+ ${peerId}`);
54
+ node.send(peerId, 'chat', 'Hello from Node.js!');
95
55
  });
96
-
97
- client.onString((peerId, message) => {
98
- console.log(`Received: ${message} from ${peerId}`);
56
+ node.on('chat', (peerId, data) => {
57
+ console.log(`[chat] ${peerId}: ${data.toString('utf8')}`);
99
58
  });
59
+ node.enableDht(); // find peers on the mainline DHT
60
+ node.enableMdns(); // …and on the local network
100
61
 
101
- // Start the client
102
- client.start();
103
-
104
- // Connect to another peer
105
- client.connect('127.0.0.1', 8081);
62
+ node.start();
63
+ console.log(node.localId, 'listening on', node.listenPort);
106
64
  ```
107
65
 
108
- ### File Transfer Example
66
+ ### Pub/sub
109
67
 
110
68
  ```javascript
111
- const { RatsClient } = require('librats');
112
-
113
- const client = new RatsClient(8080);
114
-
115
- // Set up file transfer progress monitoring
116
- client.onFileProgress((transferId, progressPercent, status) => {
117
- console.log(`Transfer ${transferId}: ${progressPercent}% - ${status}`);
69
+ node.enablePubsub();
70
+ node.subscribe('lobby', (peerId, topic, data) => {
71
+ console.log(`[${topic}] ${peerId}: ${data.toString('utf8')}`);
118
72
  });
73
+ node.start();
74
+ node.publish('lobby', 'hi everyone');
75
+ ```
119
76
 
120
- // Accept incoming transfer offers (transfers are push-only)
121
- client.onFileRequest((peerId, transferId, filename) => {
122
- console.log(`Incoming offer "${filename}" from ${peerId}`);
123
- client.acceptFileTransfer(transferId, `./downloads/${filename}`);
124
- });
77
+ ### Typed JSON messaging
125
78
 
126
- client.start();
79
+ Values are serialized and parsed for you — handlers receive the parsed value.
127
80
 
128
- // Send a file to a peer
129
- const transferId = client.sendFile('peer_id_here', './myfile.txt', 'remote_file.txt');
130
- console.log(`File transfer started: ${transferId}`);
81
+ ```javascript
82
+ node.enableJson();
83
+ node.onJson('greeting', (peerId, value) => console.log(peerId, value.hello));
84
+ node.start();
85
+ node.broadcastJson('greeting', { hello: 'world' });
131
86
  ```
132
87
 
133
- ### GossipSub Chat Example
88
+ ### File transfer
134
89
 
135
90
  ```javascript
136
- const { RatsClient } = require('librats');
137
-
138
- const client = new RatsClient(8080);
139
- client.start();
140
-
141
- // Subscribe to a topic
142
- client.subscribeToTopic('general-chat');
91
+ node.enableFileTransfer('./tmp'); // in-progress downloads live here
143
92
 
144
- // Publish a message
145
- const message = {
146
- type: 'chat',
147
- username: 'Alice',
148
- message: 'Hello everyone!',
149
- timestamp: Date.now()
150
- };
93
+ node.onFileOffer((peerId, transferId, name, size, isDirectory) => {
94
+ node.acceptFile(peerId, transferId, `./downloads/${name}`);
95
+ });
96
+ node.onFileProgress((transferId, peerId, done, total) => {
97
+ console.log(`${transferId}: ${done}/${total}`);
98
+ });
99
+ node.onFileComplete((transferId, success, path) => {
100
+ console.log(`${transferId} ${success ? 'done' : 'failed'} ${path}`);
101
+ });
151
102
 
152
- client.publishJsonToTopic('general-chat', JSON.stringify(message));
103
+ node.start();
104
+ const transferId = node.sendFile(peerId, './myfile.txt'); // 0 on failure
153
105
  ```
154
106
 
155
- ## API Reference
107
+ ### NAT traversal
156
108
 
157
- ### RatsClient
109
+ Port forwarding is the easy path; hole punching covers the networks where it
110
+ fails. Both are opt-in, and punching needs peers that relay the rendezvous.
158
111
 
159
- #### Constructor
112
+ ```javascript
113
+ node.enablePortMapping(); // UPnP IGD + NAT-PMP
114
+ node.enableHolePunch(true); // true = also relay other peers' rendezvous
115
+ node.enableRelay(false); // last resort; true = also carry others' connections
116
+ node.start();
160
117
 
161
- - `new RatsClient(listenPort: number)` - Create a new client instance
118
+ node.punchPeer(peerId); // success arrives as onPeerConnected
119
+ console.log(node.natMapping); // NatMapping.ENDPOINT_INDEPENDENT ⇒ punchable
120
+ ```
162
121
 
163
- #### Basic Operations
122
+ A symmetric NAT cannot be punched at all, and that is what `enableRelay` is for: the
123
+ connection itself is routed through a node both ends already reach. It stays
124
+ encrypted end to end — the relay moves ciphertext — and the peer behaves like any
125
+ other, except that `peerTransport(peerId)` reports `Transport.RELAY`. With both
126
+ enabled the ladder runs itself: a punch that cannot work falls back to a relay, and
127
+ a relayed peer keeps trying to become a direct one.
164
128
 
165
- - `start(): boolean` - Start the client
166
- - `stop(): void` - Stop the client
167
- - `connect(host: string, port: number): boolean` - Connect to a peer
168
- - `connectWithStrategy(host: string, port: number, strategy: number): boolean` - Connect with specific strategy
169
- - `disconnect(peerId: string): void` - Disconnect from a peer
129
+ ## API
170
130
 
171
- #### Messaging
131
+ ### Construction
172
132
 
173
- - `sendString(peerId: string, message: string): boolean` - Send string message
174
- - `sendBinary(peerId: string, data: Buffer): boolean` - Send binary data
175
- - `sendJson(peerId: string, jsonStr: string): boolean` - Send JSON data
176
- - `broadcastString(message: string): number` - Broadcast string to all peers
177
- - `broadcastBinary(data: Buffer): number` - Broadcast binary to all peers
178
- - `broadcastJson(jsonStr: string): number` - Broadcast JSON to all peers
133
+ ```javascript
134
+ new RatsNode(port) // listen on port (0 = ephemeral)
135
+ new RatsNode(config) // full config
136
+ ```
179
137
 
180
- #### Information
138
+ | config field | default | meaning |
139
+ |---|---|---|
140
+ | `listenPort` | `0` | inbound port shared by both transports; 0 = ephemeral |
141
+ | `enableListen` | `true` | `false` makes a dial-only node |
142
+ | `bindAddress` | `"::"` | dual-stack wildcard by default |
143
+ | `security` | `Security.NOISE` | or `Security.PLAINTEXT` |
144
+ | `dataDir` | — | persistent identity + subsystem state; omit for an ephemeral identity |
145
+ | `protocol` | `"librats/1.0"` | handshake app id; peers whose protocol differs cannot connect |
146
+ | `maxPeers` | `0` | established-peer cap; 0 = unlimited |
147
+ | `enableTcp` / `enableUdp` | `true` | which wires to accept and dial on |
148
+ | `preferredTransport` | `Transport.UDP` | which one a dial tries first |
149
+ | `transportFallbackMs` | `1200` | delay before racing the other; 0 disables |
181
150
 
182
- - `getPeerCount(): number` - Get number of connected peers
183
- - `getOurPeerId(): string | null` - Get our peer ID
184
- - `getPeerIds(): string[]` - Get list of connected peer IDs
185
- - `getConnectionStatistics(): string | null` - Get connection statistics as JSON
151
+ ### Lifecycle
186
152
 
187
- #### File Transfer
153
+ `start()` · `stop()` · `destroy()`
188
154
 
189
- - `sendFile(peerId: string, filePath: string, remoteFilename?: string): string | null` - Send file
190
- - `sendDirectory(peerId: string, dirPath: string, remoteDirName?: string): string | null` - Send directory (always recursive)
191
- - `acceptFileTransfer(transferId: string, localPath: string): boolean` - Accept an incoming file/directory transfer offer
192
- - `rejectFileTransfer(transferId: string, reason?: string): boolean` - Reject file transfer
193
- - `cancelFileTransfer(transferId: string): boolean` - Cancel file transfer
194
- - `pauseFileTransfer(transferId: string): boolean` - Pause file transfer
195
- - `resumeFileTransfer(transferId: string): boolean` - Resume file transfer
155
+ ### Properties
196
156
 
197
- #### GossipSub
157
+ `listenPort` · `localId` · `protocol` · `transports` · `peerCount` · `peerIds` ·
158
+ `maxPeers` *(settable)* · `natMapping`
198
159
 
199
- - `isGossipsubAvailable(): boolean` - Check if GossipSub is available
200
- - `subscribeToTopic(topic: string): boolean` - Subscribe to topic
201
- - `unsubscribeFromTopic(topic: string): boolean` - Unsubscribe from topic
202
- - `publishToTopic(topic: string, message: string): boolean` - Publish message
203
- - `publishJsonToTopic(topic: string, jsonStr: string): boolean` - Publish JSON
204
- - `getSubscribedTopics(): string[]` - Get subscribed topics
205
- - `getTopicPeers(topic: string): string[]` - Get peers in topic
160
+ ### Connections
206
161
 
207
- #### DHT
162
+ `connect(host, port)` · `peerTransport(peerId)` · `peerTransports(peerId)`
208
163
 
209
- - `startDhtDiscovery(dhtPort: number): boolean` - Start DHT discovery
210
- - `stopDhtDiscovery(): void` - Stop DHT discovery
211
- - `isDhtRunning(): boolean` - Check if DHT is running
212
- - `announceForHash(contentHash: string, port: number, callback?: (peers: string[]) => void): boolean` - Announce for hash with optional peer discovery callback
164
+ ### Raw channel messaging
213
165
 
214
- #### Encryption
166
+ `send(peerId, channel, data)` · `broadcast(channel, data)` ·
167
+ `on(channel, (peerId, data) => …)` — `data` is a `Buffer` in, `string | Buffer` out
215
168
 
216
- - `setEncryptionEnabled(enabled: boolean): boolean` - Enable/disable encryption
217
- - `isEncryptionEnabled(): boolean` - Check if encryption is enabled
218
- - `generateEncryptionKey(): string | null` - Generate new encryption key
219
- - `setEncryptionKey(keyHex: string): boolean` - Set encryption key
220
- - `getEncryptionKey(): string | null` - Get current encryption key
169
+ ### Peer events *(before start)*
221
170
 
222
- #### Event Handlers
171
+ `onPeerConnected(cb)` · `onPeerDisconnected(cb)`
223
172
 
224
- - `onConnection(callback: (peerId: string) => void): void` - Set connection callback
225
- - `onString(callback: (peerId: string, message: string) => void): void` - Set string message callback
226
- - `onBinary(callback: (peerId: string, data: Buffer) => void): void` - Set binary message callback
227
- - `onJson(callback: (peerId: string, jsonStr: string) => void): void` - Set JSON message callback
228
- - `onDisconnect(callback: (peerId: string) => void): void` - Set disconnect callback
229
- - `onFileProgress(callback: (transferId: string, progressPercent: number, status: string) => void): void` - Set file progress callback
230
- - `onFileRequest(callback: (peerId: string, transferId: string, filename: string) => void): void` - Set incoming transfer offer callback (respond with `acceptFileTransfer`/`rejectFileTransfer`)
173
+ ### Subsystems *(enable before start)*
231
174
 
232
- ### Utility Functions
175
+ | subsystem | enable | then |
176
+ |---|---|---|
177
+ | DHT discovery | `enableDht(dhtPort?, discoveryKey?)` | — |
178
+ | mDNS discovery | `enableMdns()` | — |
179
+ | NAT port mapping | `enablePortMapping(upnp?, natpmp?)` | — |
180
+ | Hole punching | `enableHolePunch(serveAsRelay?)` | `punchPeer(peerId)`, `natMapping` |
181
+ | Relaying | `enableRelay(serveAsRelay?)` | `connectViaRelay(peerId)` |
182
+ | Pub/sub | `enablePubsub()` | `subscribe(topic, cb)`, `unsubscribe(topic)`, `publish(topic, data)` |
183
+ | Typed JSON | `enableJson()` | `onJson(type, cb)`, `onceJson(type, cb)`, `offJson(type)`, `sendJson(peerId, type, value)`, `broadcastJson(type, value)` |
184
+ | File transfer | `enableFileTransfer(tempDir?)` | `onFileOffer/onFileProgress/onFileComplete`, `sendFile`, `sendDirectory`, `acceptFile`, `rejectFile`, `cancelFile`, `pauseFile`, `resumeFile` |
185
+ | Liveness | `enablePing()` | `peerRttMs(peerId)` — ms, or -1 if unknown |
186
+ | Reconnection | `enableReconnect()` | `addReconnect(host, port)`, `removeReconnect(host, port)` |
233
187
 
234
- - `getVersionString(): string` - Get librats version string
235
- - `getVersion(): VersionInfo` - Get version components
236
- - `getGitDescribe(): string` - Get git describe string
237
- - `getAbi(): number` - Get ABI version
188
+ ### Module level
238
189
 
239
- ### Constants
190
+ `version()` · `versionInfo()` · `gitDescribe()` · `abi()` ·
191
+ `setLogLevel(level)` · `setLogFile(path?)` ·
192
+ `Security` · `Transport` · `TransportMask` · `NatMapping` · `LogLevel`
240
193
 
241
- #### ConnectionStrategy
194
+ ## TypeScript
242
195
 
243
- - `ConnectionStrategy.DIRECT_ONLY` - Direct connection only
244
- - `ConnectionStrategy.STUN_ASSISTED` - STUN-assisted connection
245
- - `ConnectionStrategy.ICE_FULL` - Full ICE negotiation
246
- - `ConnectionStrategy.TURN_RELAY` - TURN relay connection
247
- - `ConnectionStrategy.AUTO_ADAPTIVE` - Automatic strategy selection
196
+ Definitions ship with the package.
248
197
 
249
- #### ErrorCodes
198
+ ```typescript
199
+ import { RatsNode, Security } from 'librats';
250
200
 
251
- - `ErrorCodes.SUCCESS` - Operation successful
252
- - `ErrorCodes.INVALID_HANDLE` - Invalid client handle
253
- - `ErrorCodes.INVALID_PARAMETER` - Invalid parameter
254
- - `ErrorCodes.NOT_RUNNING` - Client not running
255
- - `ErrorCodes.OPERATION_FAILED` - Operation failed
256
- - `ErrorCodes.PEER_NOT_FOUND` - Peer not found
257
- - `ErrorCodes.MEMORY_ALLOCATION` - Memory allocation error
258
- - `ErrorCodes.JSON_PARSE` - JSON parsing error
201
+ const node = new RatsNode({ listenPort: 8080, security: Security.NOISE });
202
+ node.start();
203
+ ```
259
204
 
260
205
  ## Examples
261
206
 
262
- The `examples/` directory contains comprehensive examples:
263
-
264
- - **`basic_client.js`** - Basic peer-to-peer networking and messaging
265
- - **`file_transfer.js`** - File and directory transfer with interactive CLI
266
- - **`gossipsub_chat.js`** - Topic-based chat using GossipSub
267
-
268
- ### Running Examples
269
-
270
207
  ```bash
271
- # Basic client (listens on port 8080)
272
- node examples/basic_client.js
273
-
274
- # Basic client connecting to another peer
208
+ node examples/basic_client.js 8080
275
209
  node examples/basic_client.js 8081 127.0.0.1 8080
276
-
277
- # File transfer client
278
210
  node examples/file_transfer.js 8080
279
-
280
- # GossipSub chat
281
- node examples/gossipsub_chat.js 8080 Alice
211
+ node examples/gossipsub_chat.js 8080 Alice lobby
282
212
  ```
283
213
 
284
214
  ## Testing
285
215
 
286
- Run the test suite:
287
-
288
216
  ```bash
289
217
  npm test
218
+ npm run verify # check a fresh install end-to-end
219
+ LIBRATS_DEBUG=1 node examples/basic_client.js # log which addon was loaded
290
220
  ```
291
221
 
292
- Or run the simple test script:
293
-
294
- ```bash
295
- node test/test.js
296
- ```
297
-
298
- ## Building from Source
299
-
300
- ### Debug Build
301
-
302
- ```bash
303
- npm run build
304
- ```
305
-
306
- ### Clean Build
307
-
308
- ```bash
309
- npm run clean
310
- npm run build
311
- ```
312
-
313
- ## TypeScript Support
314
-
315
- Full TypeScript definitions are included. Import types:
316
-
317
- ```typescript
318
- import { RatsClient, ConnectionStrategy, ErrorCodes, VersionInfo } from 'librats';
319
-
320
- const client: RatsClient = new RatsClient(8080);
321
- client.start();
322
- ```
323
-
324
- ## Error Handling
325
-
326
- Most operations return boolean values indicating success/failure. For detailed error information, check the console output or use the statistics functions:
327
-
328
- ```javascript
329
- const stats = client.getConnectionStatistics();
330
- if (stats) {
331
- const parsed = JSON.parse(stats);
332
- console.log('Connection stats:', parsed);
333
- }
334
- ```
335
-
336
- ## Performance Considerations
337
-
338
- - Use binary messages for large data transfers
339
- - Enable encryption only when needed (adds overhead)
340
- - Monitor file transfer progress for large files
341
- - Use appropriate connection strategies for your network environment
342
-
343
- ## Platform Support
344
-
345
- - **Windows** - Requires Visual Studio Build Tools
346
- - **Linux** - Requires build-essential
347
- - **macOS** - Requires Xcode Command Line Tools
348
- - **Android** - Supported via native Android bindings (separate package)
349
-
350
- ## Contributing
351
-
352
- 1. Fork the repository
353
- 2. Create a feature branch
354
- 3. Make your changes
355
- 4. Add tests for new functionality
356
- 5. Submit a pull request
357
-
358
222
  ## License
359
223
 
360
- This project is licensed under the MIT License - see the LICENSE file for details.
361
-
362
- ## Troubleshooting
363
-
364
- ### Build Issues
365
-
366
- **Windows**: Ensure Visual Studio Build Tools are installed
367
- ```bash
368
- npm install --global windows-build-tools
369
- ```
370
-
371
- **Linux**: Install build dependencies
372
- ```bash
373
- sudo apt install build-essential python3
374
- ```
375
-
376
- **macOS**: Install Xcode Command Line Tools
377
- ```bash
378
- xcode-select --install
379
- ```
380
-
381
- ### Runtime Issues
382
-
383
- **Port already in use**: Choose a different port or kill the process using the port
384
- ```bash
385
- # Find process using port
386
- netstat -tulpn | grep :8080
387
-
388
- # Kill process
389
- kill -9 <pid>
390
- ```
391
-
392
- **Permission denied**: Run with appropriate permissions or use ports > 1024
393
-
394
- **Connection timeout**: Check firewall settings and ensure peers are reachable
395
-
396
- ### Debug Mode
397
-
398
- Enable debug logging by setting environment variable:
399
- ```bash
400
- export LIBRATS_DEBUG=1
401
- node examples/basic_client.js
402
- ```
403
-
404
- ## Support
405
-
406
- - [GitHub Issues](https://github.com/librats/librats/issues)
407
- - [Documentation](https://librats.github.io/)
408
- - [Examples Repository](https://github.com/librats/librats/tree/main/nodejs/examples)
409
-
410
- For more advanced usage, see the [C API documentation](../docs/) and the [main project README](../README.md).
224
+ MIT see [LICENSE](../LICENSE).
package/binding.gyp CHANGED
@@ -8,8 +8,15 @@
8
8
  ],
9
9
  "include_dirs": [
10
10
  "<!@(node -p \"require('node-addon-api').include\")",
11
+ # librats headers. "librats/bindings/rats.h" is the canonical C ABI; it
12
+ # pulls in librats/util/rats_export.h. These paths are the include ROOT
13
+ # (the parent of librats/), matching CMakeLists.txt. native-src/src is
14
+ # used when the package is installed from npm (sources bundled there);
15
+ # ../src in dev.
11
16
  "native-src/src",
12
17
  "../src",
18
+ # Generated headers (version.h, features.h) produced by the CMake build into
19
+ # build-native/src/. Mirrors PROJECT_BINARY_DIR/src in CMakeLists.txt.
13
20
  "build-native/src"
14
21
  ],
15
22
  "dependencies": [
@@ -17,20 +24,26 @@
17
24
  ],
18
25
  "cflags!": [ "-fno-exceptions" ],
19
26
  "cflags_cc!": [ "-fno-exceptions" ],
27
+ "cflags_cc": [ "-std=c++17" ],
20
28
  "xcode_settings": {
21
29
  "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
22
30
  "CLANG_CXX_LIBRARY": "libc++",
23
- "MACOSX_DEPLOYMENT_TARGET": "10.7"
31
+ "CLANG_CXX_LANGUAGE_STANDARD": "c++17",
32
+ "MACOSX_DEPLOYMENT_TARGET": "10.13"
24
33
  },
25
34
  "msvs_settings": {
26
- "VCCLCompilerTool": {
35
+ "VCCLCompilerTool": {
27
36
  "ExceptionHandling": 1,
28
- "RuntimeLibrary": 2
37
+ "RuntimeLibrary": 2,
38
+ "AdditionalOptions": [ "/std:c++17" ]
29
39
  }
30
40
  },
31
41
  "defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
32
42
  "conditions": [
33
43
  ["OS=='win'", {
44
+ # Link the prebuilt static archive produced by scripts/build-librats.js
45
+ # (CMake builds rats.lib with RATS_BINDINGS=ON, so the rats_* C ABI is
46
+ # already inside). Plus the platform networking/crypto libs.
34
47
  "configurations": {
35
48
  "Debug": {
36
49
  "msvs_settings": {