windmill-cli 1.479.2 → 1.479.3

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 (82) hide show
  1. package/esm/deps/jsr.io/@std/encoding/1.0.4/_base32_common.js +183 -0
  2. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/_validate_binary_like.js +1 -1
  3. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/ascii85.js +1 -1
  4. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/base32.js +22 -40
  5. package/esm/deps/jsr.io/@std/encoding/1.0.4/base32_stream.js +92 -0
  6. package/esm/deps/jsr.io/@std/encoding/1.0.4/base32hex.js +77 -0
  7. package/esm/deps/jsr.io/@std/encoding/1.0.4/base32hex_stream.js +92 -0
  8. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/base58.js +1 -1
  9. package/esm/deps/jsr.io/@std/encoding/1.0.4/base64.js +163 -0
  10. package/esm/deps/jsr.io/@std/encoding/1.0.4/base64_stream.js +92 -0
  11. package/esm/deps/jsr.io/@std/encoding/1.0.4/base64url.js +81 -0
  12. package/esm/deps/jsr.io/@std/encoding/1.0.4/base64url_stream.js +93 -0
  13. package/esm/deps/jsr.io/@std/encoding/1.0.4/hex.js +109 -0
  14. package/esm/deps/jsr.io/@std/encoding/1.0.4/hex_stream.js +81 -0
  15. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/mod.js +7 -2
  16. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/varint.js +3 -1
  17. package/esm/deps.js +1 -1
  18. package/esm/gen/core/OpenAPI.js +1 -1
  19. package/esm/hub.js +3 -16
  20. package/esm/main.js +1 -1
  21. package/package.json +1 -1
  22. package/types/deps/jsr.io/@std/encoding/1.0.4/_base32_common.d.ts +17 -0
  23. package/types/deps/jsr.io/@std/encoding/1.0.4/_base32_common.d.ts.map +1 -0
  24. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/_validate_binary_like.d.ts.map +1 -1
  25. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/ascii85.d.ts +1 -3
  26. package/types/deps/jsr.io/@std/encoding/1.0.4/ascii85.d.ts.map +1 -0
  27. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/base32.d.ts +15 -17
  28. package/types/deps/jsr.io/@std/encoding/1.0.4/base32.d.ts.map +1 -0
  29. package/types/deps/jsr.io/@std/encoding/1.0.4/base32_stream.d.ts +48 -0
  30. package/types/deps/jsr.io/@std/encoding/1.0.4/base32_stream.d.ts.map +1 -0
  31. package/types/deps/jsr.io/@std/encoding/1.0.4/base32hex.d.ts +42 -0
  32. package/types/deps/jsr.io/@std/encoding/1.0.4/base32hex.d.ts.map +1 -0
  33. package/types/deps/jsr.io/@std/encoding/1.0.4/base32hex_stream.d.ts +48 -0
  34. package/types/deps/jsr.io/@std/encoding/1.0.4/base32hex_stream.d.ts.map +1 -0
  35. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/base58.d.ts +1 -3
  36. package/types/deps/jsr.io/@std/encoding/1.0.4/base58.d.ts.map +1 -0
  37. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/base64.d.ts +1 -3
  38. package/types/deps/jsr.io/@std/encoding/1.0.4/base64.d.ts.map +1 -0
  39. package/types/deps/jsr.io/@std/encoding/1.0.4/base64_stream.d.ts +48 -0
  40. package/types/deps/jsr.io/@std/encoding/1.0.4/base64_stream.d.ts.map +1 -0
  41. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/base64url.d.ts +1 -3
  42. package/types/deps/jsr.io/@std/encoding/1.0.4/base64url.d.ts.map +1 -0
  43. package/types/deps/jsr.io/@std/encoding/1.0.4/base64url_stream.d.ts +49 -0
  44. package/types/deps/jsr.io/@std/encoding/1.0.4/base64url_stream.d.ts.map +1 -0
  45. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/hex.d.ts +1 -3
  46. package/types/deps/jsr.io/@std/encoding/1.0.4/hex.d.ts.map +1 -0
  47. package/types/deps/jsr.io/@std/encoding/1.0.4/hex_stream.d.ts +48 -0
  48. package/types/deps/jsr.io/@std/encoding/1.0.4/hex_stream.d.ts.map +1 -0
  49. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/mod.d.ts +6 -0
  50. package/types/deps/jsr.io/@std/encoding/1.0.4/mod.d.ts.map +1 -0
  51. package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/varint.d.ts +1 -3
  52. package/types/deps/jsr.io/@std/encoding/1.0.4/varint.d.ts.map +1 -0
  53. package/types/deps.d.ts +1 -1
  54. package/types/hub.d.ts.map +1 -1
  55. package/types/main.d.ts +1 -1
  56. package/esm/deps/jsr.io/@std/encoding/1.0.8/_common16.js +0 -45
  57. package/esm/deps/jsr.io/@std/encoding/1.0.8/_common32.js +0 -175
  58. package/esm/deps/jsr.io/@std/encoding/1.0.8/_common64.js +0 -98
  59. package/esm/deps/jsr.io/@std/encoding/1.0.8/_common_detach.js +0 -13
  60. package/esm/deps/jsr.io/@std/encoding/1.0.8/_types.js +0 -2
  61. package/esm/deps/jsr.io/@std/encoding/1.0.8/base64.js +0 -82
  62. package/esm/deps/jsr.io/@std/encoding/1.0.8/base64url.js +0 -72
  63. package/esm/deps/jsr.io/@std/encoding/1.0.8/hex.js +0 -87
  64. package/types/deps/jsr.io/@std/encoding/1.0.8/_common16.d.ts +0 -21
  65. package/types/deps/jsr.io/@std/encoding/1.0.8/_common16.d.ts.map +0 -1
  66. package/types/deps/jsr.io/@std/encoding/1.0.8/_common32.d.ts +0 -21
  67. package/types/deps/jsr.io/@std/encoding/1.0.8/_common32.d.ts.map +0 -1
  68. package/types/deps/jsr.io/@std/encoding/1.0.8/_common64.d.ts +0 -21
  69. package/types/deps/jsr.io/@std/encoding/1.0.8/_common64.d.ts.map +0 -1
  70. package/types/deps/jsr.io/@std/encoding/1.0.8/_common_detach.d.ts +0 -4
  71. package/types/deps/jsr.io/@std/encoding/1.0.8/_common_detach.d.ts.map +0 -1
  72. package/types/deps/jsr.io/@std/encoding/1.0.8/_types.d.ts +0 -9
  73. package/types/deps/jsr.io/@std/encoding/1.0.8/_types.d.ts.map +0 -1
  74. package/types/deps/jsr.io/@std/encoding/1.0.8/ascii85.d.ts.map +0 -1
  75. package/types/deps/jsr.io/@std/encoding/1.0.8/base32.d.ts.map +0 -1
  76. package/types/deps/jsr.io/@std/encoding/1.0.8/base58.d.ts.map +0 -1
  77. package/types/deps/jsr.io/@std/encoding/1.0.8/base64.d.ts.map +0 -1
  78. package/types/deps/jsr.io/@std/encoding/1.0.8/base64url.d.ts.map +0 -1
  79. package/types/deps/jsr.io/@std/encoding/1.0.8/hex.d.ts.map +0 -1
  80. package/types/deps/jsr.io/@std/encoding/1.0.8/mod.d.ts.map +0 -1
  81. package/types/deps/jsr.io/@std/encoding/1.0.8/varint.d.ts.map +0 -1
  82. /package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.4}/_validate_binary_like.d.ts +0 -0
