@scriptc/cli-darwin-x64 0.0.0 → 0.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 (960) hide show
  1. package/dist/LICENSE +202 -0
  2. package/dist/THIRD_PARTY_NOTICES +4 -0
  3. package/dist/bin/scriptc +0 -0
  4. package/dist/bin/scriptc.json +21 -0
  5. package/dist/lib/declarations/scriptc-node-fallback.d.ts +3847 -0
  6. package/dist/lib/declarations/scriptc-overrides.d.ts +92 -0
  7. package/dist/lib/declarations/scriptc.d.ts +98 -0
  8. package/dist/lib/llvm/LICENSE +1 -0
  9. package/dist/lib/llvm/SCRIPTC_LICENSE +1 -0
  10. package/dist/lib/llvm/THIRD_PARTY_NOTICES +1 -0
  11. package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
  12. package/dist/lib/llvm/package.json +35 -0
  13. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_array.o +0 -0
  14. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_assert.o +0 -0
  15. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async.o +0 -0
  16. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
  17. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
  18. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint_assert.o +0 -0
  19. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
  20. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
  21. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_child.o +0 -0
  22. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_closure.o +0 -0
  23. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console.o +0 -0
  24. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console_native.o +0 -0
  25. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_copying.o +0 -0
  26. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
  27. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_cycle.o +0 -0
  28. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dc.o +0 -0
  29. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dgram.o +0 -0
  30. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_handle.o +0 -0
  31. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
  32. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_error.o +0 -0
  33. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events.o +0 -0
  34. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events_emitter.o +0 -0
  35. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_exception.o +0 -0
  36. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_fetch.o +0 -0
  37. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_ffi.o +0 -0
  38. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_ffi_queue.o +0 -0
  39. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
  40. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_grapheme.o +0 -0
  41. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http.o +0 -0
  42. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http2.o +0 -0
  43. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_inspect.o +0 -0
  44. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_json.o +0 -0
  45. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_lib.o +0 -0
  46. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_epoll.o +0 -0
  47. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_kqueue.o +0 -0
  48. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_wsapoll.o +0 -0
  49. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_map.o +0 -0
  50. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_net.o +0 -0
  51. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
  52. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_number.o +0 -0
  53. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_object.o +0 -0
  54. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_path.o +0 -0
  55. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_qs.o +0 -0
  56. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_readline.o +0 -0
  57. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_regex.o +0 -0
  58. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_stream.o +0 -0
  59. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_string.o +0 -0
  60. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
  61. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_test.o +0 -0
  62. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_tls.o +0 -0
  63. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_tls_ca.o +0 -0
  64. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_union.o +0 -0
  65. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url.o +0 -0
  66. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url_params.o +0 -0
  67. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_util.o +0 -0
  68. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_watch.o +0 -0
  69. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_zlib.o +0 -0
  70. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
  71. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
  72. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
  73. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
  74. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
  75. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint_assert.o +0 -0
  76. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
  77. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
  78. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_child.o +0 -0
  79. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_closure.o +0 -0
  80. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console.o +0 -0
  81. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console_native.o +0 -0
  82. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_copying.o +0 -0
  83. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
  84. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_cycle.o +0 -0
  85. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dc.o +0 -0
  86. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dgram.o +0 -0
  87. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_handle.o +0 -0
  88. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
  89. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_error.o +0 -0
  90. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
  91. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events_emitter.o +0 -0
  92. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
  93. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_fetch.o +0 -0
  94. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_ffi.o +0 -0
  95. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_ffi_queue.o +0 -0
  96. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
  97. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_grapheme.o +0 -0
  98. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http.o +0 -0
  99. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http2.o +0 -0
  100. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_inspect.o +0 -0
  101. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_inspect_island.o +0 -0
  102. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
  103. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
  104. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
  105. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_epoll.o +0 -0
  106. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_kqueue.o +0 -0
  107. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_wsapoll.o +0 -0
  108. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
  109. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_net.o +0 -0
  110. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_net_island.o +0 -0
  111. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
  112. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_number.o +0 -0
  113. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_object.o +0 -0
  114. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_path.o +0 -0
  115. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_qs.o +0 -0
  116. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_readline.o +0 -0
  117. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
  118. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_stream.o +0 -0
  119. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
  120. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
  121. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_test.o +0 -0
  122. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_tls.o +0 -0
  123. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_tls_ca.o +0 -0
  124. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_union.o +0 -0
  125. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
  126. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url_params.o +0 -0
  127. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_util.o +0 -0
  128. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_watch.o +0 -0
  129. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
  130. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_zlib.o +0 -0
  131. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_zlib_island.o +0 -0
  132. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
  133. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  134. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
  135. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
  136. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
  137. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint_assert.o +0 -0
  138. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
  139. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
  140. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_closure.o +0 -0
  141. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_console.o +0 -0
  142. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_console_native.o +0 -0
  143. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_copying.o +0 -0
  144. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_cycle.o +0 -0
  145. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_handle.o +0 -0
  146. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
  147. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_error.o +0 -0
  148. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_events_emitter.o +0 -0
  149. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
  150. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_grapheme.o +0 -0
  151. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_inspect.o +0 -0
  152. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
  153. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
  154. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_library.o +0 -0
  155. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
  156. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
  157. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_number.o +0 -0
  158. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_object.o +0 -0
  159. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_path.o +0 -0
  160. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
  161. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
  162. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
  163. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_union.o +0 -0
  164. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
  165. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url_params.o +0 -0
  166. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_zlib.o +0 -0
  167. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  168. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_array.o +0 -0
  169. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
  170. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
  171. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint_assert.o +0 -0
  172. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
  173. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
  174. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_closure.o +0 -0
  175. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_console.o +0 -0
  176. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_console_native.o +0 -0
  177. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_copying.o +0 -0
  178. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_cycle.o +0 -0
  179. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_handle.o +0 -0
  180. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
  181. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_error.o +0 -0
  182. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_events_emitter.o +0 -0
  183. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
  184. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_grapheme.o +0 -0
  185. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_inspect.o +0 -0
  186. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_json.o +0 -0
  187. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
  188. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_library.o +0 -0
  189. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_map.o +0 -0
  190. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
  191. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_number.o +0 -0
  192. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_object.o +0 -0
  193. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_path.o +0 -0
  194. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
  195. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_string.o +0 -0
  196. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
  197. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_union.o +0 -0
  198. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url.o +0 -0
  199. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url_params.o +0 -0
  200. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_zlib.o +0 -0
  201. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  202. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
  203. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
  204. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
  205. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint_assert.o +0 -0
  206. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
  207. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
  208. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_closure.o +0 -0
  209. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_console.o +0 -0
  210. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_console_native.o +0 -0
  211. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_copying.o +0 -0
  212. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_cycle.o +0 -0
  213. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_handle.o +0 -0
  214. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
  215. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_error.o +0 -0
  216. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_events_emitter.o +0 -0
  217. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
  218. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_grapheme.o +0 -0
  219. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_inspect.o +0 -0
  220. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
  221. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
  222. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_library.o +0 -0
  223. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
  224. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
  225. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_number.o +0 -0
  226. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_object.o +0 -0
  227. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_path.o +0 -0
  228. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
  229. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
  230. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
  231. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_union.o +0 -0
  232. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
  233. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url_params.o +0 -0
  234. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_zlib.o +0 -0
  235. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  236. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
  237. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
  238. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
  239. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint_assert.o +0 -0
  240. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
  241. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
  242. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_closure.o +0 -0
  243. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_console.o +0 -0
  244. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_console_native.o +0 -0
  245. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_copying.o +0 -0
  246. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_cycle.o +0 -0
  247. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_handle.o +0 -0
  248. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
  249. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_error.o +0 -0
  250. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_events_emitter.o +0 -0
  251. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
  252. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_grapheme.o +0 -0
  253. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_inspect.o +0 -0
  254. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
  255. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
  256. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_library.o +0 -0
  257. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
  258. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
  259. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_number.o +0 -0
  260. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_object.o +0 -0
  261. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_path.o +0 -0
  262. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
  263. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
  264. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
  265. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_union.o +0 -0
  266. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
  267. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url_params.o +0 -0
  268. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_zlib.o +0 -0
  269. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  270. package/dist/lib/runtime-darwin-x64/artifacts/licenses/mbedtls.txt +553 -0
  271. package/dist/lib/runtime-darwin-x64/artifacts/licenses/quickjs-ng.txt +24 -0
  272. package/dist/lib/runtime-darwin-x64/artifacts/licenses/ryu.txt +23 -0
  273. package/dist/lib/runtime-darwin-x64/artifacts/licenses/scriptc-runtime.txt +202 -0
  274. package/dist/lib/runtime-darwin-x64/artifacts/licenses/unicode.txt +39 -0
  275. package/dist/lib/runtime-darwin-x64/artifacts/licenses/zlib.txt +22 -0
  276. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_array.o +0 -0
  277. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_assert.o +0 -0
  278. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async.o +0 -0
  279. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
  280. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint.o +0 -0
  281. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint_assert.o +0 -0
  282. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes.o +0 -0
  283. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
  284. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_child.o +0 -0
  285. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_closure.o +0 -0
  286. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console.o +0 -0
  287. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console_native.o +0 -0
  288. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_copying.o +0 -0
  289. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
  290. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_cycle.o +0 -0
  291. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dc.o +0 -0
  292. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dgram.o +0 -0
  293. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_handle.o +0 -0
  294. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
  295. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_error.o +0 -0
  296. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events.o +0 -0
  297. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events_emitter.o +0 -0
  298. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_exception.o +0 -0
  299. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_fetch.o +0 -0
  300. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_ffi.o +0 -0
  301. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_ffi_queue.o +0 -0
  302. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
  303. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_grapheme.o +0 -0
  304. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http.o +0 -0
  305. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http2.o +0 -0
  306. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_inspect.o +0 -0
  307. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_json.o +0 -0
  308. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_lib.o +0 -0
  309. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_epoll.o +0 -0
  310. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_kqueue.o +0 -0
  311. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_wsapoll.o +0 -0
  312. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_map.o +0 -0
  313. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_net.o +0 -0
  314. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
  315. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_number.o +0 -0
  316. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_object.o +0 -0
  317. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_path.o +0 -0
  318. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_qs.o +0 -0
  319. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_readline.o +0 -0
  320. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_regex.o +0 -0
  321. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_stream.o +0 -0
  322. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_string.o +0 -0
  323. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_symbol.o +0 -0
  324. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_test.o +0 -0
  325. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_tls.o +0 -0
  326. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_tls_ca.o +0 -0
  327. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_union.o +0 -0
  328. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url.o +0 -0
  329. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url_params.o +0 -0
  330. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_util.o +0 -0
  331. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_watch.o +0 -0
  332. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_zlib.o +0 -0
  333. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
  334. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
  335. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
  336. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
  337. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
  338. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint_assert.o +0 -0
  339. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
  340. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
  341. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_child.o +0 -0
  342. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_closure.o +0 -0
  343. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console.o +0 -0
  344. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console_native.o +0 -0
  345. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_copying.o +0 -0
  346. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
  347. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_cycle.o +0 -0
  348. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dc.o +0 -0
  349. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dgram.o +0 -0
  350. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_handle.o +0 -0
  351. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
  352. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_error.o +0 -0
  353. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
  354. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events_emitter.o +0 -0
  355. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
  356. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_fetch.o +0 -0
  357. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_ffi.o +0 -0
  358. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_ffi_queue.o +0 -0
  359. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
  360. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_grapheme.o +0 -0
  361. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http.o +0 -0
  362. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http2.o +0 -0
  363. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_inspect.o +0 -0
  364. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_inspect_island.o +0 -0
  365. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
  366. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
  367. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
  368. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_epoll.o +0 -0
  369. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_kqueue.o +0 -0
  370. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_wsapoll.o +0 -0
  371. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
  372. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_net.o +0 -0
  373. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_net_island.o +0 -0
  374. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
  375. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_number.o +0 -0
  376. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_object.o +0 -0
  377. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_path.o +0 -0
  378. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_qs.o +0 -0
  379. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_readline.o +0 -0
  380. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
  381. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_stream.o +0 -0
  382. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
  383. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
  384. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_test.o +0 -0
  385. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_tls.o +0 -0
  386. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_tls_ca.o +0 -0
  387. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_union.o +0 -0
  388. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
  389. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url_params.o +0 -0
  390. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_util.o +0 -0
  391. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_watch.o +0 -0
  392. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
  393. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_zlib.o +0 -0
  394. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_zlib_island.o +0 -0
  395. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
  396. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  397. package/dist/lib/runtime-darwin-x64/artifacts/vendor/libregexp/libscriptc-libregexp.a +0 -0
  398. package/dist/lib/runtime-darwin-x64/artifacts/vendor/mbedtls/libscriptc-mbedtls.a +0 -0
  399. package/dist/lib/runtime-darwin-x64/artifacts/vendor/quickjs/libscriptc-quickjs.a +0 -0
  400. package/dist/lib/runtime-darwin-x64/artifacts/vendor/zlib/libscriptc-zlib.a +0 -0
  401. package/dist/lib/runtime-darwin-x64/package.json +24 -0
  402. package/dist/lib/runtime-darwin-x64/runtime-pack.json +5758 -0
  403. package/dist/lib/runtime-sources/LICENSE +202 -0
  404. package/dist/lib/runtime-sources/package.json +22 -0
  405. package/dist/lib/runtime-sources/src/scr_array.c +1444 -0
  406. package/dist/lib/runtime-sources/src/scr_assert.c +1537 -0
  407. package/dist/lib/runtime-sources/src/scr_async.c +3920 -0
  408. package/dist/lib/runtime-sources/src/scr_async.test.c +134 -0
  409. package/dist/lib/runtime-sources/src/scr_async.test.ts +34 -0
  410. package/dist/lib/runtime-sources/src/scr_async_dyn.c +803 -0
  411. package/dist/lib/runtime-sources/src/scr_bigint.c +890 -0
  412. package/dist/lib/runtime-sources/src/scr_bigint_assert.c +22 -0
  413. package/dist/lib/runtime-sources/src/scr_bytes.c +2518 -0
  414. package/dist/lib/runtime-sources/src/scr_bytes_io.c +755 -0
  415. package/dist/lib/runtime-sources/src/scr_child.c +5808 -0
  416. package/dist/lib/runtime-sources/src/scr_closure.c +213 -0
  417. package/dist/lib/runtime-sources/src/scr_console.c +259 -0
  418. package/dist/lib/runtime-sources/src/scr_console_native.c +95 -0
  419. package/dist/lib/runtime-sources/src/scr_copying.c +146 -0
  420. package/dist/lib/runtime-sources/src/scr_crypto_async.c +24 -0
  421. package/dist/lib/runtime-sources/src/scr_cycle.c +565 -0
  422. package/dist/lib/runtime-sources/src/scr_dc.c +814 -0
  423. package/dist/lib/runtime-sources/src/scr_dgram.c +1182 -0
  424. package/dist/lib/runtime-sources/src/scr_dyn_handle.c +96 -0
  425. package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +1626 -0
  426. package/dist/lib/runtime-sources/src/scr_error.c +372 -0
  427. package/dist/lib/runtime-sources/src/scr_events.c +1222 -0
  428. package/dist/lib/runtime-sources/src/scr_events_emitter.c +842 -0
  429. package/dist/lib/runtime-sources/src/scr_exception.c +468 -0
  430. package/dist/lib/runtime-sources/src/scr_fetch.c +7215 -0
  431. package/dist/lib/runtime-sources/src/scr_fetch_curl.c +666 -0
  432. package/dist/lib/runtime-sources/src/scr_ffi.c +143 -0
  433. package/dist/lib/runtime-sources/src/scr_ffi_queue.c +379 -0
  434. package/dist/lib/runtime-sources/src/scr_file_handle.c +562 -0
  435. package/dist/lib/runtime-sources/src/scr_grapheme.c +203 -0
  436. package/dist/lib/runtime-sources/src/scr_grapheme_data.h +842 -0
  437. package/dist/lib/runtime-sources/src/scr_http.c +5808 -0
  438. package/dist/lib/runtime-sources/src/scr_http2.c +3243 -0
  439. package/dist/lib/runtime-sources/src/scr_inspect.c +923 -0
  440. package/dist/lib/runtime-sources/src/scr_inspect_island.c +51 -0
  441. package/dist/lib/runtime-sources/src/scr_island.c +9987 -0
  442. package/dist/lib/runtime-sources/src/scr_island_manifest.h +153 -0
  443. package/dist/lib/runtime-sources/src/scr_json.c +7928 -0
  444. package/dist/lib/runtime-sources/src/scr_json.test.c +182 -0
  445. package/dist/lib/runtime-sources/src/scr_json.test.ts +33 -0
  446. package/dist/lib/runtime-sources/src/scr_lib.c +6304 -0
  447. package/dist/lib/runtime-sources/src/scr_library.c +444 -0
  448. package/dist/lib/runtime-sources/src/scr_loop_epoll.c +241 -0
  449. package/dist/lib/runtime-sources/src/scr_loop_kqueue.c +121 -0
  450. package/dist/lib/runtime-sources/src/scr_loop_wsapoll.c +208 -0
  451. package/dist/lib/runtime-sources/src/scr_map.c +705 -0
  452. package/dist/lib/runtime-sources/src/scr_musl.c +438 -0
  453. package/dist/lib/runtime-sources/src/scr_net.c +3708 -0
  454. package/dist/lib/runtime-sources/src/scr_net_island.c +458 -0
  455. package/dist/lib/runtime-sources/src/scr_node_builtin.c +281 -0
  456. package/dist/lib/runtime-sources/src/scr_number.c +192 -0
  457. package/dist/lib/runtime-sources/src/scr_object.c +80 -0
  458. package/dist/lib/runtime-sources/src/scr_path.c +1281 -0
  459. package/dist/lib/runtime-sources/src/scr_platform.h +119 -0
  460. package/dist/lib/runtime-sources/src/scr_qs.c +496 -0
  461. package/dist/lib/runtime-sources/src/scr_readline.c +288 -0
  462. package/dist/lib/runtime-sources/src/scr_regex.c +1274 -0
  463. package/dist/lib/runtime-sources/src/scr_runtime.h +7207 -0
  464. package/dist/lib/runtime-sources/src/scr_stream.c +3149 -0
  465. package/dist/lib/runtime-sources/src/scr_string.c +1849 -0
  466. package/dist/lib/runtime-sources/src/scr_symbol.c +234 -0
  467. package/dist/lib/runtime-sources/src/scr_test.c +662 -0
  468. package/dist/lib/runtime-sources/src/scr_text_decoder_data.h +7389 -0
  469. package/dist/lib/runtime-sources/src/scr_tls.c +1806 -0
  470. package/dist/lib/runtime-sources/src/scr_tls_ca.c +433 -0
  471. package/dist/lib/runtime-sources/src/scr_union.c +105 -0
  472. package/dist/lib/runtime-sources/src/scr_url.c +1231 -0
  473. package/dist/lib/runtime-sources/src/scr_url_internal.h +29 -0
  474. package/dist/lib/runtime-sources/src/scr_url_params.c +526 -0
  475. package/dist/lib/runtime-sources/src/scr_util.c +984 -0
  476. package/dist/lib/runtime-sources/src/scr_watch.c +568 -0
  477. package/dist/lib/runtime-sources/src/scr_web.c +1854 -0
  478. package/dist/lib/runtime-sources/src/scr_win.c +231 -0
  479. package/dist/lib/runtime-sources/src/scr_win_stats.h +23 -0
  480. package/dist/lib/runtime-sources/src/scr_zlib.c +358 -0
  481. package/dist/lib/runtime-sources/src/scr_zlib_island.c +15 -0
  482. package/dist/lib/runtime-sources/vendor/README.md +60 -0
  483. package/dist/lib/runtime-sources/vendor/curl/COPYRIGHT +534 -0
  484. package/dist/lib/runtime-sources/vendor/curl/include/curl/curl.h +3214 -0
  485. package/dist/lib/runtime-sources/vendor/curl/include/curl/curlver.h +79 -0
  486. package/dist/lib/runtime-sources/vendor/curl/include/curl/easy.h +125 -0
  487. package/dist/lib/runtime-sources/vendor/curl/include/curl/header.h +74 -0
  488. package/dist/lib/runtime-sources/vendor/curl/include/curl/mprintf.h +52 -0
  489. package/dist/lib/runtime-sources/vendor/curl/include/curl/multi.h +460 -0
  490. package/dist/lib/runtime-sources/vendor/curl/include/curl/options.h +70 -0
  491. package/dist/lib/runtime-sources/vendor/curl/include/curl/stdcheaders.h +35 -0
  492. package/dist/lib/runtime-sources/vendor/curl/include/curl/system.h +508 -0
  493. package/dist/lib/runtime-sources/vendor/curl/include/curl/typecheck-gcc.h +716 -0
  494. package/dist/lib/runtime-sources/vendor/curl/include/curl/urlapi.h +149 -0
  495. package/dist/lib/runtime-sources/vendor/curl/include/curl/websockets.h +84 -0
  496. package/dist/lib/runtime-sources/vendor/mbedtls/LICENSE +553 -0
  497. package/dist/lib/runtime-sources/vendor/mbedtls/include/CMakeLists.txt +22 -0
  498. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/aes.h +631 -0
  499. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/aria.h +343 -0
  500. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/asn1.h +642 -0
  501. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/asn1write.h +390 -0
  502. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/base64.h +82 -0
  503. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/bignum.h +1088 -0
  504. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/block_cipher.h +76 -0
  505. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/build_info.h +194 -0
  506. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/camellia.h +305 -0
  507. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ccm.h +526 -0
  508. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/chacha20.h +209 -0
  509. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/chachapoly.h +351 -0
  510. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/check_config.h +1149 -0
  511. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/cipher.h +1250 -0
  512. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/cmac.h +246 -0
  513. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/compat-2.x.h +46 -0
  514. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h +578 -0
  515. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_legacy_from_psa.h +873 -0
  516. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_psa_from_legacy.h +359 -0
  517. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_psa_superset_legacy.h +145 -0
  518. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_ssl.h +91 -0
  519. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_x509.h +35 -0
  520. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_psa.h +61 -0
  521. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/constant_time.h +36 -0
  522. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ctr_drbg.h +596 -0
  523. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/debug.h +156 -0
  524. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/des.h +385 -0
  525. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/dhm.h +972 -0
  526. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecdh.h +455 -0
  527. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecdsa.h +674 -0
  528. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecjpake.h +298 -0
  529. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecp.h +1517 -0
  530. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/entropy.h +274 -0
  531. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/error.h +201 -0
  532. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/gcm.h +387 -0
  533. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/hkdf.h +124 -0
  534. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/hmac_drbg.h +434 -0
  535. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/lms.h +440 -0
  536. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/mbedtls_config.h +4446 -0
  537. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/md.h +526 -0
  538. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/md5.h +190 -0
  539. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/memory_buffer_alloc.h +142 -0
  540. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/net_sockets.h +299 -0
  541. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/nist_kw.h +166 -0
  542. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/oid.h +727 -0
  543. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pem.h +160 -0
  544. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pk.h +1303 -0
  545. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs12.h +186 -0
  546. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs5.h +198 -0
  547. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs7.h +252 -0
  548. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform.h +516 -0
  549. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform_time.h +79 -0
  550. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform_util.h +247 -0
  551. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/poly1305.h +168 -0
  552. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/private_access.h +20 -0
  553. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/psa_util.h +207 -0
  554. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ripemd160.h +136 -0
  555. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/rsa.h +1170 -0
  556. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha1.h +219 -0
  557. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha256.h +200 -0
  558. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha3.h +172 -0
  559. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha512.h +208 -0
  560. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl.h +5887 -0
  561. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_cache.h +187 -0
  562. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_ciphersuites.h +482 -0
  563. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_cookie.h +106 -0
  564. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_ticket.h +199 -0
  565. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/threading.h +167 -0
  566. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/timing.h +94 -0
  567. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/version.h +78 -0
  568. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509.h +500 -0
  569. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_crl.h +184 -0
  570. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_crt.h +1208 -0
  571. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_csr.h +382 -0
  572. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/build_info.h +20 -0
  573. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto.h +4998 -0
  574. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_auto_enabled.h +31 -0
  575. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_dependencies.h +51 -0
  576. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_key_pair_types.h +101 -0
  577. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_synonyms.h +49 -0
  578. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_composites.h +214 -0
  579. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_key_derivation.h +118 -0
  580. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_primitives.h +114 -0
  581. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_compat.h +230 -0
  582. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_config.h +145 -0
  583. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_common.h +44 -0
  584. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_composites.h +151 -0
  585. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_key_derivation.h +52 -0
  586. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_primitives.h +105 -0
  587. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_extra.h +2145 -0
  588. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_legacy.h +88 -0
  589. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_platform.h +102 -0
  590. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_se_driver.h +1383 -0
  591. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_sizes.h +1319 -0
  592. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_struct.h +527 -0
  593. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_types.h +508 -0
  594. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_values.h +2782 -0
  595. package/dist/lib/runtime-sources/vendor/mbedtls/library/aes.c +2294 -0
  596. package/dist/lib/runtime-sources/vendor/mbedtls/library/aesce.c +624 -0
  597. package/dist/lib/runtime-sources/vendor/mbedtls/library/aesce.h +136 -0
  598. package/dist/lib/runtime-sources/vendor/mbedtls/library/aesni.c +846 -0
  599. package/dist/lib/runtime-sources/vendor/mbedtls/library/aesni.h +162 -0
  600. package/dist/lib/runtime-sources/vendor/mbedtls/library/alignment.h +704 -0
  601. package/dist/lib/runtime-sources/vendor/mbedtls/library/aria.c +969 -0
  602. package/dist/lib/runtime-sources/vendor/mbedtls/library/asn1parse.c +468 -0
  603. package/dist/lib/runtime-sources/vendor/mbedtls/library/asn1write.c +440 -0
  604. package/dist/lib/runtime-sources/vendor/mbedtls/library/base64.c +322 -0
  605. package/dist/lib/runtime-sources/vendor/mbedtls/library/base64_internal.h +45 -0
  606. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum.c +2583 -0
  607. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core.c +1240 -0
  608. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core.h +872 -0
  609. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core_invasive.h +38 -0
  610. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_internal.h +122 -0
  611. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod.c +394 -0
  612. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod.h +452 -0
  613. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw.c +276 -0
  614. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw.h +416 -0
  615. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw_invasive.h +34 -0
  616. package/dist/lib/runtime-sources/vendor/mbedtls/library/block_cipher.c +207 -0
  617. package/dist/lib/runtime-sources/vendor/mbedtls/library/block_cipher_internal.h +99 -0
  618. package/dist/lib/runtime-sources/vendor/mbedtls/library/bn_mul.h +1094 -0
  619. package/dist/lib/runtime-sources/vendor/mbedtls/library/camellia.c +1058 -0
  620. package/dist/lib/runtime-sources/vendor/mbedtls/library/ccm.c +777 -0
  621. package/dist/lib/runtime-sources/vendor/mbedtls/library/chacha20.c +563 -0
  622. package/dist/lib/runtime-sources/vendor/mbedtls/library/chacha20_internal.h +23 -0
  623. package/dist/lib/runtime-sources/vendor/mbedtls/library/chachapoly.c +487 -0
  624. package/dist/lib/runtime-sources/vendor/mbedtls/library/check_crypto_config.h +136 -0
  625. package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher.c +1712 -0
  626. package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_invasive.h +28 -0
  627. package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_wrap.c +2482 -0
  628. package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_wrap.h +178 -0
  629. package/dist/lib/runtime-sources/vendor/mbedtls/library/cmac.c +1067 -0
  630. package/dist/lib/runtime-sources/vendor/mbedtls/library/common.h +487 -0
  631. package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time.c +247 -0
  632. package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time_impl.h +541 -0
  633. package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time_internal.h +579 -0
  634. package/dist/lib/runtime-sources/vendor/mbedtls/library/ctr.h +35 -0
  635. package/dist/lib/runtime-sources/vendor/mbedtls/library/ctr_drbg.c +1016 -0
  636. package/dist/lib/runtime-sources/vendor/mbedtls/library/debug.c +475 -0
  637. package/dist/lib/runtime-sources/vendor/mbedtls/library/debug_internal.h +185 -0
  638. package/dist/lib/runtime-sources/vendor/mbedtls/library/des.c +1042 -0
  639. package/dist/lib/runtime-sources/vendor/mbedtls/library/dhm.c +700 -0
  640. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecdh.c +696 -0
  641. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecdsa.c +858 -0
  642. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecjpake.c +1216 -0
  643. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp.c +3674 -0
  644. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_curves.c +6125 -0
  645. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_curves_new.c +9 -0
  646. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_internal_alt.h +287 -0
  647. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_invasive.h +305 -0
  648. package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy.c +680 -0
  649. package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy_poll.c +233 -0
  650. package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy_poll.h +64 -0
  651. package/dist/lib/runtime-sources/vendor/mbedtls/library/error.c +878 -0
  652. package/dist/lib/runtime-sources/vendor/mbedtls/library/gcm.c +1330 -0
  653. package/dist/lib/runtime-sources/vendor/mbedtls/library/hkdf.c +161 -0
  654. package/dist/lib/runtime-sources/vendor/mbedtls/library/hmac_drbg.c +633 -0
  655. package/dist/lib/runtime-sources/vendor/mbedtls/library/lmots.c +789 -0
  656. package/dist/lib/runtime-sources/vendor/mbedtls/library/lmots.h +288 -0
  657. package/dist/lib/runtime-sources/vendor/mbedtls/library/lms.c +778 -0
  658. package/dist/lib/runtime-sources/vendor/mbedtls/library/md.c +1108 -0
  659. package/dist/lib/runtime-sources/vendor/mbedtls/library/md5.c +426 -0
  660. package/dist/lib/runtime-sources/vendor/mbedtls/library/md_psa.h +26 -0
  661. package/dist/lib/runtime-sources/vendor/mbedtls/library/md_wrap.h +46 -0
  662. package/dist/lib/runtime-sources/vendor/mbedtls/library/memory_buffer_alloc.c +751 -0
  663. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_common.h +181 -0
  664. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_error.h +89 -0
  665. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_reader.c +538 -0
  666. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_reader.h +366 -0
  667. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_trace.c +112 -0
  668. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_trace.h +154 -0
  669. package/dist/lib/runtime-sources/vendor/mbedtls/library/net_sockets.c +694 -0
  670. package/dist/lib/runtime-sources/vendor/mbedtls/library/nist_kw.c +729 -0
  671. package/dist/lib/runtime-sources/vendor/mbedtls/library/oid.c +1166 -0
  672. package/dist/lib/runtime-sources/vendor/mbedtls/library/padlock.c +157 -0
  673. package/dist/lib/runtime-sources/vendor/mbedtls/library/padlock.h +111 -0
  674. package/dist/lib/runtime-sources/vendor/mbedtls/library/pem.c +554 -0
  675. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk.c +1602 -0
  676. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_ecc.c +261 -0
  677. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_internal.h +241 -0
  678. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_wrap.c +1618 -0
  679. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_wrap.h +138 -0
  680. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs12.c +437 -0
  681. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs5.c +500 -0
  682. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs7.c +787 -0
  683. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkparse.c +1392 -0
  684. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkwrite.c +631 -0
  685. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkwrite.h +121 -0
  686. package/dist/lib/runtime-sources/vendor/mbedtls/library/platform.c +402 -0
  687. package/dist/lib/runtime-sources/vendor/mbedtls/library/platform_util.c +258 -0
  688. package/dist/lib/runtime-sources/vendor/mbedtls/library/poly1305.c +492 -0
  689. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto.c +9532 -0
  690. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_aead.c +646 -0
  691. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_aead.h +499 -0
  692. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_cipher.c +747 -0
  693. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_cipher.h +316 -0
  694. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_client.c +22 -0
  695. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_core.h +983 -0
  696. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_core_common.h +52 -0
  697. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers.h +2896 -0
  698. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.c +256 -0
  699. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.h +31 -0
  700. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ecp.c +594 -0
  701. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ecp.h +267 -0
  702. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ffdh.c +361 -0
  703. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ffdh.h +131 -0
  704. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_hash.c +470 -0
  705. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_hash.h +211 -0
  706. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_invasive.h +92 -0
  707. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_its.h +131 -0
  708. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_mac.c +505 -0
  709. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_mac.h +264 -0
  710. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_pake.c +571 -0
  711. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_pake.h +159 -0
  712. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random.c +181 -0
  713. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random.h +72 -0
  714. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random_impl.h +200 -0
  715. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_rsa.c +714 -0
  716. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_rsa.h +321 -0
  717. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_se.c +373 -0
  718. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_se.h +192 -0
  719. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_slot_management.c +1137 -0
  720. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_slot_management.h +344 -0
  721. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_storage.c +481 -0
  722. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_storage.h +392 -0
  723. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_its_file.c +254 -0
  724. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_util.c +614 -0
  725. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_util_internal.h +100 -0
  726. package/dist/lib/runtime-sources/vendor/mbedtls/library/ripemd160.c +490 -0
  727. package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa.c +3121 -0
  728. package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_alt_helpers.c +455 -0
  729. package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_alt_helpers.h +209 -0
  730. package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_internal.h +188 -0
  731. package/dist/lib/runtime-sources/vendor/mbedtls/library/sha1.c +480 -0
  732. package/dist/lib/runtime-sources/vendor/mbedtls/library/sha256.c +983 -0
  733. package/dist/lib/runtime-sources/vendor/mbedtls/library/sha3.c +721 -0
  734. package/dist/lib/runtime-sources/vendor/mbedtls/library/sha512.c +1115 -0
  735. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_cache.c +410 -0
  736. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ciphersuites.c +2050 -0
  737. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ciphersuites_internal.h +154 -0
  738. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_client.c +1023 -0
  739. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_client.h +22 -0
  740. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_cookie.c +384 -0
  741. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_debug_helpers.h +85 -0
  742. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_debug_helpers_generated.c +251 -0
  743. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_misc.h +3198 -0
  744. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_msg.c +6619 -0
  745. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ticket.c +556 -0
  746. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls.c +10234 -0
  747. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls12_client.c +3688 -0
  748. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls12_server.c +4311 -0
  749. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_client.c +3208 -0
  750. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_generic.c +1793 -0
  751. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_invasive.h +23 -0
  752. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_keys.c +1918 -0
  753. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_keys.h +668 -0
  754. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_server.c +3624 -0
  755. package/dist/lib/runtime-sources/vendor/mbedtls/library/threading.c +193 -0
  756. package/dist/lib/runtime-sources/vendor/mbedtls/library/threading_internal.h +28 -0
  757. package/dist/lib/runtime-sources/vendor/mbedtls/library/timing.c +152 -0
  758. package/dist/lib/runtime-sources/vendor/mbedtls/library/version.c +32 -0
  759. package/dist/lib/runtime-sources/vendor/mbedtls/library/version_features.c +856 -0
  760. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509.c +1776 -0
  761. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_create.c +570 -0
  762. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_crl.c +708 -0
  763. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_crt.c +3311 -0
  764. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_csr.c +648 -0
  765. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_internal.h +101 -0
  766. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write.c +174 -0
  767. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write_crt.c +688 -0
  768. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write_csr.c +336 -0
  769. package/dist/lib/runtime-sources/vendor/quickjs-ng/CMakeLists.txt +566 -0
  770. package/dist/lib/runtime-sources/vendor/quickjs-ng/LICENSE +24 -0
  771. package/dist/lib/runtime-sources/vendor/quickjs-ng/README.md +24 -0
  772. package/dist/lib/runtime-sources/vendor/quickjs-ng/api-test.c +1195 -0
  773. package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
  774. package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
  775. package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
  776. package/dist/lib/runtime-sources/vendor/quickjs-ng/cutils.h +1998 -0
  777. package/dist/lib/runtime-sources/vendor/quickjs-ng/dtoa.c +1619 -0
  778. package/dist/lib/runtime-sources/vendor/quickjs-ng/dtoa.h +87 -0
  779. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/function_source.c +81 -0
  780. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/hello.c +53 -0
  781. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/hello_module.c +106 -0
  782. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/repl.c +3036 -0
  783. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/standalone.c +323 -0
  784. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/test_fib.c +81 -0
  785. package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp-opcode.h +73 -0
  786. package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp.c +3474 -0
  787. package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp.h +101 -0
  788. package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode-table.h +5173 -0
  789. package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode.c +2069 -0
  790. package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode.h +172 -0
  791. package/dist/lib/runtime-sources/vendor/quickjs-ng/list.h +107 -0
  792. package/dist/lib/runtime-sources/vendor/quickjs-ng/lre-test.c +52 -0
  793. package/dist/lib/runtime-sources/vendor/quickjs-ng/qjs.c +762 -0
  794. package/dist/lib/runtime-sources/vendor/quickjs-ng/qjsc.c +673 -0
  795. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-atom.h +280 -0
  796. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
  797. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-libc.c +5037 -0
  798. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-libc.h +87 -0
  799. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-opcode.h +377 -0
  800. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs.c +64041 -0
  801. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs.h +1447 -0
  802. package/dist/lib/runtime-sources/vendor/quickjs-ng/run-test262.c +2374 -0
  803. package/dist/lib/runtime-sources/vendor/quickjs-ng/unicode_gen.c +3121 -0
  804. package/dist/lib/runtime-sources/vendor/quickjs-ng/unicode_gen_def.h +310 -0
  805. package/dist/lib/runtime-sources/vendor/ryu/LICENSE-Boost +23 -0
  806. package/dist/lib/runtime-sources/vendor/ryu/common.h +114 -0
  807. package/dist/lib/runtime-sources/vendor/ryu/d2s.c +509 -0
  808. package/dist/lib/runtime-sources/vendor/ryu/d2s_full_table.h +367 -0
  809. package/dist/lib/runtime-sources/vendor/ryu/d2s_intrinsics.h +357 -0
  810. package/dist/lib/runtime-sources/vendor/ryu/d2s_small_table.h +186 -0
  811. package/dist/lib/runtime-sources/vendor/ryu/digit_table.h +35 -0
  812. package/dist/lib/runtime-sources/vendor/ryu/ryu.h +46 -0
  813. package/dist/lib/runtime-sources/vendor/unicode/LICENSE +39 -0
  814. package/dist/lib/runtime-sources/vendor/zlib/LICENSE +22 -0
  815. package/dist/lib/runtime-sources/vendor/zlib/adler32.c +164 -0
  816. package/dist/lib/runtime-sources/vendor/zlib/compress.c +75 -0
  817. package/dist/lib/runtime-sources/vendor/zlib/crc32.c +1049 -0
  818. package/dist/lib/runtime-sources/vendor/zlib/crc32.h +9446 -0
  819. package/dist/lib/runtime-sources/vendor/zlib/deflate.c +2139 -0
  820. package/dist/lib/runtime-sources/vendor/zlib/deflate.h +377 -0
  821. package/dist/lib/runtime-sources/vendor/zlib/gzclose.c +23 -0
  822. package/dist/lib/runtime-sources/vendor/zlib/gzguts.h +214 -0
  823. package/dist/lib/runtime-sources/vendor/zlib/gzlib.c +582 -0
  824. package/dist/lib/runtime-sources/vendor/zlib/gzread.c +602 -0
  825. package/dist/lib/runtime-sources/vendor/zlib/gzwrite.c +631 -0
  826. package/dist/lib/runtime-sources/vendor/zlib/infback.c +628 -0
  827. package/dist/lib/runtime-sources/vendor/zlib/inffast.c +320 -0
  828. package/dist/lib/runtime-sources/vendor/zlib/inffast.h +11 -0
  829. package/dist/lib/runtime-sources/vendor/zlib/inffixed.h +94 -0
  830. package/dist/lib/runtime-sources/vendor/zlib/inflate.c +1526 -0
  831. package/dist/lib/runtime-sources/vendor/zlib/inflate.h +126 -0
  832. package/dist/lib/runtime-sources/vendor/zlib/inftrees.c +299 -0
  833. package/dist/lib/runtime-sources/vendor/zlib/inftrees.h +62 -0
  834. package/dist/lib/runtime-sources/vendor/zlib/trees.c +1117 -0
  835. package/dist/lib/runtime-sources/vendor/zlib/trees.h +128 -0
  836. package/dist/lib/runtime-sources/vendor/zlib/uncompr.c +85 -0
  837. package/dist/lib/runtime-sources/vendor/zlib/zconf.h +543 -0
  838. package/dist/lib/runtime-sources/vendor/zlib/zlib.h +1938 -0
  839. package/dist/lib/runtime-sources/vendor/zlib/zutil.c +299 -0
  840. package/dist/lib/runtime-sources/vendor/zlib/zutil.h +254 -0
  841. package/dist/lib/scriptc-comptime +0 -0
  842. package/dist/lib/typescript/LICENSE +55 -0
  843. package/dist/lib/typescript/NOTICE.txt +436 -0
  844. package/dist/lib/typescript/lib/lib.d.ts +20 -0
  845. package/dist/lib/typescript/lib/lib.decorators.d.ts +382 -0
  846. package/dist/lib/typescript/lib/lib.decorators.legacy.d.ts +20 -0
  847. package/dist/lib/typescript/lib/lib.dom.asynciterable.d.ts +18 -0
  848. package/dist/lib/typescript/lib/lib.dom.d.ts +45125 -0
  849. package/dist/lib/typescript/lib/lib.dom.iterable.d.ts +18 -0
  850. package/dist/lib/typescript/lib/lib.es2015.collection.d.ts +159 -0
  851. package/dist/lib/typescript/lib/lib.es2015.core.d.ts +595 -0
  852. package/dist/lib/typescript/lib/lib.es2015.d.ts +26 -0
  853. package/dist/lib/typescript/lib/lib.es2015.generator.d.ts +75 -0
  854. package/dist/lib/typescript/lib/lib.es2015.iterable.d.ts +603 -0
  855. package/dist/lib/typescript/lib/lib.es2015.promise.d.ts +79 -0
  856. package/dist/lib/typescript/lib/lib.es2015.proxy.d.ts +126 -0
  857. package/dist/lib/typescript/lib/lib.es2015.reflect.d.ts +142 -0
  858. package/dist/lib/typescript/lib/lib.es2015.symbol.d.ts +44 -0
  859. package/dist/lib/typescript/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  860. package/dist/lib/typescript/lib/lib.es2016.array.include.d.ts +114 -0
  861. package/dist/lib/typescript/lib/lib.es2016.d.ts +19 -0
  862. package/dist/lib/typescript/lib/lib.es2016.full.d.ts +21 -0
  863. package/dist/lib/typescript/lib/lib.es2016.intl.d.ts +29 -0
  864. package/dist/lib/typescript/lib/lib.es2017.arraybuffer.d.ts +19 -0
  865. package/dist/lib/typescript/lib/lib.es2017.d.ts +24 -0
  866. package/dist/lib/typescript/lib/lib.es2017.date.d.ts +29 -0
  867. package/dist/lib/typescript/lib/lib.es2017.full.d.ts +21 -0
  868. package/dist/lib/typescript/lib/lib.es2017.intl.d.ts +42 -0
  869. package/dist/lib/typescript/lib/lib.es2017.object.d.ts +47 -0
  870. package/dist/lib/typescript/lib/lib.es2017.sharedmemory.d.ts +133 -0
  871. package/dist/lib/typescript/lib/lib.es2017.string.d.ts +47 -0
  872. package/dist/lib/typescript/lib/lib.es2017.typedarrays.d.ts +51 -0
  873. package/dist/lib/typescript/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  874. package/dist/lib/typescript/lib/lib.es2018.asynciterable.d.ts +51 -0
  875. package/dist/lib/typescript/lib/lib.es2018.d.ts +22 -0
  876. package/dist/lib/typescript/lib/lib.es2018.full.d.ts +22 -0
  877. package/dist/lib/typescript/lib/lib.es2018.intl.d.ts +81 -0
  878. package/dist/lib/typescript/lib/lib.es2018.promise.d.ts +28 -0
  879. package/dist/lib/typescript/lib/lib.es2018.regexp.d.ts +35 -0
  880. package/dist/lib/typescript/lib/lib.es2019.array.d.ts +77 -0
  881. package/dist/lib/typescript/lib/lib.es2019.d.ts +22 -0
  882. package/dist/lib/typescript/lib/lib.es2019.full.d.ts +22 -0
  883. package/dist/lib/typescript/lib/lib.es2019.intl.d.ts +21 -0
  884. package/dist/lib/typescript/lib/lib.es2019.object.d.ts +31 -0
  885. package/dist/lib/typescript/lib/lib.es2019.string.d.ts +35 -0
  886. package/dist/lib/typescript/lib/lib.es2019.symbol.d.ts +22 -0
  887. package/dist/lib/typescript/lib/lib.es2020.bigint.d.ts +763 -0
  888. package/dist/lib/typescript/lib/lib.es2020.d.ts +25 -0
  889. package/dist/lib/typescript/lib/lib.es2020.date.d.ts +40 -0
  890. package/dist/lib/typescript/lib/lib.es2020.full.d.ts +22 -0
  891. package/dist/lib/typescript/lib/lib.es2020.intl.d.ts +472 -0
  892. package/dist/lib/typescript/lib/lib.es2020.number.d.ts +26 -0
  893. package/dist/lib/typescript/lib/lib.es2020.promise.d.ts +45 -0
  894. package/dist/lib/typescript/lib/lib.es2020.sharedmemory.d.ts +97 -0
  895. package/dist/lib/typescript/lib/lib.es2020.string.d.ts +42 -0
  896. package/dist/lib/typescript/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  897. package/dist/lib/typescript/lib/lib.es2021.d.ts +21 -0
  898. package/dist/lib/typescript/lib/lib.es2021.full.d.ts +22 -0
  899. package/dist/lib/typescript/lib/lib.es2021.intl.d.ts +164 -0
  900. package/dist/lib/typescript/lib/lib.es2021.promise.d.ts +46 -0
  901. package/dist/lib/typescript/lib/lib.es2021.string.d.ts +31 -0
  902. package/dist/lib/typescript/lib/lib.es2021.weakref.d.ts +76 -0
  903. package/dist/lib/typescript/lib/lib.es2022.array.d.ts +119 -0
  904. package/dist/lib/typescript/lib/lib.es2022.d.ts +23 -0
  905. package/dist/lib/typescript/lib/lib.es2022.error.d.ts +73 -0
  906. package/dist/lib/typescript/lib/lib.es2022.full.d.ts +22 -0
  907. package/dist/lib/typescript/lib/lib.es2022.intl.d.ts +143 -0
  908. package/dist/lib/typescript/lib/lib.es2022.object.d.ts +24 -0
  909. package/dist/lib/typescript/lib/lib.es2022.regexp.d.ts +37 -0
  910. package/dist/lib/typescript/lib/lib.es2022.string.d.ts +23 -0
  911. package/dist/lib/typescript/lib/lib.es2023.array.d.ts +922 -0
  912. package/dist/lib/typescript/lib/lib.es2023.collection.d.ts +19 -0
  913. package/dist/lib/typescript/lib/lib.es2023.d.ts +20 -0
  914. package/dist/lib/typescript/lib/lib.es2023.full.d.ts +22 -0
  915. package/dist/lib/typescript/lib/lib.es2023.intl.d.ts +62 -0
  916. package/dist/lib/typescript/lib/lib.es2024.arraybuffer.d.ts +63 -0
  917. package/dist/lib/typescript/lib/lib.es2024.collection.d.ts +27 -0
  918. package/dist/lib/typescript/lib/lib.es2024.d.ts +24 -0
  919. package/dist/lib/typescript/lib/lib.es2024.full.d.ts +22 -0
  920. package/dist/lib/typescript/lib/lib.es2024.object.d.ts +27 -0
  921. package/dist/lib/typescript/lib/lib.es2024.promise.d.ts +33 -0
  922. package/dist/lib/typescript/lib/lib.es2024.regexp.d.ts +23 -0
  923. package/dist/lib/typescript/lib/lib.es2024.sharedmemory.d.ts +66 -0
  924. package/dist/lib/typescript/lib/lib.es2024.string.d.ts +27 -0
  925. package/dist/lib/typescript/lib/lib.es2025.collection.d.ts +94 -0
  926. package/dist/lib/typescript/lib/lib.es2025.d.ts +23 -0
  927. package/dist/lib/typescript/lib/lib.es2025.float16.d.ts +443 -0
  928. package/dist/lib/typescript/lib/lib.es2025.full.d.ts +22 -0
  929. package/dist/lib/typescript/lib/lib.es2025.intl.d.ts +200 -0
  930. package/dist/lib/typescript/lib/lib.es2025.iterator.d.ts +146 -0
  931. package/dist/lib/typescript/lib/lib.es2025.promise.d.ts +32 -0
  932. package/dist/lib/typescript/lib/lib.es2025.regexp.d.ts +30 -0
  933. package/dist/lib/typescript/lib/lib.es5.d.ts +4599 -0
  934. package/dist/lib/typescript/lib/lib.es6.d.ts +21 -0
  935. package/dist/lib/typescript/lib/lib.esnext.array.d.ts +33 -0
  936. package/dist/lib/typescript/lib/lib.esnext.collection.d.ts +47 -0
  937. package/dist/lib/typescript/lib/lib.esnext.d.ts +27 -0
  938. package/dist/lib/typescript/lib/lib.esnext.date.d.ts +21 -0
  939. package/dist/lib/typescript/lib/lib.esnext.decorators.d.ts +26 -0
  940. package/dist/lib/typescript/lib/lib.esnext.disposable.d.ts +191 -0
  941. package/dist/lib/typescript/lib/lib.esnext.error.d.ts +22 -0
  942. package/dist/lib/typescript/lib/lib.esnext.full.d.ts +22 -0
  943. package/dist/lib/typescript/lib/lib.esnext.intl.d.ts +107 -0
  944. package/dist/lib/typescript/lib/lib.esnext.sharedmemory.d.ts +23 -0
  945. package/dist/lib/typescript/lib/lib.esnext.temporal.d.ts +485 -0
  946. package/dist/lib/typescript/lib/lib.esnext.typedarrays.d.ts +90 -0
  947. package/dist/lib/typescript/lib/lib.scripthost.d.ts +320 -0
  948. package/dist/lib/typescript/lib/lib.webworker.asynciterable.d.ts +18 -0
  949. package/dist/lib/typescript/lib/lib.webworker.d.ts +15606 -0
  950. package/dist/lib/typescript/lib/lib.webworker.importscripts.d.ts +21 -0
  951. package/dist/lib/typescript/lib/lib.webworker.iterable.d.ts +18 -0
  952. package/dist/lib/typescript/lib/tsc +0 -0
  953. package/dist/lib/typescript/package.json +45 -0
  954. package/dist/lib/wasi/cli/wasi-paths.js +41 -0
  955. package/dist/lib/wasi/cli/wasi-runner.js +28 -0
  956. package/dist/lib/wasi/package.json +1 -0
  957. package/dist/lib/wasi/wasi-paths.js +25 -0
  958. package/package.json +22 -6
  959. package/README.md +0 -3
  960. package/index.js +0 -2
