windmill-cli 1.478.1 → 1.479.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 (187) hide show
  1. package/esm/bootstrap/script_bootstrap.js +13 -0
  2. package/esm/deps/jsr.io/@std/encoding/1.0.8/_common16.js +45 -0
  3. package/esm/deps/jsr.io/@std/encoding/1.0.8/_common32.js +175 -0
  4. package/esm/deps/jsr.io/@std/encoding/1.0.8/_common64.js +98 -0
  5. package/esm/deps/jsr.io/@std/encoding/1.0.8/_common_detach.js +13 -0
  6. package/esm/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/base32.js +39 -21
  7. package/esm/deps/jsr.io/@std/encoding/1.0.8/base64.js +82 -0
  8. package/esm/deps/jsr.io/@std/encoding/1.0.8/base64url.js +72 -0
  9. package/esm/deps/jsr.io/@std/encoding/1.0.8/hex.js +87 -0
  10. package/esm/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/mod.js +1 -0
  11. package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/eol.js +1 -0
  12. package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
  13. package/esm/deps.js +2 -2
  14. package/esm/gen/core/OpenAPI.js +1 -1
  15. package/esm/gen/services.gen.js +146 -20
  16. package/esm/hub.js +11 -7
  17. package/esm/instance.js +8 -0
  18. package/esm/main.js +1 -1
  19. package/esm/metadata.js +29 -4
  20. package/esm/script.js +15 -0
  21. package/esm/script_common.js +8 -0
  22. package/esm/settings.js +3 -11
  23. package/esm/sync.js +19 -1
  24. package/esm/types.js +3 -0
  25. package/esm/wasm/csharp/windmill_parser_wasm.js +103 -0
  26. package/esm/wasm/csharp/windmill_parser_wasm_bg.wasm +0 -0
  27. package/esm/wasm/go/windmill_parser_wasm.js +103 -0
  28. package/esm/wasm/go/windmill_parser_wasm_bg.wasm +0 -0
  29. package/esm/wasm/java/windmill_parser_wasm.js +103 -0
  30. package/esm/wasm/java/windmill_parser_wasm_bg.wasm +0 -0
  31. package/esm/wasm/nu/windmill_parser_wasm.js +103 -0
  32. package/esm/wasm/nu/windmill_parser_wasm_bg.wasm +0 -0
  33. package/esm/wasm/php/windmill_parser_wasm.js +103 -0
  34. package/esm/wasm/php/windmill_parser_wasm_bg.wasm +0 -0
  35. package/esm/wasm/python/windmill_parser_wasm.js +109 -0
  36. package/esm/wasm/python/windmill_parser_wasm_bg.wasm +0 -0
  37. package/esm/wasm/regex/windmill_parser_wasm.js +270 -0
  38. package/esm/wasm/regex/windmill_parser_wasm_bg.wasm +0 -0
  39. package/esm/wasm/rust/windmill_parser_wasm.js +103 -0
  40. package/esm/wasm/rust/windmill_parser_wasm_bg.wasm +0 -0
  41. package/esm/wasm/ts/windmill_parser_wasm.js +419 -0
  42. package/esm/wasm/ts/windmill_parser_wasm_bg.wasm +0 -0
  43. package/esm/wasm/yaml/windmill_parser_wasm.js +103 -0
  44. package/esm/wasm/yaml/windmill_parser_wasm_bg.wasm +0 -0
  45. package/package.json +1 -1
  46. package/types/bootstrap/script_bootstrap.d.ts +2 -0
  47. package/types/bootstrap/script_bootstrap.d.ts.map +1 -1
  48. package/types/conf.d.ts +1 -0
  49. package/types/conf.d.ts.map +1 -1
  50. package/types/deps/jsr.io/@std/encoding/1.0.8/_common16.d.ts +21 -0
  51. package/types/deps/jsr.io/@std/encoding/1.0.8/_common16.d.ts.map +1 -0
  52. package/types/deps/jsr.io/@std/encoding/1.0.8/_common32.d.ts +21 -0
  53. package/types/deps/jsr.io/@std/encoding/1.0.8/_common32.d.ts.map +1 -0
  54. package/types/deps/jsr.io/@std/encoding/1.0.8/_common64.d.ts +21 -0
  55. package/types/deps/jsr.io/@std/encoding/1.0.8/_common64.d.ts.map +1 -0
  56. package/types/deps/jsr.io/@std/encoding/1.0.8/_common_detach.d.ts +4 -0
  57. package/types/deps/jsr.io/@std/encoding/1.0.8/_common_detach.d.ts.map +1 -0
  58. package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/_types.d.ts.map +1 -1
  59. package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/_validate_binary_like.d.ts.map +1 -1
  60. package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/ascii85.d.ts.map +1 -1
  61. package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/base32.d.ts +15 -15
  62. package/types/deps/jsr.io/@std/encoding/1.0.8/base32.d.ts.map +1 -0
  63. package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/base58.d.ts.map +1 -1
  64. package/types/deps/jsr.io/@std/encoding/1.0.8/base64.d.ts.map +1 -0
  65. package/types/deps/jsr.io/@std/encoding/1.0.8/base64url.d.ts.map +1 -0
  66. package/types/deps/jsr.io/@std/encoding/1.0.8/hex.d.ts.map +1 -0
  67. package/types/deps/jsr.io/@std/encoding/1.0.8/mod.d.ts.map +1 -0
  68. package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/varint.d.ts.map +1 -1
  69. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_create_walk_entry.d.ts.map +1 -1
  70. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_get_file_info_type.d.ts.map +1 -1
  71. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_is_same_path.d.ts.map +1 -1
  72. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_is_subdir.d.ts.map +1 -1
  73. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_to_path_string.d.ts.map +1 -1
  74. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/copy.d.ts.map +1 -1
  75. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/empty_dir.d.ts.map +1 -1
  76. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_dir.d.ts.map +1 -1
  77. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_file.d.ts.map +1 -1
  78. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_link.d.ts.map +1 -1
  79. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_symlink.d.ts.map +1 -1
  80. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/eol.d.ts.map +1 -1
  81. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/exists.d.ts.map +1 -1
  82. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/expand_glob.d.ts.map +1 -1
  83. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/mod.d.ts.map +1 -1
  84. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/move.d.ts.map +1 -1
  85. package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/walk.d.ts.map +1 -1
  86. package/types/deps.d.ts +2 -2
  87. package/types/gen/services.gen.d.ts +75 -11
  88. package/types/gen/services.gen.d.ts.map +1 -1
  89. package/types/gen/types.gen.d.ts +102 -35
  90. package/types/gen/types.gen.d.ts.map +1 -1
  91. package/types/hub.d.ts.map +1 -1
  92. package/types/instance.d.ts +1 -0
  93. package/types/instance.d.ts.map +1 -1
  94. package/types/main.d.ts +1 -1
  95. package/types/metadata.d.ts +2 -2
  96. package/types/metadata.d.ts.map +1 -1
  97. package/types/script.d.ts +2 -0
  98. package/types/script.d.ts.map +1 -1
  99. package/types/script_common.d.ts +1 -1
  100. package/types/script_common.d.ts.map +1 -1
  101. package/types/settings.d.ts +2 -4
  102. package/types/settings.d.ts.map +1 -1
  103. package/types/sync.d.ts +2 -0
  104. package/types/sync.d.ts.map +1 -1
  105. package/types/types.d.ts.map +1 -1
  106. package/types/wasm/csharp/windmill_parser_wasm.d.ts +7 -0
  107. package/types/wasm/csharp/windmill_parser_wasm.d.ts.map +1 -0
  108. package/types/wasm/go/windmill_parser_wasm.d.ts +7 -0
  109. package/types/wasm/go/windmill_parser_wasm.d.ts.map +1 -0
  110. package/types/wasm/java/windmill_parser_wasm.d.ts +7 -0
  111. package/types/wasm/java/windmill_parser_wasm.d.ts.map +1 -0
  112. package/types/wasm/nu/windmill_parser_wasm.d.ts +7 -0
  113. package/types/wasm/nu/windmill_parser_wasm.d.ts.map +1 -0
  114. package/types/wasm/php/windmill_parser_wasm.d.ts +7 -0
  115. package/types/wasm/php/windmill_parser_wasm.d.ts.map +1 -0
  116. package/types/wasm/python/windmill_parser_wasm.d.ts +8 -0
  117. package/types/wasm/python/windmill_parser_wasm.d.ts.map +1 -0
  118. package/types/wasm/regex/windmill_parser_wasm.d.ts +52 -0
  119. package/types/wasm/regex/windmill_parser_wasm.d.ts.map +1 -0
  120. package/types/wasm/rust/windmill_parser_wasm.d.ts +7 -0
  121. package/types/wasm/rust/windmill_parser_wasm.d.ts.map +1 -0
  122. package/types/wasm/ts/windmill_parser_wasm.d.ts +19 -0
  123. package/types/wasm/ts/windmill_parser_wasm.d.ts.map +1 -0
  124. package/types/wasm/yaml/windmill_parser_wasm.d.ts +7 -0
  125. package/types/wasm/yaml/windmill_parser_wasm.d.ts.map +1 -0
  126. package/esm/deps/jsr.io/@std/encoding/1.0.7/_base32_common.js +0 -183
  127. package/esm/deps/jsr.io/@std/encoding/1.0.7/base64.js +0 -163
  128. package/esm/deps/jsr.io/@std/encoding/1.0.7/base64url.js +0 -81
  129. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.js +0 -109
  130. package/esm/wasm/windmill_parser_wasm.generated.js +0 -1135
  131. package/esm/wasm/windmill_parser_wasm_bg.wasm +0 -0
  132. package/types/deps/jsr.io/@std/encoding/1.0.7/_base32_common.d.ts +0 -18
  133. package/types/deps/jsr.io/@std/encoding/1.0.7/_base32_common.d.ts.map +0 -1
  134. package/types/deps/jsr.io/@std/encoding/1.0.7/base32.d.ts.map +0 -1
  135. package/types/deps/jsr.io/@std/encoding/1.0.7/base64.d.ts.map +0 -1
  136. package/types/deps/jsr.io/@std/encoding/1.0.7/base64url.d.ts.map +0 -1
  137. package/types/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +0 -1
  138. package/types/deps/jsr.io/@std/encoding/1.0.7/mod.d.ts.map +0 -1
  139. package/types/wasm/windmill_parser_wasm.generated.d.ts +0 -146
  140. package/types/wasm/windmill_parser_wasm.generated.d.ts.map +0 -1
  141. /package/esm/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/_types.js +0 -0
  142. /package/esm/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/_validate_binary_like.js +0 -0
  143. /package/esm/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/ascii85.js +0 -0
  144. /package/esm/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/base58.js +0 -0
  145. /package/esm/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/varint.js +0 -0
  146. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_create_walk_entry.js +0 -0
  147. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_get_file_info_type.js +0 -0
  148. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_is_same_path.js +0 -0
  149. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_is_subdir.js +0 -0
  150. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_to_path_string.js +0 -0
  151. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/copy.js +0 -0
  152. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/empty_dir.js +0 -0
  153. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_dir.js +0 -0
  154. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_file.js +0 -0
  155. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_link.js +0 -0
  156. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_symlink.js +0 -0
  157. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/exists.js +0 -0
  158. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/expand_glob.js +0 -0
  159. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/mod.js +0 -0
  160. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/move.js +0 -0
  161. /package/esm/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/walk.js +0 -0
  162. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/_types.d.ts +0 -0
  163. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/_validate_binary_like.d.ts +0 -0
  164. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/ascii85.d.ts +0 -0
  165. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/base58.d.ts +0 -0
  166. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/base64.d.ts +0 -0
  167. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/base64url.d.ts +0 -0
  168. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/hex.d.ts +0 -0
  169. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/mod.d.ts +0 -0
  170. /package/types/deps/jsr.io/@std/encoding/{1.0.7 → 1.0.8}/varint.d.ts +0 -0
  171. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_create_walk_entry.d.ts +0 -0
  172. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_get_file_info_type.d.ts +0 -0
  173. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_is_same_path.d.ts +0 -0
  174. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_is_subdir.d.ts +0 -0
  175. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/_to_path_string.d.ts +0 -0
  176. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/copy.d.ts +0 -0
  177. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/empty_dir.d.ts +0 -0
  178. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_dir.d.ts +0 -0
  179. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_file.d.ts +0 -0
  180. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_link.d.ts +0 -0
  181. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/ensure_symlink.d.ts +0 -0
  182. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/eol.d.ts +0 -0
  183. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/exists.d.ts +0 -0
  184. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/expand_glob.d.ts +0 -0
  185. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/mod.d.ts +0 -0
  186. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/move.d.ts +0 -0
  187. /package/types/deps/jsr.io/@std/fs/{1.0.14 → 1.0.15}/walk.d.ts +0 -0