@@ -0,0 +1,183 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // Copyright (c) 2014 Jameson Little. MIT License.
3
+ // This module is browser compatible.
4
+ /**
5
+ * common code for base32 and base32hex encodings.
6
+ */
7
+ import { validateBinaryLike } from "./_validate_binary_like.js";
8
+ const placeHolderPadLookup = [0, 1, , 2, 3, , 4];
9
+ function getPadLength(placeHoldersLen) {
10
+ const maybeLen = placeHolderPadLookup[placeHoldersLen];
11
+ if (typeof maybeLen !== "number") {
12
+ throw new Error("Invalid pad length");
13
+ }
14
+ return maybeLen;
15
+ }
16
+ function getLens(b32) {
17
+ const len = b32.length;
18
+ if (len % 8 > 0) {
19
+ throw new Error(`Cannot decode base32 string as the length must be a multiple of 8: received length ${len}`);
20
+ }
21
+ let validLen = b32.indexOf("=");
22
+ if (validLen === -1)
23
+ validLen = len;
24
+ const placeHoldersLen = validLen === len ? 0 : 8 - (validLen % 8);
25
+ return [validLen, placeHoldersLen];
26
+ }
27
+ function getByteLength(validLen, placeHoldersLen) {
28
+ return ((validLen + placeHoldersLen) * 5) / 8 - getPadLength(placeHoldersLen);
29
+ }
30
+ /**
31
+ * Decodes an encoded string with the given lookup table.
32
+ *
33
+ * @param b32 The string to encode.
34
+ * @param lookup The lookup table
35
+ * @returns The encoded string.
36
+ */
37
+ export function decode(b32, lookup) {
38
+ const revLookup = [];
39
+ lookup.forEach((c, i) => (revLookup[c.charCodeAt(0)] = i));
40
+ let tmp;
41
+ const [validLen, placeHoldersLen] = getLens(b32);
42
+ const arr = new Uint8Array(getByteLength(validLen, placeHoldersLen));
43
+ let curByte = 0;
44
+ // if there are placeholders, only get up to the last complete 8 chars
45
+ const len = placeHoldersLen > 0 ? validLen - 8 : validLen;
46
+ let i;
47
+ for (i = 0; i < len; i += 8) {
48
+ tmp = (revLookup[b32.charCodeAt(i)] << 20) |
49
+ (revLookup[b32.charCodeAt(i + 1)] << 15) |
50
+ (revLookup[b32.charCodeAt(i + 2)] << 10) |
51
+ (revLookup[b32.charCodeAt(i + 3)] << 5) |
52
+ revLookup[b32.charCodeAt(i + 4)];
53
+ arr[curByte++] = (tmp >> 17) & 0xff;
54
+ arr[curByte++] = (tmp >> 9) & 0xff;
55
+ arr[curByte++] = (tmp >> 1) & 0xff;
56
+ tmp = ((tmp & 1) << 15) |
57
+ (revLookup[b32.charCodeAt(i + 5)] << 10) |
58
+ (revLookup[b32.charCodeAt(i + 6)] << 5) |
59
+ revLookup[b32.charCodeAt(i + 7)];
60
+ arr[curByte++] = (tmp >> 8) & 0xff;
61
+ arr[curByte++] = tmp & 0xff;
62
+ }
63
+ if (placeHoldersLen === 1) {
64
+ tmp = (revLookup[b32.charCodeAt(i)] << 20) |
65
+ (revLookup[b32.charCodeAt(i + 1)] << 15) |
66
+ (revLookup[b32.charCodeAt(i + 2)] << 10) |
67
+ (revLookup[b32.charCodeAt(i + 3)] << 5) |
68
+ revLookup[b32.charCodeAt(i + 4)];
69
+ arr[curByte++] = (tmp >> 17) & 0xff;
70
+ arr[curByte++] = (tmp >> 9) & 0xff;
71
+ arr[curByte++] = (tmp >> 1) & 0xff;
72
+ tmp = ((tmp & 1) << 7) |
73
+ (revLookup[b32.charCodeAt(i + 5)] << 2) |
74
+ (revLookup[b32.charCodeAt(i + 6)] >> 3);
75
+ arr[curByte++] = tmp & 0xff;
76
+ }
77
+ else if (placeHoldersLen === 3) {
78
+ tmp = (revLookup[b32.charCodeAt(i)] << 19) |
79
+ (revLookup[b32.charCodeAt(i + 1)] << 14) |
80
+ (revLookup[b32.charCodeAt(i + 2)] << 9) |
81
+ (revLookup[b32.charCodeAt(i + 3)] << 4) |
82
+ (revLookup[b32.charCodeAt(i + 4)] >> 1);
83
+ arr[curByte++] = (tmp >> 16) & 0xff;
84
+ arr[curByte++] = (tmp >> 8) & 0xff;
85
+ arr[curByte++] = tmp & 0xff;
86
+ }
87
+ else if (placeHoldersLen === 4) {
88
+ tmp = (revLookup[b32.charCodeAt(i)] << 11) |
89
+ (revLookup[b32.charCodeAt(i + 1)] << 6) |
90
+ (revLookup[b32.charCodeAt(i + 2)] << 1) |
91
+ (revLookup[b32.charCodeAt(i + 3)] >> 4);
92
+ arr[curByte++] = (tmp >> 8) & 0xff;
93
+ arr[curByte++] = tmp & 0xff;
94
+ }
95
+ else if (placeHoldersLen === 6) {
96
+ tmp = (revLookup[b32.charCodeAt(i)] << 3) |
97
+ (revLookup[b32.charCodeAt(i + 1)] >> 2);
98
+ arr[curByte++] = tmp & 0xff;
99
+ }
100
+ return arr;
101
+ }
102
+ function encodeChunk(uint8, start, end, lookup) {
103
+ let tmp;
104
+ const output = [];
105
+ for (let i = start; i < end; i += 5) {
106
+ tmp = ((uint8[i] << 16) & 0xff0000) |
107
+ ((uint8[i + 1] << 8) & 0xff00) |
108
+ (uint8[i + 2] & 0xff);
109
+ output.push(lookup[(tmp >> 19) & 0x1f]);
110
+ output.push(lookup[(tmp >> 14) & 0x1f]);
111
+ output.push(lookup[(tmp >> 9) & 0x1f]);
112
+ output.push(lookup[(tmp >> 4) & 0x1f]);
113
+ tmp = ((tmp & 0xf) << 16) |
114
+ ((uint8[i + 3] << 8) & 0xff00) |
115
+ (uint8[i + 4] & 0xff);
116
+ output.push(lookup[(tmp >> 15) & 0x1f]);
117
+ output.push(lookup[(tmp >> 10) & 0x1f]);
118
+ output.push(lookup[(tmp >> 5) & 0x1f]);
119
+ output.push(lookup[tmp & 0x1f]);
120
+ }
121
+ return output.join("");
122
+ }
123
+ /**
124
+ * Encodes the given data using the lookup table.
125
+ *
126
+ * @param data The data to encode.
127
+ * @param lookup The lookup table.
128
+ * @returns The encoded string.
129
+ */
130
+ export function encode(data, lookup) {
131
+ const uint8 = validateBinaryLike(data);
132
+ let tmp;
133
+ const len = uint8.length;
134
+ const extraBytes = len % 5;
135
+ const parts = [];
136
+ const maxChunkLength = 16385; // must be multiple of 5
137
+ const len2 = len - extraBytes;
138
+ // go through the array every 5 bytes, we'll deal with trailing stuff later
139
+ for (let i = 0; i < len2; i += maxChunkLength) {
140
+ parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength, lookup));
141
+ }
142
+ // pad the end with zeros, but make sure to not forget the extra bytes
143
+ if (extraBytes === 4) {
144
+ tmp = ((uint8[len2] & 0xff) << 16) |
145
+ ((uint8[len2 + 1] & 0xff) << 8) |
146
+ (uint8[len2 + 2] & 0xff);
147
+ parts.push(lookup[(tmp >> 19) & 0x1f]);
148
+ parts.push(lookup[(tmp >> 14) & 0x1f]);
149
+ parts.push(lookup[(tmp >> 9) & 0x1f]);
150
+ parts.push(lookup[(tmp >> 4) & 0x1f]);
151
+ tmp = ((tmp & 0xf) << 11) | (uint8[len2 + 3] << 3);
152
+ parts.push(lookup[(tmp >> 10) & 0x1f]);
153
+ parts.push(lookup[(tmp >> 5) & 0x1f]);
154
+ parts.push(lookup[tmp & 0x1f]);
155
+ parts.push("=");
156
+ }
157
+ else if (extraBytes === 3) {
158
+ tmp = ((uint8[len2] & 0xff) << 17) |
159
+ ((uint8[len2 + 1] & 0xff) << 9) |
160
+ ((uint8[len2 + 2] & 0xff) << 1);
161
+ parts.push(lookup[(tmp >> 20) & 0x1f]);
162
+ parts.push(lookup[(tmp >> 15) & 0x1f]);
163
+ parts.push(lookup[(tmp >> 10) & 0x1f]);
164
+ parts.push(lookup[(tmp >> 5) & 0x1f]);
165
+ parts.push(lookup[tmp & 0x1f]);
166
+ parts.push("===");
167
+ }
168
+ else if (extraBytes === 2) {
169
+ tmp = ((uint8[len2] & 0xff) << 12) | ((uint8[len2 + 1] & 0xff) << 4);
170
+ parts.push(lookup[(tmp >> 15) & 0x1f]);
171
+ parts.push(lookup[(tmp >> 10) & 0x1f]);
172
+ parts.push(lookup[(tmp >> 5) & 0x1f]);
173
+ parts.push(lookup[tmp & 0x1f]);
174
+ parts.push("====");
175
+ }
176
+ else if (extraBytes === 1) {
177
+ tmp = (uint8[len2] & 0xff) << 2;
178
+ parts.push(lookup[(tmp >> 5) & 0x1f]);
179
+ parts.push(lookup[tmp & 0x1f]);
180
+ parts.push("======");
181
+ }
182
+ return parts.join("");
183
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
2
  const encoder = new TextEncoder();