@@ -0,0 +1,1806 @@
1
+ /* node:tls + node:https — the TLS transport under the socket kind,
2
+ * layered exactly the way scr_http.c layers on scr_net.c: the socket
3
+ * surface (ScrNetSocket, and the http req/res/client handles above it)
4
+ * is unchanged, and this unit plugs the ScrNetTransportOps table into
5
+ * the socket so reads decrypt, writes encrypt, and readiness drives the
6
+ * handshake. Link-gated like every optional unit: TLS-free binaries
7
+ * never compile this file or the vendored library.
8
+ *
9
+ * ── Design note (the TLS provider decision) ──────────────────────────
10
+ *
11
+ * The provider is VENDORED mbedTLS (3.6 LTS, Apache-2.0, ~1.2MB
12
+ * archive, see vendor/README.md). The alternatives and why they lost:
13
+ *
14
+ * - Security.framework / SecureTransport: zero vendoring and present on
15
+ * every macOS, but (a) deprecated since 10.15 with no non-deprecated
16
+ * replacement below Network.framework's connection model, (b) macOS-
17
+ * only — the queued Linux port would need a second backend behind the
18
+ * same ops table, and (c) DISQUALIFYING for this program: a server
19
+ * identity must be a SecIdentity, which public API only mints through
20
+ * a keychain import — portless mints per-hostname cert/key PEM FILES
21
+ * with openssl and loads them headlessly; a temp-keychain dance per
22
+ * certificate is exactly the fragility this compiler avoids.
23
+ * - BoringSSL: no releases/versioning to pin, a CMake+Go build, and an
24
+ * order of magnitude more code than the slice needs.
25
+ * - LibreSSL libtls: the cleanest API of the four, but macOS ships no
26
+ * linkable libtls (the system LibreSSL is the CLI only) — it would be
27
+ * a brew dependency whose availability varies, weaker than the
28
+ * libcurl precedent (libcurl is a macOS SYSTEM library).
29
+ *
30
+ * mbedTLS wins on the two axes that matter here: PEM cert/key/CA
31
+ * loading is first-class (mbedtls_x509_crt_parse / pk_parse_key over
32
+ * bytes — the portless local-CA flow needs nothing else), and the same
33
+ * vendored tree compiles unchanged on Linux, so the port pays zero
34
+ * extra. It builds as plain C11 with the stock config (no generator
35
+ * scripts, no CMake — the libregexp cache precedent), and its
36
+ * nonblocking BIO contract (WANT_READ/WANT_WRITE) maps 1:1 onto the
37
+ * kqueue readiness loop. Migration cost if ever needed: everything
38
+ * mbedTLS-specific lives behind ScrNetTransportOps in this one file.
39
+ *
40
+ * ── The wiring ────────────────────────────────────────────────────────
41
+ *
42
+ * Server: tls.createServer(cert, key, handler) is an ordinary
43
+ * ScrNetServer whose native-connection hook installs the transport on
44
+ * each accepted socket and whose 'connection' listeners are DEFERRED to
45
+ * handshake completion — the handler is Node's 'secureConnection', fired
46
+ * with a socket that then behaves exactly like a net socket.
47
+ * https.createServer is scr_http_create_server with its parser hook
48
+ * WRAPPED: the TLS hook installs the transport first and attaches the
49
+ * http parser from on_established, so the parser only ever sees
50
+ * plaintext. Handshake failures on the server side tear the socket down
51
+ * SILENTLY — Node's default for 'tlsClientError' with no listener, which
52
+ * is what portless observes (it registers none).
53
+ *
54
+ * Client: https.request is scr_http_request_ex with a wrap hook that
55
+ * installs a client transport on the freshly dialed socket; the request
56
+ * head buffers in the socket's write buffer until the handshake
57
+ * establishes (the mid-connect buffering path, reused verbatim).
58
+ * rejectUnauthorized:false maps to VERIFY_NONE; `ca` replaces the trust
59
+ * anchors; with neither, the host trust store stands in for Node's bundled
60
+ * Mozilla roots (SEMANTICS.md documents the divergence). Verify
61
+ * failures surface as Node-shaped 'error' messages on the request
62
+ * ("self-signed certificate", "self-signed certificate in certificate
63
+ * chain", "unable to verify the first certificate", "certificate has
64
+ * expired") through the socket's pending-error sweep — then 'close',
65
+ * Node's order, exactly like ECONNREFUSED.
66
+ *
67
+ * Bounds (SEMANTICS.md divergence 55): no session resumption or
68
+ * tickets, no renegotiation/post-handshake auth, no client
69
+ * certificates, hostname verification is skipped for IP-literal peers
70
+ * (mbedTLS has no IP-SAN matching in 3.6), and non-verify client
71
+ * handshake failures carry a generic message where Node prints an
72
+ * OpenSSL one. */
73
+ #include "scr_runtime.h"
74
+
75
+ #include <errno.h>
76
+ #include <math.h>
77
+ #include <stdio.h>
78
+ #include <stdlib.h>
79
+ #include <string.h>
80
+ #include <unistd.h>
81
+ #ifdef _WIN32
82
+ #include <winsock2.h>
83
+ #include <ws2tcpip.h> /* inet_pton, in6_addr */
84
+ #else
85
+ #include <arpa/inet.h>
86
+ #endif
87
+
88
+ #include "mbedtls/ctr_drbg.h"
89
+ #include "mbedtls/entropy.h"
90
+ #include "mbedtls/error.h"
91
+ #include "mbedtls/net_sockets.h" /* the MBEDTLS_ERR_NET_* codes the BIOs answer */
92
+ #include "mbedtls/pk.h"
93
+ #include "mbedtls/ssl.h"
94
+ #include "mbedtls/x509_crt.h"
95
+
96
+ static void scr_tls_oom(void) {
97
+ fputs("scriptc: out of memory\n", stderr);
98
+ abort();
99
+ }
100
+
101
+ #ifdef _WIN32
102
+ /* ── the winsock arm (scr_net.c's respelling, the two calls this unit
103
+ * makes) ──────────────────────────────────────────────────────────────
104
+ * The BIOs and the SNI pre-parse do raw fd I/O beside the socket's own
105
+ * transport plumbing, so the same one-time respelling applies: socket
106
+ * reads are recv, writes are send (ReadFile/_read do not apply to
107
+ * winsock handles), and failures land their WSA code in errno TRANSLATED
108
+ * to the POSIX constant the call sites test. WSAECONNABORTED joins the
109
+ * reset arm deliberately: at the TLS layer both spell "the peer died",
110
+ * and the reset arms (CONN_RESET → silent server teardown / the client's
111
+ * socket-hang-up classification) are Node's rendering for each. Winsock
112
+ * is already started whenever this unit runs — every TLS socket is an
113
+ * ScrNetSocket, and scr_net.c initializes the poller (WSAStartup) before
114
+ * any socket exists. */
115
+ static int scr_tls_w32_map_err(int e) {
116
+ switch (e) {
117
+ case WSAEWOULDBLOCK: return EAGAIN;
118
+ case WSAEINTR: return EINTR;
119
+ case WSAECONNRESET: return ECONNRESET;
120
+ case WSAECONNABORTED: return ECONNRESET;
121
+ case WSAESHUTDOWN: return EPIPE; /* libuv's map: send-after-shutdown is EPIPE */
122
+ default: return e;
123
+ }
124
+ }
125
+
126
+ static ssize_t scr_tls_w32_read(int fd, void *buf, size_t len) {
127
+ int n = recv((SOCKET)fd, (char *)buf, len > 0x40000000 ? 0x40000000 : (int)len, 0);
128
+ if (n < 0) errno = scr_tls_w32_map_err((int)WSAGetLastError());
129
+ return n;
130
+ }
131
+
132
+ static ssize_t scr_tls_w32_write(int fd, const void *buf, size_t len) {
133
+ int n = send((SOCKET)fd, (const char *)buf, len > 0x40000000 ? 0x40000000 : (int)len, 0);
134
+ if (n < 0) errno = scr_tls_w32_map_err((int)WSAGetLastError());
135
+ return n;
136
+ }
137
+
138
+ #define read(fd, buf, len) scr_tls_w32_read((fd), (buf), (len))
139
+ #define write(fd, buf, len) scr_tls_w32_write((fd), (buf), (len))
140
+ #endif /* _WIN32 */
141
+
142
+ /* ── the unit RNG (one CTR_DRBG, lazily seeded) ──────────────────────── */
143
+
144
+ static mbedtls_entropy_context scr_tls_entropy;
145
+ static mbedtls_ctr_drbg_context scr_tls_drbg;
146
+ static bool scr_tls_rng_ready = false;
147
+
148
+ /* Defined with the dyn-member hooks at the tail of this file; registered
149
+ * from rng_init so every TLS entry point installs the TLSSocket member
150
+ * dispatch before any TLS socket can reach a dyn binding. */
151
+ static const ScrNetDynhTlsHooks SCR_TLS_DYNH;
152
+
153
+ static void scr_tls_rng_init(void) {
154
+ if (scr_tls_rng_ready) return;
155
+ mbedtls_entropy_init(&scr_tls_entropy);
156
+ mbedtls_ctr_drbg_init(&scr_tls_drbg);
157
+ if (mbedtls_ctr_drbg_seed(&scr_tls_drbg, mbedtls_entropy_func, &scr_tls_entropy,
158
+ (const unsigned char *)"scriptc-tls", 11) != 0) {
159
+ fputs("scriptc: tls: RNG seeding failed\n", stderr);
160
+ abort();
161
+ }
162
+ scr_net_set_dynh_tls(&SCR_TLS_DYNH);
163
+ scr_tls_rng_ready = true;
164
+ }
165
+
166
+ /* PEM parsers want a NUL-terminated buffer with the NUL counted. */
167
+ static int scr_tls_parse_crt(mbedtls_x509_crt *crt, const char *pem, size_t len) {
168
+ unsigned char *buf = malloc(len + 1);
169
+ if (!buf) scr_tls_oom();
170
+ memcpy(buf, pem, len);
171
+ buf[len] = 0;
172
+ int r = mbedtls_x509_crt_parse(crt, buf, len + 1);
173
+ free(buf);
174
+ return r;
175
+ }
176
+
177
+ static int scr_tls_parse_key(mbedtls_pk_context *pk, const char *pem, size_t len) {
178
+ unsigned char *buf = malloc(len + 1);
179
+ if (!buf) scr_tls_oom();
180
+ memcpy(buf, pem, len);
181
+ buf[len] = 0;
182
+ int r = mbedtls_pk_parse_key(pk, buf, len + 1, NULL, 0, mbedtls_ctr_drbg_random,
183
+ &scr_tls_drbg);
184
+ free(buf);
185
+ return r;
186
+ }
187
+
188
+ /* Bad cert/key material is a construction-time crash in Node (createServer
189
+ * throws); this runtime's shape for it is the print-and-die trap. */
190
+ static void scr_tls_bad_material(const char *what, int err) {
191
+ char detail[128];
192
+ mbedtls_strerror(err, detail, sizeof detail);
193
+ fflush(stdout);
194
+ fprintf(stderr, "scriptc: tls: failed to parse %s (%s)\n", what, detail);
195
+ _Exit(1);
196
+ }
197
+
198
+ /* ── SecureContext (tls.createSecureContext) ─────────────────────────── */
199
+
200
+ /* An opaque refcounted parsed cert/key pair — what an SNI callback
201
+ * answers with; the handshake serves it via mbedtls_ssl_set_hs_own_cert. */
202
+ struct ScrSecureCtx {
203
+ size_t rc;
204
+ mbedtls_x509_crt cert;
205
+ mbedtls_pk_context pk;
206
+ };
207
+
208
+ #ifdef SCR_RC_AUDIT
209
+ static long scr_live_secure_ctx = 0;
210
+ long scr_secure_ctx_live_count(void) { return scr_live_secure_ctx; }
211
+ #endif
212
+
213
+ ScrSecureCtx *scr_tls_create_secure_context(const char *cert, size_t cert_len,
214
+ const char *key, size_t key_len) {
215
+ scr_tls_rng_init();
216
+ ScrSecureCtx *c = calloc(1, sizeof *c);
217
+ if (!c) scr_tls_oom();
218
+ c->rc = 1;
219
+ mbedtls_x509_crt_init(&c->cert);
220
+ mbedtls_pk_init(&c->pk);
221
+ int r = scr_tls_parse_crt(&c->cert, cert, cert_len);
222
+ if (r != 0) scr_tls_bad_material("certificate", r);
223
+ r = scr_tls_parse_key(&c->pk, key, key_len);
224
+ if (r != 0) scr_tls_bad_material("private key", r);
225
+ #ifdef SCR_RC_AUDIT
226
+ scr_live_secure_ctx++;
227
+ #endif
228
+ return c;
229
+ }
230
+
231
+ ScrSecureCtx *scr_secure_ctx_retain(ScrSecureCtx *c) {
232
+ if (c) c->rc++;
233
+ return c;
234
+ }
235
+
236
+ void scr_secure_ctx_release(ScrSecureCtx *c) {
237
+ if (!c || --c->rc != 0) return;
238
+ mbedtls_x509_crt_free(&c->cert);
239
+ mbedtls_pk_free(&c->pk);
240
+ free(c);
241
+ #ifdef SCR_RC_AUDIT
242
+ scr_live_secure_ctx--;
243
+ #endif
244
+ }
245
+
246
+ void *scr_secure_ctx_retain_v(void *p) { return scr_secure_ctx_retain((ScrSecureCtx *)p); }
247
+ void scr_secure_ctx_release_v(void *p) { scr_secure_ctx_release((ScrSecureCtx *)p); }
248
+
249
+ /* ── the server config (one per created server, rc'd) ────────────────── */
250
+
251
+ typedef struct ScrTlsSrv {
252
+ size_t rc;
253
+ mbedtls_ssl_config conf;
254
+ mbedtls_x509_crt cert;
255
+ mbedtls_pk_context pk;
256
+ /* https: the wrapped http-parser connection hook, attached from
257
+ * on_established so it only ever sees plaintext */
258
+ ScrNetNativeConnFn inner_conn;
259
+ void *inner_ctx;
260
+ void (*inner_ctx_free)(void *);
261
+ /* h2 over TLS (http2.createSecureServer): the h2 session attach —
262
+ * on_established dispatches on the NEGOTIATED protocol (h2 → this
263
+ * hook; http/1.1 → inner_conn; no answer → teardown). */
264
+ ScrNetNativeConnFn h2_conn;
265
+ void *h2_ctx;
266
+ void (*h2_ctx_free)(void *);
267
+ /* SNI: the JS SNICallback (owned, nullable) and the emitted answer
268
+ * thunk that becomes each minted answer closure's fn */
269
+ ScrClosure *sni_cb;
270
+ void *sni_answer_fn;
271
+ } ScrTlsSrv;
272
+
273
+ /* The ALPN answers (static storage — mbedTLS keeps the pointers). Plain
274
+ * tls servers configure none, like Node; https advertises http/1.1; the
275
+ * h2 secure server advertises h2 alone (an http/1.1-only client fails
276
+ * the handshake with no_application_protocol — Node's h2-only split). */
277
+ static const char *SCR_TLS_ALPN_HTTP11[] = {"http/1.1", NULL};
278
+ static const char *SCR_TLS_ALPN_H2[] = {"h2", NULL};
279
+ static const char *SCR_TLS_ALPN_H2_HTTP11[] = {"h2", "http/1.1", NULL};
280
+
281
+ static ScrTlsSrv *scr_tls_srv_new(const char *cert, size_t cert_len, const char *key,
282
+ size_t key_len, bool alpn_http11) {
283
+ scr_tls_rng_init();
284
+ ScrTlsSrv *s = calloc(1, sizeof *s);
285
+ if (!s) scr_tls_oom();
286
+ s->rc = 1;
287
+ mbedtls_x509_crt_init(&s->cert);
288
+ mbedtls_pk_init(&s->pk);
289
+ mbedtls_ssl_config_init(&s->conf);
290
+ int r = scr_tls_parse_crt(&s->cert, cert, cert_len);
291
+ if (r != 0) scr_tls_bad_material("certificate", r);
292
+ r = scr_tls_parse_key(&s->pk, key, key_len);
293
+ if (r != 0) scr_tls_bad_material("private key", r);
294
+ if (mbedtls_ssl_config_defaults(&s->conf, MBEDTLS_SSL_IS_SERVER,
295
+ MBEDTLS_SSL_TRANSPORT_STREAM,
296
+ MBEDTLS_SSL_PRESET_DEFAULT) != 0) {
297
+ scr_tls_oom();
298
+ }
299
+ mbedtls_ssl_conf_rng(&s->conf, mbedtls_ctr_drbg_random, &scr_tls_drbg);
300
+ mbedtls_ssl_conf_authmode(&s->conf, MBEDTLS_SSL_VERIFY_NONE); /* no client certs, Node's default */
301
+ if (mbedtls_ssl_conf_own_cert(&s->conf, &s->cert, &s->pk) != 0) {
302
+ scr_tls_bad_material("certificate/key pair", 0);
303
+ }
304
+ if (alpn_http11) mbedtls_ssl_conf_alpn_protocols(&s->conf, SCR_TLS_ALPN_HTTP11);
305
+ return s;
306
+ }
307
+
308
+ static ScrTlsSrv *scr_tls_srv_retain(ScrTlsSrv *s) {
309
+ s->rc++;
310
+ return s;
311
+ }
312
+
313
+ static void scr_tls_srv_release(ScrTlsSrv *s) {
314
+ if (!s || --s->rc != 0) return;
315
+ if (s->inner_ctx_free) s->inner_ctx_free(s->inner_ctx);
316
+ if (s->h2_ctx_free) s->h2_ctx_free(s->h2_ctx);
317
+ scr_closure_release(s->sni_cb);
318
+ mbedtls_ssl_config_free(&s->conf);
319
+ mbedtls_x509_crt_free(&s->cert);
320
+ mbedtls_pk_free(&s->pk);
321
+ free(s);
322
+ }
323
+
324
+ static void scr_tls_srv_release_v(void *p) { scr_tls_srv_release((ScrTlsSrv *)p); }
325
+
326
+ /* ── the client config (one per https.request, owned by its tctx) ────── */
327
+
328
+ typedef struct ScrTlsCli {
329
+ mbedtls_ssl_config conf;
330
+ mbedtls_x509_crt ca;
331
+ char *hostname; /* NULL for IP-literal peers (no SNI, no name check) */
332
+ /* true when the handshake RECORDS verification (VERIFY_OPTIONAL /
333
+ * VERIFY_REQUIRED) — socket.authorized answers from the result; a
334
+ * VERIFY_NONE socket (the https client's rejectUnauthorized:false)
335
+ * never verified, so authorized answers false like Node's. */
336
+ bool verify_recorded;
337
+ } ScrTlsCli;
338
+
339
+ /* The default trust anchors when no `ca` option is given: the host trust
340
+ * store, standing in for Node's compiled-in Mozilla roots, plus
341
+ * NODE_EXTRA_CA_CERTS. Windows certificates live as DER entries across the
342
+ * machine, enterprise, current-user, and policy ROOT/CA/TrustedPeople store
343
+ * locations; mbedTLS copies each successfully parsed entry into its own chain.
344
+ * POSIX hosts probe the established bundle spellings — /etc/ssl/cert.pem
345
+ * first (macOS ships it; Alpine links it), then Debian/Ubuntu's
346
+ * ca-certificates.crt, Fedora/RHEL's ca-bundle.crt, and openSUSE's
347
+ * ca-bundle.pem. */
348
+ static mbedtls_x509_crt scr_tls_system_roots;
349
+ static bool scr_tls_system_roots_loaded = false;
350
+
351
+ /* setDefaultCACertificates' replacement anchors (scr_tls_ca.c — always
352
+ * compiled alongside this unit): parsed lazily per generation, so each
353
+ * set re-parses once and every later dial reuses the chain. An EMPTY
354
+ * replacement keeps an initialized, certificate-free chain — every
355
+ * verification fails, Node's own consequence of trusting nothing. */
356
+ static mbedtls_x509_crt scr_tls_override_roots;
357
+ static uint64_t scr_tls_override_parsed_gen = 0;
358
+
359
+ #ifdef _WIN32
360
+ static void scr_tls_add_windows_ca(void *ctx, const unsigned char *der, size_t len) {
361
+ (void)mbedtls_x509_crt_parse_der((mbedtls_x509_crt *)ctx, der, len);
362
+ }
363
+ #endif
364
+
365
+ static mbedtls_x509_crt *scr_tls_system_ca(void) {
366
+ const char *pem = NULL;
367
+ size_t pem_len = 0;
368
+ uint64_t gen = 0;
369
+ if (scr_tls_ca_default_override(&pem, &pem_len, &gen)) {
370
+ if (gen != scr_tls_override_parsed_gen) {
371
+ if (scr_tls_override_parsed_gen != 0) mbedtls_x509_crt_free(&scr_tls_override_roots);
372
+ mbedtls_x509_crt_init(&scr_tls_override_roots);
373
+ /* +1 for the NUL — mbedTLS's PEM mode wants it counted. A parse
374
+ * failure inside one block leaves the chain with the blocks that
375
+ * did parse (the scr_tls_ca.c divergence note). */
376
+ if (pem_len > 0) (void)mbedtls_x509_crt_parse(&scr_tls_override_roots, (const unsigned char *)pem, pem_len + 1);
377
+ scr_tls_override_parsed_gen = gen;
378
+ }
379
+ return &scr_tls_override_roots;
380
+ }
381
+ if (!scr_tls_system_roots_loaded) {
382
+ scr_tls_system_roots_loaded = true;
383
+ mbedtls_x509_crt_init(&scr_tls_system_roots);
384
+ #ifdef _WIN32
385
+ /* The shared enumerator applies Windows' effective server-auth EKU
386
+ * policy before yielding DER. mbedTLS copies every successfully parsed
387
+ * entry, so the store contexts may die immediately after each callback. */
388
+ scr_tls_ca_windows_certs(scr_tls_add_windows_ca, &scr_tls_system_roots);
389
+ #else
390
+ static const char *const bundles[] = {
391
+ "/etc/ssl/cert.pem", /* macOS, Alpine */
392
+ "/etc/ssl/certs/ca-certificates.crt", /* Debian/Ubuntu */
393
+ "/etc/pki/tls/certs/ca-bundle.crt", /* Fedora/RHEL */
394
+ "/etc/ssl/ca-bundle.pem", /* openSUSE */
395
+ };
396
+ for (size_t i = 0; i < sizeof bundles / sizeof bundles[0]; i++) {
397
+ if (mbedtls_x509_crt_parse_file(&scr_tls_system_roots, bundles[i]) == 0) break;
398
+ }
399
+ #endif
400
+ const char *extra = NULL;
401
+ size_t extra_len = 0;
402
+ if (scr_tls_ca_extra_pem(&extra, &extra_len) && extra_len > 0) {
403
+ (void)mbedtls_x509_crt_parse(
404
+ &scr_tls_system_roots, (const unsigned char *)extra,
405
+ extra_len + 1);
406
+ }
407
+ }
408
+ return &scr_tls_system_roots;
409
+ }
410
+
411
+ /* `verify_optional` is tls.connect's rejectUnauthorized:false: the
412
+ * handshake proceeds regardless of the verdict but verification still
413
+ * RUNS and records (socket.authorized / authorizationError answer
414
+ * Node's split); the https client's historical false keeps VERIFY_NONE
415
+ * (verify_optional false there — nothing recorded, nothing read). */
416
+ static ScrTlsCli *scr_tls_cli_new2(ScrStr *host, bool reject_unauthorized, const char *ca,
417
+ size_t ca_len, bool verify_optional) {
418
+ scr_tls_rng_init();
419
+ ScrTlsCli *c = calloc(1, sizeof *c);
420
+ if (!c) scr_tls_oom();
421
+ mbedtls_ssl_config_init(&c->conf);
422
+ mbedtls_x509_crt_init(&c->ca);
423
+ if (mbedtls_ssl_config_defaults(&c->conf, MBEDTLS_SSL_IS_CLIENT,
424
+ MBEDTLS_SSL_TRANSPORT_STREAM,
425
+ MBEDTLS_SSL_PRESET_DEFAULT) != 0) {
426
+ scr_tls_oom();
427
+ }
428
+ mbedtls_ssl_conf_rng(&c->conf, mbedtls_ctr_drbg_random, &scr_tls_drbg);
429
+ c->verify_recorded = reject_unauthorized || verify_optional;
430
+ if (ca_len > 0) {
431
+ int r = scr_tls_parse_crt(&c->ca, ca, ca_len);
432
+ if (r != 0) scr_tls_bad_material("ca certificate", r);
433
+ }
434
+ if (!reject_unauthorized && !verify_optional) {
435
+ mbedtls_ssl_conf_authmode(&c->conf, MBEDTLS_SSL_VERIFY_NONE);
436
+ } else {
437
+ mbedtls_ssl_conf_authmode(&c->conf, reject_unauthorized ? MBEDTLS_SSL_VERIFY_REQUIRED
438
+ : MBEDTLS_SSL_VERIFY_OPTIONAL);
439
+ mbedtls_ssl_conf_ca_chain(&c->conf, ca_len > 0 ? &c->ca : scr_tls_system_ca(), NULL);
440
+ }
441
+ /* SNI + name verification want the DNS name; an IP literal gets
442
+ * neither (mbedTLS 3.6 has no IP-SAN matching — SEMANTICS.md). */
443
+ struct in_addr a4;
444
+ struct in6_addr a6;
445
+ const char *h = host->len > 0 ? host->data : "localhost";
446
+ if (inet_pton(AF_INET, h, &a4) != 1 && inet_pton(AF_INET6, h, &a6) != 1) {
447
+ c->hostname = strdup(h);
448
+ if (!c->hostname) scr_tls_oom();
449
+ }
450
+ return c;
451
+ }
452
+
453
+ static ScrTlsCli *scr_tls_cli_new(ScrStr *host, bool reject_unauthorized, const char *ca,
454
+ size_t ca_len) {
455
+ return scr_tls_cli_new2(host, reject_unauthorized, ca, ca_len, false);
456
+ }
457
+
458
+ static void scr_tls_cli_free(ScrTlsCli *c) {
459
+ mbedtls_ssl_config_free(&c->conf);
460
+ mbedtls_x509_crt_free(&c->ca);
461
+ free(c->hostname);
462
+ free(c);
463
+ }
464
+
465
+ /* ── the per-socket transport ────────────────────────────────────────── */
466
+
467
+ /* The SNI pre-parse states: NONE (no callback on the server — the
468
+ * handshake runs directly), COLLECT (buffering the ClientHello),
469
+ * WAIT (the JS callback is deciding), DONE (answered/skipped — the
470
+ * hello replayed into the bio; the handshake runs). */
471
+ enum { SCR_SNI_NONE = 0, SCR_SNI_COLLECT, SCR_SNI_WAIT, SCR_SNI_DONE };
472
+
473
+ typedef struct ScrTlsSock {
474
+ mbedtls_ssl_context ssl;
475
+ ScrNetSocket *sock; /* BORROWED: the tctx lives and dies with the socket */
476
+ ScrTlsSrv *srv; /* +1 server side, NULL client side */
477
+ ScrTlsCli *cli; /* owned client side, NULL server side */
478
+ bool notify_sent;
479
+ bool established; /* the handshake stood — socket.authorized reads gate on it */
480
+ /* the client 'session' event: listeners + the fired-once latch (Node
481
+ * fires per received ticket; this surface fires once per socket) */
482
+ ScrNetLs session_ls;
483
+ bool session_fired;
484
+ /* what the verify callback saw (the peer chain is gone once the
485
+ * handshake has failed, so the shape is recorded as it verifies) */
486
+ bool vrfy_leaf_self;
487
+ bool vrfy_chain_self;
488
+ bool vrfy_expired;
489
+ bool vrfy_cn_mismatch;
490
+ /* SNI pre-parse state (server side with an SNI callback only) */
491
+ int sni_state;
492
+ bool in_handshake; /* a synchronous cb answer must not re-pump */
493
+ unsigned char *hello; /* the raw ClientHello flight, replayed at DONE */
494
+ size_t hello_len, hello_cap;
495
+ ScrSecureCtx *sni_ctx; /* owned; the answer (NULL = default cert) */
496
+ } ScrTlsSock;
497
+
498
+ /* The client verify callback: records WHERE verification failed and how
499
+ * the presented chain is shaped, per certificate (depth 0 = leaf), so
500
+ * the failure message can be Node's exact split. Never overrides flags —
501
+ * the verdict stays mbedTLS's. */
502
+ static int scr_tls_vrfy_cb(void *ctx, mbedtls_x509_crt *crt, int depth, uint32_t *flags) {
503
+ ScrTlsSock *t = (ScrTlsSock *)ctx;
504
+ bool self = crt->issuer_raw.len == crt->subject_raw.len &&
505
+ memcmp(crt->issuer_raw.p, crt->subject_raw.p, crt->subject_raw.len) == 0;
506
+ if (*flags & MBEDTLS_X509_BADCERT_EXPIRED) t->vrfy_expired = true;
507
+ if (*flags & MBEDTLS_X509_BADCERT_CN_MISMATCH) t->vrfy_cn_mismatch = true;
508
+ if (*flags & MBEDTLS_X509_BADCERT_NOT_TRUSTED) {
509
+ if (depth == 0 && self) t->vrfy_leaf_self = true;
510
+ if (depth > 0 && self) t->vrfy_chain_self = true;
511
+ }
512
+ return 0;
513
+ }
514
+
515
+ /* The BIOs: nonblocking fd I/O in mbedTLS's own convention. A send that
516
+ * would block arms the socket's write filter so the handshake resumes on
517
+ * writability. */
518
+ static int scr_tls_bio_send(void *ctx, const unsigned char *buf, size_t len) {
519
+ ScrTlsSock *t = (ScrTlsSock *)ctx;
520
+ int fd = scr_net_sock_fd(t->sock);
521
+ if (fd < 0) return MBEDTLS_ERR_NET_CONN_RESET;
522
+ ssize_t n = write(fd, buf, len);
523
+ if (n >= 0) return (int)n;
524
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
525
+ scr_net_sock_transport_want_write(t->sock);
526
+ return MBEDTLS_ERR_SSL_WANT_WRITE;
527
+ }
528
+ if (errno == EPIPE || errno == ECONNRESET) return MBEDTLS_ERR_NET_CONN_RESET;
529
+ return MBEDTLS_ERR_NET_SEND_FAILED;
530
+ }
531
+
532
+ static int scr_tls_bio_recv(void *ctx, unsigned char *buf, size_t len) {
533
+ ScrTlsSock *t = (ScrTlsSock *)ctx;
534
+ int fd = scr_net_sock_fd(t->sock);
535
+ if (fd < 0) return MBEDTLS_ERR_NET_CONN_RESET;
536
+ /* bytes a consumer peeked and unshifted (the demux path) re-enter the
537
+ * stream here, ahead of the kernel's */
538
+ size_t took = scr_net_sock_take_buffered(t->sock, (char *)buf, len);
539
+ if (took > 0) return (int)took;
540
+ ssize_t n = read(fd, buf, len);
541
+ if (n >= 0) return (int)n; /* 0 = EOF; mbedTLS maps it to CONN_EOF */
542
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
543
+ return MBEDTLS_ERR_SSL_WANT_READ;
544
+ }
545
+ if (errno == ECONNRESET) return MBEDTLS_ERR_NET_CONN_RESET;
546
+ return MBEDTLS_ERR_NET_RECV_FAILED;
547
+ }
548
+
549
+ /* ── the transport ops ───────────────────────────────────────────────── */
550
+
551
+ static void scr_tls_fire_session(ScrTlsSock *t);
552
+
553
+ static ssize_t scr_tls_xread(void *tctx, char *buf, size_t n) {
554
+ ScrTlsSock *t = (ScrTlsSock *)tctx;
555
+ for (;;) {
556
+ int r = mbedtls_ssl_read(&t->ssl, (unsigned char *)buf, n);
557
+ if (r > 0) return r;
558
+ if (r == 0 || r == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY || r == MBEDTLS_ERR_SSL_CONN_EOF) {
559
+ return 0; /* orderly (or abrupt-but-quiet) EOF — Node's 'end' either way */
560
+ }
561
+ #if defined(MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET)
562
+ if (r == MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET) {
563
+ /* a 1.3 ticket, not app data: the client 'session' event's moment */
564
+ if (!scr_exc_pending()) scr_tls_fire_session(t);
565
+ continue;
566
+ }
567
+ #endif
568
+ if (r == MBEDTLS_ERR_SSL_WANT_READ || r == MBEDTLS_ERR_SSL_WANT_WRITE) {
569
+ errno = EAGAIN;
570
+ return -1;
571
+ }
572
+ errno = ECONNRESET; /* protocol-level death reads as a reset */
573
+ return -1;
574
+ }
575
+ }
576
+
577
+ static ssize_t scr_tls_xwrite(void *tctx, const char *buf, size_t n) {
578
+ ScrTlsSock *t = (ScrTlsSock *)tctx;
579
+ int r = mbedtls_ssl_write(&t->ssl, (const unsigned char *)buf, n);
580
+ if (r >= 0) return r;
581
+ if (r == MBEDTLS_ERR_SSL_WANT_READ || r == MBEDTLS_ERR_SSL_WANT_WRITE) {
582
+ errno = EAGAIN;
583
+ return -1;
584
+ }
585
+ errno = EPIPE;
586
+ return -1;
587
+ }
588
+
589
+ /* Node's message for the verify failures the local-CA flows can meet.
590
+ * The split mirrors Node's openssl-error mapping: a self-signed LEAF is
591
+ * "self-signed certificate"; a chain that carries its own (self-signed)
592
+ * root is "self-signed certificate in certificate chain"; a chain whose
593
+ * issuer never arrived is "unable to verify the first certificate". The
594
+ * shape comes from the verify callback's records — the peer chain is
595
+ * already gone once the handshake has failed. */
596
+ static void scr_tls_verify_msg(ScrTlsSock *t, char *out, size_t n) {
597
+ if (t->vrfy_expired) {
598
+ snprintf(out, n, "certificate has expired");
599
+ return;
600
+ }
601
+ /* Node appends the --use-system-ca hint for exactly these two codes
602
+ * (src/crypto/crypto_common.cc: DEPTH_ZERO_SELF_SIGNED_CERT and
603
+ * UNABLE_TO_VERIFY_LEAF_SIGNATURE) — and NOT for the in-chain one. */
604
+ static const char hint[] =
605
+ "; if the root CA is installed locally, try running Node.js with --use-system-ca";
606
+ if (t->vrfy_leaf_self) {
607
+ snprintf(out, n, "self-signed certificate%s", hint);
608
+ return;
609
+ }
610
+ if (t->vrfy_chain_self) {
611
+ snprintf(out, n, "self-signed certificate in certificate chain");
612
+ return;
613
+ }
614
+ /* the identity check only decides on a TRUSTED chain — Node's order
615
+ * (checkServerIdentity runs after verification succeeds) */
616
+ if (t->vrfy_cn_mismatch &&
617
+ (mbedtls_ssl_get_verify_result(&t->ssl) & MBEDTLS_X509_BADCERT_NOT_TRUSTED) == 0) {
618
+ snprintf(out, n, "Hostname/IP does not match certificate's altnames");
619
+ return;
620
+ }
621
+ snprintf(out, n, "unable to verify the first certificate%s", hint);
622
+ }
623
+
624
+ /* ── the SNI pre-parse ────────────────────────────────────────────────
625
+ * mbedTLS's f_sni must answer synchronously from inside the handshake,
626
+ * but the JS SNICallback is asynchronous (per-hostname certs generate on
627
+ * demand — the portless flow). So a callback-carrying server resolves
628
+ * the name FIRST: it buffers the raw ClientHello flight off the socket,
629
+ * parses the server_name extension itself, parks the handshake while the
630
+ * JS callback decides, then replays the buffered bytes into the bio and
631
+ * runs the real handshake — whose f_sni serves the answered context. */
632
+
633
+ /* The socket whose handshake this unit is driving — f_sni's route back
634
+ * to the answered context (single-threaded runtime; set around
635
+ * mbedtls_ssl_handshake). */
636
+ static ScrTlsSock *scr_tls_current = NULL;
637
+
638
+ /* Defined with the other transport ops below; the answer path needs the
639
+ * table's identity to re-find its engine from the boxed socket. */
640
+ static const ScrNetTransportOps SCR_TLS_OPS;
641
+
642
+ static int scr_tls_f_sni(void *p, mbedtls_ssl_context *ssl, const unsigned char *name,
643
+ size_t len) {
644
+ (void)p; (void)name; (void)len;
645
+ ScrTlsSock *t = scr_tls_current;
646
+ if (t != NULL && t->sni_ctx != NULL) {
647
+ return mbedtls_ssl_set_hs_own_cert(ssl, &t->sni_ctx->cert, &t->sni_ctx->pk);
648
+ }
649
+ return 0; /* default cert (no answer / cb passed no context) */
650
+ }
651
+
652
+ /* The ClientHello body walk (past the 4-byte handshake header): version +
653
+ * random, session id, cipher suites, compression, then the extension list
654
+ * — server_name (type 0) holds one host_name (type 0) entry. Answers 1
655
+ * with `out` set, 2 for a well-formed hello without SNI or anything
656
+ * malformed (the real handshake will judge it). */
657
+ static int scr_tls_parse_ch_body(const unsigned char *b, size_t n, char *out, size_t out_cap) {
658
+ size_t i = 34; /* version(2) + random(32) */
659
+ if (i + 1 > n) return 2;
660
+ i += 1 + b[i]; /* session id: length byte + body */
661
+ if (i + 2 > n) return 2;
662
+ size_t cs = ((size_t)b[i] << 8) | b[i + 1];
663
+ i += 2 + cs;
664
+ if (i + 1 > n) return 2;
665
+ i += 1 + b[i];
666
+ if (i + 2 > n) return 2;
667
+ size_t ext_total = ((size_t)b[i] << 8) | b[i + 1];
668
+ i += 2;
669
+ size_t end = i + ext_total <= n ? i + ext_total : n;
670
+ while (i + 4 <= end) {
671
+ size_t et = ((size_t)b[i] << 8) | b[i + 1];
672
+ size_t el = ((size_t)b[i + 2] << 8) | b[i + 3];
673
+ i += 4;
674
+ if (i + el > end) return 2;
675
+ if (et == 0) {
676
+ /* server_name: list length(2), then entry type(1) + length(2) + name */
677
+ if (el < 5 || b[i + 2] != 0) return 2;
678
+ size_t nl = ((size_t)b[i + 3] << 8) | b[i + 4];
679
+ if (nl == 0 || nl + 5 > el || nl + 1 > out_cap) return 2;
680
+ memcpy(out, b + i + 5, nl);
681
+ out[nl] = 0;
682
+ return 1;
683
+ }
684
+ i += el;
685
+ }
686
+ return 2;
687
+ }
688
+
689
+ /* Reassemble the handshake stream from the raw record flight and look for
690
+ * the server_name extension. 0 = need more bytes; 1 = found (out set);
691
+ * 2 = no SNI / not parseable (serve the default cert). */
692
+ static int scr_tls_parse_sni(const unsigned char *buf, size_t len, char *out, size_t out_cap) {
693
+ unsigned char *hs = NULL;
694
+ size_t hs_len = 0, hs_cap = 0;
695
+ size_t off = 0;
696
+ for (;;) {
697
+ if (off + 5 > len) { free(hs); return 0; }
698
+ if (buf[off] != 0x16) { free(hs); return 2; } /* not a handshake record */
699
+ size_t rlen = ((size_t)buf[off + 3] << 8) | buf[off + 4];
700
+ if (rlen == 0 || rlen > 16640) { free(hs); return 2; }
701
+ if (off + 5 + rlen > len) { free(hs); return 0; }
702
+ if (hs_len + rlen > hs_cap) {
703
+ hs_cap = hs_cap ? hs_cap * 2 : 4096;
704
+ while (hs_cap < hs_len + rlen) hs_cap *= 2;
705
+ hs = realloc(hs, hs_cap);
706
+ if (!hs) scr_tls_oom();
707
+ }
708
+ memcpy(hs + hs_len, buf + off + 5, rlen);
709
+ hs_len += rlen;
710
+ off += 5 + rlen;
711
+ if (hs_len >= 4) {
712
+ if (hs[0] != 0x01) { free(hs); return 2; } /* not a ClientHello */
713
+ size_t chlen = ((size_t)hs[1] << 16) | ((size_t)hs[2] << 8) | hs[3];
714
+ if (chlen > 131072) { free(hs); return 2; }
715
+ if (hs_len >= 4 + chlen) {
716
+ int r = scr_tls_parse_ch_body(hs + 4, chlen, out, out_cap);
717
+ free(hs);
718
+ return r;
719
+ }
720
+ }
721
+ }
722
+ }
723
+
724
+ /* Hand the buffered flight back: the bio reads it ahead of the kernel. */
725
+ static void scr_tls_sni_replay(ScrTlsSock *t) {
726
+ if (t->hello_len > 0) {
727
+ scr_net_sock_replay(t->sock, (const char *)t->hello, t->hello_len);
728
+ }
729
+ free(t->hello);
730
+ t->hello = NULL;
731
+ t->hello_len = t->hello_cap = 0;
732
+ }
733
+
734
+ /* The COLLECT step: buffer what the socket has, decide, invoke the JS
735
+ * callback. Answers like the transport handshake contract: 1 = proceed
736
+ * to the real handshake, 0 = parked (more bytes, or the callback is
737
+ * deciding), -1 = the socket died (already torn down). */
738
+ static int scr_tls_sni_collect(ScrTlsSock *t) {
739
+ char servername[256];
740
+ for (;;) {
741
+ if (t->hello_len > 0) {
742
+ int r = scr_tls_parse_sni(t->hello, t->hello_len, servername, sizeof servername);
743
+ if (r == 2 || t->hello_len > 65536) {
744
+ /* no SNI (or unparseable): skip the callback, serve the default
745
+ * pair — Node's SNICallback never fires without a server_name */
746
+ t->sni_state = SCR_SNI_DONE;
747
+ scr_tls_sni_replay(t);
748
+ return 1;
749
+ }
750
+ if (r == 1) {
751
+ t->sni_state = SCR_SNI_WAIT;
752
+ ScrClosure *cb = scr_closure_retain(t->srv->sni_cb);
753
+ ScrClosure *ans = scr_closure_new(t->srv->sni_answer_fn, 1);
754
+ ScrBox *box = scr_box_new_obj(scr_net_sock_retain_v, scr_net_sock_release_v, NULL);
755
+ scr_box_set_ref(box, scr_net_sock_retain(t->sock));
756
+ ans->caps[0] = box;
757
+ ScrStr *name = scr_str_new(servername, strlen(servername));
758
+ /* the callback owns its +1 params per the universal convention */
759
+ ((void (*)(ScrClosure *, ScrStr *, ScrClosure *))cb->fn)(cb, name, ans);
760
+ scr_closure_release(cb);
761
+ if (scr_net_sock_fd(t->sock) < 0) return -1; /* a sync cb(err) tore it down */
762
+ if (t->sni_state == SCR_SNI_WAIT) return 0; /* asynchronous answer */
763
+ return 1; /* a synchronous answer already replayed the flight */
764
+ }
765
+ }
766
+ /* need more bytes: buffered (unshifted demux peeks) first, then the fd */
767
+ if (t->hello_len + 4096 > t->hello_cap) {
768
+ t->hello_cap = t->hello_cap ? t->hello_cap * 2 : 8192;
769
+ t->hello = realloc(t->hello, t->hello_cap);
770
+ if (!t->hello) scr_tls_oom();
771
+ }
772
+ size_t room = t->hello_cap - t->hello_len;
773
+ size_t took = scr_net_sock_take_buffered(t->sock, (char *)t->hello + t->hello_len, room);
774
+ if (took == 0) {
775
+ int fd = scr_net_sock_fd(t->sock);
776
+ if (fd < 0) return -1;
777
+ ssize_t n = read(fd, t->hello + t->hello_len, room);
778
+ if (n < 0) {
779
+ if (errno == EINTR) continue;
780
+ if (errno == EAGAIN || errno == EWOULDBLOCK) return 0; /* readiness re-drives */
781
+ scr_net_sock_transport_error(t->sock, NULL);
782
+ return -1;
783
+ }
784
+ if (n == 0) { /* the peer died mid-hello: silent server-side teardown */
785
+ scr_net_sock_transport_error(t->sock, NULL);
786
+ return -1;
787
+ }
788
+ took = (size_t)n;
789
+ }
790
+ t->hello_len += took;
791
+ }
792
+ }
793
+
794
+ /* The answer closure's runtime half (its fn is the emitted per-shape
795
+ * thunk; caps[0] boxes the socket). Late, repeated, or dead-socket
796
+ * answers are ignored — the first answer decides, like Node. */
797
+ void scr_tls_sni_answer(ScrClosure *self, bool has_err, ScrSecureCtx *ctx /*moves, nullable*/) {
798
+ ScrNetSocket *sock = (ScrNetSocket *)scr_box_get_ref(self->caps[0]);
799
+ ScrTlsSock *t =
800
+ sock != NULL ? (ScrTlsSock *)scr_net_sock_transport_ctx_for(sock, &SCR_TLS_OPS) : NULL;
801
+ if (t == NULL || t->sni_state != SCR_SNI_WAIT) {
802
+ scr_secure_ctx_release(ctx);
803
+ scr_net_sock_release(sock);
804
+ return;
805
+ }
806
+ t->sni_state = SCR_SNI_DONE;
807
+ if (has_err) {
808
+ /* Node destroys the socket ('tlsClientError'; silent with no
809
+ * listener — what portless observes). */
810
+ scr_secure_ctx_release(ctx);
811
+ free(t->hello);
812
+ t->hello = NULL;
813
+ t->hello_len = t->hello_cap = 0;
814
+ scr_net_sock_transport_error(t->sock, NULL);
815
+ scr_net_sock_release(sock);
816
+ return;
817
+ }
818
+ t->sni_ctx = ctx; /* moves; NULL = the default pair */
819
+ scr_tls_sni_replay(t);
820
+ /* An asynchronous answer must re-drive the parked handshake itself —
821
+ * the client is waiting for the ServerHello, so no readiness comes. A
822
+ * SYNCHRONOUS answer (cache hit) returns into the running collect
823
+ * step, which proceeds directly. */
824
+ if (!t->in_handshake) scr_net_sock_transport_resume(sock);
825
+ scr_net_sock_release(sock);
826
+ }
827
+
828
+ static int scr_tls_handshake(void *tctx) {
829
+ ScrTlsSock *t = (ScrTlsSock *)tctx;
830
+ if (t->sni_state == SCR_SNI_COLLECT) {
831
+ t->in_handshake = true;
832
+ int c = scr_tls_sni_collect(t);
833
+ t->in_handshake = false;
834
+ if (c <= 0) return c;
835
+ }
836
+ if (t->sni_state == SCR_SNI_WAIT) return 0; /* the callback is deciding */
837
+ scr_tls_current = t;
838
+ int r = mbedtls_ssl_handshake(&t->ssl);
839
+ scr_tls_current = NULL;
840
+ if (r == 0) return 1;
841
+ if (r == MBEDTLS_ERR_SSL_WANT_READ || r == MBEDTLS_ERR_SSL_WANT_WRITE) return 0;
842
+ if (t->srv != NULL) {
843
+ /* Node's server default: 'tlsClientError' with no listener destroys
844
+ * the socket silently — exactly what portless (no listener) sees. */
845
+ scr_net_sock_transport_error(t->sock, NULL);
846
+ return -1;
847
+ }
848
+ char msg[160];
849
+ if (r == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) {
850
+ scr_tls_verify_msg(t, msg, sizeof msg);
851
+ } else if (r == MBEDTLS_ERR_SSL_CONN_EOF || r == MBEDTLS_ERR_NET_CONN_RESET) {
852
+ /* the peer died mid-handshake: the http layer's own premature-close
853
+ * shape ('socket hang up') is Node's message — teardown silently at
854
+ * this level and let the closed hook classify it */
855
+ scr_net_sock_transport_error(t->sock, NULL);
856
+ return -1;
857
+ } else {
858
+ /* non-verify handshake failures: honest but not Node's exact openssl
859
+ * string (SEMANTICS.md divergence 55) */
860
+ snprintf(msg, sizeof msg, "client TLS handshake failed");
861
+ }
862
+ scr_net_sock_transport_error(t->sock, msg);
863
+ return -1;
864
+ }
865
+
866
+ static void scr_tls_on_established(void *tctx) {
867
+ ScrTlsSock *t = (ScrTlsSock *)tctx;
868
+ t->established = true;
869
+ if (t->cli != NULL) scr_tls_fire_session(t); /* the 1.2 arm; 1.3 fires on ticket receipt */
870
+ if (t->srv != NULL && t->srv->h2_conn != NULL) {
871
+ /* the h2 secure server: dispatch on the NEGOTIATED protocol — the
872
+ * h2 session attaches as the socket's native reader (it reads
873
+ * plaintext through this transport, exactly like the https parser);
874
+ * an http/1.1 answer routes to the wrapped parser when one exists;
875
+ * a client that answered nothing tears down (Node parks it as
876
+ * 'unknownProtocol' and destroys at the timeout — this surface
877
+ * destroys now; SEMANTICS.md). */
878
+ const char *alpn = mbedtls_ssl_get_alpn_protocol(&t->ssl);
879
+ if (alpn != NULL && strcmp(alpn, "h2") == 0) {
880
+ t->srv->h2_conn(t->srv->h2_ctx, t->sock);
881
+ } else if (t->srv->inner_conn != NULL &&
882
+ (alpn == NULL || strcmp(alpn, "http/1.1") == 0)) {
883
+ t->srv->inner_conn(t->srv->inner_ctx, t->sock);
884
+ } else {
885
+ scr_net_sock_transport_error(t->sock, NULL);
886
+ }
887
+ return;
888
+ }
889
+ if (t->srv != NULL && t->srv->inner_conn != NULL) {
890
+ /* https: the http parser attaches now, over plaintext only */
891
+ t->srv->inner_conn(t->srv->inner_ctx, t->sock);
892
+ }
893
+ }
894
+
895
+ static bool scr_tls_pending(void *tctx) {
896
+ ScrTlsSock *t = (ScrTlsSock *)tctx;
897
+ return mbedtls_ssl_check_pending(&t->ssl) != 0 ||
898
+ mbedtls_ssl_get_bytes_avail(&t->ssl) > 0;
899
+ }
900
+
901
+ static void scr_tls_shutdown_write(void *tctx) {
902
+ ScrTlsSock *t = (ScrTlsSock *)tctx;
903
+ if (t->notify_sent) return;
904
+ t->notify_sent = true;
905
+ (void)mbedtls_ssl_close_notify(&t->ssl); /* best effort; EAGAIN drops it */
906
+ }
907
+
908
+ static void scr_tls_free(void *tctx) {
909
+ ScrTlsSock *t = (ScrTlsSock *)tctx;
910
+ mbedtls_ssl_free(&t->ssl);
911
+ if (t->srv) scr_tls_srv_release(t->srv);
912
+ if (t->cli) scr_tls_cli_free(t->cli);
913
+ scr_net_ls_drop(&t->session_ls);
914
+ free(t->hello);
915
+ scr_secure_ctx_release(t->sni_ctx);
916
+ free(t);
917
+ }
918
+
919
+ static const ScrNetTransportOps SCR_TLS_OPS = {
920
+ .xread = scr_tls_xread,
921
+ .xwrite = scr_tls_xwrite,
922
+ .handshake = scr_tls_handshake,
923
+ .on_established = scr_tls_on_established,
924
+ .pending = scr_tls_pending,
925
+ .shutdown_write = scr_tls_shutdown_write,
926
+ .free = scr_tls_free,
927
+ };
928
+
929
+ /* ── the server surface ──────────────────────────────────────────────── */
930
+
931
+ /* The server's native-connection hook: one TLS engine per accepted
932
+ * socket; the deferred 'connection' fires from the net pump once the
933
+ * handshake stands. */
934
+ static void scr_tls_srv_on_conn(void *ctx, ScrNetSocket *sock) {
935
+ ScrTlsSrv *srv = (ScrTlsSrv *)ctx;
936
+ ScrTlsSock *t = calloc(1, sizeof *t);
937
+ if (!t) scr_tls_oom();
938
+ mbedtls_ssl_init(&t->ssl);
939
+ if (mbedtls_ssl_setup(&t->ssl, &srv->conf) != 0) scr_tls_oom();
940
+ t->sock = sock;
941
+ t->srv = scr_tls_srv_retain(srv);
942
+ if (srv->sni_cb != NULL) t->sni_state = SCR_SNI_COLLECT; /* pre-parse the hello */
943
+ mbedtls_ssl_set_bio(&t->ssl, t, scr_tls_bio_send, scr_tls_bio_recv, NULL);
944
+ scr_net_sock_set_transport(sock, &SCR_TLS_OPS, t);
945
+ }
946
+
947
+ ScrNetServer *scr_tls_create_server(const char *cert, size_t cert_len, const char *key,
948
+ size_t key_len, ScrClosure *handler /*moves, nullable*/,
949
+ ScrNetConnFn fn) {
950
+ ScrTlsSrv *srv = scr_tls_srv_new(cert, cert_len, key, key_len, false);
951
+ ScrNetServer *s = scr_net_create_server(handler, fn);
952
+ scr_net_server_set_native_conn(s, &scr_tls_srv_on_conn, srv, &scr_tls_srv_release_v);
953
+ scr_net_server_defer_connections(s); /* the handler is 'secureConnection' */
954
+ return s;
955
+ }
956
+
957
+ ScrNetServer *scr_https_create_server(const char *cert, size_t cert_len, const char *key,
958
+ size_t key_len, ScrClosure *handler /*moves*/,
959
+ ScrHttpReqFn fn) {
960
+ ScrNetServer *s = scr_http_create_server(handler, fn);
961
+ ScrTlsSrv *srv = scr_tls_srv_new(cert, cert_len, key, key_len, true /* ALPN http/1.1 */);
962
+ /* wrap the parser hook: TLS first, parser at establishment */
963
+ scr_net_server_get_native_conn(s, &srv->inner_conn, &srv->inner_ctx, &srv->inner_ctx_free);
964
+ scr_net_server_set_native_conn(s, &scr_tls_srv_on_conn, srv, &scr_tls_srv_release_v);
965
+ scr_net_server_defer_connections(s);
966
+ return s;
967
+ }
968
+
969
+ /* The SNI-callback form of the allowHTTP1 compatibility server: the same
970
+ * handler-less https server, plus the pre-parse machinery (design note
971
+ * atop the SNI section). A NULL sni_cb — the conditional spread's
972
+ * undefined arm — is exactly scr_https_create_server(…, NULL, NULL). */
973
+ ScrNetServer *scr_https_create_server_sni(const char *cert, size_t cert_len, const char *key,
974
+ size_t key_len, ScrClosure *sni_cb /*moves, nullable*/,
975
+ void *answer_fn) {
976
+ ScrNetServer *s = scr_http_create_server(NULL, NULL);
977
+ ScrTlsSrv *srv = scr_tls_srv_new(cert, cert_len, key, key_len, true /* ALPN http/1.1 */);
978
+ if (sni_cb != NULL) {
979
+ srv->sni_cb = sni_cb; /* moves */
980
+ srv->sni_answer_fn = answer_fn;
981
+ mbedtls_ssl_conf_sni(&srv->conf, &scr_tls_f_sni, NULL);
982
+ }
983
+ scr_net_server_get_native_conn(s, &srv->inner_conn, &srv->inner_ctx, &srv->inner_ctx_free);
984
+ scr_net_server_set_native_conn(s, &scr_tls_srv_on_conn, srv, &scr_tls_srv_release_v);
985
+ scr_net_server_defer_connections(s);
986
+ return s;
987
+ }
988
+
989
+ /* ── the client surface (https.request) ──────────────────────────────── */
990
+
991
+ static void scr_tls_cli_wrap(ScrNetSocket *sock, void *ctx) {
992
+ ScrTlsCli *cli = (ScrTlsCli *)ctx;
993
+ ScrTlsSock *t = calloc(1, sizeof *t);
994
+ if (!t) scr_tls_oom();
995
+ mbedtls_ssl_init(&t->ssl);
996
+ if (mbedtls_ssl_setup(&t->ssl, &cli->conf) != 0) scr_tls_oom();
997
+ if (cli->hostname != NULL) (void)mbedtls_ssl_set_hostname(&t->ssl, cli->hostname);
998
+ mbedtls_ssl_set_verify(&t->ssl, &scr_tls_vrfy_cb, t);
999
+ t->sock = sock;
1000
+ t->cli = cli; /* the tctx owns the per-request config now */
1001
+ mbedtls_ssl_set_bio(&t->ssl, t, scr_tls_bio_send, scr_tls_bio_recv, NULL);
1002
+ scr_net_sock_set_transport(sock, &SCR_TLS_OPS, t);
1003
+ }
1004
+
1005
+ /* The fetch unit's https leg: the same per-request client config +
1006
+ * transport wrap https.request uses, split apart because fetch dials a
1007
+ * RESOLVED IP while SNI and certificate verification must see the URL
1008
+ * hostname. The ctx moves into the socket's transport at wrap time. */
1009
+ void *scr_tls_fetch_client_ctx(ScrStr *host /*borrowed*/, bool reject_unauthorized) {
1010
+ return scr_tls_cli_new(host, reject_unauthorized, NULL, 0);
1011
+ }
1012
+
1013
+ void scr_tls_fetch_client_wrap(ScrNetSocket *sock, void *ctx) {
1014
+ scr_tls_cli_wrap(sock, ctx);
1015
+ }
1016
+
1017
+ ScrHttpClientReq *scr_https_request(ScrStr *host /*borrowed*/, double port,
1018
+ ScrStr *path /*borrowed*/, ScrStr *method /*borrowed*/,
1019
+ double timeout_ms, ScrArr *header_pairs /*borrowed*/,
1020
+ bool auto_end, bool reject_unauthorized,
1021
+ const char *ca /*borrowed, len 0 = none*/, size_t ca_len,
1022
+ ScrClosure *cb /*moves, nullable*/, ScrHttpRespFn fn) {
1023
+ ScrTlsCli *cli = scr_tls_cli_new(host, reject_unauthorized, ca, ca_len);
1024
+ return scr_http_request_ex(host, port, path, method, timeout_ms, header_pairs, auto_end, cb,
1025
+ fn, 443, &scr_tls_cli_wrap, cli);
1026
+ }
1027
+
1028
+ /* https.get('https://host/path') — the URL-string spelling, sharing
1029
+ * scr_http.c's parse (which rejects a non-https scheme here with Node's
1030
+ * ERR_INVALID_PROTOCOL) and dialing through the same per-request client
1031
+ * config as the options form. No options means Node's defaults: the
1032
+ * certificate is verified against the default trust anchors. */
1033
+ ScrHttpClientReq *scr_https_request_url(ScrStr *url /*borrowed*/, ScrStr *method /*borrowed*/,
1034
+ bool auto_end, ScrClosure *cb /*moves, nullable*/,
1035
+ ScrHttpRespFn fn) {
1036
+ ScrStr *host;
1037
+ ScrStr *path;
1038
+ double port;
1039
+ if (!scr_http_url_parts(url, true, &host, &port, &path)) {
1040
+ if (cb) scr_closure_release(cb);
1041
+ return NULL; /* Invalid URL / ERR_INVALID_PROTOCOL pending */
1042
+ }
1043
+ ScrArr *pairs = scr_arr_new(SCR_ELEM_STR, 0);
1044
+ ScrHttpClientReq *c = scr_https_request(host, port, path, method, 0, pairs, auto_end,
1045
+ true /* rejectUnauthorized */, NULL, 0, cb, fn);
1046
+ scr_arr_release(pairs);
1047
+ scr_str_release(host);
1048
+ scr_str_release(path);
1049
+ return c;
1050
+ }
1051
+
1052
+ ScrHttpClientReq *scr_https_request_agent(ScrStr *host /*borrowed*/, double port,
1053
+ ScrStr *path /*borrowed*/, ScrStr *method /*borrowed*/,
1054
+ double timeout_ms, ScrArr *header_pairs /*borrowed*/,
1055
+ bool auto_end, bool reject_unauthorized,
1056
+ const char *ca /*borrowed, len 0 = none*/, size_t ca_len,
1057
+ const ScrDyn *agent /*borrowed*/,
1058
+ ScrClosure *cb /*moves, nullable*/, ScrHttpRespFn fn) {
1059
+ ScrTlsCli *cli = scr_tls_cli_new(host, reject_unauthorized, ca, ca_len);
1060
+ return scr_http_request_agent_ex(host, port, path, method, timeout_ms, header_pairs, auto_end,
1061
+ agent, cb, fn, 443, &scr_tls_cli_wrap, cli);
1062
+ }
1063
+
1064
+ /* ── RUNTIME options records (the divergence-66 stance) ────────────────
1065
+ * A non-literal options value — the checked-dynamic JS lane's dyn record
1066
+ * — reads its members at RUNTIME. Members the literal path lowers take
1067
+ * the same lowering; members whose literal forms are compile fences
1068
+ * become runtime gates that THROW the catchable fence instead of
1069
+ * behaving differently; undocumented keys drop exactly like Node drops
1070
+ * them (the value already evaluated, so dropping is always safe). */
1071
+
1072
+ static void scr_tls_opt_fence(const char *api, const char *key, const char *hint) {
1073
+ ScrJsonBuf b;
1074
+ scr_jb_init(&b);
1075
+ scr_jb_puts(&b, api);
1076
+ scr_jb_puts(&b, " option '");
1077
+ scr_jb_puts(&b, key);
1078
+ scr_jb_puts(&b, "' has no static lowering — ");
1079
+ scr_jb_puts(&b, hint);
1080
+ scr_throw_error(SCR_ERR_ERROR, scr_jb_finish(&b));
1081
+ }
1082
+
1083
+ /* JS truthiness over the dyn kinds — Node reads requestCert /
1084
+ * rejectUnauthorized through `if (options.x)`. */
1085
+ static bool scr_tls_dyn_truthy(const ScrDyn *v) {
1086
+ switch (v->kind) {
1087
+ case SCR_DYN_UNDEF:
1088
+ case SCR_DYN_NULL: return false;
1089
+ case SCR_DYN_BOOL: return v->v.b;
1090
+ case SCR_DYN_NUM: return v->v.num != 0 && v->v.num == v->v.num;
1091
+ case SCR_DYN_STR: return v->v.str->len > 0;
1092
+ default: return true; /* objects, arrays, functions, handles, bytes */
1093
+ }
1094
+ }
1095
+
1096
+ /* PEM material from a runtime option value: a string, a Buffer/Uint8Array,
1097
+ * or an array of those. `concat` (the client `ca` bundle) joins array
1098
+ * entries; cert/key arrays accept exactly one entry (one identity per
1099
+ * server here — multi-key servers fence). Returns +1 bytes, or NULL with
1100
+ * the exception pending. `what` names the fence ("a tls.createServer
1101
+ * 'cert' option"). */
1102
+ static ScrBytes *scr_tls_pem_dyn(const ScrDyn *v, const char *what, bool concat) {
1103
+ if (v->kind == SCR_DYN_STR) {
1104
+ ScrBytes *b = scr_bytes_new(SCR_BYTES_U8, (double)v->v.str->len);
1105
+ memcpy(b->data, v->v.str->data, v->v.str->len);
1106
+ return b;
1107
+ }
1108
+ if (scr_dyn_bytes_is(v, SCR_BYTES_U8)) return scr_dyn_bytes_unbox(v);
1109
+ if (v->kind == SCR_DYN_ARR) {
1110
+ if (v->v.arr.len == 0) {
1111
+ ScrJsonBuf b;
1112
+ scr_jb_init(&b);
1113
+ scr_jb_puts(&b, what);
1114
+ scr_jb_puts(&b, " holding an empty array has no static lowering — pass PEM material");
1115
+ scr_throw_error(SCR_ERR_ERROR, scr_jb_finish(&b));
1116
+ return NULL;
1117
+ }
1118
+ if (v->v.arr.len > 1 && !concat) {
1119
+ ScrJsonBuf b;
1120
+ scr_jb_init(&b);
1121
+ scr_jb_puts(&b, what);
1122
+ scr_jb_puts(&b, " with more than one array entry has no static lowering — one cert/key pair per server here");
1123
+ scr_throw_error(SCR_ERR_ERROR, scr_jb_finish(&b));
1124
+ return NULL;
1125
+ }
1126
+ /* concatenate (mbedTLS parses concatenated PEM — the ca-bundle shape) */
1127
+ size_t total = 0;
1128
+ for (size_t i = 0; i < v->v.arr.len; i++) {
1129
+ const ScrDyn *e = v->v.arr.items[i];
1130
+ if (e->kind == SCR_DYN_STR) total += e->v.str->len + 1;
1131
+ else if (scr_dyn_bytes_is(e, SCR_BYTES_U8)) total += e->v.bytes->len + 1;
1132
+ else {
1133
+ scr_dyn_arg_type_fail(what, "of type string or an instance of Buffer or Uint8Array", e);
1134
+ return NULL;
1135
+ }
1136
+ }
1137
+ ScrBytes *b = scr_bytes_new(SCR_BYTES_U8, (double)total);
1138
+ size_t off = 0;
1139
+ for (size_t i = 0; i < v->v.arr.len; i++) {
1140
+ const ScrDyn *e = v->v.arr.items[i];
1141
+ const char *p = e->kind == SCR_DYN_STR ? e->v.str->data : (const char *)e->v.bytes->data;
1142
+ size_t n = e->kind == SCR_DYN_STR ? e->v.str->len : e->v.bytes->len;
1143
+ memcpy(b->data + off, p, n);
1144
+ off += n;
1145
+ b->data[off++] = '\n'; /* PEM blocks join on line boundaries */
1146
+ }
1147
+ return b;
1148
+ }
1149
+ scr_dyn_arg_type_fail(what, "of type string or an instance of Buffer or Uint8Array", v);
1150
+ return NULL;
1151
+ }
1152
+
1153
+ /* The literal path's runtime-valued cert/key extraction (the compiler's
1154
+ * tls.pemDyn libCall): `what` arrives precomposed. undefined throws — the
1155
+ * literal walk required the member's presence. */
1156
+ ScrBytes *scr_tls_pem_from_dyn(const ScrDyn *v, const char *what) {
1157
+ if (v->kind == SCR_DYN_UNDEF || v->kind == SCR_DYN_NULL) {
1158
+ ScrJsonBuf b;
1159
+ scr_jb_init(&b);
1160
+ scr_jb_puts(&b, what);
1161
+ scr_jb_puts(&b, " holding undefined has no static lowering — pass PEM material (a string or a Buffer)");
1162
+ scr_throw_error(SCR_ERR_ERROR, scr_jb_finish(&b));
1163
+ return NULL;
1164
+ }
1165
+ return scr_tls_pem_dyn(v, what, false);
1166
+ }
1167
+
1168
+ /* The tls/https createServer documented keys OUTSIDE the implemented set
1169
+ * (cert/key/ca/requestCert/rejectUnauthorized/SNICallback walk their own
1170
+ * arms below): present-with-a-value throws the runtime fence — an option
1171
+ * that changes Node-observable behavior must work or fence, never
1172
+ * silently drop. Undocumented keys drop, exactly Node. */
1173
+ static const char *const SCR_TLS_SRV_FENCED_OPTIONS[] = {
1174
+ "ALPNProtocols", "ALPNCallback", "allowHalfOpen", "ciphers",
1175
+ "clientCertEngine", "crl", "dhparam", "ecdhCurve", "enableTrace",
1176
+ "handshakeTimeout", "highWaterMark", "honorCipherOrder", "keepAlive",
1177
+ "keepAliveInitialDelay", "maxVersion", "minVersion", "noDelay",
1178
+ "passphrase", "pauseOnConnect", "pfx", "privateKeyEngine",
1179
+ "privateKeyIdentifier", "pskCallback", "pskIdentityHint", "requestOCSP",
1180
+ "secureContext", "secureOptions", "secureProtocol", "sessionIdContext",
1181
+ "sessionTimeout", "sigalgs", "ticketKeys", NULL,
1182
+ };
1183
+
1184
+ /* ── the typed option-validation ladders (checked-dynamic lane) ────────
1185
+ * Node's configSecureContext / Server-constructor argument contracts over
1186
+ * every PRESENT validated key, run BEFORE the pem walk and its fences so
1187
+ * Node's typed errors always come first (the invalid-input probes isolate
1188
+ * one bad option per call, so the fixed order below matches each).
1189
+ * false = exception pending. */
1190
+ static bool scr_tls_opts_validate(const ScrDyn *opts) {
1191
+ if (opts == NULL || opts->kind != SCR_DYN_OBJ) return true;
1192
+ static const char *const STR_OPTS[] = { "ciphers", "passphrase", "ecdhCurve", "sessionIdContext", NULL };
1193
+ for (size_t i = 0; STR_OPTS[i] != NULL; i++) {
1194
+ const ScrDyn *v = scr_dyn_obj_get(opts, STR_OPTS[i], strlen(STR_OPTS[i]));
1195
+ if (v != NULL && v->kind != SCR_DYN_UNDEF && v->kind != SCR_DYN_NULL && v->kind != SCR_DYN_STR) {
1196
+ char name[48];
1197
+ snprintf(name, sizeof name, "options.%s", STR_OPTS[i]);
1198
+ scr_dyn_prop_type_fail(name, "of type string", v);
1199
+ return false;
1200
+ }
1201
+ }
1202
+ static const char *const ENGINE_OPTS[] = { "clientCertEngine", "privateKeyEngine", "privateKeyIdentifier", NULL };
1203
+ for (size_t i = 0; ENGINE_OPTS[i] != NULL; i++) {
1204
+ const ScrDyn *v = scr_dyn_obj_get(opts, ENGINE_OPTS[i], strlen(ENGINE_OPTS[i]));
1205
+ if (v != NULL && v->kind != SCR_DYN_UNDEF && v->kind != SCR_DYN_NULL && v->kind != SCR_DYN_STR) {
1206
+ char name[48];
1207
+ snprintf(name, sizeof name, "options.%s", ENGINE_OPTS[i]);
1208
+ scr_dyn_prop_type_fail(name, "of type string or one of null or undefined", v);
1209
+ return false;
1210
+ }
1211
+ }
1212
+ static const char *const VERSION_OPTS[] = { "minVersion", "maxVersion", NULL };
1213
+ for (size_t i = 0; VERSION_OPTS[i] != NULL; i++) {
1214
+ const ScrDyn *v = scr_dyn_obj_get(opts, VERSION_OPTS[i], strlen(VERSION_OPTS[i]));
1215
+ if (v == NULL || v->kind == SCR_DYN_UNDEF) continue;
1216
+ bool valid = false;
1217
+ if (v->kind == SCR_DYN_STR) {
1218
+ static const char *const KNOWN[] = { "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3", NULL };
1219
+ for (size_t k = 0; KNOWN[k] != NULL; k++) {
1220
+ if (v->v.str->len == strlen(KNOWN[k]) && memcmp(v->v.str->data, KNOWN[k], v->v.str->len) == 0) {
1221
+ valid = true;
1222
+ break;
1223
+ }
1224
+ }
1225
+ }
1226
+ if (!valid) {
1227
+ /* %j: strings render JSON-quoted, everything else inspect-lite. */
1228
+ char rendered[96];
1229
+ if (v->kind == SCR_DYN_STR) {
1230
+ snprintf(rendered, sizeof rendered, "\"%.*s\"",
1231
+ (int)(v->v.str->len < 80 ? v->v.str->len : 80), v->v.str->data);
1232
+ } else {
1233
+ /* %j over non-strings: JSON.stringify's scalar renderings. */
1234
+ char lite[64];
1235
+ snprintf(rendered, sizeof rendered, "%s", scr_dyn_inspect_lite(v, lite, sizeof lite));
1236
+ }
1237
+ char msg[192];
1238
+ int len = snprintf(msg, sizeof msg, "%s is not a valid %s TLS protocol version",
1239
+ rendered, VERSION_OPTS[i][2] == 'n' ? "minimum" : "maximum");
1240
+ scr_throw_error_msg_code(SCR_ERR_TYPE, msg, (size_t)len, "ERR_TLS_INVALID_PROTOCOL_VERSION");
1241
+ return false;
1242
+ }
1243
+ }
1244
+ static const char *const NUM_OPTS[] = { "handshakeTimeout", "keepAliveInitialDelay", NULL };
1245
+ for (size_t i = 0; NUM_OPTS[i] != NULL; i++) {
1246
+ const ScrDyn *v = scr_dyn_obj_get(opts, NUM_OPTS[i], strlen(NUM_OPTS[i]));
1247
+ if (v != NULL && v->kind != SCR_DYN_UNDEF && v->kind != SCR_DYN_NULL && v->kind != SCR_DYN_NUM) {
1248
+ char name[48];
1249
+ snprintf(name, sizeof name, "options.%s", NUM_OPTS[i]);
1250
+ scr_dyn_prop_type_fail(name, "of type number", v);
1251
+ return false;
1252
+ }
1253
+ }
1254
+ {
1255
+ const ScrDyn *v = scr_dyn_obj_get(opts, "sessionTimeout", 14);
1256
+ if (v != NULL && v->kind != SCR_DYN_UNDEF && v->kind != SCR_DYN_NULL) {
1257
+ if (v->kind != SCR_DYN_NUM) {
1258
+ scr_dyn_prop_type_fail("options.sessionTimeout", "of type number", v);
1259
+ return false;
1260
+ }
1261
+ double n = v->v.num;
1262
+ char recv[48], msg[192];
1263
+ if (!(isfinite(n) && trunc(n) == n)) {
1264
+ scr_num_received(n, recv);
1265
+ int len = snprintf(msg, sizeof msg,
1266
+ "The value of \"options.sessionTimeout\" is out of range. It must be an integer. Received %s", recv);
1267
+ scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)len, "ERR_OUT_OF_RANGE");
1268
+ return false;
1269
+ }
1270
+ if (n < 0 || n > 2147483647.0) {
1271
+ scr_num_received(n, recv);
1272
+ int len = snprintf(msg, sizeof msg,
1273
+ "The value of \"options.sessionTimeout\" is out of range. It must be >= 0 && <= 2147483647. Received %s", recv);
1274
+ scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)len, "ERR_OUT_OF_RANGE");
1275
+ return false;
1276
+ }
1277
+ }
1278
+ }
1279
+ {
1280
+ const ScrDyn *v = scr_dyn_obj_get(opts, "ticketKeys", 10);
1281
+ if (v != NULL && v->kind != SCR_DYN_UNDEF && v->kind != SCR_DYN_NULL) {
1282
+ if (v->kind != SCR_DYN_BYTES) {
1283
+ scr_dyn_prop_type_fail("options.ticketKeys", "an instance of Buffer, TypedArray, or DataView", v);
1284
+ return false;
1285
+ }
1286
+ double bytelen = scr_bytes_byte_len(v->v.bytes);
1287
+ if (bytelen != 48) {
1288
+ char msg[160];
1289
+ int len = snprintf(msg, sizeof msg,
1290
+ "The property 'options.ticketKeys' must be exactly 48 bytes. Received %.0f", bytelen);
1291
+ scr_throw_error_msg_code(SCR_ERR_TYPE, msg, (size_t)len, "ERR_INVALID_ARG_VALUE");
1292
+ return false;
1293
+ }
1294
+ }
1295
+ }
1296
+ return true;
1297
+ }
1298
+
1299
+ /* The server-options walk. Fills the cert/key out-params (+1 each) from a
1300
+ * dyn options record; false = exception pending (partial results released).
1301
+ * Exported runtime-internally: scr_http2.c's createSecureServerDyn rides
1302
+ * the same walk (scr_http2.c always links alongside this unit). */
1303
+ bool scr_tls_srv_opts_walk(const ScrDyn *opts, const char *api, ScrBytes **cert_out,
1304
+ ScrBytes **key_out) {
1305
+ *cert_out = NULL;
1306
+ *key_out = NULL;
1307
+ if (opts == NULL || opts->kind != SCR_DYN_OBJ) {
1308
+ scr_dyn_arg_type_fail("options", "of type object", opts ? opts : scr_dyn_undefined());
1309
+ return false;
1310
+ }
1311
+ if (!scr_tls_opts_validate(opts)) return false; /* Node's typed errors first */
1312
+ bool ok = true;
1313
+ for (size_t i = 0; ok && i < opts->v.obj.len; i++) {
1314
+ const ScrDynEntry *e = &opts->v.obj.entries[i];
1315
+ const ScrDyn *v = e->value;
1316
+ if (v->kind == SCR_DYN_UNDEF) continue; /* an undefined member reads as absent, like Node */
1317
+ if (strcmp(e->key, "cert") == 0 || strcmp(e->key, "key") == 0) {
1318
+ char what[96];
1319
+ snprintf(what, sizeof what, "a %s '%s' option", api, e->key);
1320
+ ScrBytes *b = scr_tls_pem_dyn(v, what, false);
1321
+ if (b == NULL) { ok = false; break; }
1322
+ ScrBytes **slot = e->key[0] == 'c' ? cert_out : key_out;
1323
+ scr_bytes_release(*slot);
1324
+ *slot = b;
1325
+ continue;
1326
+ }
1327
+ if (strcmp(e->key, "ca") == 0) {
1328
+ /* the server's `ca` verifies CLIENT certificates — inert without
1329
+ * requestCert (which fences below), so Node-observably droppable */
1330
+ continue;
1331
+ }
1332
+ if (strcmp(e->key, "requestCert") == 0) {
1333
+ if (scr_tls_dyn_truthy(v)) {
1334
+ scr_tls_opt_fence(api, "requestCert",
1335
+ "client-certificate handshakes are not modeled (SEMANTICS.md divergence 55) — requestCert stays at Node's false default");
1336
+ ok = false;
1337
+ }
1338
+ continue;
1339
+ }
1340
+ if (strcmp(e->key, "rejectUnauthorized") == 0) {
1341
+ continue; /* meaningful only with requestCert, which fences */
1342
+ }
1343
+ if (strcmp(e->key, "SNICallback") == 0) {
1344
+ scr_tls_opt_fence(api, "SNICallback",
1345
+ "SNICallback lowers only on http2.createSecureServer({ allowHTTP1: true, ... }) with a literal options object");
1346
+ ok = false;
1347
+ continue;
1348
+ }
1349
+ for (size_t k = 0; SCR_TLS_SRV_FENCED_OPTIONS[k] != NULL; k++) {
1350
+ if (strcmp(e->key, SCR_TLS_SRV_FENCED_OPTIONS[k]) == 0) {
1351
+ scr_tls_opt_fence(api, e->key,
1352
+ "cert and key (PEM strings or Buffers) are the honestly-implemented members of a runtime options record");
1353
+ ok = false;
1354
+ break;
1355
+ }
1356
+ }
1357
+ /* anything else: an undocumented key, dropped like Node drops it */
1358
+ }
1359
+ if (ok && (*cert_out == NULL || *key_out == NULL)) {
1360
+ ScrJsonBuf b;
1361
+ scr_jb_init(&b);
1362
+ scr_jb_puts(&b, api);
1363
+ scr_jb_puts(&b, " without both cert and key has no static lowering — the supported options are { cert, key } (PEM strings or Buffers)");
1364
+ scr_throw_error(SCR_ERR_ERROR, scr_jb_finish(&b));
1365
+ ok = false;
1366
+ }
1367
+ if (!ok) {
1368
+ scr_bytes_release(*cert_out);
1369
+ scr_bytes_release(*key_out);
1370
+ *cert_out = NULL;
1371
+ *key_out = NULL;
1372
+ }
1373
+ return ok;
1374
+ }
1375
+
1376
+ /* createSecureContext over a RUNTIME options record: Node's typed
1377
+ * validations first (scr_tls_opts_validate), then the pem walk — a bag
1378
+ * that validates AND carries both cert and key builds the real context;
1379
+ * everything else met its ladder error or the walk's per-key fence.
1380
+ * +1, or NULL with the exception pending. */
1381
+ ScrSecureCtx *scr_tls_create_secure_context_dyn(const ScrDyn *opts /*borrowed*/) {
1382
+ ScrBytes *cert, *key;
1383
+ if (!scr_tls_srv_opts_walk(opts, "tls.createSecureContext", &cert, &key)) return NULL;
1384
+ ScrSecureCtx *c = scr_tls_create_secure_context((const char *)cert->data, cert->len,
1385
+ (const char *)key->data, key->len);
1386
+ scr_bytes_release(cert);
1387
+ scr_bytes_release(key);
1388
+ return c;
1389
+ }
1390
+
1391
+ /* tls.getCACertificates(type): validateString, then the documented name
1392
+ * set — an unknown name answers ERR_INVALID_ARG_VALUE; the real CA list
1393
+ * has no lowering, so a valid name meets the fence. Always throws. */
1394
+ void scr_tls_ca_certs_chk(const ScrDyn *type, const ScrStr *fence) {
1395
+ if (type->kind != SCR_DYN_STR) {
1396
+ scr_dyn_arg_type_fail("type", "of type string", type);
1397
+ return;
1398
+ }
1399
+ static const char *const KNOWN[] = { "default", "system", "bundled", "extra", NULL };
1400
+ bool valid = false;
1401
+ for (size_t i = 0; KNOWN[i] != NULL; i++) {
1402
+ if (type->v.str->len == strlen(KNOWN[i]) &&
1403
+ memcmp(type->v.str->data, KNOWN[i], type->v.str->len) == 0) {
1404
+ valid = true;
1405
+ break;
1406
+ }
1407
+ }
1408
+ if (!valid) {
1409
+ scr_dyn_arg_value_fail("type", NULL, type);
1410
+ return;
1411
+ }
1412
+ scr_throw_lowering_fence(fence);
1413
+ }
1414
+
1415
+ ScrNetServer *scr_tls_create_server_dyn(const ScrDyn *opts /*borrowed*/,
1416
+ ScrClosure *handler /*moves, nullable*/,
1417
+ ScrNetConnFn fn) {
1418
+ ScrBytes *cert, *key;
1419
+ if (!scr_tls_srv_opts_walk(opts, "tls.createServer", &cert, &key)) {
1420
+ scr_closure_release(handler);
1421
+ return NULL;
1422
+ }
1423
+ ScrNetServer *s = scr_tls_create_server((const char *)cert->data, cert->len,
1424
+ (const char *)key->data, key->len, handler, fn);
1425
+ scr_bytes_release(cert);
1426
+ scr_bytes_release(key);
1427
+ return s;
1428
+ }
1429
+
1430
+ ScrNetServer *scr_https_create_server_dyn(const ScrDyn *opts /*borrowed*/,
1431
+ ScrClosure *handler /*moves, nullable*/,
1432
+ ScrHttpReqFn fn) {
1433
+ /* HTTPS ServerOptions extends http.ServerOptions. Consume the one HTTP
1434
+ * constructor field this runtime models before the shared TLS walker;
1435
+ * that walker deliberately owns only the TLS-side option surface. */
1436
+ bool has_timeout_buffer = false;
1437
+ double timeout_buffer = 0;
1438
+ if (opts != NULL && opts->kind == SCR_DYN_OBJ) {
1439
+ const ScrDyn *v = scr_dyn_obj_get(opts, "keepAliveTimeoutBuffer", 22);
1440
+ if (v != NULL && v->kind != SCR_DYN_UNDEF) {
1441
+ if (v->kind != SCR_DYN_NUM) {
1442
+ scr_dyn_arg_type_fail("keepAliveTimeoutBuffer", "of type number", v);
1443
+ scr_closure_release(handler);
1444
+ return NULL;
1445
+ }
1446
+ timeout_buffer = v->v.num;
1447
+ if (!scr_net_server_timeout_option_check(4, timeout_buffer)) {
1448
+ scr_closure_release(handler);
1449
+ return NULL;
1450
+ }
1451
+ has_timeout_buffer = true;
1452
+ }
1453
+ }
1454
+ ScrBytes *cert, *key;
1455
+ if (!scr_tls_srv_opts_walk(opts, "https.createServer", &cert, &key)) {
1456
+ scr_closure_release(handler);
1457
+ return NULL;
1458
+ }
1459
+ ScrNetServer *s = scr_https_create_server((const char *)cert->data, cert->len,
1460
+ (const char *)key->data, key->len, handler, fn);
1461
+ if (has_timeout_buffer) scr_net_server_timeout_set(s, 4, timeout_buffer);
1462
+ scr_bytes_release(cert);
1463
+ scr_bytes_release(key);
1464
+ return s;
1465
+ }
1466
+
1467
+ /* ── tls.connect (the TLS client socket) ──────────────────────────────── */
1468
+
1469
+ /* tls.connect's documented keys outside the implemented set: present
1470
+ * throws (the server walk's stance). */
1471
+ static const char *const SCR_TLS_CONNECT_FENCED_OPTIONS[] = {
1472
+ "ALPNProtocols", "allowHalfOpen", "autoSelectFamily",
1473
+ "autoSelectFamilyAttemptTimeout", "cert", "checkServerIdentity",
1474
+ "ciphers", "clientCertEngine", "crl", "dhparam", "ecdhCurve",
1475
+ "enableTrace", "family", "fd", "hints", "highWaterMark",
1476
+ "honorCipherOrder", "keepAlive", "keepAliveInitialDelay", "key",
1477
+ "localAddress", "localPort", "lookup", "maxVersion", "minDHSize",
1478
+ "minVersion", "noDelay", "onread", "passphrase", "path", "pfx",
1479
+ "privateKeyEngine", "privateKeyIdentifier", "pskCallback", "readable",
1480
+ "secureContext", "secureOptions", "secureProtocol", "session",
1481
+ "sessionIdContext", "sigalgs", "signal", "socket", "ticketKeys",
1482
+ "timeout", "writable", NULL,
1483
+ };
1484
+
1485
+ ScrNetSocket *scr_tls_connect_dyn(double port, ScrStr *host /*borrowed, nullable*/,
1486
+ const ScrDyn *opts /*borrowed, nullable*/,
1487
+ ScrClosure *cb /*moves, nullable*/) {
1488
+ scr_tls_rng_init();
1489
+ bool reject = true;
1490
+ ScrBytes *ca = NULL;
1491
+ const ScrStr *servername = NULL;
1492
+ const ScrStr *opt_host = NULL;
1493
+ bool ok = true;
1494
+ if (opts != NULL && opts->kind != SCR_DYN_UNDEF && opts->kind != SCR_DYN_NULL) {
1495
+ if (opts->kind != SCR_DYN_OBJ) {
1496
+ scr_dyn_arg_type_fail("options", "of type object", opts);
1497
+ ok = false;
1498
+ }
1499
+ for (size_t i = 0; ok && i < opts->v.obj.len; i++) {
1500
+ const ScrDynEntry *e = &opts->v.obj.entries[i];
1501
+ const ScrDyn *v = e->value;
1502
+ if (strcmp(e->key, "checkServerIdentity") == 0) {
1503
+ /* Node spreads user options over the defaults, so a PRESENT key
1504
+ * replaces the builtin verifier even when its value is undefined
1505
+ * — validateFunction then throws for anything non-callable. A
1506
+ * real function keeps the fence (custom verification has no
1507
+ * lowering). */
1508
+ if (v->kind != SCR_DYN_FUNC) {
1509
+ scr_dyn_prop_type_fail("options.checkServerIdentity", "of type function", v);
1510
+ ok = false;
1511
+ } else {
1512
+ scr_tls_opt_fence("tls.connect", "checkServerIdentity",
1513
+ "custom identity verification has no lowering — the runtime verifies against the servername/host");
1514
+ ok = false;
1515
+ }
1516
+ continue;
1517
+ }
1518
+ if (v->kind == SCR_DYN_UNDEF) continue;
1519
+ if (strcmp(e->key, "port") == 0) {
1520
+ if (port >= 0) continue; /* the argument form wins, like Node */
1521
+ if (v->kind == SCR_DYN_NUM) port = v->v.num;
1522
+ else if (v->kind == SCR_DYN_STR) port = strtod(v->v.str->data, NULL); /* Node coerces numeric strings */
1523
+ else {
1524
+ scr_dyn_arg_type_fail("options.port", "of type number", v);
1525
+ ok = false;
1526
+ }
1527
+ continue;
1528
+ }
1529
+ if (strcmp(e->key, "host") == 0) {
1530
+ if (v->kind == SCR_DYN_STR) opt_host = v->v.str;
1531
+ else {
1532
+ scr_dyn_arg_type_fail("options.host", "of type string", v);
1533
+ ok = false;
1534
+ }
1535
+ continue;
1536
+ }
1537
+ if (strcmp(e->key, "rejectUnauthorized") == 0) {
1538
+ reject = scr_tls_dyn_truthy(v);
1539
+ continue;
1540
+ }
1541
+ if (strcmp(e->key, "ca") == 0) {
1542
+ scr_bytes_release(ca);
1543
+ ca = scr_tls_pem_dyn(v, "a tls.connect 'ca' option", true);
1544
+ if (ca == NULL) ok = false;
1545
+ continue;
1546
+ }
1547
+ if (strcmp(e->key, "servername") == 0) {
1548
+ if (v->kind == SCR_DYN_STR) servername = v->v.str;
1549
+ else {
1550
+ scr_dyn_arg_type_fail("options.servername", "of type string", v);
1551
+ ok = false;
1552
+ }
1553
+ continue;
1554
+ }
1555
+ for (size_t k = 0; SCR_TLS_CONNECT_FENCED_OPTIONS[k] != NULL; k++) {
1556
+ if (strcmp(e->key, SCR_TLS_CONNECT_FENCED_OPTIONS[k]) == 0) {
1557
+ scr_tls_opt_fence("tls.connect", e->key,
1558
+ "port/host/rejectUnauthorized/ca/servername are the honestly-implemented members of a runtime options record");
1559
+ ok = false;
1560
+ break;
1561
+ }
1562
+ }
1563
+ /* anything else: an undocumented key, dropped like Node drops it */
1564
+ }
1565
+ }
1566
+ if (ok && port < 0) {
1567
+ scr_dyn_arg_type_fail("options.port", "of type number", scr_dyn_undefined());
1568
+ ok = false;
1569
+ }
1570
+ if (!ok) {
1571
+ scr_bytes_release(ca);
1572
+ scr_closure_release(cb);
1573
+ return NULL;
1574
+ }
1575
+ ScrStr *dial_host = (ScrStr *)(host != NULL && host->len > 0 ? host : opt_host);
1576
+ /* SNI + verification see the servername when given, the host name
1577
+ * otherwise (Node's servername default). */
1578
+ ScrStr *verify_host = (ScrStr *)(servername != NULL ? servername : dial_host);
1579
+ ScrStr *localhost_fallback = NULL;
1580
+ if (verify_host == NULL) {
1581
+ localhost_fallback = scr_str_new("localhost", 9);
1582
+ verify_host = localhost_fallback;
1583
+ }
1584
+ /* Resolve for the dial only (the http client's rule): verify_host above
1585
+ * already holds the NAME, which is what SNI and certificate verification
1586
+ * must see. A null dial_host stays null — scr_net_connect's own arm. */
1587
+ ScrStr *dial_addr = dial_host != NULL ? scr_net_blocking_lookup(dial_host) : NULL;
1588
+ ScrNetSocket *s = scr_net_connect(port, dial_addr, cb); /* cb fires post-handshake — secureConnect */
1589
+ if (dial_addr) scr_str_release(dial_addr);
1590
+ ScrTlsCli *cli = scr_tls_cli_new2(verify_host, reject,
1591
+ ca != NULL ? (const char *)ca->data : NULL,
1592
+ ca != NULL ? ca->len : 0, !reject);
1593
+ scr_tls_cli_wrap(s, cli);
1594
+ scr_str_release(localhost_fallback);
1595
+ scr_bytes_release(ca);
1596
+ return s;
1597
+ }
1598
+
1599
+ /* ── h2 over TLS (http2.createSecureServer / the https-authority client)
1600
+ * — the mbedTLS half: scr_http2.c owns the sessions and calls these two
1601
+ * (every http2-using binary links this unit — the moduleUsesTls switch
1602
+ * counts http2 libCalls). */
1603
+
1604
+ /* Wrap an h2 server: the TLS engine installs per accepted socket, ALPN
1605
+ * advertises h2 (plus http/1.1 when the caller wired an inner parser
1606
+ * hook first — none today), and on_established attaches the h2 session
1607
+ * via `h2_conn` (the ctx moves in with its release fn). */
1608
+ void scr_tls_server_wrap_h2(ScrNetServer *s, const char *cert, size_t cert_len,
1609
+ const char *key, size_t key_len,
1610
+ ScrNetNativeConnFn h2_conn, void *h2_ctx /*moves*/,
1611
+ void (*h2_ctx_free)(void *),
1612
+ ScrClosure *sni_cb /*moves, nullable*/, void *sni_answer_fn) {
1613
+ ScrTlsSrv *srv = scr_tls_srv_new(cert, cert_len, key, key_len, false);
1614
+ srv->h2_conn = h2_conn;
1615
+ srv->h2_ctx = h2_ctx;
1616
+ srv->h2_ctx_free = h2_ctx_free;
1617
+ scr_net_server_get_native_conn(s, &srv->inner_conn, &srv->inner_ctx, &srv->inner_ctx_free);
1618
+ mbedtls_ssl_conf_alpn_protocols(
1619
+ &srv->conf, srv->inner_conn != NULL ? SCR_TLS_ALPN_H2_HTTP11 : SCR_TLS_ALPN_H2);
1620
+ if (sni_cb != NULL) {
1621
+ srv->sni_cb = sni_cb;
1622
+ srv->sni_answer_fn = sni_answer_fn;
1623
+ mbedtls_ssl_conf_sni(&srv->conf, &scr_tls_f_sni, NULL);
1624
+ }
1625
+ scr_net_server_set_native_conn(s, &scr_tls_srv_on_conn, srv, &scr_tls_srv_release_v);
1626
+ scr_net_server_defer_connections(s); /* 'connection'/'secureConnection' wait for the handshake */
1627
+ }
1628
+
1629
+ /* The h2-over-TLS CLIENT wrap (http2.connect with an https authority):
1630
+ * a client transport offering ALPN ["h2"] — SNI/verification against
1631
+ * the authority host; `ca` replaces the trust anchors ("" = none) and
1632
+ * reject_unauthorized false records like tls.connect's. The session's
1633
+ * preface/SETTINGS ride the socket's write buffer until establishment. */
1634
+ void scr_tls_h2_client_wrap(ScrNetSocket *sock, ScrStr *host /*borrowed*/,
1635
+ bool reject_unauthorized, const char *ca, size_t ca_len) {
1636
+ ScrTlsCli *cli = scr_tls_cli_new2(host, reject_unauthorized, ca, ca_len, !reject_unauthorized);
1637
+ mbedtls_ssl_conf_alpn_protocols(&cli->conf, SCR_TLS_ALPN_H2);
1638
+ scr_tls_cli_wrap(sock, cli);
1639
+ }
1640
+
1641
+ /* ── the checked-dynamic TLSSocket members (scr_net.c's hook table) ──── */
1642
+
1643
+ /* Node's authorizationError: the verify-failure CODE string (null when
1644
+ * authorized). Chain errors dominate the identity check — Node records
1645
+ * ssl.verifyError() first and only reaches checkServerIdentity's
1646
+ * ERR_TLS_CERT_ALTNAME_INVALID on a VERIFIED chain. */
1647
+ static const char *scr_tls_auth_code(ScrTlsSock *t) {
1648
+ uint32_t vr = mbedtls_ssl_get_verify_result(&t->ssl);
1649
+ if (t->vrfy_expired) return "CERT_HAS_EXPIRED";
1650
+ if (t->vrfy_leaf_self) return "DEPTH_ZERO_SELF_SIGNED_CERT";
1651
+ if (t->vrfy_chain_self) return "SELF_SIGNED_CERT_IN_CHAIN";
1652
+ if (vr & MBEDTLS_X509_BADCERT_NOT_TRUSTED) return "UNABLE_TO_VERIFY_LEAF_SIGNATURE";
1653
+ if (t->vrfy_cn_mismatch) return "ERR_TLS_CERT_ALTNAME_INVALID";
1654
+ return "UNABLE_TO_VERIFY_LEAF_SIGNATURE";
1655
+ }
1656
+
1657
+ static ScrTlsSock *scr_tls_sock_of(ScrNetSocket *s) {
1658
+ return (ScrTlsSock *)scr_net_sock_transport_ctx_for(s, &SCR_TLS_OPS);
1659
+ }
1660
+
1661
+ /* The client 'session' event: fires ONCE per socket with the serialized
1662
+ * mbedTLS session — a real ticket where one arrived (the 1.3 receipt
1663
+ * path), the established session otherwise (1.2). Node fires per
1664
+ * received ticket; the once-latch satisfies the suite's once-listener
1665
+ * shapes, and resumption itself stays out (divergence 55). */
1666
+ static void scr_tls_fire_session(ScrTlsSock *t) {
1667
+ if (t->session_fired || t->session_ls.n == 0 || t->cli == NULL) return;
1668
+ mbedtls_ssl_session sess;
1669
+ mbedtls_ssl_session_init(&sess);
1670
+ if (mbedtls_ssl_get_session(&t->ssl, &sess) != 0) {
1671
+ mbedtls_ssl_session_free(&sess); /* no resumable session yet (1.3 pre-ticket) */
1672
+ return;
1673
+ }
1674
+ size_t need = 0;
1675
+ (void)mbedtls_ssl_session_save(&sess, NULL, 0, &need);
1676
+ ScrBytes *buf = scr_bytes_new(SCR_BYTES_U8, (double)need);
1677
+ size_t used = 0;
1678
+ int ok = mbedtls_ssl_session_save(&sess, buf->data, need, &used) == 0;
1679
+ mbedtls_ssl_session_free(&sess);
1680
+ if (!ok) {
1681
+ scr_bytes_release(buf);
1682
+ return;
1683
+ }
1684
+ t->session_fired = true;
1685
+ ScrNetL *snap;
1686
+ size_t n = scr_net_ls_snapshot(&t->session_ls, &snap);
1687
+ scr_dyn_this_push(t->sock, SCR_DYNH_NET_SOCKET);
1688
+ for (size_t i = 0; i < n; i++) {
1689
+ if (!scr_exc_pending()) ((ScrNetDataFn)snap[i].fn)(snap[i].cb, buf);
1690
+ scr_closure_release(snap[i].cb);
1691
+ }
1692
+ scr_dyn_this_pop();
1693
+ free(snap);
1694
+ scr_bytes_release(buf);
1695
+ }
1696
+
1697
+ /* The STATIC-lane TLSSocket members (the lowered socket surface). */
1698
+
1699
+ bool scr_tls_sock_authorized(ScrNetSocket *s) {
1700
+ ScrTlsSock *t = scr_tls_sock_of(s);
1701
+ return t != NULL && t->established && t->cli != NULL && t->cli->verify_recorded &&
1702
+ mbedtls_ssl_get_verify_result(&t->ssl) == 0;
1703
+ }
1704
+
1705
+ ScrStr *scr_tls_sock_auth_error(ScrNetSocket *s) {
1706
+ ScrTlsSock *t = scr_tls_sock_of(s);
1707
+ if (t == NULL || !t->established || t->cli == NULL || !t->cli->verify_recorded ||
1708
+ mbedtls_ssl_get_verify_result(&t->ssl) == 0) {
1709
+ return NULL; /* the null arm — authorized, or never verified */
1710
+ }
1711
+ const char *code = scr_tls_auth_code(t);
1712
+ return scr_str_new(code, strlen(code));
1713
+ }
1714
+
1715
+ void scr_tls_sock_on_secure_connect(ScrNetSocket *s, ScrClosure *cb /*moves*/, bool once) {
1716
+ if (scr_tls_sock_of(s) == NULL) {
1717
+ scr_closure_release(cb); /* a plain socket never fires it, like Node */
1718
+ return;
1719
+ }
1720
+ scr_net_sock_on_connect(s, cb, once); /* fires at establishment — secureConnect timing */
1721
+ }
1722
+
1723
+ void scr_tls_sock_on_session(ScrNetSocket *s, ScrClosure *cb /*moves*/, void *fn, bool once) {
1724
+ ScrTlsSock *t = scr_tls_sock_of(s);
1725
+ if (t == NULL) {
1726
+ scr_closure_release(cb); /* a plain socket never fires it, like Node */
1727
+ return;
1728
+ }
1729
+ scr_net_ls_add(&t->session_ls, cb, fn, once);
1730
+ if (t->established) scr_tls_fire_session(t); /* the ticket already arrived */
1731
+ }
1732
+
1733
+ static bool scr_tls_dynh_get(ScrNetSocket *s, const char *key, ScrDyn **out) {
1734
+ ScrTlsSock *t = scr_tls_sock_of(s);
1735
+ if (t == NULL) return false; /* a plain socket: the net dispatch answers */
1736
+ if (strcmp(key, "authorized") == 0) {
1737
+ bool a = t->established && t->cli != NULL && t->cli->verify_recorded &&
1738
+ mbedtls_ssl_get_verify_result(&t->ssl) == 0;
1739
+ *out = scr_dyn_new_bool(a);
1740
+ return true;
1741
+ }
1742
+ if (strcmp(key, "authorizationError") == 0) {
1743
+ if (!t->established || t->cli == NULL || !t->cli->verify_recorded ||
1744
+ mbedtls_ssl_get_verify_result(&t->ssl) == 0) {
1745
+ *out = scr_dyn_new_null();
1746
+ return true;
1747
+ }
1748
+ const char *code = scr_tls_auth_code(t);
1749
+ ScrStr *str = scr_str_new(code, strlen(code));
1750
+ *out = scr_dyn_new_str(str);
1751
+ scr_str_release(str);
1752
+ return true;
1753
+ }
1754
+ return false;
1755
+ }
1756
+
1757
+ static bool scr_tls_dynh_on(ScrNetSocket *s, const char *event, const ScrDyn *cb, bool once) {
1758
+ ScrTlsSock *t = scr_tls_sock_of(s);
1759
+ if (t == NULL) return false;
1760
+ if (strcmp(event, "secureConnect") == 0) {
1761
+ /* a TLS socket's 'connect' list fires at establishment — exactly
1762
+ * Node's secureConnect timing (scr_net.c's transport pump) */
1763
+ scr_net_sock_on_connect(s, scr_dyn_listener_closure0(cb), once);
1764
+ return true;
1765
+ }
1766
+ if (strcmp(event, "session") == 0) {
1767
+ scr_net_ls_add(&t->session_ls, scr_dyn_listener_closure_data(cb),
1768
+ (void *)&scr_dyn_listener_fire_data, once);
1769
+ /* a late registration on an established socket fires directly (the
1770
+ * ticket already arrived — nothing further would trigger it) */
1771
+ if (t->established) scr_tls_fire_session(t);
1772
+ return true;
1773
+ }
1774
+ return false;
1775
+ }
1776
+
1777
+ static bool scr_tls_dynh_invoke(ScrNetSocket *s, const char *method, ScrDyn *const *args,
1778
+ size_t argc, ScrDyn **out) {
1779
+ (void)args;
1780
+ (void)argc;
1781
+ if (scr_tls_sock_of(s) == NULL) return false;
1782
+ static const char *const tls_methods[] = {
1783
+ "getPeerCertificate", "getCertificate", "getCipher", "getProtocol", "getSession",
1784
+ "getTLSTicket", "getEphemeralKeyInfo", "getFinished", "getPeerFinished",
1785
+ "getSharedSigalgs", "getPeerX509Certificate", "getX509Certificate",
1786
+ "exportKeyingMaterial", "isSessionReused", "renegotiate", "setMaxSendFragment",
1787
+ "enableTrace", "disableRenegotiation", "setServername", "setSession", NULL,
1788
+ };
1789
+ for (size_t i = 0; tls_methods[i] != NULL; i++) {
1790
+ if (strcmp(method, tls_methods[i]) == 0) {
1791
+ char msg[160];
1792
+ int n = snprintf(msg, sizeof msg,
1793
+ "'TLSSocket.prototype.%s' on a dynamic value is not supported yet", method);
1794
+ scr_throw_error_msg(SCR_ERR_ERROR, msg, (size_t)n);
1795
+ *out = NULL;
1796
+ return true;
1797
+ }
1798
+ }
1799
+ return false;
1800
+ }
1801
+
1802
+ static const ScrNetDynhTlsHooks SCR_TLS_DYNH = {
1803
+ &scr_tls_dynh_get,
1804
+ &scr_tls_dynh_on,
1805
+ &scr_tls_dynh_invoke,
1806
+ };