@mtkruto/node 0.1.100 → 0.1.101

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 (231) hide show
  1. package/esm/0_deps.d.ts +4 -3
  2. package/esm/0_deps.js +4 -3
  3. package/esm/4_constants.d.ts +1 -1
  4. package/esm/4_constants.js +1 -1
  5. package/esm/client/0_message.js +3 -9
  6. package/esm/client/3_types.d.ts +2 -0
  7. package/esm/client/4_client.d.ts +19 -3
  8. package/esm/client/4_client.js +209 -68
  9. package/esm/connection/1_connection_web_socket.js +5 -2
  10. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.js +1 -0
  11. package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.d.ts +2 -0
  12. package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.js +24 -0
  13. package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.d.ts +2 -0
  14. package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.js +27 -0
  15. package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/mod.d.ts +1 -0
  16. package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/mod.js +21 -0
  17. package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/util.d.ts +13 -0
  18. package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/util.js +48 -0
  19. package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.d.ts +125 -0
  20. package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.js +3337 -0
  21. package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/mod.d.ts +12 -0
  22. package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/mod.js +39 -0
  23. package/esm/deps/deno.land/std@0.203.0/crypto/crypto.d.ts +157 -0
  24. package/esm/deps/deno.land/std@0.203.0/crypto/crypto.js +266 -0
  25. package/esm/deps/deno.land/std@0.203.0/crypto/keystack.d.ts +4 -0
  26. package/esm/deps/deno.land/std@0.203.0/crypto/keystack.js +6 -0
  27. package/esm/deps/deno.land/std@0.203.0/crypto/mod.d.ts +12 -0
  28. package/esm/deps/deno.land/std@0.203.0/crypto/mod.js +14 -0
  29. package/esm/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.d.ts +28 -0
  30. package/esm/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.js +54 -0
  31. package/esm/deps/deno.land/std@0.203.0/crypto/to_hash_string.d.ts +19 -0
  32. package/esm/deps/deno.land/std@0.203.0/crypto/to_hash_string.js +31 -0
  33. package/esm/deps/deno.land/std@0.203.0/crypto/unstable/keystack.d.ts +46 -0
  34. package/esm/deps/deno.land/std@0.203.0/crypto/unstable/keystack.js +149 -0
  35. package/esm/deps/deno.land/std@0.203.0/encoding/_util.d.ts +1 -0
  36. package/esm/deps/deno.land/std@0.203.0/encoding/_util.js +26 -0
  37. package/esm/deps/deno.land/std@0.203.0/encoding/base64.d.ts +23 -0
  38. package/{script/deps/deno.land/std@0.201.0 → esm/deps/deno.land/std@0.203.0}/encoding/base64.js +23 -18
  39. package/esm/deps/deno.land/std@0.203.0/encoding/base64url.d.ts +24 -0
  40. package/esm/deps/deno.land/std@0.203.0/encoding/base64url.js +80 -0
  41. package/esm/deps/deno.land/std@0.203.0/encoding/hex.d.ts +18 -0
  42. package/esm/deps/deno.land/std@0.203.0/encoding/hex.js +115 -0
  43. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.js +1 -1
  44. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.js +10 -4
  45. package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +324 -0
  46. package/esm/types/3_message.js +1 -1
  47. package/esm/utilities/0_bigint.d.ts +1 -0
  48. package/esm/utilities/0_bigint.js +1 -0
  49. package/esm/utilities/0_queue.js +1 -1
  50. package/package.json +1 -1
  51. package/script/0_deps.d.ts +4 -3
  52. package/script/0_deps.js +6 -4
  53. package/script/4_constants.d.ts +1 -1
  54. package/script/4_constants.js +1 -1
  55. package/script/client/0_message.js +2 -8
  56. package/script/client/3_types.d.ts +2 -0
  57. package/script/client/4_client.d.ts +19 -3
  58. package/script/client/4_client.js +208 -66
  59. package/script/connection/1_connection_web_socket.js +5 -2
  60. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.js +1 -0
  61. package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.d.ts +2 -0
  62. package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.js +29 -0
  63. package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.d.ts +2 -0
  64. package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.js +32 -0
  65. package/script/deps/deno.land/std@0.203.0/crypto/_fnv/mod.d.ts +1 -0
  66. package/script/deps/deno.land/std@0.203.0/crypto/_fnv/mod.js +25 -0
  67. package/script/deps/deno.land/std@0.203.0/crypto/_fnv/util.d.ts +13 -0
  68. package/script/deps/deno.land/std@0.203.0/crypto/_fnv/util.js +54 -0
  69. package/script/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.d.ts +125 -0
  70. package/script/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.js +3345 -0
  71. package/script/deps/deno.land/std@0.203.0/crypto/_wasm/mod.d.ts +12 -0
  72. package/script/deps/deno.land/std@0.203.0/crypto/_wasm/mod.js +44 -0
  73. package/script/deps/deno.land/std@0.203.0/crypto/crypto.d.ts +157 -0
  74. package/script/deps/deno.land/std@0.203.0/crypto/crypto.js +292 -0
  75. package/script/deps/deno.land/std@0.203.0/crypto/keystack.d.ts +4 -0
  76. package/script/deps/deno.land/std@0.203.0/crypto/keystack.js +22 -0
  77. package/script/deps/deno.land/std@0.203.0/crypto/mod.d.ts +12 -0
  78. package/script/deps/deno.land/std@0.203.0/crypto/mod.js +30 -0
  79. package/script/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.d.ts +28 -0
  80. package/script/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.js +58 -0
  81. package/script/deps/deno.land/std@0.203.0/crypto/to_hash_string.d.ts +19 -0
  82. package/script/deps/deno.land/std@0.203.0/crypto/to_hash_string.js +35 -0
  83. package/script/deps/deno.land/std@0.203.0/crypto/unstable/keystack.d.ts +46 -0
  84. package/script/deps/deno.land/std@0.203.0/crypto/unstable/keystack.js +176 -0
  85. package/script/deps/deno.land/std@0.203.0/encoding/_util.d.ts +1 -0
  86. package/script/deps/deno.land/std@0.203.0/encoding/_util.js +30 -0
  87. package/script/deps/deno.land/std@0.203.0/encoding/base64.d.ts +23 -0
  88. package/{esm/deps/deno.land/std@0.201.0 → script/deps/deno.land/std@0.203.0}/encoding/base64.js +28 -13
  89. package/script/deps/deno.land/std@0.203.0/encoding/base64url.d.ts +24 -0
  90. package/script/deps/deno.land/std@0.203.0/encoding/base64url.js +108 -0
  91. package/script/deps/deno.land/std@0.203.0/encoding/hex.d.ts +18 -0
  92. package/script/deps/deno.land/std@0.203.0/encoding/hex.js +122 -0
  93. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.js +1 -1
  94. package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.js +10 -4
  95. package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +326 -0
  96. package/script/types/3_message.js +1 -1
  97. package/script/utilities/0_bigint.d.ts +1 -0
  98. package/script/utilities/0_bigint.js +1 -0
  99. package/script/utilities/0_queue.js +1 -1
  100. package/esm/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
  101. package/esm/deps/deno.land/x/tgcrypto@0.3.2/tgcrypto.js +0 -308
  102. package/script/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
  103. package/script/deps/deno.land/x/tgcrypto@0.3.2/tgcrypto.js +0 -310
  104. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.d.ts +0 -0
  105. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.js +0 -0
  106. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.d.ts +0 -0
  107. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.js +0 -0
  108. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.d.ts +0 -0
  109. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.js +0 -0
  110. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.d.ts +0 -0
  111. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.js +0 -0
  112. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.d.ts +0 -0
  113. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.js +0 -0
  114. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.d.ts +0 -0
  115. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.js +0 -0
  116. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.d.ts +0 -0
  117. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.js +0 -0
  118. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.d.ts +0 -0
  119. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.js +0 -0
  120. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.d.ts +1 -1
  121. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.d.ts +0 -0
  122. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.js +0 -0
  123. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.d.ts +0 -0
  124. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.js +0 -0
  125. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.d.ts +0 -0
  126. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.js +0 -0
  127. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.d.ts +0 -0
  128. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.js +0 -0
  129. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.d.ts +0 -0
  130. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.js +0 -0
  131. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.d.ts +0 -0
  132. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.js +0 -0
  133. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.d.ts +0 -0
  134. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.js +0 -0
  135. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.d.ts +0 -0
  136. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.js +0 -0
  137. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.d.ts +0 -0
  138. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.js +0 -0
  139. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.d.ts +0 -0
  140. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.js +0 -0
  141. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.d.ts +0 -0
  142. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.js +0 -0
  143. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.d.ts +0 -0
  144. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.js +0 -0
  145. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.d.ts +0 -0
  146. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.js +0 -0
  147. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.d.ts +0 -0
  148. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.js +0 -0
  149. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.d.ts +0 -0
  150. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.js +0 -0
  151. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.d.ts +0 -0
  152. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.js +0 -0
  153. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.d.ts +0 -0
  154. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.js +0 -0
  155. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.d.ts +0 -0
  156. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.js +0 -0
  157. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.d.ts +0 -0
  158. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.js +0 -0
  159. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.d.ts +0 -0
  160. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.js +0 -0
  161. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.d.ts +0 -0
  162. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.js +0 -0
  163. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.d.ts +0 -0
  164. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.js +0 -0
  165. package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.d.ts +0 -0
  166. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.d.ts +0 -0
  167. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
  168. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.d.ts +0 -0
  169. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.js +0 -0
  170. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.d.ts +0 -0
  171. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.js +0 -0
  172. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.d.ts +0 -0
  173. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.js +0 -0
  174. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.d.ts +0 -0
  175. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.js +0 -0
  176. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.d.ts +0 -0
  177. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.js +0 -0
  178. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.d.ts +0 -0
  179. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.js +0 -0
  180. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.d.ts +0 -0
  181. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.js +0 -0
  182. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.d.ts +0 -0
  183. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.js +0 -0
  184. package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.d.ts +1 -1
  185. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.d.ts +0 -0
  186. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.js +0 -0
  187. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.d.ts +0 -0
  188. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.js +0 -0
  189. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.d.ts +0 -0
  190. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.js +0 -0
  191. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.d.ts +0 -0
  192. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.js +0 -0
  193. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.d.ts +0 -0
  194. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.js +0 -0
  195. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.d.ts +0 -0
  196. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.js +0 -0
  197. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.d.ts +0 -0
  198. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.js +0 -0
  199. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.d.ts +0 -0
  200. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.js +0 -0
  201. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.d.ts +0 -0
  202. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.js +0 -0
  203. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.d.ts +0 -0
  204. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.js +0 -0
  205. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.d.ts +0 -0
  206. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.js +0 -0
  207. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.d.ts +0 -0
  208. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.js +0 -0
  209. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.d.ts +0 -0
  210. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.js +0 -0
  211. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.d.ts +0 -0
  212. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.js +0 -0
  213. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.d.ts +0 -0
  214. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.js +0 -0
  215. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.d.ts +0 -0
  216. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.js +0 -0
  217. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.d.ts +0 -0
  218. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.js +0 -0
  219. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.d.ts +0 -0
  220. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.js +0 -0
  221. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.d.ts +0 -0
  222. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.js +0 -0
  223. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.d.ts +0 -0
  224. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.js +0 -0
  225. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.d.ts +0 -0
  226. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.js +0 -0
  227. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.d.ts +0 -0
  228. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.js +0 -0
  229. /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.d.ts +0 -0
  230. /package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.d.ts +0 -0
  231. /package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