3
3
  function getTypeName(value) {
4
4
  const type = typeof value;
@@ -1,4 +1,4 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
2
  // This module is browser compatible.
3
3
  /**
4
4
  * Utilities for working with {@link https://en.wikipedia.org/wiki/Ascii85 | ascii85} encoding.
@@ -1,4 +1,4 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
2
  // Copyright (c) 2014 Jameson Little. MIT License.
3
3
  // This module is browser compatible.
4
4
  /**
@@ -22,66 +22,48 @@
22
22
  *
23
23
  * @module
24
24
  */
25
- import { calcMax, decode, encode } from "./_common32.js";
26
- import { detach } from "./_common_detach.js";
27
- const padding = "=".charCodeAt(0);
28
- const alphabet = new TextEncoder()
29
- .encode("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
30
- const rAlphabet = new Uint8Array(128).fill(32); //alphabet.length
31
- alphabet.forEach((byte, i) => rAlphabet[byte] = i);
25
+ import { decode, encode } from "./_base32_common.js";
26
+ const lookup = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split("");
27
+ const revLookup = [];
28
+ lookup.forEach((c, i) => (revLookup[c.charCodeAt(0)] = i));
32
29
  /**
33
- * Converts data into a base32-encoded string.
30
+ * Decodes a base32-encoded string.
34
31
  *
35
32
  * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
36
33
  *
37
- * @param data The data to encode.
38
- * @returns The base32-encoded string.
34
+ * @param b32 The base32-encoded string to decode.
35
+ * @returns The decoded data.
39
36
  *
40
37
  * @example Usage
41
38
  * ```ts
42
- * import { encodeBase32 } from "@std/encoding/base32";
39
+ * import { decodeBase32 } from "@std/encoding/base32";
43
40
  * import { assertEquals } from "@std/assert";
44
41
  *
45
- * assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
42
+ * assertEquals(
43
+ * decodeBase32("GZRTMMDDGA======"),
44
+ * new TextEncoder().encode("6c60c0"),
45
+ * );
46
46
  * ```
47
47
  */
48
- export function encodeBase32(data) {
49
- if (typeof data === "string") {
50
- data = new TextEncoder().encode(data);
51
- }
52
- else if (data instanceof ArrayBuffer)
53
- data = new Uint8Array(data).slice();
54
- else
55
- data = data.slice();
56
- const [output, i] = detach(data, calcMax(data.length));
57
- encode(output, i, 0, alphabet, padding);
58
- return new TextDecoder().decode(output);
48
+ export function decodeBase32(b32) {
49
+ return decode(b32, lookup);
59
50
  }
60
51
  /**
61
- * Decodes a base32-encoded string.
52
+ * Converts data into a base32-encoded string.
62
53
  *
63
54
  * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
64
55
  *
65
- * @param b32 The base32-encoded string to decode.
66
- * @returns The decoded data.
56
+ * @param data The data to encode.
57
+ * @returns The base32-encoded string.
67
58
  *
68
59
  * @example Usage
69
60
  * ```ts
70
- * import { decodeBase32 } from "@std/encoding/base32";
61
+ * import { encodeBase32 } from "@std/encoding/base32";
71
62
  * import { assertEquals } from "@std/assert";
72
63
  *
73
- * assertEquals(
74
- * decodeBase32("GZRTMMDDGA======"),
75
- * new TextEncoder().encode("6c60c0"),
76
- * );
64
+ * assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
77
65
  * ```
78
66
  */
79
- export function decodeBase32(b32) {
80
- const output = new TextEncoder().encode(b32);
81
- if (output.length % 8) {
82
- throw new TypeError(`Invalid base32 string: length (${output.length}) must be a multiple of 8`);
83
- }
84
- // deno-lint-ignore no-explicit-any
85
- return new Uint8Array(output.buffer
86
- .transfer(decode(output, 0, 0, rAlphabet, padding)));
67
+ export function encodeBase32(data) {
68
+ return encode(data, lookup);
87
69
  }
@@ -0,0 +1,92 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ /**
4
+ * Utilities for encoding and decoding to and from base32 in a streaming manner.
5
+ *
6
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
7
+ *
8
+ * @module
9
+ */
10
+ import { decodeBase32, encodeBase32 } from "./base32.js";
11
+ /**
12
+ * Converts a Uint8Array stream into a base32-encoded stream.
13
+ *
14
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
15
+ *
16
+ * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
17
+ *
18
+ * @example Usage
19
+ * ```ts
20
+ * import { assertEquals } from "@std/assert";
21
+ * import { encodeBase32 } from "@std/encoding/base32";
22
+ * import { Base32EncoderStream } from "@std/encoding/base32-stream";
23
+ * import { toText } from "@std/streams/to-text";
24
+ *
25
+ * const stream = ReadableStream.from(["Hello,", " world!"])
26
+ * .pipeThrough(new TextEncoderStream())
27
+ * .pipeThrough(new Base32EncoderStream());
28
+ *
29
+ * assertEquals(await toText(stream), encodeBase32(new TextEncoder().encode("Hello, world!")));
30
+ * ```
31
+ */
32
+ export class Base32EncoderStream extends TransformStream {
33
+ constructor() {
34
+ let push = new Uint8Array(0);
35
+ super({
36
+ transform(chunk, controller) {
37
+ const concat = new Uint8Array(push.length + chunk.length);
38
+ concat.set(push);
39
+ concat.set(chunk, push.length);
40
+ const remainder = -concat.length % 5;
41
+ controller.enqueue(encodeBase32(concat.slice(0, remainder || undefined)));
42
+ push = remainder ? concat.slice(remainder) : new Uint8Array(0);
43
+ },
44
+ flush(controller) {
45
+ if (push.length) {
46
+ controller.enqueue(encodeBase32(push));
47
+ }
48
+ },
49
+ });
50
+ }
51
+ }
52
+ /**
53
+ * Decodes a base32-encoded stream into a Uint8Array stream.
54
+ *
55
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
56
+ *
57
+ * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
58
+ *
59
+ * @example Usage
60
+ * ```ts
61
+ * import { assertEquals } from "@std/assert";
62
+ * import { Base32DecoderStream } from "@std/encoding/base32-stream";
63
+ * import { toText } from "@std/streams/to-text";
64
+ *
65
+ * const stream = ReadableStream.from(["JBSWY3DPEBLW64TMMQQQ===="])
66
+ * .pipeThrough(new Base32DecoderStream())
67
+ * .pipeThrough(new TextDecoderStream());
68
+ *
69
+ * assertEquals(await toText(stream), "Hello World!");
70
+ * ```
71
+ */
72
+ export class Base32DecoderStream extends TransformStream {
73
+ constructor() {
74
+ let push = "";
75
+ super({
76
+ transform(chunk, controller) {
77
+ push += chunk;
78
+ if (push.length < 8) {
79
+ return;
80
+ }
81
+ const remainder = -push.length % 8;
82
+ controller.enqueue(decodeBase32(push.slice(0, remainder || undefined)));
83
+ push = remainder ? chunk.slice(remainder) : "";
84
+ },
85
+ flush(controller) {
86
+ if (push.length) {
87
+ controller.enqueue(decodeBase32(push));
88
+ }
89
+ },
90
+ });
91
+ }
92
+ }
@@ -0,0 +1,77 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // Copyright (c) 2014 Jameson Little. MIT License.
3
+ // This module is browser compatible.
4
+ /**
5
+ * Utilities for
6
+ * {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-7 | base32hex}
7
+ * encoding and decoding.
8
+ *
9
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
10
+ *
11
+ * Modified from {@link [base32]}.
12
+ *
13
+ * This module is browser compatible.
14
+ *
15
+ * ```ts
16
+ * import { encodeBase32Hex, decodeBase32Hex } from "@std/encoding/base32hex";
17
+ * import { assertEquals } from "@std/assert";
18
+ *
19
+ * assertEquals(encodeBase32Hex("foobar"), "CPNMUOJ1E8======");
20
+ *
21
+ * assertEquals(
22
+ * decodeBase32Hex("CPNMUOJ1E8======"),
23
+ * new TextEncoder().encode("foobar")
24
+ * );
25
+ * ```
26
+ *
27
+ * @module
28
+ */
29
+ import { decode, encode } from "./_base32_common.js";
30
+ const lookup = "0123456789ABCDEFGHIJKLMNOPQRSTUV".split("");
31
+ const revLookup = [];
32
+ lookup.forEach((c, i) => revLookup[c.charCodeAt(0)] = i);
33
+ /**
34
+ * Decodes a base32hex-encoded string.
35
+ *
36
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
37
+ *
38
+ * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-7}
39
+ *
40
+ * @param b32 The base32hex-encoded string to decode.
41
+ * @returns The decoded data.
42
+ *
43
+ * @example Usage
44
+ * ```ts
45
+ * import { decodeBase32Hex } from "@std/encoding/base32hex";
46
+ * import { assertEquals } from "@std/assert";
47
+ *
48
+ * assertEquals(
49
+ * decodeBase32Hex("6PHJCC3360======"),
50
+ * new TextEncoder().encode("6c60c0"),
51
+ * );
52
+ * ```
53
+ */
54
+ export function decodeBase32Hex(b32) {
55
+ return decode(b32, lookup);
56
+ }
57
+ /**
58
+ * Converts data into a base32hex-encoded string.
59
+ *
60
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
61
+ *
62
+ * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-7}
63
+ *
64
+ * @param data The data to encode.
65
+ * @returns The base32hex-encoded string.
66
+ *
67
+ * @example Usage
68
+ * ```ts
69
+ * import { encodeBase32Hex } from "@std/encoding/base32hex";
70
+ * import { assertEquals } from "@std/assert";
71
+ *
72
+ * assertEquals(encodeBase32Hex("6c60c0"), "6PHJCC3360======");
73
+ * ```
74
+ */
75
+ export function encodeBase32Hex(data) {
76
+ return encode(data, lookup);
77
+ }
@@ -0,0 +1,92 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ /**
4
+ * Utilities for encoding and decoding to and from base32hex in a streaming manner.
5
+ *
6
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
7
+ *
8
+ * @module
9
+ */
10
+ import { decodeBase32Hex, encodeBase32Hex } from "./base32hex.js";
11
+ /**
12
+ * Converts a Uint8Array stream into a base32hex-encoded stream.
13
+ *
14
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
15
+ *
16
+ * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
17
+ *
18
+ * @example Usage
19
+ * ```ts
20
+ * import { assertEquals } from "@std/assert";
21
+ * import { encodeBase32Hex } from "@std/encoding/base32hex";
22
+ * import { Base32HexEncoderStream } from "@std/encoding/base32hex-stream";
23
+ * import { toText } from "@std/streams/to-text";
24
+ *
25
+ * const stream = ReadableStream.from(["Hello,", " world!"])
26
+ * .pipeThrough(new TextEncoderStream())
27
+ * .pipeThrough(new Base32HexEncoderStream());
28
+ *
29
+ * assertEquals(await toText(stream), encodeBase32Hex(new TextEncoder().encode("Hello, world!")));
30
+ * ```
31
+ */
32
+ export class Base32HexEncoderStream extends TransformStream {
33
+ constructor() {
34
+ let push = new Uint8Array(0);
35
+ super({
36
+ transform(chunk, controller) {
37
+ const concat = new Uint8Array(push.length + chunk.length);
38
+ concat.set(push);
39
+ concat.set(chunk, push.length);
40
+ const remainder = -concat.length % 5;
41
+ controller.enqueue(encodeBase32Hex(concat.slice(0, remainder || undefined)));
42
+ push = remainder ? concat.slice(remainder) : new Uint8Array(0);
43
+ },
44
+ flush(controller) {
45
+ if (push.length) {
46
+ controller.enqueue(encodeBase32Hex(push));
47
+ }
48
+ },
49
+ });
50
+ }
51
+ }
52
+ /**
53
+ * Decodes a base32hex-encoded stream into a Uint8Array stream.
54
+ *
55
+ * @experimental **UNSTABLE**: New API, yet to be vetted.
56
+ *
57
+ * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
58
+ *
59
+ * @example Usage
60
+ * ```ts
61
+ * import { assertEquals } from "@std/assert";
62
+ * import { Base32HexDecoderStream } from "@std/encoding/base32hex-stream";
63
+ * import { toText } from "@std/streams/to-text";
64
+ *
65
+ * const stream = ReadableStream.from(["91IMOR3F5GG7ERRI", "DHI22==="])
66
+ * .pipeThrough(new Base32HexDecoderStream())
67
+ * .pipeThrough(new TextDecoderStream());
68
+ *
69
+ * assertEquals(await toText(stream), "Hello, world!");
70
+ * ```
71
+ */
72
+ export class Base32HexDecoderStream extends TransformStream {
73
+ constructor() {
74
+ let push = "";
75
+ super({
76
+ transform(chunk, controller) {
77
+ push += chunk;
78
+ if (push.length < 8) {
79
+ return;
80
+ }
81
+ const remainder = -push.length % 8;
82
+ controller.enqueue(decodeBase32Hex(push.slice(0, remainder || undefined)));
83
+ push = remainder ? chunk.slice(remainder) : "";
84
+ },
85
+ flush(controller) {
86
+ if (push.length) {
87
+ controller.enqueue(decodeBase32Hex(push));
88
+ }
89
+ },
90
+ });
91
+ }
92
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
2
  // This module is browser compatible.
3
3
  /**
4
4
  * Utilities for