git-remote-ops 0.1.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 (274) hide show
  1. package/AGENTS.md +33 -32
  2. package/README.md +80 -206
  3. package/dist/cli.js +215 -0
  4. package/dist/cli.js.map +1 -0
  5. package/{types → dist}/client.d.ts +11 -15
  6. package/dist/client.d.ts.map +1 -0
  7. package/{esm → dist}/client.js +107 -83
  8. package/dist/client.js.map +1 -0
  9. package/{types → dist}/errors.d.ts +30 -16
  10. package/dist/errors.d.ts.map +1 -0
  11. package/{esm → dist}/errors.js +17 -8
  12. package/dist/errors.js.map +1 -0
  13. package/{types → dist}/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/{esm → dist}/index.js +2 -0
  16. package/dist/index.js.map +1 -0
  17. package/{types → dist}/logger.d.ts +11 -0
  18. package/dist/logger.d.ts.map +1 -0
  19. package/{esm → dist}/logger.js +3 -19
  20. package/dist/logger.js.map +1 -0
  21. package/{esm → dist}/objects/commit.js +1 -0
  22. package/dist/objects/commit.js.map +1 -0
  23. package/{esm → dist}/objects/index.js +1 -0
  24. package/dist/objects/index.js.map +1 -0
  25. package/{types → dist}/objects/tree.d.ts.map +1 -1
  26. package/{esm → dist}/objects/tree.js +2 -2
  27. package/dist/objects/tree.js.map +1 -0
  28. package/{esm → dist}/pack/delta.js +1 -0
  29. package/dist/pack/delta.js.map +1 -0
  30. package/{esm → dist}/pack/index.js +1 -0
  31. package/dist/pack/index.js.map +1 -0
  32. package/{types → dist}/pack/objects.d.ts.map +1 -1
  33. package/{esm → dist}/pack/objects.js +3 -3
  34. package/dist/pack/objects.js.map +1 -0
  35. package/{types → dist}/pack/parser.d.ts +19 -3
  36. package/dist/pack/parser.d.ts.map +1 -0
  37. package/{esm → dist}/pack/parser.js +46 -15
  38. package/dist/pack/parser.js.map +1 -0
  39. package/{esm → dist}/protocol/index.js +1 -0
  40. package/dist/protocol/index.js.map +1 -0
  41. package/{types → dist}/protocol/pkt_line.d.ts +3 -3
  42. package/{types → dist}/protocol/pkt_line.d.ts.map +1 -1
  43. package/{esm → dist}/protocol/pkt_line.js +1 -0
  44. package/dist/protocol/pkt_line.js.map +1 -0
  45. package/{esm → dist}/protocol/refs.js +1 -0
  46. package/dist/protocol/refs.js.map +1 -0
  47. package/{types → dist}/protocol/upload_pack.d.ts +1 -0
  48. package/{types → dist}/protocol/upload_pack.d.ts.map +1 -1
  49. package/{esm → dist}/protocol/upload_pack.js +10 -1
  50. package/dist/protocol/upload_pack.js.map +1 -0
  51. package/dist/store.d.ts +28 -0
  52. package/dist/store.d.ts.map +1 -0
  53. package/dist/store.js +179 -0
  54. package/dist/store.js.map +1 -0
  55. package/{types → dist}/transport.d.ts +15 -2
  56. package/dist/transport.d.ts.map +1 -0
  57. package/{esm → dist}/transport.js +44 -15
  58. package/dist/transport.js.map +1 -0
  59. package/{types → dist}/types.d.ts +12 -7
  60. package/dist/types.d.ts.map +1 -0
  61. package/{esm → dist}/types.js +1 -0
  62. package/dist/types.js.map +1 -0
  63. package/package.json +42 -29
  64. package/esm/_dnt.shims.js +0 -72
  65. package/esm/cli.js +0 -217
  66. package/esm/deps/jsr.io/@cliffy/command/1.1.0/_argument_types.js +0 -1
  67. package/esm/deps/jsr.io/@cliffy/command/1.1.0/_errors.js +0 -133
  68. package/esm/deps/jsr.io/@cliffy/command/1.1.0/_spread.js +0 -1
  69. package/esm/deps/jsr.io/@cliffy/command/1.1.0/_type_utils.js +0 -1
  70. package/esm/deps/jsr.io/@cliffy/command/1.1.0/_utils.js +0 -141
  71. package/esm/deps/jsr.io/@cliffy/command/1.1.0/command.js +0 -1861
  72. package/esm/deps/jsr.io/@cliffy/command/1.1.0/help/_help_generator.js +0 -357
  73. package/esm/deps/jsr.io/@cliffy/command/1.1.0/mod.js +0 -13
  74. package/esm/deps/jsr.io/@cliffy/command/1.1.0/type.js +0 -27
  75. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/action_list.js +0 -16
  76. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/boolean.js +0 -13
  77. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/child_command.js +0 -14
  78. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/command.js +0 -9
  79. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/enum.js +0 -24
  80. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/file.js +0 -12
  81. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/integer.js +0 -9
  82. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/number.js +0 -9
  83. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/secret.js +0 -7
  84. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types/string.js +0 -9
  85. package/esm/deps/jsr.io/@cliffy/command/1.1.0/types.js +0 -2
  86. package/esm/deps/jsr.io/@cliffy/command/1.1.0/upgrade/_check_version.js +0 -26
  87. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/_errors.js +0 -129
  88. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/_utils.js +0 -100
  89. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/_validate_flags.js +0 -166
  90. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/flags.js +0 -750
  91. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/mod.js +0 -55
  92. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/types/boolean.js +0 -11
  93. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/types/integer.js +0 -9
  94. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/types/number.js +0 -11
  95. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/types/string.js +0 -4
  96. package/esm/deps/jsr.io/@cliffy/flags/1.1.0/types.js +0 -1
  97. package/esm/deps/jsr.io/@cliffy/internal/1.1.0/runtime/exit.js +0 -16
  98. package/esm/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_args.js +0 -11
  99. package/esm/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_columns.js +0 -25
  100. package/esm/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_env.js +0 -18
  101. package/esm/deps/jsr.io/@cliffy/internal/1.1.0/runtime/inspect.js +0 -11
  102. package/esm/deps/jsr.io/@cliffy/table/1.1.0/_layout.js +0 -616
  103. package/esm/deps/jsr.io/@cliffy/table/1.1.0/_utils.js +0 -79
  104. package/esm/deps/jsr.io/@cliffy/table/1.1.0/border.js +0 -18
  105. package/esm/deps/jsr.io/@cliffy/table/1.1.0/cell.js +0 -190
  106. package/esm/deps/jsr.io/@cliffy/table/1.1.0/column.js +0 -117
  107. package/esm/deps/jsr.io/@cliffy/table/1.1.0/consume_words.js +0 -64
  108. package/esm/deps/jsr.io/@cliffy/table/1.1.0/mod.js +0 -42
  109. package/esm/deps/jsr.io/@cliffy/table/1.1.0/row.js +0 -82
  110. package/esm/deps/jsr.io/@cliffy/table/1.1.0/table.js +0 -341
  111. package/esm/deps/jsr.io/@cliffy/table/1.1.0/unicode_width.js +0 -101
  112. package/esm/deps/jsr.io/@std/crypto/1.1.0/_types.js +0 -2
  113. package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.js +0 -237
  114. package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.js +0 -2277
  115. package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.js +0 -46
  116. package/esm/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.js +0 -132
  117. package/esm/deps/jsr.io/@std/crypto/1.1.0/crypto.js +0 -270
  118. package/esm/deps/jsr.io/@std/crypto/1.1.0/mod.js +0 -23
  119. package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.js +0 -61
  120. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -51
  121. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -13
  122. package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -2
  123. package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -87
  124. package/esm/deps/jsr.io/@std/fmt/1.0.10/colors.js +0 -903
  125. package/esm/deps/jsr.io/@std/text/1.0.18/closest_string.js +0 -46
  126. package/esm/deps/jsr.io/@std/text/1.0.18/levenshtein_distance.js +0 -127
  127. package/esm/package.json +0 -3
  128. package/types/_dnt.shims.d.ts +0 -16
  129. package/types/_dnt.shims.d.ts.map +0 -1
  130. package/types/client.d.ts.map +0 -1
  131. package/types/deps/jsr.io/@cliffy/command/1.1.0/_argument_types.d.ts +0 -163
  132. package/types/deps/jsr.io/@cliffy/command/1.1.0/_argument_types.d.ts.map +0 -1
  133. package/types/deps/jsr.io/@cliffy/command/1.1.0/_errors.d.ts +0 -71
  134. package/types/deps/jsr.io/@cliffy/command/1.1.0/_errors.d.ts.map +0 -1
  135. package/types/deps/jsr.io/@cliffy/command/1.1.0/_spread.d.ts +0 -16
  136. package/types/deps/jsr.io/@cliffy/command/1.1.0/_spread.d.ts.map +0 -1
  137. package/types/deps/jsr.io/@cliffy/command/1.1.0/_type_utils.d.ts +0 -15
  138. package/types/deps/jsr.io/@cliffy/command/1.1.0/_type_utils.d.ts.map +0 -1
  139. package/types/deps/jsr.io/@cliffy/command/1.1.0/_utils.d.ts +0 -38
  140. package/types/deps/jsr.io/@cliffy/command/1.1.0/_utils.d.ts.map +0 -1
  141. package/types/deps/jsr.io/@cliffy/command/1.1.0/command.d.ts +0 -1086
  142. package/types/deps/jsr.io/@cliffy/command/1.1.0/command.d.ts.map +0 -1
  143. package/types/deps/jsr.io/@cliffy/command/1.1.0/help/_help_generator.d.ts +0 -33
  144. package/types/deps/jsr.io/@cliffy/command/1.1.0/help/_help_generator.d.ts.map +0 -1
  145. package/types/deps/jsr.io/@cliffy/command/1.1.0/mod.d.ts +0 -78
  146. package/types/deps/jsr.io/@cliffy/command/1.1.0/mod.d.ts.map +0 -1
  147. package/types/deps/jsr.io/@cliffy/command/1.1.0/type.d.ts +0 -51
  148. package/types/deps/jsr.io/@cliffy/command/1.1.0/type.d.ts.map +0 -1
  149. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/action_list.d.ts +0 -10
  150. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/action_list.d.ts.map +0 -1
  151. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/boolean.d.ts +0 -10
  152. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/boolean.d.ts.map +0 -1
  153. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/child_command.d.ts +0 -10
  154. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/child_command.d.ts.map +0 -1
  155. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/command.d.ts +0 -8
  156. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/command.d.ts.map +0 -1
  157. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/enum.d.ts +0 -11
  158. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/enum.d.ts.map +0 -1
  159. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/file.d.ts +0 -6
  160. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/file.d.ts.map +0 -1
  161. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/integer.d.ts +0 -8
  162. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/integer.d.ts.map +0 -1
  163. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/number.d.ts +0 -8
  164. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/number.d.ts.map +0 -1
  165. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/secret.d.ts +0 -6
  166. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/secret.d.ts.map +0 -1
  167. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/string.d.ts +0 -8
  168. package/types/deps/jsr.io/@cliffy/command/1.1.0/types/string.d.ts.map +0 -1
  169. package/types/deps/jsr.io/@cliffy/command/1.1.0/types.d.ts +0 -161
  170. package/types/deps/jsr.io/@cliffy/command/1.1.0/types.d.ts.map +0 -1
  171. package/types/deps/jsr.io/@cliffy/command/1.1.0/upgrade/_check_version.d.ts +0 -4
  172. package/types/deps/jsr.io/@cliffy/command/1.1.0/upgrade/_check_version.d.ts.map +0 -1
  173. package/types/deps/jsr.io/@cliffy/flags/1.1.0/_errors.d.ts +0 -67
  174. package/types/deps/jsr.io/@cliffy/flags/1.1.0/_errors.d.ts.map +0 -1
  175. package/types/deps/jsr.io/@cliffy/flags/1.1.0/_utils.d.ts +0 -17
  176. package/types/deps/jsr.io/@cliffy/flags/1.1.0/_utils.d.ts.map +0 -1
  177. package/types/deps/jsr.io/@cliffy/flags/1.1.0/_validate_flags.d.ts +0 -11
  178. package/types/deps/jsr.io/@cliffy/flags/1.1.0/_validate_flags.d.ts.map +0 -1
  179. package/types/deps/jsr.io/@cliffy/flags/1.1.0/flags.d.ts +0 -154
  180. package/types/deps/jsr.io/@cliffy/flags/1.1.0/flags.d.ts.map +0 -1
  181. package/types/deps/jsr.io/@cliffy/flags/1.1.0/mod.d.ts +0 -57
  182. package/types/deps/jsr.io/@cliffy/flags/1.1.0/mod.d.ts.map +0 -1
  183. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types/boolean.d.ts +0 -4
  184. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types/boolean.d.ts.map +0 -1
  185. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types/integer.d.ts +0 -4
  186. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types/integer.d.ts.map +0 -1
  187. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types/number.d.ts +0 -4
  188. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types/number.d.ts.map +0 -1
  189. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types/string.d.ts +0 -4
  190. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types/string.d.ts.map +0 -1
  191. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types.d.ts +0 -170
  192. package/types/deps/jsr.io/@cliffy/flags/1.1.0/types.d.ts.map +0 -1
  193. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/exit.d.ts +0 -8
  194. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/exit.d.ts.map +0 -1
  195. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_args.d.ts +0 -7
  196. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_args.d.ts.map +0 -1
  197. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_columns.d.ts +0 -7
  198. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_columns.d.ts.map +0 -1
  199. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_env.d.ts +0 -8
  200. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/get_env.d.ts.map +0 -1
  201. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/inspect.d.ts +0 -7
  202. package/types/deps/jsr.io/@cliffy/internal/1.1.0/runtime/inspect.d.ts.map +0 -1
  203. package/types/deps/jsr.io/@cliffy/table/1.1.0/_layout.d.ts +0 -108
  204. package/types/deps/jsr.io/@cliffy/table/1.1.0/_layout.d.ts.map +0 -1
  205. package/types/deps/jsr.io/@cliffy/table/1.1.0/_utils.d.ts +0 -26
  206. package/types/deps/jsr.io/@cliffy/table/1.1.0/_utils.d.ts.map +0 -1
  207. package/types/deps/jsr.io/@cliffy/table/1.1.0/border.d.ts +0 -21
  208. package/types/deps/jsr.io/@cliffy/table/1.1.0/border.d.ts.map +0 -1
  209. package/types/deps/jsr.io/@cliffy/table/1.1.0/cell.d.ts +0 -155
  210. package/types/deps/jsr.io/@cliffy/table/1.1.0/cell.d.ts.map +0 -1
  211. package/types/deps/jsr.io/@cliffy/table/1.1.0/column.d.ts +0 -97
  212. package/types/deps/jsr.io/@cliffy/table/1.1.0/column.d.ts.map +0 -1
  213. package/types/deps/jsr.io/@cliffy/table/1.1.0/consume_words.d.ts +0 -30
  214. package/types/deps/jsr.io/@cliffy/table/1.1.0/consume_words.d.ts.map +0 -1
  215. package/types/deps/jsr.io/@cliffy/table/1.1.0/mod.d.ts +0 -43
  216. package/types/deps/jsr.io/@cliffy/table/1.1.0/mod.d.ts.map +0 -1
  217. package/types/deps/jsr.io/@cliffy/table/1.1.0/row.d.ts +0 -67
  218. package/types/deps/jsr.io/@cliffy/table/1.1.0/row.d.ts.map +0 -1
  219. package/types/deps/jsr.io/@cliffy/table/1.1.0/table.d.ts +0 -235
  220. package/types/deps/jsr.io/@cliffy/table/1.1.0/table.d.ts.map +0 -1
  221. package/types/deps/jsr.io/@cliffy/table/1.1.0/unicode_width.d.ts +0 -40
  222. package/types/deps/jsr.io/@cliffy/table/1.1.0/unicode_width.d.ts.map +0 -1
  223. package/types/deps/jsr.io/@std/crypto/1.1.0/_types.d.ts +0 -9
  224. package/types/deps/jsr.io/@std/crypto/1.1.0/_types.d.ts.map +0 -1
  225. package/types/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.d.ts +0 -2
  226. package/types/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.d.ts.map +0 -1
  227. package/types/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.d.ts +0 -69
  228. package/types/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.d.ts.map +0 -1
  229. package/types/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.d.ts +0 -13
  230. package/types/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.d.ts.map +0 -1
  231. package/types/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.d.ts +0 -76
  232. package/types/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.d.ts.map +0 -1
  233. package/types/deps/jsr.io/@std/crypto/1.1.0/crypto.d.ts +0 -149
  234. package/types/deps/jsr.io/@std/crypto/1.1.0/crypto.d.ts.map +0 -1
  235. package/types/deps/jsr.io/@std/crypto/1.1.0/mod.d.ts +0 -22
  236. package/types/deps/jsr.io/@std/crypto/1.1.0/mod.d.ts.map +0 -1
  237. package/types/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts +0 -40
  238. package/types/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts.map +0 -1
  239. package/types/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
  240. package/types/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
  241. package/types/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
  242. package/types/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
  243. package/types/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
  244. package/types/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
  245. package/types/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
  246. package/types/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
  247. package/types/deps/jsr.io/@std/fmt/1.0.10/colors.d.ts +0 -700
  248. package/types/deps/jsr.io/@std/fmt/1.0.10/colors.d.ts.map +0 -1
  249. package/types/deps/jsr.io/@std/text/1.0.18/closest_string.d.ts +0 -42
  250. package/types/deps/jsr.io/@std/text/1.0.18/closest_string.d.ts.map +0 -1
  251. package/types/deps/jsr.io/@std/text/1.0.18/levenshtein_distance.d.ts +0 -23
  252. package/types/deps/jsr.io/@std/text/1.0.18/levenshtein_distance.d.ts.map +0 -1
  253. package/types/errors.d.ts.map +0 -1
  254. package/types/index.d.ts.map +0 -1
  255. package/types/logger.d.ts.map +0 -1
  256. package/types/pack/parser.d.ts.map +0 -1
  257. package/types/transport.d.ts.map +0 -1
  258. package/types/types.d.ts.map +0 -1
  259. /package/{types → dist}/cli.d.ts +0 -0
  260. /package/{types → dist}/cli.d.ts.map +0 -0
  261. /package/{types → dist}/objects/commit.d.ts +0 -0
  262. /package/{types → dist}/objects/commit.d.ts.map +0 -0
  263. /package/{types → dist}/objects/index.d.ts +0 -0
  264. /package/{types → dist}/objects/index.d.ts.map +0 -0
  265. /package/{types → dist}/objects/tree.d.ts +0 -0
  266. /package/{types → dist}/pack/delta.d.ts +0 -0
  267. /package/{types → dist}/pack/delta.d.ts.map +0 -0
  268. /package/{types → dist}/pack/index.d.ts +0 -0
  269. /package/{types → dist}/pack/index.d.ts.map +0 -0
  270. /package/{types → dist}/pack/objects.d.ts +0 -0
  271. /package/{types → dist}/protocol/index.d.ts +0 -0
  272. /package/{types → dist}/protocol/index.d.ts.map +0 -0
  273. /package/{types → dist}/protocol/refs.d.ts +0 -0
  274. /package/{types → dist}/protocol/refs.d.ts.map +0 -0