@@ -12,8 +12,9 @@ export declare const getStickerSetName: unique symbol;
12
12
  export declare const handleMigrationError: unique symbol;
13
13
  export declare const getMessageWithReply: unique symbol;
14
14
  export declare const restartAuth: unique symbol;
15
+ export declare class ConnectionError extends Error {
16
+ }
15
17
  export declare class Client extends ClientAbstract {
16
- readonly storage: Storage;
17
18
  readonly apiId: number | null;
18
19
  readonly apiHash: string | null;
19
20
  private auth;
@@ -22,6 +23,8 @@ export declare class Client extends ClientAbstract {
22
23
  private promises;
23
24
  private toAcknowledge;
24
25
  private updateState?;
26
+ private readonly errorHandler?;
27
+ readonly storage: Storage;
25
28
  readonly parseMode: ParseMode;
26
29
  readonly appVersion: string;
27
30
  readonly deviceModel: string;
@@ -38,7 +41,7 @@ export declare class Client extends ClientAbstract {
38
41
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
39
42
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
40
43
  */
41
- constructor(storage?: Storage, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
44
+ constructor(storage: Storage | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
42
45
  private propagateConnectionState;
43
46
  private lastPropagatedConnectionState;
44
47
  protected stateChangeHandler: (connected: boolean) => void;
@@ -91,6 +94,7 @@ export declare class Client extends ClientAbstract {
91
94
  start(params?: string | types.AuthExportedAuthorization | AuthorizeUserParams): Promise<void>;
92
95
  private receiveLoop;
93
96
  private pingLoop;
97
+ private pingLoopStarted;
94
98
  private autoStarted;
95
99
  private lastMsgId;
96
100
  /**
@@ -164,7 +168,9 @@ export declare class Client extends ClientAbstract {
164
168
  *
165
169
  * @param fileId The identifier of the file to download.
166
170
  */
167
- download(fileId: string): Promise<AsyncGenerator<Uint8Array, void, unknown>>;
171
+ download(fileId: string, params?: {
172
+ chunkSize?: number;
173
+ }): Promise<AsyncGenerator<Uint8Array, void, unknown>>;
168
174
  [getStickerSetName](inputStickerSet: types.InputStickerSetID, hash?: number): Promise<string>;
169
175
  /**
170
176
  * Forward multiple messages.
@@ -212,6 +218,16 @@ export declare class Client extends ClientAbstract {
212
218
  * @param messageThreadId The thread to send the chat action to.
213
219
  */
214
220
  sendChatAction(chatId: ChatID, action_: ChatAction, messageThreadId?: number): Promise<void>;
221
+ /**
222
+ * Upload a file.
223
+ *
224
+ * @param contents The contents of the file.
225
+ */
226
+ upload(contents: Uint8Array, params?: {
227
+ fileName?: string;
228
+ chunkSize?: number;
229
+ signal?: AbortSignal | null;
230
+ }): Promise<types.InputFile | types.InputFileBig>;
215
231
  setMyCommands(commands: BotCommand[], params?: {
216
232
  languageCode?: string;
217
233
  scope?: BotCommandScope;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
3
+ exports.Client = exports.ConnectionError = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
4
4
  const _0_deps_js_1 = require("../0_deps.js");
5
5
  const _1_utilities_js_1 = require("../1_utilities.js");
6
6
  const _2_tl_js_1 = require("../2_tl.js");
@@ -20,11 +20,15 @@ const dGap = (0, _0_deps_js_1.debug)("Client/recoverUpdateGap");
20
20
  const dGapC = (0, _0_deps_js_1.debug)("Client/recoverChannelUpdateGap");
21
21
  const dAuth = (0, _0_deps_js_1.debug)("Client/authorize");
22
22
  const dRecv = (0, _0_deps_js_1.debug)("Client/receiveLoop");
23
+ const dUpload = (0, _0_deps_js_1.debug)("Client/upload");
23
24
  exports.getEntity = Symbol();
24
25
  exports.getStickerSetName = Symbol();
25
26
  exports.handleMigrationError = Symbol();
26
27
  exports.getMessageWithReply = Symbol();
27
28
  exports.restartAuth = Symbol();
29
+ class ConnectionError extends Error {
30
+ }
31
+ exports.ConnectionError = ConnectionError;
28
32
  class Client extends _1_client_abstract_js_1.ClientAbstract {
29
33
  /**
30
34
  * Constructs the client.
@@ -33,14 +37,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
33
37
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
34
38
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
35
39
  */
36
- constructor(storage = new _3_storage_js_1.StorageMemory(), apiId = 0, apiHash = "", params) {
40
+ constructor(storage, apiId = 0, apiHash = "", params) {
37
41
  super(params);
38
- Object.defineProperty(this, "storage", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: storage
43
- });
44
42
  Object.defineProperty(this, "apiId", {
45
43
  enumerable: true,
46
44
  configurable: true,
@@ -89,6 +87,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
89
87
  writable: true,
90
88
  value: void 0
91
89
  });
90
+ Object.defineProperty(this, "errorHandler", {
91
+ enumerable: true,
92
+ configurable: true,
93
+ writable: true,
94
+ value: void 0
95
+ });
96
+ Object.defineProperty(this, "storage", {
97
+ enumerable: true,
98
+ configurable: true,
99
+ writable: true,
100
+ value: void 0
101
+ });
92
102
  Object.defineProperty(this, "parseMode", {
93
103
  enumerable: true,
94
104
  configurable: true,
@@ -192,6 +202,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
192
202
  writable: true,
193
203
  value: null
194
204
  });
205
+ Object.defineProperty(this, "pingLoopStarted", {
206
+ enumerable: true,
207
+ configurable: true,
208
+ writable: true,
209
+ value: false
210
+ });
195
211
  Object.defineProperty(this, "autoStarted", {
196
212
  enumerable: true,
197
213
  configurable: true,
@@ -231,6 +247,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
231
247
  writable: true,
232
248
  value: _3_types_js_2.skip
233
249
  });
250
+ this.storage = storage ?? new _3_storage_js_1.StorageMemory();
234
251
  this.parseMode = params?.parseMode ?? null;
235
252
  this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
236
253
  this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
@@ -240,6 +257,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
240
257
  this.systemVersion = params?.systemVersion ?? _4_constants_js_1.SYSTEM_VERSION;
241
258
  this.publicKeys = params?.publicKeys;
242
259
  this.autoStart = params?.autoStart ?? true;
260
+ this.errorHandler = params?.errorHandler;
243
261
  }
244
262
  propagateConnectionState(connectionState) {
245
263
  return this.handle({ connectionState }, _0_utilities_js_1.resolve);
@@ -309,7 +327,6 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
309
327
  }
310
328
  d("encrypted client connected");
311
329
  (0, _1_utilities_js_1.drop)(this.receiveLoop());
312
- (0, _1_utilities_js_1.drop)(this.pingLoop());
313
330
  }
314
331
  finally {
315
332
  release();
@@ -551,7 +568,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
551
568
  }
552
569
  async receiveLoop() {
553
570
  if (!this.auth || !this.transport) {
554
- throw new Error("Not connected");
571
+ throw new ConnectionError("Not connected");
555
572
  }
556
573
  while (this.connected) {
557
574
  try {
@@ -579,6 +596,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
579
596
  if (body instanceof _2_tl_js_1.types._TypeUpdates || body instanceof _2_tl_js_1.types._TypeUpdate) {
580
597
  this.processUpdatesQueue.add(() => this.processUpdates(body));
581
598
  }
599
+ else if (body instanceof _2_tl_js_1.types.NewSessionCreated) {
600
+ this.state.salt = body.serverSalt;
601
+ }
582
602
  else if (message.body instanceof _2_tl_js_1.RPCResult) {
583
603
  let result = message.body.result;
584
604
  if (result instanceof _2_tl_js_1.types.GZIPPacked) {
@@ -642,10 +662,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
642
662
  (0, _1_utilities_js_1.drop)(this.recoverUpdateGap("deserialize"));
643
663
  }
644
664
  else {
645
- throw err;
665
+ dRecv("uncaught error: %o", err);
646
666
  }
647
667
  }
648
668
  }
669
+ if (!this.connected) {
670
+ for (const { reject } of this.promises.values()) {
671
+ reject(new ConnectionError("Connection was closed"));
672
+ }
673
+ }
674
+ else {
675
+ (0, _1_utilities_js_1.UNREACHABLE)();
676
+ }
649
677
  }
650
678
  async pingLoop() {
651
679
  while (this.connected) {
@@ -664,41 +692,61 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
664
692
  await this.start();
665
693
  }
666
694
  else {
667
- throw new Error("Not connected");
695
+ throw new ConnectionError("Not connected");
668
696
  }
669
697
  }
670
698
  if (!this.auth || !this.transport) {
671
699
  (0, _1_utilities_js_1.UNREACHABLE)();
672
700
  }
673
- let seqNo = this.state.seqNo * 2;
674
- if (!(function_ instanceof _2_tl_js_1.functions.Ping) && !(function_ instanceof _2_tl_js_1.types.MsgsAck)) {
675
- seqNo++;
676
- this.state.seqNo++;
677
- }
678
- const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
679
- const message = new _2_tl_js_1.Message_(messageId, seqNo, function_);
680
- await this.transport.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
681
- d("invoked %s", function_.constructor.name);
682
- if (noWait) {
683
- return;
684
- }
685
- let result;
686
- try {
687
- result = await new Promise((resolve, reject) => {
688
- this.promises.set(message.id, { resolve, reject });
689
- });
690
- }
691
- catch (err) {
692
- if (err instanceof _4_errors_js_1.AuthKeyUnregistered) {
693
- await this.propagateAuthorizationState(false);
701
+ let n = 1;
702
+ while (true) {
703
+ try {
704
+ let seqNo = this.state.seqNo * 2;
705
+ if (!(function_ instanceof _2_tl_js_1.functions.Ping) && !(function_ instanceof _2_tl_js_1.types.MsgsAck)) {
706
+ seqNo++;
707
+ this.state.seqNo++;
708
+ }
709
+ const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
710
+ const message = new _2_tl_js_1.Message_(messageId, seqNo, function_);
711
+ await this.transport.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
712
+ d("invoked %s", function_.constructor.name);
713
+ if (noWait) {
714
+ return;
715
+ }
716
+ let result;
717
+ try {
718
+ result = await new Promise((resolve, reject) => {
719
+ this.promises.set(message.id, { resolve, reject });
720
+ });
721
+ }
722
+ catch (err) {
723
+ if (err instanceof _4_errors_js_1.AuthKeyUnregistered) {
724
+ await this.propagateAuthorizationState(false);
725
+ }
726
+ throw err;
727
+ }
728
+ if (result instanceof _2_tl_js_1.types.BadServerSalt) {
729
+ return await this.invoke(function_);
730
+ }
731
+ else {
732
+ if (!this.pingLoopStarted) {
733
+ (0, _1_utilities_js_1.drop)(this.pingLoop());
734
+ this.pingLoopStarted = true;
735
+ }
736
+ return result;
737
+ }
738
+ }
739
+ catch (err) {
740
+ if (this.errorHandler === undefined) {
741
+ throw err;
742
+ }
743
+ if (this.errorHandler !== undefined && await this.errorHandler(err, function_, n++)) {
744
+ continue;
745
+ }
746
+ else {
747
+ throw err;
748
+ }
694
749
  }
695
- throw err;
696
- }
697
- if (result instanceof _2_tl_js_1.types.BadServerSalt) {
698
- return await this.invoke(function_);
699
- }
700
- else {
701
- return result;
702
750
  }
703
751
  }
704
752
  /**
@@ -1308,29 +1356,30 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1308
1356
  const messages = await this.getMessages(chatId, [messageId]);
1309
1357
  return messages[0] ?? null;
1310
1358
  }
1311
- async *downloadInner(location, dcId) {
1312
- let client = null;
1313
- if (dcId != undefined && dcId != this.dcId) {
1314
- const exportedAuth = await this.invoke(new _2_tl_js_1.functions.AuthExportAuthorization({ dcId }));
1315
- client = new Client(new _3_storage_js_1.StorageMemory(), this.apiId, this.apiHash, {
1316
- transportProvider: this.transportProvider,
1317
- appVersion: this.appVersion,
1318
- deviceModel: this.deviceModel,
1319
- langCode: this.langCode,
1320
- langPack: this.langPack,
1321
- systemLangCode: this.systemLangCode,
1322
- systemVersion: this.systemVersion,
1323
- cdn: true,
1324
- });
1325
- let dc = String(dcId);
1326
- if (this.dcId < 0) {
1327
- dc += "-test";
1328
- }
1329
- await client.setDc(dc);
1330
- await client.connect();
1331
- await client.authorize(exportedAuth);
1332
- }
1333
- const limit = 1024 * 1024;
1359
+ async *downloadInner(location, dcId, params) {
1360
+ const chunkSize = params?.chunkSize ?? 1024 * 1024;
1361
+ if ((0, _1_utilities_js_1.mod)(chunkSize, 1024) != 0) {
1362
+ throw new Error("chunkSize must be divisible by 1024");
1363
+ }
1364
+ const exportedAuth = await this.invoke(new _2_tl_js_1.functions.AuthExportAuthorization({ dcId }));
1365
+ const client = new Client(new _3_storage_js_1.StorageMemory(), this.apiId, this.apiHash, {
1366
+ transportProvider: this.transportProvider,
1367
+ appVersion: this.appVersion,
1368
+ deviceModel: this.deviceModel,
1369
+ langCode: this.langCode,
1370
+ langPack: this.langPack,
1371
+ systemLangCode: this.systemLangCode,
1372
+ systemVersion: this.systemVersion,
1373
+ cdn: true,
1374
+ });
1375
+ let dc = String(dcId);
1376
+ if (this.dcId < 0) {
1377
+ dc += "-test";
1378
+ }
1379
+ await client.setDc(dc);
1380
+ await client.connect();
1381
+ await client.authorize(exportedAuth);
1382
+ const limit = chunkSize;
1334
1383
  let offset = 0n;
1335
1384
  while (true) {
1336
1385
  const file = await (client ?? this).invoke(new _2_tl_js_1.functions.UploadGetFile({ location, offset, limit }));
@@ -1353,14 +1402,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1353
1402
  *
1354
1403
  * @param fileId The identifier of the file to download.
1355
1404
  */
1356
- async download(fileId) {
1405
+ async download(fileId, params) {
1357
1406
  const fileId_ = _3_types_js_1.FileID.decode(fileId);
1358
1407
  switch (fileId_.fileType) {
1359
1408
  case _3_types_js_1.FileType.ChatPhoto: {
1360
1409
  const big = fileId_.params.thumbnailSource == _3_types_js_1.ThumbnailSource.ChatPhotoBig;
1361
1410
  const peer = await this.getInputPeer(fileId_.params.chatId);
1362
1411
  const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photoId: fileId_.params.mediaId });
1363
- return this.downloadInner(location);
1412
+ return this.downloadInner(location, fileId_.dcId, params);
1364
1413
  }
1365
1414
  case _3_types_js_1.FileType.Photo: {
1366
1415
  if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
@@ -1372,7 +1421,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1372
1421
  fileReference: fileId_.params.fileReference,
1373
1422
  thumbSize: fileId_.params.thumbnailSize,
1374
1423
  });
1375
- return this.downloadInner(location);
1424
+ return this.downloadInner(location, fileId_.dcId, params);
1376
1425
  }
1377
1426
  default:
1378
1427
  (0, _1_utilities_js_1.UNREACHABLE)();
@@ -1610,6 +1659,99 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1610
1659
  }
1611
1660
  await this.invoke(new _2_tl_js_1.functions.MessagesSetTyping({ peer: await this.getInputPeer(chatId), action, topMsgId: messageThreadId }));
1612
1661
  }
1662
+ /**
1663
+ * Upload a file.
1664
+ *
1665
+ * @param contents The contents of the file.
1666
+ */
1667
+ async upload(contents, params) {
1668
+ const isBig = contents.length > 1048576; // 10 MB
1669
+ const chunkSize = params?.chunkSize ?? 512 * 1024;
1670
+ if ((0, _1_utilities_js_1.mod)(chunkSize, 1024) != 0) {
1671
+ throw new Error("chunkSize must be divisible by 1024");
1672
+ }
1673
+ const signal = params?.signal;
1674
+ dUpload("uploading " + (isBig ? "big " : "") + "file of size " + contents.length + " with chunk size of " + chunkSize);
1675
+ const fileId = (0, _1_utilities_js_1.getRandomId)();
1676
+ const name = params?.fileName ?? fileId.toString();
1677
+ const client = new Client(this.storage, this.apiId, this.apiHash, {
1678
+ transportProvider: this.transportProvider,
1679
+ appVersion: this.appVersion,
1680
+ deviceModel: this.deviceModel,
1681
+ langCode: this.langCode,
1682
+ langPack: this.langPack,
1683
+ systemLangCode: this.systemLangCode,
1684
+ systemVersion: this.systemVersion,
1685
+ cdn: true,
1686
+ initialDc: this.initialDc,
1687
+ autoStart: false,
1688
+ });
1689
+ signal?.addEventListener("abort", () => (0, _1_utilities_js_1.drop)(client.disconnect()));
1690
+ client.state.salt = this.state.salt;
1691
+ await client.connect();
1692
+ let part = 0;
1693
+ const md5sum = await _0_deps_js_1.crypto.subtle.digest("MD5", contents).then((v) => [...new Uint8Array(v)]
1694
+ .map((b) => b.toString(16).padStart(2, "0"))
1695
+ .join(""));
1696
+ const partCount = Math.ceil(contents.length / chunkSize);
1697
+ try {
1698
+ main: for (; part < partCount; part++) {
1699
+ chunk: while (true) {
1700
+ try {
1701
+ const start = part * chunkSize;
1702
+ const end = start + chunkSize;
1703
+ const bytes = contents.slice(start, end);
1704
+ if (bytes.length == 0) {
1705
+ continue main;
1706
+ }
1707
+ if (isBig) {
1708
+ await client.invoke(new _2_tl_js_1.functions.UploadSaveBigFilePart({ fileId, filePart: part, bytes, fileTotalParts: partCount }));
1709
+ }
1710
+ else {
1711
+ await client.invoke(new _2_tl_js_1.functions.UploadSaveFilePart({ fileId, bytes, filePart: part }));
1712
+ }
1713
+ dUpload((part + 1) + " out of " + partCount + " chunks have been uploaded so far");
1714
+ break chunk;
1715
+ }
1716
+ catch (err) {
1717
+ if (signal?.aborted) {
1718
+ break main;
1719
+ }
1720
+ if (err instanceof _4_errors_js_1.FloodWait) {
1721
+ dUpload("got a flood wait of " + err.seconds + " seconds");
1722
+ await new Promise((r) => setTimeout(r, err.seconds * 1000));
1723
+ }
1724
+ else if (err instanceof ConnectionError) {
1725
+ while (true) {
1726
+ try {
1727
+ await new Promise((r) => setTimeout(r, 3000));
1728
+ await client.connect();
1729
+ }
1730
+ catch {
1731
+ if (signal?.aborted) {
1732
+ break main;
1733
+ }
1734
+ }
1735
+ }
1736
+ }
1737
+ else {
1738
+ throw err;
1739
+ }
1740
+ }
1741
+ }
1742
+ }
1743
+ }
1744
+ finally {
1745
+ (0, _1_utilities_js_1.drop)(client.disconnect());
1746
+ }
1747
+ dUpload("uploaded all " + partCount + " chunk(s)");
1748
+ if (isBig) {
1749
+ return new _2_tl_js_1.types.InputFileBig({ id: fileId, parts: contents.length / chunkSize, name });
1750
+ }
1751
+ else {
1752
+ return new _2_tl_js_1.types.InputFile({ id: fileId, name, parts: part, md5Checksum: md5sum });
1753
+ }
1754
+ }
1613
1755
  async setMyCommands(commands, params) {
1614
1756
  await this.invoke(new _2_tl_js_1.functions.BotsSetBotCommands({
1615
1757
  commands: commands.map((v) => new _2_tl_js_1.types.BotCommand(v)),
@@ -107,7 +107,7 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
107
107
  this.buffer.push(byte);
108
108
  }
109
109
  if (this.nextResolve != null && this.buffer.length >= this.nextResolve[0]) {
110
- this.nextResolve[1]();
110
+ this.nextResolve[1].resolve();
111
111
  this.nextResolve = null;
112
112
  }
113
113
  release();
@@ -162,7 +162,7 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
162
162
  const release = await this.rMutex.acquire();
163
163
  try {
164
164
  if (this.buffer.length < p.length) {
165
- await new Promise((r) => this.nextResolve = [p.length, r]);
165
+ await new Promise((resolve, reject) => this.nextResolve = [p.length, { resolve, reject }]);
166
166
  }
167
167
  p.set(this.buffer.splice(0, p.length));
168
168
  }
@@ -187,6 +187,9 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
187
187
  throw new Error("Connection not open");
188
188
  }
189
189
  this.webSocket.close(1000, "method");
190
+ if (this.nextResolve != null) {
191
+ this.nextResolve[1].reject(new Error("Connection not open"));
192
+ }
190
193
  }
191
194
  }
192
195
  exports.ConnectionWebSocket = ConnectionWebSocket;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertFalse = void 0;
4
4
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
5
  const assertion_error_js_1 = require("./assertion_error.js");
6
+ /** Make an assertion, error will be thrown if `expr` have truthy value. */
6
7
  function assertFalse(expr, msg = "") {
7
8
  if (expr) {
8
9
  throw new assertion_error_js_1.AssertionError(msg);
@@ -0,0 +1,2 @@
1
+ export declare const fnv32: (data: Uint8Array) => ArrayBuffer;
2
+ export declare const fnv32a: (data: Uint8Array) => ArrayBuffer;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // Ported from Go:
3
+ // https://github.com/golang/go/tree/go1.13.10/src/hash/fnv/fnv.go
4
+ // Copyright 2011 The Go Authors. All rights reserved. BSD license.
5
+ // https://github.com/golang/go/blob/master/LICENSE
6
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
7
+ // This module is browser compatible.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.fnv32a = exports.fnv32 = void 0;
10
+ const util_js_1 = require("./util.js");
11
+ const prime32 = 16777619;
12
+ const fnv32 = (data) => {
13
+ let hash = 2166136261;
14
+ data.forEach((c) => {
15
+ hash = (0, util_js_1.mul32)(hash, prime32);
16
+ hash ^= c;
17
+ });
18
+ return Uint32Array.from([(0, util_js_1.swap32)(hash)]).buffer;
19
+ };
20
+ exports.fnv32 = fnv32;
21
+ const fnv32a = (data) => {
22
+ let hash = 2166136261;
23
+ data.forEach((c) => {
24
+ hash ^= c;
25
+ hash = (0, util_js_1.mul32)(hash, prime32);
26
+ });
27
+ return Uint32Array.from([(0, util_js_1.swap32)(hash)]).buffer;
28
+ };
29
+ exports.fnv32a = fnv32a;
@@ -0,0 +1,2 @@
1
+ export declare const fnv64: (data: Uint8Array) => ArrayBuffer;
2
+ export declare const fnv64a: (data: Uint8Array) => ArrayBuffer;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // Ported from Go:
3
+ // https://github.com/golang/go/tree/go1.13.10/src/hash/fnv/fnv.go
4
+ // Copyright 2011 The Go Authors. All rights reserved. BSD license.
5
+ // https://github.com/golang/go/blob/master/LICENSE
6
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
7
+ // This module is browser compatible.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.fnv64a = exports.fnv64 = void 0;
10
+ const util_js_1 = require("./util.js");
11
+ const prime64Lo = 435;
12
+ const prime64Hi = 256;
13
+ const fnv64 = (data) => {
14
+ let hashLo = 2216829733;
15
+ let hashHi = 3421674724;
16
+ data.forEach((c) => {
17
+ [hashHi, hashLo] = (0, util_js_1.mul64)([hashHi, hashLo], [prime64Hi, prime64Lo]);
18
+ hashLo ^= c;
19
+ });
20
+ return new Uint32Array([(0, util_js_1.swap32)(hashHi >>> 0), (0, util_js_1.swap32)(hashLo >>> 0)]).buffer;
21
+ };
22
+ exports.fnv64 = fnv64;
23
+ const fnv64a = (data) => {
24
+ let hashLo = 2216829733;
25
+ let hashHi = 3421674724;
26
+ data.forEach((c) => {
27
+ hashLo ^= c;
28
+ [hashHi, hashLo] = (0, util_js_1.mul64)([hashHi, hashLo], [prime64Hi, prime64Lo]);
29
+ });
30
+ return new Uint32Array([(0, util_js_1.swap32)(hashHi >>> 0), (0, util_js_1.swap32)(hashLo >>> 0)]).buffer;
31
+ };
32
+ exports.fnv64a = fnv64a;
@@ -0,0 +1 @@
1
+ export declare function fnv(name: string, buf?: Uint8Array): ArrayBuffer;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.fnv = void 0;
6
+ const fnv32_js_1 = require("./fnv32.js");
7
+ const fnv64_js_1 = require("./fnv64.js");
8
+ function fnv(name, buf) {
9
+ if (!buf) {
10
+ throw new TypeError("no data provided for hashing");
11
+ }
12
+ switch (name) {
13
+ case "FNV32":
14
+ return (0, fnv32_js_1.fnv32)(buf);
15
+ case "FNV64":
16
+ return (0, fnv64_js_1.fnv64)(buf);
17
+ case "FNV32A":
18
+ return (0, fnv32_js_1.fnv32a)(buf);
19
+ case "FNV64A":
20
+ return (0, fnv64_js_1.fnv64a)(buf);
21
+ default:
22
+ throw new TypeError(`unsupported fnv digest: ${name}`);
23
+ }
24
+ }
25
+ exports.fnv = fnv;
@@ -0,0 +1,13 @@
1
+ export declare function swap32(val: number): number;
2
+ /**
3
+ * mul32 performs 32-bit multiplication, a * b
4
+ * @param a
5
+ * @param b
6
+ */
7
+ export declare function mul32(a: number, b: number): number;
8
+ /**
9
+ * mul64 performs 64-bit multiplication with two 32-bit words
10
+ * @param [ah, al]
11
+ * @param [bh, bl]
12
+ */
13
+ export declare function mul64([ah, al]: [number, number], [bh, bl]: [number, number]): [number, number];