@@ -1,163 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- /**
4
- * Utilities for
5
- * {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4 | base64}
6
- * encoding and decoding.
7
- *
8
- * ```ts
9
- * import {
10
- * encodeBase64,
11
- * decodeBase64,
12
- * } from "@std/encoding/base64";
13
- * import { assertEquals } from "@std/assert";
14
- *
15
- * const foobar = new TextEncoder().encode("foobar");
16
- *
17
- * assertEquals(encodeBase64(foobar), "Zm9vYmFy");
18
- * assertEquals(decodeBase64("Zm9vYmFy"), foobar);
19
- * ```
20
- *
21
- * @module
22
- */
23
- import { validateBinaryLike } from "./_validate_binary_like.js";
24
- const base64abc = [
25
- "A",
26
- "B",
27
- "C",
28
- "D",
29
- "E",
30
- "F",
31
- "G",
32
- "H",
33
- "I",
34
- "J",
35
- "K",
36
- "L",
37
- "M",
38
- "N",
39
- "O",
40
- "P",
41
- "Q",
42
- "R",
43
- "S",
44
- "T",
45
- "U",
46
- "V",
47
- "W",
48
- "X",
49
- "Y",
50
- "Z",
51
- "a",
52
- "b",
53
- "c",
54
- "d",
55
- "e",
56
- "f",
57
- "g",
58
- "h",
59
- "i",
60
- "j",
61
- "k",
62
- "l",
63
- "m",
64
- "n",
65
- "o",
66
- "p",
67
- "q",
68
- "r",
69
- "s",
70
- "t",
71
- "u",
72
- "v",
73
- "w",
74
- "x",
75
- "y",
76
- "z",
77
- "0",
78
- "1",
79
- "2",
80
- "3",
81
- "4",
82
- "5",
83
- "6",
84
- "7",
85
- "8",
86
- "9",
87
- "+",
88
- "/",
89
- ];
90
- /**
91
- * Converts data into a base64-encoded string.
92
- *
93
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
94
- *
95
- * @param data The data to encode.
96
- * @returns The base64-encoded string.
97
- *
98
- * @example Usage
99
- * ```ts
100
- * import { encodeBase64 } from "@std/encoding/base64";
101
- * import { assertEquals } from "@std/assert";
102
- *
103
- * assertEquals(encodeBase64("foobar"), "Zm9vYmFy");
104
- * ```
105
- */
106
- export function encodeBase64(data) {
107
- // CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
108
- const uint8 = validateBinaryLike(data);
109
- let result = "";
110
- let i;
111
- const l = uint8.length;
112
- for (i = 2; i < l; i += 3) {
113
- result += base64abc[(uint8[i - 2]) >> 2];
114
- result += base64abc[(((uint8[i - 2]) & 0x03) << 4) |
115
- ((uint8[i - 1]) >> 4)];
116
- result += base64abc[(((uint8[i - 1]) & 0x0f) << 2) |
117
- ((uint8[i]) >> 6)];
118
- result += base64abc[(uint8[i]) & 0x3f];
119
- }
120
- if (i === l + 1) {
121
- // 1 octet yet to write
122
- result += base64abc[(uint8[i - 2]) >> 2];
123
- result += base64abc[((uint8[i - 2]) & 0x03) << 4];
124
- result += "==";
125
- }
126
- if (i === l) {
127
- // 2 octets yet to write
128
- result += base64abc[(uint8[i - 2]) >> 2];
129
- result += base64abc[(((uint8[i - 2]) & 0x03) << 4) |
130
- ((uint8[i - 1]) >> 4)];
131
- result += base64abc[((uint8[i - 1]) & 0x0f) << 2];
132
- result += "=";
133
- }
134
- return result;
135
- }
136
- /**
137
- * Decodes a base64-encoded string.
138
- *
139
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
140
- *
141
- * @param b64 The base64-encoded string to decode.
142
- * @returns The decoded data.
143
- *
144
- * @example Usage
145
- * ```ts
146
- * import { decodeBase64 } from "@std/encoding/base64";
147
- * import { assertEquals } from "@std/assert";
148
- *
149
- * assertEquals(
150
- * decodeBase64("Zm9vYmFy"),
151
- * new TextEncoder().encode("foobar")
152
- * );
153
- * ```
154
- */
155
- export function decodeBase64(b64) {
156
- const binString = atob(b64);
157
- const size = binString.length;
158
- const bytes = new Uint8Array(size);
159
- for (let i = 0; i < size; i++) {
160
- bytes[i] = binString.charCodeAt(i);
161
- }
162
- return bytes;
163
- }
@@ -1,81 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- /**
4
- * Utilities for
5
- * {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-5 | base64url}
6
- * encoding and decoding.
7
- *
8
- * @module
9
- */
10
- import * as base64 from "./base64.js";
11
- /**
12
- * Some variants allow or require omitting the padding '=' signs:
13
- * https://en.wikipedia.org/wiki/Base64#The_URL_applications
14
- *
15
- * @param base64url
16
- */
17
- function addPaddingToBase64url(base64url) {
18
- if (base64url.length % 4 === 2)
19
- return base64url + "==";
20
- if (base64url.length % 4 === 3)
21
- return base64url + "=";
22
- if (base64url.length % 4 === 1) {
23
- throw new TypeError("Illegal base64url string");
24
- }
25
- return base64url;
26
- }
27
- function convertBase64urlToBase64(b64url) {
28
- if (!/^[-_A-Z0-9]*?={0,2}$/i.test(b64url)) {
29
- // Contains characters not part of base64url spec.
30
- throw new TypeError("Failed to decode base64url: invalid character");
31
- }
32
- return addPaddingToBase64url(b64url).replace(/\-/g, "+").replace(/_/g, "/");
33
- }
34
- function convertBase64ToBase64url(b64) {
35
- return b64.endsWith("=")
36
- ? b64.endsWith("==")
37
- ? b64.replace(/\+/g, "-").replace(/\//g, "_").slice(0, -2)
38
- : b64.replace(/\+/g, "-").replace(/\//g, "_").slice(0, -1)
39
- : b64.replace(/\+/g, "-").replace(/\//g, "_");
40
- }
41
- /**
42
- * Convert data into a base64url-encoded string.
43
- *
44
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-5}
45
- *
46
- * @param data The data to encode.
47
- * @returns The base64url-encoded string.
48
- *
49
- * @example Usage
50
- * ```ts
51
- * import { encodeBase64Url } from "@std/encoding/base64url";
52
- * import { assertEquals } from "@std/assert";
53
- *
54
- * assertEquals(encodeBase64Url("foobar"), "Zm9vYmFy");
55
- * ```
56
- */
57
- export function encodeBase64Url(data) {
58
- return convertBase64ToBase64url(base64.encodeBase64(data));
59
- }
60
- /**
61
- * Decodes a given base64url-encoded string.
62
- *
63
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-5}
64
- *
65
- * @param b64url The base64url-encoded string to decode.
66
- * @returns The decoded data.
67
- *
68
- * @example Usage
69
- * ```ts
70
- * import { decodeBase64Url } from "@std/encoding/base64url";
71
- * import { assertEquals } from "@std/assert";
72
- *
73
- * assertEquals(
74
- * decodeBase64Url("Zm9vYmFy"),
75
- * new TextEncoder().encode("foobar")
76
- * );
77
- * ```
78
- */
79
- export function decodeBase64Url(b64url) {
80
- return base64.decodeBase64(convertBase64urlToBase64(b64url));
81
- }
@@ -1,109 +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 { validateBinaryLike } from "./_validate_binary_like.js";
28
- const hexTable = new TextEncoder().encode("0123456789abcdef");
29
- const textEncoder = new TextEncoder();
30
- const textDecoder = new TextDecoder();
31
- function errInvalidByte(byte) {
32
- return new TypeError(`Invalid byte '${String.fromCharCode(byte)}'`);
33
- }
34
- function errLength(len) {
35
- return new RangeError(`Cannot decode the hex string as the input length should be even: length is ${len}`);
36
- }
37
- /** Converts a hex character into its value. */
38
- function fromHexChar(byte) {
39
- // '0' <= byte && byte <= '9'
40
- if (48 <= byte && byte <= 57)
41
- return byte - 48;
42
- // 'a' <= byte && byte <= 'f'
43
- if (97 <= byte && byte <= 102)
44
- return byte - 97 + 10;
45
- // 'A' <= byte && byte <= 'F'
46
- if (65 <= byte && byte <= 70)
47
- return byte - 65 + 10;
48
- throw errInvalidByte(byte);
49
- }
50
- /**
51
- * Converts data into a hex-encoded string.
52
- *
53
- * @param src The data to encode.
54
- *
55
- * @returns The hex-encoded string.
56
- *
57
- * @example Usage
58
- * ```ts
59
- * import { encodeHex } from "@std/encoding/hex";
60
- * import { assertEquals } from "@std/assert";
61
- *
62
- * assertEquals(encodeHex("abc"), "616263");
63
- * ```
64
- */
65
- export function encodeHex(src) {
66
- const u8 = validateBinaryLike(src);
67
- const dst = new Uint8Array(u8.length * 2);
68
- for (let i = 0; i < u8.length; i++) {
69
- const v = u8[i];
70
- dst[i * 2] = hexTable[v >> 4];
71
- dst[i * 2 + 1] = hexTable[v & 0x0f];
72
- }
73
- return textDecoder.decode(dst);
74
- }
75
- /**
76
- * Decodes the given hex-encoded string. If the input is malformed, an error is
77
- * thrown.
78
- *
79
- * @param src The hex-encoded string to decode.
80
- *
81
- * @returns The decoded data.
82
- *
83
- * @example Usage
84
- * ```ts
85
- * import { decodeHex } from "@std/encoding/hex";
86
- * import { assertEquals } from "@std/assert";
87
- *
88
- * assertEquals(
89
- * decodeHex("616263"),
90
- * new TextEncoder().encode("abc"),
91
- * );
92
- * ```
93
- */
94
- export function decodeHex(src) {
95
- const u8 = textEncoder.encode(src);
96
- const dst = new Uint8Array(u8.length / 2);
97
- for (let i = 0; i < dst.length; i++) {
98
- const a = fromHexChar(u8[i * 2]);
99
- const b = fromHexChar(u8[i * 2 + 1]);
100
- dst[i] = (a << 4) | b;
101
- }
102
- if (u8.length % 2 === 1) {
103
- // Check for invalid char before reporting bad length,
104
- // since the invalid char (if present) is an earlier problem.
105
- fromHexChar(u8[dst.length * 2]);
106
- throw errLength(u8.length);
107
- }
108
- return dst;
109
- }