@@ -1,46 +0,0 @@
1
- // Copyright 2018-2026 the Deno authors. MIT license.
2
- export { digest, DigestContext } from "./lib/deno_std_wasm_crypto.js";
3
- /**
4
- * All cryptographic hash/digest algorithms supported by std/crypto.
5
- *
6
- * For algorithms that are supported by WebCrypto, the name here will match the
7
- * one used by WebCrypto. Otherwise we prefer the formatting used in the
8
- * algorithm's official specification. All names are uppercase to facilitate
9
- * case-insensitive comparisons required by the WebCrypto spec.
10
- */
11
- export const DIGEST_ALGORITHM_NAMES = [
12
- "BLAKE2B",
13
- "BLAKE2B-128",
14
- "BLAKE2B-160",
15
- "BLAKE2B-224",
16
- "BLAKE2B-256",
17
- "BLAKE2B-384",
18
- "BLAKE2S",
19
- "BLAKE3",
20
- "KECCAK-224",
21
- "KECCAK-256",
22
- "KECCAK-384",
23
- "KECCAK-512",
24
- "SHA-384",
25
- "SHA3-224",
26
- "SHA3-256",
27
- "SHA3-384",
28
- "SHA3-512",
29
- "SHAKE128",
30
- "SHAKE256",
31
- "TIGER",
32
- // insecure (length-extendable):
33
- "RIPEMD-160",
34
- "SHA-224",
35
- "SHA-256",
36
- "SHA-512",
37
- // insecure (length-extendable and collidable):
38
- "MD4",
39
- "MD5",
40
- "SHA-1",
41
- // insecure (non-cryptographic)
42
- "FNV32",
43
- "FNV32A",
44
- "FNV64",
45
- "FNV64A",
46
- ];
@@ -1,132 +0,0 @@
1
- // Copyright 2018-2026 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- import * as dntShim from "../../../../../_dnt.shims.js";
4
- /**
5
- * High-level AES-GCM authenticated encryption with automatic nonce generation.
6
- *
7
- * With random nonces, do not encrypt more than ~2^32 messages under the same
8
- * key. Beyond this limit, nonce collision probability becomes non-negligible.
9
- *
10
- * @example Usage
11
- * ```ts
12
- * import { encryptAesGcm, decryptAesGcm } from "@std/crypto/aes-gcm";
13
- * import { assertEquals } from "@std/assert";
14
- *
15
- * const key = await crypto.subtle.generateKey(
16
- * { name: "AES-GCM", length: 256 },
17
- * false,
18
- * ["encrypt", "decrypt"],
19
- * );
20
- *
21
- * const plaintext = new TextEncoder().encode("hello world");
22
- * const encrypted = await encryptAesGcm(key, plaintext);
23
- * const decrypted = await decryptAesGcm(key, encrypted);
24
- *
25
- * assertEquals(decrypted, plaintext);
26
- * ```
27
- *
28
- * @module
29
- */
30
- const NONCE_LENGTH = 12;
31
- const TAG_LENGTH = 16;
32
- const OVERHEAD = NONCE_LENGTH + TAG_LENGTH;
33
- /**
34
- * Encrypts plaintext using AES-GCM with a random 96-bit nonce.
35
- *
36
- * Returns `nonce (12 bytes) || ciphertext || tag (16 bytes)`.
37
- *
38
- * @example Usage
39
- * ```ts
40
- * import { encryptAesGcm } from "@std/crypto/aes-gcm";
41
- * import { assertNotEquals } from "@std/assert";
42
- *
43
- * const key = await crypto.subtle.generateKey(
44
- * { name: "AES-GCM", length: 256 },
45
- * false,
46
- * ["encrypt", "decrypt"],
47
- * );
48
- *
49
- * const encrypted = await encryptAesGcm(
50
- * key,
51
- * new TextEncoder().encode("hello world"),
52
- * );
53
- *
54
- * assertNotEquals(encrypted.length, 0);
55
- * ```
56
- *
57
- * @param key The AES-GCM `CryptoKey` to encrypt with.
58
- * @param plaintext The data to encrypt.
59
- * @param options Optional additional authenticated data.
60
- * @returns The concatenated nonce, ciphertext, and authentication tag.
61
- *
62
- * @remarks With random nonces, do not encrypt more than ~2^32 messages
63
- * under the same key. Beyond this limit, nonce collision probability
64
- * becomes non-negligible.
65
- *
66
- * @see {@link https://csrc.nist.gov/pubs/sp/800/38/d/final | NIST SP 800-38D} Section 8.3
67
- */
68
- export async function encryptAesGcm(key, plaintext, options) {
69
- const nonce = dntShim.crypto.getRandomValues(new Uint8Array(NONCE_LENGTH));
70
- const params = {
71
- name: "AES-GCM",
72
- iv: nonce,
73
- tagLength: TAG_LENGTH * 8,
74
- };
75
- if (options?.additionalData !== undefined) {
76
- params.additionalData = options.additionalData;
77
- }
78
- const ciphertextAndTag = new Uint8Array(await dntShim.crypto.subtle.encrypt(params, key, plaintext));
79
- const result = new Uint8Array(NONCE_LENGTH + ciphertextAndTag.byteLength);
80
- result.set(nonce);
81
- result.set(ciphertextAndTag, NONCE_LENGTH);
82
- return result;
83
- }
84
- /**
85
- * Decrypts data produced by {@linkcode encryptAesGcm}.
86
- *
87
- * Expects input in the format `nonce (12 bytes) || ciphertext || tag (16 bytes)`.
88
- *
89
- * @example Usage
90
- * ```ts
91
- * import { decryptAesGcm, encryptAesGcm } from "@std/crypto/aes-gcm";
92
- * import { assertEquals } from "@std/assert";
93
- *
94
- * const key = await crypto.subtle.generateKey(
95
- * { name: "AES-GCM", length: 256 },
96
- * false,
97
- * ["encrypt", "decrypt"],
98
- * );
99
- *
100
- * const plaintext = new TextEncoder().encode("hello world");
101
- * const encrypted = await encryptAesGcm(key, plaintext);
102
- *
103
- * assertEquals(await decryptAesGcm(key, encrypted), plaintext);
104
- * ```
105
- *
106
- * @param key The AES-GCM `CryptoKey` to decrypt with.
107
- * @param data The wire-format output from {@linkcode encryptAesGcm}: nonce (12 B) || ciphertext || tag (16 B).
108
- * @param options Optional additional authenticated data (must match what was used during encryption).
109
- * @returns The decrypted plaintext.
110
- * @throws {RangeError} If `data` is shorter than 28 bytes (12 nonce + 16 tag).
111
- * @throws {DOMException} If authentication fails (wrong key, tampered data, or
112
- * mismatched additional data).
113
- */
114
- export async function decryptAesGcm(key, data, options) {
115
- const bytes = ArrayBuffer.isView(data)
116
- ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength)
117
- : new Uint8Array(data);
118
- if (bytes.byteLength < OVERHEAD) {
119
- throw new RangeError(`Data is too short: expected at least ${OVERHEAD} bytes, got ${bytes.byteLength}`);
120
- }
121
- const nonce = bytes.subarray(0, NONCE_LENGTH);
122
- const ciphertextAndTag = bytes.subarray(NONCE_LENGTH);
123
- const params = {
124
- name: "AES-GCM",
125
- iv: nonce,
126
- tagLength: TAG_LENGTH * 8,
127
- };
128
- if (options?.additionalData !== undefined) {
129
- params.additionalData = options.additionalData;
130
- }
131
- return new Uint8Array(await dntShim.crypto.subtle.decrypt(params, key, ciphertextAndTag));
132
- }
@@ -1,270 +0,0 @@
1
- // Copyright 2018-2026 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- /**
4
- * Extensions to the
5
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API | Web Crypto API}
6
- * supporting additional encryption APIs, but also delegating to the built-in
7
- * APIs when possible.
8
- *
9
- * Provides additional digest algorithms that are not part of the WebCrypto
10
- * standard as well as a `subtle.digest` and `subtle.digestSync` methods.
11
- *
12
- * The {@linkcode KeyStack} export implements the {@linkcode KeyRing} interface
13
- * for managing rotatable keys for signing data to prevent tampering, like with
14
- * HTTP cookies.
15
- *
16
- * ## Supported algorithms
17
- *
18
- * Here is a list of supported algorithms. If the algorithm name in WebCrypto
19
- * and Wasm/Rust is the same, this library prefers to use the implementation
20
- * provided by WebCrypto.
21
- *
22
- * Length-adjustable algorithms support the
23
- * {@linkcode DigestAlgorithmObject.length} option.
24
- *
25
- * WebCrypto:
26
- * - `SHA-384`
27
- * - `SHA-256` (length-extendable)
28
- * - `SHA-512` (length-extendable)
29
- *
30
- * Wasm/Rust:
31
- * - `BLAKE2B`
32
- * - `BLAKE2B-128`
33
- * - `BLAKE2B-160`
34
- * - `BLAKE2B-224`
35
- * - `BLAKE2B-256`
36
- * - `BLAKE2B-384`
37
- * - `BLAKE2S`
38
- * - `BLAKE3` (length-adjustable)
39
- * - `KECCAK-224`
40
- * - `KECCAK-256`
41
- * - `KECCAK-384`
42
- * - `KECCAK-512`
43
- * - `SHA-384`
44
- * - `SHA3-224`
45
- * - `SHA3-256`
46
- * - `SHA3-384`
47
- * - `SHA3-512`
48
- * - `SHAKE128` (length-adjustable)
49
- * - `SHAKE256` (length-adjustable)
50
- * - `TIGER`
51
- * - `RIPEMD-160` (length-extendable)
52
- * - `SHA-224` (length-extendable)
53
- * - `SHA-256` (length-extendable)
54
- * - `SHA-512` (length-extendable)
55
- * - `MD4` (length-extendable and collidable)
56
- * - `MD5` (length-extendable and collidable)
57
- * - `SHA-1` (length-extendable and collidable)
58
- * - `FNV32` (non-cryptographic)
59
- * - `FNV32A` (non-cryptographic)
60
- * - `FNV64` (non-cryptographic)
61
- * - `FNV64A` (non-cryptographic)
62
- *
63
- * @example
64
- * ```ts
65
- * import { crypto } from "@std/crypto";
66
- *
67
- * // This will delegate to the runtime's WebCrypto implementation.
68
- * console.log(
69
- * new Uint8Array(
70
- * await crypto.subtle.digest(
71
- * "SHA-384",
72
- * new TextEncoder().encode("hello world"),
73
- * ),
74
- * ),
75
- * );
76
- *
77
- * // This will use a bundled Wasm/Rust implementation.
78
- * console.log(
79
- * new Uint8Array(
80
- * await crypto.subtle.digest(
81
- * "BLAKE3",
82
- * new TextEncoder().encode("hello world"),
83
- * ),
84
- * ),
85
- * );
86
- * ```
87
- *
88
- * @example Convert hash to a string
89
- *
90
- * ```ts
91
- * import {
92
- * crypto,
93
- * } from "@std/crypto";
94
- * import { encodeHex } from "@std/encoding/hex"
95
- * import { encodeBase64 } from "@std/encoding/base64"
96
- *
97
- * const hash = await crypto.subtle.digest(
98
- * "SHA-384",
99
- * new TextEncoder().encode("You hear that Mr. Anderson?"),
100
- * );
101
- *
102
- * // Hex encoding
103
- * console.log(encodeHex(hash));
104
- *
105
- * // Or with base64 encoding
106
- * console.log(encodeBase64(hash));
107
- * ```
108
- *
109
- * @module
110
- */
111
- import * as dntShim from "../../../../../_dnt.shims.js";
112
- import { digest, DIGEST_ALGORITHM_NAMES, DigestContext, } from "./_wasm/mod.js";
113
- export { DIGEST_ALGORITHM_NAMES };
114
- /** Digest algorithms supported by WebCrypto. */
115
- const WEB_CRYPTO_DIGEST_ALGORITHM_NAMES = [
116
- "SHA-384",
117
- "SHA-256",
118
- "SHA-512",
119
- // insecure (length-extendable and collidable):
120
- "SHA-1",
121
- ];
122
- /**
123
- * A copy of the global WebCrypto interface, with methods bound so they're
124
- * safe to re-export.
125
- */
126
- const webCrypto = ((crypto) => ({
127
- getRandomValues: crypto.getRandomValues?.bind(crypto),
128
- randomUUID: crypto.randomUUID?.bind(crypto),
129
- subtle: {
130
- decrypt: crypto.subtle?.decrypt?.bind(crypto.subtle),
131
- deriveBits: crypto.subtle?.deriveBits?.bind(crypto.subtle),
132
- deriveKey: crypto.subtle?.deriveKey?.bind(crypto.subtle),
133
- digest: crypto.subtle?.digest?.bind(crypto.subtle),
134
- encrypt: crypto.subtle?.encrypt?.bind(crypto.subtle),
135
- exportKey: crypto.subtle?.exportKey?.bind(crypto.subtle),
136
- generateKey: crypto.subtle?.generateKey?.bind(crypto.subtle),
137
- importKey: crypto.subtle?.importKey?.bind(crypto.subtle),
138
- sign: crypto.subtle?.sign?.bind(crypto.subtle),
139
- unwrapKey: crypto.subtle?.unwrapKey?.bind(crypto.subtle),
140
- verify: crypto.subtle?.verify?.bind(crypto.subtle),
141
- wrapKey: crypto.subtle?.wrapKey?.bind(crypto.subtle),
142
- },
143
- }))(dntShim.dntGlobalThis.crypto);
144
- function toUint8Array(data) {
145
- if (data instanceof Uint8Array) {
146
- return data;
147
- }
148
- else if (ArrayBuffer.isView(data)) {
149
- return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
150
- }
151
- else if (data instanceof ArrayBuffer) {
152
- return new Uint8Array(data);
153
- }
154
- return undefined;
155
- }
156
- /**
157
- * A wrapper for WebCrypto which adds support for additional non-standard
158
- * algorithms, but delegates to the runtime WebCrypto implementation whenever
159
- * possible.
160
- */
161
- const stdCrypto = ((x) => x)({
162
- ...webCrypto,
163
- subtle: {
164
- ...webCrypto.subtle,
165
- /**
166
- * Polyfills stream support until the Web Crypto API does so:
167
- * @see {@link https://github.com/wintercg/proposal-webcrypto-streams}
168
- */
169
- async digest(algorithm, data) {
170
- const { name, length } = normalizeAlgorithm(algorithm);
171
- assertValidDigestLength(length);
172
- // We delegate to WebCrypto whenever possible,
173
- if (
174
- // if the algorithm is supported by the WebCrypto standard,
175
- WEB_CRYPTO_DIGEST_ALGORITHM_NAMES.includes(name) &&
176
- // and the data is a single buffer,
177
- isBufferSource(data)) {
178
- return await webCrypto.subtle.digest(algorithm, data);
179
- }
180
- else if (DIGEST_ALGORITHM_NAMES.includes(name)) {
181
- if (isBufferSource(data)) {
182
- // Otherwise, we use our bundled Wasm implementation via digestSync
183
- // if it supports the algorithm.
184
- return stdCrypto.subtle.digestSync(algorithm, data);
185
- }
186
- else if (isIterable(data)) {
187
- return stdCrypto.subtle.digestSync(algorithm, data);
188
- }
189
- else if (isAsyncIterable(data)) {
190
- const context = new DigestContext(name);
191
- for await (const chunk of data) {
192
- const chunkBytes = toUint8Array(chunk);
193
- if (!chunkBytes) {
194
- throw new TypeError("Cannot digest the data: A chunk is not ArrayBuffer nor ArrayBufferView");
195
- }
196
- context.update(chunkBytes);
197
- }
198
- return context.digestAndDrop(length).buffer;
199
- }
200
- else {
201
- throw new TypeError(
202
- // deno-lint-ignore deno-style-guide/error-message
203
- "data must be a BufferSource or [Async]Iterable<BufferSource>");
204
- }
205
- }
206
- // (TypeScript type definitions prohibit this case.) If they're trying
207
- // to call an algorithm we don't recognize, pass it along to WebCrypto
208
- // in case it's a non-standard algorithm supported by the the runtime
209
- // they're using.
210
- return await webCrypto.subtle.digest(algorithm, data);
211
- },
212
- digestSync(algorithm, data) {
213
- const { name, length } = normalizeAlgorithm(algorithm);
214
- assertValidDigestLength(length);
215
- if (isBufferSource(data)) {
216
- const bytes = toUint8Array(data);
217
- return digest(name, bytes, length).buffer;
218
- }
219
- if (isIterable(data)) {
220
- const context = new DigestContext(name);
221
- for (const chunk of data) {
222
- const chunkBytes = toUint8Array(chunk);
223
- if (!chunkBytes) {
224
- throw new TypeError("Cannot digest the data: A chunk is not ArrayBuffer nor ArrayBufferView");
225
- }
226
- context.update(chunkBytes);
227
- }
228
- return context.digestAndDrop(length).buffer;
229
- }
230
- throw new TypeError(
231
- // deno-lint-ignore deno-style-guide/error-message
232
- "data must be a BufferSource or Iterable<BufferSource>");
233
- },
234
- },
235
- });
236
- /*
237
- * The largest digest length the current Wasm implementation can support. This
238
- * is the value of `isize::MAX` on 32-bit platforms like Wasm, which is the
239
- * maximum allowed capacity of a Rust `Vec<u8>`.
240
- */
241
- const MAX_DIGEST_LENGTH = 0x7FFF_FFFF;
242
- /**
243
- * Asserts that a number is a valid length for a digest, which must be an
244
- * integer that fits in a Rust `Vec<u8>`, or be undefined.
245
- */
246
- function assertValidDigestLength(value) {
247
- if (value !== undefined &&
248
- (value < 0 || value > MAX_DIGEST_LENGTH ||
249
- !Number.isInteger(value))) {
250
- throw new RangeError(`length must be an integer between 0 and ${MAX_DIGEST_LENGTH}, inclusive`);
251
- }
252
- }
253
- function normalizeAlgorithm(algorithm) {
254
- return ((typeof algorithm === "string")
255
- ? { name: algorithm.toUpperCase() }
256
- : {
257
- ...algorithm,
258
- name: algorithm.name.toUpperCase(),
259
- });
260
- }
261
- function isBufferSource(obj) {
262
- return obj instanceof ArrayBuffer || ArrayBuffer.isView(obj);
263
- }
264
- function isIterable(obj) {
265
- return typeof obj[Symbol.iterator] === "function";
266
- }
267
- function isAsyncIterable(obj) {
268
- return typeof obj[Symbol.asyncIterator] === "function";
269
- }
270
- export { stdCrypto as crypto };
@@ -1,23 +0,0 @@
1
- // Copyright 2018-2026 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- /**
4
- * Extensions to the
5
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API | Web Crypto}
6
- * supporting additional encryption APIs, but also delegating to the built-in
7
- * APIs when possible.
8
- *
9
- * ```ts no-assert
10
- * import { crypto } from "@std/crypto/crypto";
11
- *
12
- * const message = "Hello, Deno!";
13
- * const encoder = new TextEncoder();
14
- * const data = encoder.encode(message);
15
- *
16
- * await crypto.subtle.digest("BLAKE3", data);
17
- * ```
18
- *
19
- * @module
20
- */
21
- export * from "./aes_gcm.js";
22
- export * from "./crypto.js";
23
- export * from "./timing_safe_equal.js";
@@ -1,61 +0,0 @@
1
- // Copyright 2018-2026 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- function toUint8Array(value) {
4
- if (value instanceof Uint8Array) {
5
- return value;
6
- }
7
- return ArrayBuffer.isView(value)
8
- ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength)
9
- : new Uint8Array(value);
10
- }
11
- /**
12
- * When checking the values of cryptographic hashes are equal, default
13
- * comparisons can be susceptible to timing based attacks, where attacker is
14
- * able to find out information about the host system by repeatedly checking
15
- * response times to equality comparisons of values.
16
- *
17
- * It is likely some form of timing safe equality will make its way to the
18
- * WebCrypto standard (see:
19
- * {@link https://github.com/w3c/webcrypto/issues/270 | w3c/webcrypto#270}), but until
20
- * that time, `timingSafeEqual()` is provided.
21
- *
22
- * Note: This is a best-effort constant-time comparison implemented in
23
- * JavaScript. The V8 JIT compiler does not provide formal constant-time
24
- * guarantees, and inputs backed by `SharedArrayBuffer` are susceptible to
25
- * concurrent modification during comparison.
26
- *
27
- * @example Usage
28
- * ```ts
29
- * import { timingSafeEqual } from "@std/crypto/timing-safe-equal";
30
- * import { assert } from "@std/assert";
31
- *
32
- * const a = await crypto.subtle.digest(
33
- * "SHA-384",
34
- * new TextEncoder().encode("hello world"),
35
- * );
36
- * const b = await crypto.subtle.digest(
37
- * "SHA-384",
38
- * new TextEncoder().encode("hello world"),
39
- * );
40
- *
41
- * assert(timingSafeEqual(a, b));
42
- * ```
43
- *
44
- * @param a The first value to compare.
45
- * @param b The second value to compare.
46
- * @returns `true` if the values are equal, otherwise `false`.
47
- * @throws {TypeError} If the byte lengths of the two buffers are not equal.
48
- */
49
- export function timingSafeEqual(a, b) {
50
- if (a.byteLength !== b.byteLength) {
51
- throw new TypeError(`Cannot compare buffers of different byte lengths (${a.byteLength} vs ${b.byteLength})`);
52
- }
53
- const ua = toUint8Array(a);
54
- const ub = toUint8Array(b);
55
- const length = ua.length;
56
- let out = 0;
57
- for (let i = 0; i < length; i++) {
58
- out |= ua[i] ^ ub[i];
59
- }
60
- return out === 0;
61
- }
@@ -1,51 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- export const alphabet = new TextEncoder().encode("0123456789abcdef");
3
- export const rAlphabet = new Uint8Array(128).fill(16); // alphabet.Hex.length
4
- alphabet.forEach((byte, i) => rAlphabet[byte] = i);
5
- new TextEncoder()
6
- .encode("ABCDEF")
7
- .forEach((byte, i) => rAlphabet[byte] = i + 10);
8
- /**
9
- * Calculate the output size needed to encode a given input size for
10
- * {@linkcode encodeIntoHex}.
11
- *
12
- * @param originalSize The size of the input buffer.
13
- * @returns The size of the output buffer.
14
- *
15
- * @example Basic Usage
16
- * ```ts
17
- * import { assertEquals } from "@std/assert";
18
- * import { calcSizeHex } from "@std/encoding/unstable-hex";
19
- *
20
- * assertEquals(calcSizeHex(1), 2);
21
- * ```
22
- */
23
- export function calcSizeHex(originalSize) {
24
- return originalSize * 2;
25
- }
26
- export function encode(buffer, i, o, alphabet) {
27
- for (; i < buffer.length; ++i) {
28
- const x = buffer[i];
29
- buffer[o++] = alphabet[x >> 4];
30
- buffer[o++] = alphabet[x & 0xF];
31
- }
32
- return o;
33
- }
34
- export function decode(buffer, i, o, alphabet) {
35
- if ((buffer.length - o) % 2 === 1) {
36
- throw new RangeError(`Cannot decode input as hex: Length (${buffer.length - o}) must be divisible by 2`);
37
- }
38
- i += 1;
39
- for (; i < buffer.length; i += 2) {
40
- buffer[o++] = (getByte(buffer[i - 1], alphabet) << 4) |
41
- getByte(buffer[i], alphabet);
42
- }
43
- return o;
44
- }
45
- function getByte(char, alphabet) {
46
- const byte = alphabet[char] ?? 16;
47
- if (byte === 16) { // alphabet.Hex.length
48
- throw new TypeError(`Cannot decode input as hex: Invalid character (${String.fromCharCode(char)})`);
49
- }
50
- return byte;
51
- }
@@ -1,13 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- export function detach(buffer, maxSize) {
3
- const originalSize = buffer.length;
4
- if (buffer.byteOffset) {
5
- const b = new Uint8Array(buffer.buffer);
6
- b.set(buffer);
7
- buffer = b.subarray(0, originalSize);
8
- }
9
- // deno-lint-ignore no-explicit-any
10
- buffer = new Uint8Array(buffer.buffer.transfer(maxSize));
11
- buffer.set(buffer.subarray(0, originalSize), maxSize - originalSize);
12
- return [buffer, maxSize - originalSize];
13
- }
@@ -1,2 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- export {};
@@ -1,87 +0,0 @@
1
- // Copyright 2009 The Go Authors. All rights reserved.
2
- // https://github.com/golang/go/blob/master/LICENSE
3
- // Copyright 2018-2025 the Deno authors. MIT license.
4
- // This module is browser compatible.
5
- /**
6
- * Port of the Go
7
- * {@link https://github.com/golang/go/blob/go1.12.5/src/encoding/hex/hex.go | encoding/hex}
8
- * library.
9
- *
10
- * ```ts
11
- * import {
12
- * decodeHex,
13
- * encodeHex,
14
- * } from "@std/encoding/hex";
15
- * import { assertEquals } from "@std/assert";
16
- *
17
- * assertEquals(encodeHex("abc"), "616263");
18
- *
19
- * assertEquals(
20
- * decodeHex("616263"),
21
- * new TextEncoder().encode("abc"),
22
- * );
23
- * ```
24
- *
25
- * @module
26
- */
27
- import { calcSizeHex, decode, encode } from "./_common16.js";
28
- import { detach } from "./_common_detach.js";
29
- const alphabet = new TextEncoder()
30
- .encode("0123456789abcdef");
31
- const rAlphabet = new Uint8Array(128).fill(16); // alphabet.length
32
- alphabet.forEach((byte, i) => rAlphabet[byte] = i);
33
- new TextEncoder()
34
- .encode("ABCDEF")
35
- .forEach((byte, i) => rAlphabet[byte] = i + 10);
36
- /**
37
- * Converts data into a hex-encoded string.
38
- *
39
- * @param src The data to encode.
40
- *
41
- * @returns The hex-encoded string.
42
- *
43
- * @example Usage
44
- * ```ts
45
- * import { encodeHex } from "@std/encoding/hex";
46
- * import { assertEquals } from "@std/assert";
47
- *
48
- * assertEquals(encodeHex("abc"), "616263");
49
- * ```
50
- */
51
- export function encodeHex(src) {
52
- if (typeof src === "string") {
53
- src = new TextEncoder().encode(src);
54
- }
55
- else if (src instanceof ArrayBuffer)
56
- src = new Uint8Array(src).slice();
57
- else
58
- src = src.slice();
59
- const [output, i] = detach(src, calcSizeHex(src.length));
60
- encode(output, i, 0, alphabet);
61
- return new TextDecoder().decode(output);
62
- }
63
- /**
64
- * Decodes the given hex-encoded string. If the input is malformed, an error is
65
- * thrown.
66
- *
67
- * @param src The hex-encoded string to decode.
68
- *
69
- * @returns The decoded data.
70
- *
71
- * @example Usage
72
- * ```ts
73
- * import { decodeHex } from "@std/encoding/hex";
74
- * import { assertEquals } from "@std/assert";
75
- *
76
- * assertEquals(
77
- * decodeHex("616263"),
78
- * new TextEncoder().encode("abc"),
79
- * );
80
- * ```
81
- */
82
- export function decodeHex(src) {
83
- const output = new TextEncoder().encode(src);
84
- // deno-lint-ignore no-explicit-any
85
- return new Uint8Array(output.buffer
86
- .transfer(decode(output, 0, 0, rAlphabet)));
87
- }