@mtkruto/node 0.1.100 → 0.1.102

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 (197) hide show
  1. package/esm/0_deps.d.ts +3 -3
  2. package/esm/0_deps.js +3 -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 +55 -4
  8. package/esm/client/4_client.js +260 -72
  9. package/esm/connection/1_connection_web_socket.js +5 -2
  10. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.js +10 -3
  11. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.js +1 -0
  12. package/esm/deps/deno.land/std@0.204.0/encoding/_util.d.ts +1 -0
  13. package/esm/deps/deno.land/std@0.204.0/encoding/_util.js +26 -0
  14. package/esm/deps/deno.land/std@0.204.0/encoding/base64.d.ts +23 -0
  15. package/{script/deps/deno.land/std@0.201.0 → esm/deps/deno.land/std@0.204.0}/encoding/base64.js +23 -18
  16. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.js +1 -1
  17. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.js +10 -4
  18. package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +324 -0
  19. package/esm/tl/6_message.d.ts +1 -0
  20. package/esm/tl/6_message.js +1 -2
  21. package/esm/tl/6_message_test.d.ts +1 -0
  22. package/esm/transport/0_obfuscation.js +3 -3
  23. package/esm/transport/0_transport.d.ts +2 -2
  24. package/esm/transport/0_transport.js +2 -8
  25. package/esm/transport/1_transport_abridged.js +9 -7
  26. package/esm/transport/1_transport_intermediate.js +7 -3
  27. package/esm/types/3_message.d.ts +4 -0
  28. package/esm/types/3_message.js +4 -1
  29. package/esm/utilities/0_bigint.d.ts +1 -0
  30. package/esm/utilities/0_bigint.js +2 -0
  31. package/esm/utilities/0_crypto.d.ts +1 -1
  32. package/esm/utilities/0_crypto.js +1 -3
  33. package/esm/utilities/0_queue.js +1 -1
  34. package/package.json +1 -1
  35. package/script/0_deps.d.ts +3 -3
  36. package/script/0_deps.js +3 -3
  37. package/script/4_constants.d.ts +1 -1
  38. package/script/4_constants.js +1 -1
  39. package/script/client/0_message.js +2 -8
  40. package/script/client/3_types.d.ts +2 -0
  41. package/script/client/4_client.d.ts +55 -4
  42. package/script/client/4_client.js +260 -71
  43. package/script/connection/1_connection_web_socket.js +5 -2
  44. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.js +10 -3
  45. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.js +1 -0
  46. package/script/deps/deno.land/std@0.204.0/encoding/_util.d.ts +1 -0
  47. package/script/deps/deno.land/std@0.204.0/encoding/_util.js +30 -0
  48. package/script/deps/deno.land/std@0.204.0/encoding/base64.d.ts +23 -0
  49. package/{esm/deps/deno.land/std@0.201.0 → script/deps/deno.land/std@0.204.0}/encoding/base64.js +28 -13
  50. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.js +1 -1
  51. package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.js +10 -4
  52. package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +326 -0
  53. package/script/tl/6_message.d.ts +1 -0
  54. package/script/tl/6_message.js +2 -2
  55. package/script/tl/6_message_test.d.ts +1 -0
  56. package/script/transport/0_obfuscation.js +3 -3
  57. package/script/transport/0_transport.d.ts +2 -2
  58. package/script/transport/0_transport.js +2 -8
  59. package/script/transport/1_transport_abridged.js +9 -7
  60. package/script/transport/1_transport_intermediate.js +7 -3
  61. package/script/types/3_message.d.ts +4 -0
  62. package/script/types/3_message.js +4 -1
  63. package/script/utilities/0_bigint.d.ts +1 -0
  64. package/script/utilities/0_bigint.js +2 -0
  65. package/script/utilities/0_crypto.d.ts +1 -1
  66. package/script/utilities/0_crypto.js +1 -3
  67. package/script/utilities/0_queue.js +1 -1
  68. package/esm/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
  69. package/esm/deps/deno.land/x/tgcrypto@0.3.2/tgcrypto.js +0 -308
  70. package/script/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
  71. package/script/deps/deno.land/x/tgcrypto@0.3.2/tgcrypto.js +0 -310
  72. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.d.ts +0 -0
  73. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.js +0 -0
  74. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.d.ts +0 -0
  75. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.d.ts +0 -0
  76. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.js +0 -0
  77. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.d.ts +0 -0
  78. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.js +0 -0
  79. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.d.ts +0 -0
  80. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.js +0 -0
  81. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.d.ts +0 -0
  82. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.js +0 -0
  83. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.d.ts +0 -0
  84. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.js +0 -0
  85. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.d.ts +0 -0
  86. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.js +0 -0
  87. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.d.ts +1 -1
  88. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.d.ts +0 -0
  89. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.js +0 -0
  90. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.d.ts +0 -0
  91. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.js +0 -0
  92. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.d.ts +0 -0
  93. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.js +0 -0
  94. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.d.ts +0 -0
  95. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.js +0 -0
  96. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.d.ts +0 -0
  97. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.js +0 -0
  98. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.d.ts +0 -0
  99. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.js +0 -0
  100. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.d.ts +0 -0
  101. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.js +0 -0
  102. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.d.ts +0 -0
  103. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.js +0 -0
  104. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.d.ts +0 -0
  105. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.js +0 -0
  106. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.d.ts +0 -0
  107. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.js +0 -0
  108. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.d.ts +0 -0
  109. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.js +0 -0
  110. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.d.ts +0 -0
  111. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.js +0 -0
  112. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.d.ts +0 -0
  113. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.js +0 -0
  114. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.d.ts +0 -0
  115. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.js +0 -0
  116. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.d.ts +0 -0
  117. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.js +0 -0
  118. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.d.ts +0 -0
  119. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.js +0 -0
  120. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.d.ts +0 -0
  121. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.js +0 -0
  122. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.d.ts +0 -0
  123. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.js +0 -0
  124. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.d.ts +0 -0
  125. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.js +0 -0
  126. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.d.ts +0 -0
  127. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.js +0 -0
  128. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.d.ts +0 -0
  129. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.js +0 -0
  130. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.d.ts +0 -0
  131. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.js +0 -0
  132. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.d.ts +0 -0
  133. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.d.ts +0 -0
  134. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
  135. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.d.ts +0 -0
  136. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.js +0 -0
  137. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.d.ts +0 -0
  138. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.d.ts +0 -0
  139. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.js +0 -0
  140. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.d.ts +0 -0
  141. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.js +0 -0
  142. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.d.ts +0 -0
  143. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.js +0 -0
  144. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.d.ts +0 -0
  145. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.js +0 -0
  146. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.d.ts +0 -0
  147. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.js +0 -0
  148. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.d.ts +0 -0
  149. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.js +0 -0
  150. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.d.ts +1 -1
  151. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.d.ts +0 -0
  152. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.js +0 -0
  153. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.d.ts +0 -0
  154. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.js +0 -0
  155. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.d.ts +0 -0
  156. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.js +0 -0
  157. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.d.ts +0 -0
  158. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.js +0 -0
  159. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.d.ts +0 -0
  160. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.js +0 -0
  161. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.d.ts +0 -0
  162. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.js +0 -0
  163. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.d.ts +0 -0
  164. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.js +0 -0
  165. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.d.ts +0 -0
  166. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.js +0 -0
  167. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.d.ts +0 -0
  168. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.js +0 -0
  169. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.d.ts +0 -0
  170. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.js +0 -0
  171. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.d.ts +0 -0
  172. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.js +0 -0
  173. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.d.ts +0 -0
  174. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.js +0 -0
  175. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.d.ts +0 -0
  176. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.js +0 -0
  177. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.d.ts +0 -0
  178. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.js +0 -0
  179. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.d.ts +0 -0
  180. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.js +0 -0
  181. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.d.ts +0 -0
  182. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.js +0 -0
  183. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.d.ts +0 -0
  184. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.js +0 -0
  185. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.d.ts +0 -0
  186. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.js +0 -0
  187. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.d.ts +0 -0
  188. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.js +0 -0
  189. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.d.ts +0 -0
  190. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.js +0 -0
  191. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.d.ts +0 -0
  192. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.js +0 -0
  193. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.d.ts +0 -0
  194. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.js +0 -0
  195. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.d.ts +0 -0
  196. /package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.d.ts +0 -0
  197. /package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
@@ -1,10 +1,10 @@
1
1
  import { debug, gunzip, Mutex } from "../0_deps.js";
2
- import { bigIntFromBuffer, drop, getRandomBigInt, getRandomId, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE } from "../1_utilities.js";
2
+ import { bigIntFromBuffer, drop, getRandomBigInt, getRandomId, mod, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE } from "../1_utilities.js";
3
3
  import { as, functions, getChannelChatId, Message_, MessageContainer, peerToChatId, RPCResult, TLError, TLReader, types } from "../2_tl.js";
4
4
  import { StorageMemory } from "../3_storage.js";
5
5
  import { botCommandScopeToTlObject, constructCallbackQuery, constructInlineQuery, constructMessage, constructUser, FileID, FileType, inlineQueryResultToTlObject, messageEntityToTlObject, replyMarkupToTlObject, ThumbnailSource } from "../3_types.js";
6
6
  import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL, ZERO_CHANNEL_ID } from "../4_constants.js";
7
- import { AuthKeyUnregistered, Migrate, PasswordHashInvalid, PhoneNumberInvalid, SessionPasswordNeeded, upgradeInstance } from "../4_errors.js";
7
+ import { AuthKeyUnregistered, FloodWait, Migrate, PasswordHashInvalid, PhoneNumberInvalid, SessionPasswordNeeded, upgradeInstance } from "../4_errors.js";
8
8
  import { parseHtml } from "./0_html.js";
9
9
  import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
10
10
  import { checkPassword } from "./0_password.js";
@@ -17,11 +17,14 @@ const dGap = debug("Client/recoverUpdateGap");
17
17
  const dGapC = debug("Client/recoverChannelUpdateGap");
18
18
  const dAuth = debug("Client/authorize");
19
19
  const dRecv = debug("Client/receiveLoop");
20
+ const dUpload = debug("Client/upload");
20
21
  export const getEntity = Symbol();
21
22
  export const getStickerSetName = Symbol();
22
23
  export const handleMigrationError = Symbol();
23
24
  export const getMessageWithReply = Symbol();
24
25
  export const restartAuth = Symbol();
26
+ export class ConnectionError extends Error {
27
+ }
25
28
  export class Client extends ClientAbstract {
26
29
  /**
27
30
  * Constructs the client.
@@ -30,14 +33,8 @@ export class Client extends ClientAbstract {
30
33
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
31
34
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
32
35
  */
33
- constructor(storage = new StorageMemory(), apiId = 0, apiHash = "", params) {
36
+ constructor(storage, apiId = 0, apiHash = "", params) {
34
37
  super(params);
35
- Object.defineProperty(this, "storage", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: storage
40
- });
41
38
  Object.defineProperty(this, "apiId", {
42
39
  enumerable: true,
43
40
  configurable: true,
@@ -86,6 +83,18 @@ export class Client extends ClientAbstract {
86
83
  writable: true,
87
84
  value: void 0
88
85
  });
86
+ Object.defineProperty(this, "errorHandler", {
87
+ enumerable: true,
88
+ configurable: true,
89
+ writable: true,
90
+ value: void 0
91
+ });
92
+ Object.defineProperty(this, "storage", {
93
+ enumerable: true,
94
+ configurable: true,
95
+ writable: true,
96
+ value: void 0
97
+ });
89
98
  Object.defineProperty(this, "parseMode", {
90
99
  enumerable: true,
91
100
  configurable: true,
@@ -189,6 +198,12 @@ export class Client extends ClientAbstract {
189
198
  writable: true,
190
199
  value: null
191
200
  });
201
+ Object.defineProperty(this, "pingLoopStarted", {
202
+ enumerable: true,
203
+ configurable: true,
204
+ writable: true,
205
+ value: false
206
+ });
192
207
  Object.defineProperty(this, "autoStarted", {
193
208
  enumerable: true,
194
209
  configurable: true,
@@ -228,6 +243,7 @@ export class Client extends ClientAbstract {
228
243
  writable: true,
229
244
  value: skip
230
245
  });
246
+ this.storage = storage ?? new StorageMemory();
231
247
  this.parseMode = params?.parseMode ?? null;
232
248
  this.appVersion = params?.appVersion ?? APP_VERSION;
233
249
  this.deviceModel = params?.deviceModel ?? DEVICE_MODEL;
@@ -237,6 +253,7 @@ export class Client extends ClientAbstract {
237
253
  this.systemVersion = params?.systemVersion ?? SYSTEM_VERSION;
238
254
  this.publicKeys = params?.publicKeys;
239
255
  this.autoStart = params?.autoStart ?? true;
256
+ this.errorHandler = params?.errorHandler;
240
257
  }
241
258
  propagateConnectionState(connectionState) {
242
259
  return this.handle({ connectionState }, resolve);
@@ -306,7 +323,6 @@ export class Client extends ClientAbstract {
306
323
  }
307
324
  d("encrypted client connected");
308
325
  drop(this.receiveLoop());
309
- drop(this.pingLoop());
310
326
  }
311
327
  finally {
312
328
  release();
@@ -548,7 +564,7 @@ export class Client extends ClientAbstract {
548
564
  }
549
565
  async receiveLoop() {
550
566
  if (!this.auth || !this.transport) {
551
- throw new Error("Not connected");
567
+ throw new ConnectionError("Not connected");
552
568
  }
553
569
  while (this.connected) {
554
570
  try {
@@ -576,6 +592,9 @@ export class Client extends ClientAbstract {
576
592
  if (body instanceof types._TypeUpdates || body instanceof types._TypeUpdate) {
577
593
  this.processUpdatesQueue.add(() => this.processUpdates(body));
578
594
  }
595
+ else if (body instanceof types.NewSessionCreated) {
596
+ this.state.salt = body.serverSalt;
597
+ }
579
598
  else if (message.body instanceof RPCResult) {
580
599
  let result = message.body.result;
581
600
  if (result instanceof types.GZIPPacked) {
@@ -639,10 +658,18 @@ export class Client extends ClientAbstract {
639
658
  drop(this.recoverUpdateGap("deserialize"));
640
659
  }
641
660
  else {
642
- throw err;
661
+ dRecv("uncaught error: %o", err);
643
662
  }
644
663
  }
645
664
  }
665
+ if (!this.connected) {
666
+ for (const { reject } of this.promises.values()) {
667
+ reject(new ConnectionError("Connection was closed"));
668
+ }
669
+ }
670
+ else {
671
+ UNREACHABLE();
672
+ }
646
673
  }
647
674
  async pingLoop() {
648
675
  while (this.connected) {
@@ -661,41 +688,61 @@ export class Client extends ClientAbstract {
661
688
  await this.start();
662
689
  }
663
690
  else {
664
- throw new Error("Not connected");
691
+ throw new ConnectionError("Not connected");
665
692
  }
666
693
  }
667
694
  if (!this.auth || !this.transport) {
668
695
  UNREACHABLE();
669
696
  }
670
- let seqNo = this.state.seqNo * 2;
671
- if (!(function_ instanceof functions.Ping) && !(function_ instanceof types.MsgsAck)) {
672
- seqNo++;
673
- this.state.seqNo++;
674
- }
675
- const messageId = this.lastMsgId = getMessageId(this.lastMsgId);
676
- const message = new Message_(messageId, seqNo, function_);
677
- await this.transport.transport.send(await encryptMessage(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
678
- d("invoked %s", function_.constructor.name);
679
- if (noWait) {
680
- return;
681
- }
682
- let result;
683
- try {
684
- result = await new Promise((resolve, reject) => {
685
- this.promises.set(message.id, { resolve, reject });
686
- });
687
- }
688
- catch (err) {
689
- if (err instanceof AuthKeyUnregistered) {
690
- await this.propagateAuthorizationState(false);
697
+ let n = 1;
698
+ while (true) {
699
+ try {
700
+ let seqNo = this.state.seqNo * 2;
701
+ if (!(function_ instanceof functions.Ping) && !(function_ instanceof types.MsgsAck)) {
702
+ seqNo++;
703
+ this.state.seqNo++;
704
+ }
705
+ const messageId = this.lastMsgId = getMessageId(this.lastMsgId);
706
+ const message = new Message_(messageId, seqNo, function_);
707
+ await this.transport.transport.send(await encryptMessage(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
708
+ d("invoked %s", function_.constructor.name);
709
+ if (noWait) {
710
+ return;
711
+ }
712
+ let result;
713
+ try {
714
+ result = await new Promise((resolve, reject) => {
715
+ this.promises.set(message.id, { resolve, reject });
716
+ });
717
+ }
718
+ catch (err) {
719
+ if (err instanceof AuthKeyUnregistered) {
720
+ await this.propagateAuthorizationState(false);
721
+ }
722
+ throw err;
723
+ }
724
+ if (result instanceof types.BadServerSalt) {
725
+ return await this.invoke(function_);
726
+ }
727
+ else {
728
+ if (!this.pingLoopStarted) {
729
+ drop(this.pingLoop());
730
+ this.pingLoopStarted = true;
731
+ }
732
+ return result;
733
+ }
734
+ }
735
+ catch (err) {
736
+ if (this.errorHandler === undefined) {
737
+ throw err;
738
+ }
739
+ if (this.errorHandler !== undefined && await this.errorHandler(err, function_, n++)) {
740
+ continue;
741
+ }
742
+ else {
743
+ throw err;
744
+ }
691
745
  }
692
- throw err;
693
- }
694
- if (result instanceof types.BadServerSalt) {
695
- return await this.invoke(function_);
696
- }
697
- else {
698
- return result;
699
746
  }
700
747
  }
701
748
  /**
@@ -1152,10 +1199,10 @@ export class Client extends ClientAbstract {
1152
1199
  const messages = new Array();
1153
1200
  if (updates instanceof types.Updates) {
1154
1201
  for (const update of updates.updates) {
1155
- if (update instanceof types.UpdateNewMessage) {
1202
+ if (update instanceof types.UpdateNewMessage || update instanceof types.UpdateEditMessage) {
1156
1203
  messages.push(await constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
1157
1204
  }
1158
- else if (update instanceof types.UpdateNewChannelMessage) {
1205
+ else if (update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage) {
1159
1206
  messages.push(await constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
1160
1207
  }
1161
1208
  }
@@ -1236,7 +1283,7 @@ export class Client extends ClientAbstract {
1236
1283
  */
1237
1284
  async editMessageText(chatId, messageId, text, params) {
1238
1285
  const [message, entities] = this.parseText(text, params);
1239
- await this.invoke(new functions.MessagesEditMessage({
1286
+ const result = await this.invoke(new functions.MessagesEditMessage({
1240
1287
  id: messageId,
1241
1288
  peer: await this.getInputPeer(chatId),
1242
1289
  entities,
@@ -1244,6 +1291,8 @@ export class Client extends ClientAbstract {
1244
1291
  noWebpage: params?.disableWebPagePreview ? true : undefined,
1245
1292
  replyMarkup: await this.constructReplyMarkup(params),
1246
1293
  }));
1294
+ const message_ = await this.updatesToMessages(chatId, result).then((v) => v[0]);
1295
+ return Client.assertMsgHas(message_, "text");
1247
1296
  }
1248
1297
  async getMessagesInner(chatId_, messageIds) {
1249
1298
  const peer = await this.getInputPeer(chatId_);
@@ -1305,29 +1354,30 @@ export class Client extends ClientAbstract {
1305
1354
  const messages = await this.getMessages(chatId, [messageId]);
1306
1355
  return messages[0] ?? null;
1307
1356
  }
1308
- async *downloadInner(location, dcId) {
1309
- let client = null;
1310
- if (dcId != undefined && dcId != this.dcId) {
1311
- const exportedAuth = await this.invoke(new functions.AuthExportAuthorization({ dcId }));
1312
- client = new Client(new StorageMemory(), this.apiId, this.apiHash, {
1313
- transportProvider: this.transportProvider,
1314
- appVersion: this.appVersion,
1315
- deviceModel: this.deviceModel,
1316
- langCode: this.langCode,
1317
- langPack: this.langPack,
1318
- systemLangCode: this.systemLangCode,
1319
- systemVersion: this.systemVersion,
1320
- cdn: true,
1321
- });
1322
- let dc = String(dcId);
1323
- if (this.dcId < 0) {
1324
- dc += "-test";
1325
- }
1326
- await client.setDc(dc);
1327
- await client.connect();
1328
- await client.authorize(exportedAuth);
1329
- }
1330
- const limit = 1024 * 1024;
1357
+ async *downloadInner(location, dcId, params) {
1358
+ const chunkSize = params?.chunkSize ?? 1024 * 1024;
1359
+ if (mod(chunkSize, 1024) != 0) {
1360
+ throw new Error("chunkSize must be divisible by 1024");
1361
+ }
1362
+ const exportedAuth = await this.invoke(new functions.AuthExportAuthorization({ dcId }));
1363
+ const client = new Client(new StorageMemory(), this.apiId, this.apiHash, {
1364
+ transportProvider: this.transportProvider,
1365
+ appVersion: this.appVersion,
1366
+ deviceModel: this.deviceModel,
1367
+ langCode: this.langCode,
1368
+ langPack: this.langPack,
1369
+ systemLangCode: this.systemLangCode,
1370
+ systemVersion: this.systemVersion,
1371
+ cdn: true,
1372
+ });
1373
+ let dc = String(dcId);
1374
+ if (this.dcId < 0) {
1375
+ dc += "-test";
1376
+ }
1377
+ await client.setDc(dc);
1378
+ await client.connect();
1379
+ await client.authorize(exportedAuth);
1380
+ const limit = chunkSize;
1331
1381
  let offset = 0n;
1332
1382
  while (true) {
1333
1383
  const file = await (client ?? this).invoke(new functions.UploadGetFile({ location, offset, limit }));
@@ -1350,14 +1400,14 @@ export class Client extends ClientAbstract {
1350
1400
  *
1351
1401
  * @param fileId The identifier of the file to download.
1352
1402
  */
1353
- async download(fileId) {
1403
+ async download(fileId, params) {
1354
1404
  const fileId_ = FileID.decode(fileId);
1355
1405
  switch (fileId_.fileType) {
1356
1406
  case FileType.ChatPhoto: {
1357
1407
  const big = fileId_.params.thumbnailSource == ThumbnailSource.ChatPhotoBig;
1358
1408
  const peer = await this.getInputPeer(fileId_.params.chatId);
1359
1409
  const location = new types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photoId: fileId_.params.mediaId });
1360
- return this.downloadInner(location);
1410
+ return this.downloadInner(location, fileId_.dcId, params);
1361
1411
  }
1362
1412
  case FileType.Photo: {
1363
1413
  if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
@@ -1369,7 +1419,7 @@ export class Client extends ClientAbstract {
1369
1419
  fileReference: fileId_.params.fileReference,
1370
1420
  thumbSize: fileId_.params.thumbnailSize,
1371
1421
  });
1372
- return this.downloadInner(location);
1422
+ return this.downloadInner(location, fileId_.dcId, params);
1373
1423
  }
1374
1424
  default:
1375
1425
  UNREACHABLE();
@@ -1607,17 +1657,107 @@ export class Client extends ClientAbstract {
1607
1657
  }
1608
1658
  await this.invoke(new functions.MessagesSetTyping({ peer: await this.getInputPeer(chatId), action, topMsgId: messageThreadId }));
1609
1659
  }
1660
+ /**
1661
+ * Upload a file.
1662
+ *
1663
+ * @param contents The contents of the file.
1664
+ */
1665
+ async upload(contents, params) {
1666
+ const isBig = contents.length > 1048576; // 10 MB
1667
+ const chunkSize = params?.chunkSize ?? 512 * 1024;
1668
+ if (mod(chunkSize, 1024) != 0) {
1669
+ throw new Error("chunkSize must be divisible by 1024");
1670
+ }
1671
+ const signal = params?.signal;
1672
+ dUpload("uploading " + (isBig ? "big " : "") + "file of size " + contents.length + " with chunk size of " + chunkSize);
1673
+ const fileId = getRandomId();
1674
+ const name = params?.fileName ?? fileId.toString();
1675
+ const client = new Client(this.storage, this.apiId, this.apiHash, {
1676
+ transportProvider: this.transportProvider,
1677
+ appVersion: this.appVersion,
1678
+ deviceModel: this.deviceModel,
1679
+ langCode: this.langCode,
1680
+ langPack: this.langPack,
1681
+ systemLangCode: this.systemLangCode,
1682
+ systemVersion: this.systemVersion,
1683
+ cdn: true,
1684
+ initialDc: this.initialDc,
1685
+ autoStart: false,
1686
+ });
1687
+ signal?.addEventListener("abort", () => drop(client.disconnect()));
1688
+ client.state.salt = this.state.salt;
1689
+ await client.connect();
1690
+ let part = 0;
1691
+ const partCount = Math.ceil(contents.length / chunkSize);
1692
+ try {
1693
+ main: for (; part < partCount; part++) {
1694
+ chunk: while (true) {
1695
+ try {
1696
+ const start = part * chunkSize;
1697
+ const end = start + chunkSize;
1698
+ const bytes = contents.slice(start, end);
1699
+ if (bytes.length == 0) {
1700
+ continue main;
1701
+ }
1702
+ if (isBig) {
1703
+ await client.invoke(new functions.UploadSaveBigFilePart({ fileId, filePart: part, bytes, fileTotalParts: partCount }));
1704
+ }
1705
+ else {
1706
+ await client.invoke(new functions.UploadSaveFilePart({ fileId, bytes, filePart: part }));
1707
+ }
1708
+ dUpload((part + 1) + " out of " + partCount + " chunks have been uploaded so far");
1709
+ break chunk;
1710
+ }
1711
+ catch (err) {
1712
+ if (signal?.aborted) {
1713
+ break main;
1714
+ }
1715
+ if (err instanceof FloodWait) {
1716
+ dUpload("got a flood wait of " + err.seconds + " seconds");
1717
+ await new Promise((r) => setTimeout(r, err.seconds * 1000));
1718
+ }
1719
+ else if (err instanceof ConnectionError) {
1720
+ while (true) {
1721
+ try {
1722
+ await new Promise((r) => setTimeout(r, 3000));
1723
+ await client.connect();
1724
+ }
1725
+ catch {
1726
+ if (signal?.aborted) {
1727
+ break main;
1728
+ }
1729
+ }
1730
+ }
1731
+ }
1732
+ else {
1733
+ throw err;
1734
+ }
1735
+ }
1736
+ }
1737
+ }
1738
+ }
1739
+ finally {
1740
+ drop(client.disconnect());
1741
+ }
1742
+ dUpload("uploaded all " + partCount + " chunk(s)");
1743
+ if (isBig) {
1744
+ return new types.InputFileBig({ id: fileId, parts: contents.length / chunkSize, name });
1745
+ }
1746
+ else {
1747
+ return new types.InputFile({ id: fileId, name, parts: part, md5Checksum: "" });
1748
+ }
1749
+ }
1610
1750
  async setMyCommands(commands, params) {
1611
1751
  await this.invoke(new functions.BotsSetBotCommands({
1612
1752
  commands: commands.map((v) => new types.BotCommand(v)),
1613
1753
  langCode: params?.languageCode ?? "",
1614
- scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)), // TODO: use params.scope
1754
+ scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
1615
1755
  }));
1616
1756
  }
1617
1757
  async getMyCommands(params) {
1618
1758
  const commands_ = await this.invoke(new functions.BotsGetBotCommands({
1619
1759
  langCode: params?.languageCode ?? "",
1620
- scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)), // TODO: use params.scope
1760
+ scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
1621
1761
  }));
1622
1762
  return commands_.map((v) => ({ command: v.command, description: v.description }));
1623
1763
  }
@@ -1679,4 +1819,52 @@ export class Client extends ClientAbstract {
1679
1819
  }
1680
1820
  }, handler);
1681
1821
  }
1822
+ async setMyInfo(info) {
1823
+ await this.invoke(new functions.BotsSetBotInfo({ bot: new types.InputUserSelf(), ...info }));
1824
+ }
1825
+ /**
1826
+ * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
1827
+ */
1828
+ async setMyDescription({ description, languageCode }) {
1829
+ await this.assertBot("setMyDescription");
1830
+ await this.setMyInfo({ description, langCode: languageCode ?? "" });
1831
+ }
1832
+ /**
1833
+ * Use this method to change the bot's name.
1834
+ */
1835
+ async setMyName({ name, languageCode }) {
1836
+ await this.assertBot("setMyName");
1837
+ await this.setMyInfo({ name, langCode: languageCode ?? "" });
1838
+ }
1839
+ /**
1840
+ * Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.
1841
+ */
1842
+ async setMyShortDescription({ shortDescription: about, languageCode }) {
1843
+ await this.assertBot("setMyShortDescription");
1844
+ await this.setMyInfo({ about, langCode: languageCode ?? "" });
1845
+ }
1846
+ getMyInfo(languageCode) {
1847
+ return this.invoke(new functions.BotsGetBotInfo({ bot: new types.InputUserSelf(), langCode: languageCode ?? "" }));
1848
+ }
1849
+ /**
1850
+ * Use this method to get the current bot description for the given user language.
1851
+ */
1852
+ async getMyDescription(languageCode) {
1853
+ await this.assertBot("getMyDescription");
1854
+ return await this.getMyInfo(languageCode).then((v) => v.description);
1855
+ }
1856
+ /**
1857
+ * Use this method to get the current bot name for the given user language.
1858
+ */
1859
+ async getMyName(languageCode) {
1860
+ await this.assertBot("getMyName");
1861
+ return await this.getMyInfo(languageCode).then((v) => v.description);
1862
+ }
1863
+ /**
1864
+ * Use this method to get the current bot short description for the given user language.
1865
+ */
1866
+ async getMyShortDescription(languageCode) {
1867
+ await this.assertBot("getMyShortDescription");
1868
+ return await this.getMyInfo(languageCode).then((v) => v.about);
1869
+ }
1682
1870
  }
@@ -81,7 +81,7 @@ export class ConnectionWebSocket extends ConnectionUnframed {
81
81
  this.buffer.push(byte);
82
82
  }
83
83
  if (this.nextResolve != null && this.buffer.length >= this.nextResolve[0]) {
84
- this.nextResolve[1]();
84
+ this.nextResolve[1].resolve();
85
85
  this.nextResolve = null;
86
86
  }
87
87
  release();
@@ -136,7 +136,7 @@ export class ConnectionWebSocket extends ConnectionUnframed {
136
136
  const release = await this.rMutex.acquire();
137
137
  try {
138
138
  if (this.buffer.length < p.length) {
139
- await new Promise((r) => this.nextResolve = [p.length, r]);
139
+ await new Promise((resolve, reject) => this.nextResolve = [p.length, { resolve, reject }]);
140
140
  }
141
141
  p.set(this.buffer.splice(0, p.length));
142
142
  }
@@ -161,5 +161,8 @@ export class ConnectionWebSocket extends ConnectionUnframed {
161
161
  throw new Error("Connection not open");
162
162
  }
163
163
  this.webSocket.close(1000, "method");
164
+ if (this.nextResolve != null) {
165
+ this.nextResolve[1].reject(new Error("Connection not open"));
166
+ }
164
167
  }
165
168
  }
@@ -239,14 +239,21 @@ export function diffstr(A, B) {
239
239
  }
240
240
  }
241
241
  // Compute word-diff
242
- const aLines = added.length < removed.length ? added : removed;
243
- const bLines = aLines === removed ? added : removed;
242
+ const hasMoreRemovedLines = added.length < removed.length;
243
+ const aLines = hasMoreRemovedLines ? added : removed;
244
+ const bLines = hasMoreRemovedLines ? removed : added;
244
245
  for (const a of aLines) {
245
246
  let tokens = [], b;
246
247
  // Search another diff line with at least one common token
247
248
  while (bLines.length) {
248
249
  b = bLines.shift();
249
- tokens = diff(tokenize(a.value, { wordDiff: true }), tokenize(b?.value ?? "", { wordDiff: true }));
250
+ const tokenized = [
251
+ tokenize(a.value, { wordDiff: true }),
252
+ tokenize(b?.value ?? "", { wordDiff: true }),
253
+ ];
254
+ if (hasMoreRemovedLines)
255
+ tokenized.reverse();
256
+ tokens = diff(tokenized[0], tokenized[1]);
250
257
  if (tokens.some(({ type, value }) => type === DiffType.common && value.trim().length)) {
251
258
  break;
252
259
  }
@@ -1,5 +1,6 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
2
  import { AssertionError } from "./assertion_error.js";
3
+ /** Make an assertion, error will be thrown if `expr` have truthy value. */
3
4
  export function assertFalse(expr, msg = "") {
4
5
  if (expr) {
5
6
  throw new AssertionError(msg);
@@ -0,0 +1 @@
1
+ export declare function validateBinaryLike(source: unknown): Uint8Array;
@@ -0,0 +1,26 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ const encoder = new TextEncoder();
3
+ function getTypeName(value) {
4
+ const type = typeof value;
5
+ if (type !== "object") {
6
+ return type;
7
+ }
8
+ else if (value === null) {
9
+ return "null";
10
+ }
11
+ else {
12
+ return value?.constructor?.name ?? "object";
13
+ }
14
+ }
15
+ export function validateBinaryLike(source) {
16
+ if (typeof source === "string") {
17
+ return encoder.encode(source);
18
+ }
19
+ else if (source instanceof Uint8Array) {
20
+ return source;
21
+ }
22
+ else if (source instanceof ArrayBuffer) {
23
+ return new Uint8Array(source);
24
+ }
25
+ throw new TypeError(`The input must be a Uint8Array, a string, or an ArrayBuffer. Received a value of the type ${getTypeName(source)}.`);
26
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @deprecated (will be removed in 0.210.0) Use a `encodeBase64` instead.
3
+ *
4
+ * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
5
+ * Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation
6
+ * @param data
7
+ */
8
+ export declare const encode: typeof encodeBase64;
9
+ /**
10
+ * @deprecated (will be removed in 0.210.0) Use a `decodeBase64` instead.
11
+ *
12
+ * Decodes a given RFC4648 base64 encoded string
13
+ * @param b64
14
+ */
15
+ export declare const decode: typeof decodeBase64;
16
+ /**
17
+ * Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation
18
+ */
19
+ export declare function encodeBase64(data: ArrayBuffer | Uint8Array | string): string;
20
+ /**
21
+ * Decodes a given RFC4648 base64 encoded string
22
+ */
23
+ export declare function decodeBase64(b64: string): Uint8Array;