@fedify/fedify 1.2.19 → 1.2.20
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.
- package/CHANGES.md +35 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.js +26 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/base64.js +163 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/base64url.js +81 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.js +109 -0
- package/esm/federation/collection.js +1 -1
- package/esm/federation/handler.js +1 -1
- package/esm/runtime/key.js +3 -3
- package/esm/sig/http.js +1 -1
- package/esm/sig/ld.js +2 -2
- package/package.json +1 -1
- package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.7}/_types.d.ts.map +1 -1
- package/types/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.d.ts +2 -0
- package/types/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/encoding/1.0.7/base64.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/encoding/1.0.7/base64url.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.8/_common16.js +0 -45
- package/esm/deps/jsr.io/@std/encoding/1.0.8/_common64.js +0 -98
- package/esm/deps/jsr.io/@std/encoding/1.0.8/_common_detach.js +0 -13
- package/esm/deps/jsr.io/@std/encoding/1.0.8/base64.js +0 -82
- package/esm/deps/jsr.io/@std/encoding/1.0.8/base64url.js +0 -72
- package/esm/deps/jsr.io/@std/encoding/1.0.8/hex.js +0 -87
- package/types/deps/jsr.io/@std/encoding/1.0.8/_common16.d.ts +0 -21
- package/types/deps/jsr.io/@std/encoding/1.0.8/_common16.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/encoding/1.0.8/_common64.d.ts +0 -21
- package/types/deps/jsr.io/@std/encoding/1.0.8/_common64.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/encoding/1.0.8/_common_detach.d.ts +0 -4
- package/types/deps/jsr.io/@std/encoding/1.0.8/_common_detach.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/encoding/1.0.8/base64.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/encoding/1.0.8/base64url.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/encoding/1.0.8/hex.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.7}/_types.js +0 -0
- /package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.7}/_types.d.ts +0 -0
- /package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.7}/base64.d.ts +0 -0
- /package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.7}/base64url.d.ts +0 -0
- /package/types/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.7}/hex.d.ts +0 -0
package/CHANGES.md
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
Fedify changelog
|
4
4
|
================
|
5
5
|
|
6
|
+
Version 1.2.20
|
7
|
+
--------------
|
8
|
+
|
9
|
+
Released on March 26, 2025.
|
10
|
+
|
11
|
+
- Fixed a `TypeError` thrown by the followers collection dispatcher when
|
12
|
+
the `base-url` parameter was provided.
|
13
|
+
- Fixed a `TypeError` thrown by the `signRequest()` function on Node.js.
|
14
|
+
[[#222]]
|
15
|
+
|
16
|
+
|
6
17
|
Version 1.2.19
|
7
18
|
--------------
|
8
19
|
|
@@ -358,6 +369,17 @@ Released on October 31, 2024.
|
|
358
369
|
[#118]: https://github.com/dahlia/fedify/issues/118
|
359
370
|
|
360
371
|
|
372
|
+
Version 1.1.20
|
373
|
+
--------------
|
374
|
+
|
375
|
+
Released on March 26, 2025.
|
376
|
+
|
377
|
+
- Fixed a `TypeError` thrown by the followers collection dispatcher when
|
378
|
+
the `base-url` parameter was provided.
|
379
|
+
- Fixed a `TypeError` thrown by the `signRequest()` function on Node.js.
|
380
|
+
[[#222]]
|
381
|
+
|
382
|
+
|
361
383
|
Version 1.1.19
|
362
384
|
--------------
|
363
385
|
|
@@ -754,6 +776,19 @@ Released on October 20, 2024.
|
|
754
776
|
[#150]: https://github.com/dahlia/fedify/issues/150
|
755
777
|
|
756
778
|
|
779
|
+
Version 1.0.23
|
780
|
+
--------------
|
781
|
+
|
782
|
+
Released on March 26, 2025.
|
783
|
+
|
784
|
+
- Fixed a `TypeError` thrown by the followers collection dispatcher when
|
785
|
+
the `base-url` parameter was provided.
|
786
|
+
- Fixed a `TypeError` thrown by the `signRequest()` function on Node.js.
|
787
|
+
[[#222]]
|
788
|
+
|
789
|
+
[#222]: https://github.com/fedify-dev/fedify/issues/222
|
790
|
+
|
791
|
+
|
757
792
|
Version 1.0.22
|
758
793
|
--------------
|
759
794
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. 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(`Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer: received a value of the type ${getTypeName(source)}`);
|
26
|
+
}
|
@@ -0,0 +1,163 @@
|
|
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
|
+
}
|
@@ -0,0 +1,81 @@
|
|
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
|
+
}
|
@@ -0,0 +1,109 @@
|
|
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
|
+
}
|
@@ -102,7 +102,7 @@ export async function handleCollection(request, { name, identifier, uriGetter, f
|
|
102
102
|
}
|
103
103
|
collection = new OrderedCollection({
|
104
104
|
id: baseUri,
|
105
|
-
totalItems: Number(totalItems),
|
105
|
+
totalItems: totalItems == null ? null : Number(totalItems),
|
106
106
|
first,
|
107
107
|
last,
|
108
108
|
});
|
package/esm/runtime/key.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
2
2
|
import { createPublicKey } from "node:crypto";
|
3
3
|
import { concat } from "../deps/jsr.io/@std/bytes/1.0.5/concat.js";
|
4
|
-
import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.
|
5
|
-
import { decodeBase64Url } from "../deps/jsr.io/@std/encoding/1.0.
|
6
|
-
import { decodeHex } from "../deps/jsr.io/@std/encoding/1.0.
|
4
|
+
import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.7/base64.js";
|
5
|
+
import { decodeBase64Url } from "../deps/jsr.io/@std/encoding/1.0.7/base64url.js";
|
6
|
+
import { decodeHex } from "../deps/jsr.io/@std/encoding/1.0.7/hex.js";
|
7
7
|
import { Integer, Sequence } from "asn1js";
|
8
8
|
import { decode, encode } from "multibase";
|
9
9
|
import { addPrefix, getCodeFromData, rmPrefix } from "multicodec";
|
package/esm/sig/http.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
2
2
|
import { getLogger } from "@logtape/logtape";
|
3
3
|
import { equals } from "../deps/jsr.io/@std/bytes/1.0.5/mod.js";
|
4
|
-
import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.
|
4
|
+
import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.7/base64.js";
|
5
5
|
import { CryptographicKey } from "../vocab/vocab.js";
|
6
6
|
import { fetchKey, validateCryptoKey } from "./key.js";
|
7
7
|
/**
|
package/esm/sig/ld.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
2
2
|
import { getLogger } from "@logtape/logtape";
|
3
|
-
import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.
|
4
|
-
import { encodeHex } from "../deps/jsr.io/@std/encoding/1.0.
|
3
|
+
import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/1.0.7/base64.js";
|
4
|
+
import { encodeHex } from "../deps/jsr.io/@std/encoding/1.0.7/hex.js";
|
5
5
|
// @ts-ignore TS7016
|
6
6
|
import jsonld from "jsonld";
|
7
7
|
import { fetchDocumentLoader, } from "../runtime/docloader.js";
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.
|
1
|
+
{"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"_validate_binary_like.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.ts"],"names":[],"mappings":"AAeA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CAa9D"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/base64.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAqE5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAmC5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAQrD"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/base64url.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAiC5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GACtC,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAE3D"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/hex.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AA4B5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAUxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAiBlD"}
|
@@ -1,45 +0,0 @@
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
2
|
-
/**
|
3
|
-
* Calculate the output size needed to encode a given input size for
|
4
|
-
* {@linkcode encodeRawHex}.
|
5
|
-
*
|
6
|
-
* @param originalSize The size of the input buffer.
|
7
|
-
* @returns The size of the output buffer.
|
8
|
-
*
|
9
|
-
* @example Basic Usage
|
10
|
-
* ```ts
|
11
|
-
* import { assertEquals } from "@std/assert";
|
12
|
-
* import { calcMax } from "@std/encoding/unstable-hex";
|
13
|
-
*
|
14
|
-
* assertEquals(calcMax(1), 2);
|
15
|
-
* ```
|
16
|
-
*/
|
17
|
-
export function calcMax(originalSize) {
|
18
|
-
return originalSize * 2;
|
19
|
-
}
|
20
|
-
export function encode(buffer, i, o, alphabet) {
|
21
|
-
for (; i < buffer.length; ++i) {
|
22
|
-
const x = buffer[i];
|
23
|
-
buffer[o++] = alphabet[x >> 4];
|
24
|
-
buffer[o++] = alphabet[x & 0xF];
|
25
|
-
}
|
26
|
-
return o;
|
27
|
-
}
|
28
|
-
export function decode(buffer, i, o, alphabet) {
|
29
|
-
if ((buffer.length - o) % 2 === 1) {
|
30
|
-
throw new RangeError(`Cannot decode input as hex: Length (${buffer.length - o}) must be divisible by 2`);
|
31
|
-
}
|
32
|
-
i += 1;
|
33
|
-
for (; i < buffer.length; i += 2) {
|
34
|
-
buffer[o++] = (getByte(buffer[i - 1], alphabet) << 4) |
|
35
|
-
getByte(buffer[i], alphabet);
|
36
|
-
}
|
37
|
-
return o;
|
38
|
-
}
|
39
|
-
function getByte(char, alphabet) {
|
40
|
-
const byte = alphabet[char] ?? 16;
|
41
|
-
if (byte === 16) { // alphabet.Hex.length
|
42
|
-
throw new TypeError(`Cannot decode input as hex: Invalid character (${String.fromCharCode(char)})`);
|
43
|
-
}
|
44
|
-
return byte;
|
45
|
-
}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
2
|
-
/**
|
3
|
-
* Calculate the output size needed to encode a given input size for
|
4
|
-
* {@linkcode encodeRawBase64}.
|
5
|
-
*
|
6
|
-
* @param originalSize The size of the input buffer.
|
7
|
-
* @returns The size of the output buffer.
|
8
|
-
*
|
9
|
-
* @example Basic Usage
|
10
|
-
* ```ts
|
11
|
-
* import { assertEquals } from "@std/assert";
|
12
|
-
* import { calcMax } from "@std/encoding/unstable-base64";
|
13
|
-
*
|
14
|
-
* assertEquals(calcMax(1), 4);
|
15
|
-
* ```
|
16
|
-
*/
|
17
|
-
export function calcMax(originalSize) {
|
18
|
-
return ((originalSize + 2) / 3 | 0) * 4;
|
19
|
-
}
|
20
|
-
export function encode(buffer, i, o, alphabet, padding) {
|
21
|
-
i += 2;
|
22
|
-
for (; i < buffer.length; i += 3) {
|
23
|
-
const x = (buffer[i - 2] << 16) | (buffer[i - 1] << 8) | buffer[i];
|
24
|
-
buffer[o++] = alphabet[x >> 18];
|
25
|
-
buffer[o++] = alphabet[x >> 12 & 0x3F];
|
26
|
-
buffer[o++] = alphabet[x >> 6 & 0x3F];
|
27
|
-
buffer[o++] = alphabet[x & 0x3F];
|
28
|
-
}
|
29
|
-
switch (i) {
|
30
|
-
case buffer.length + 1: {
|
31
|
-
const x = buffer[i - 2] << 16;
|
32
|
-
buffer[o++] = alphabet[x >> 18];
|
33
|
-
buffer[o++] = alphabet[x >> 12 & 0x3F];
|
34
|
-
buffer[o++] = padding;
|
35
|
-
buffer[o++] = padding;
|
36
|
-
break;
|
37
|
-
}
|
38
|
-
case buffer.length: {
|
39
|
-
const x = (buffer[i - 2] << 16) | (buffer[i - 1] << 8);
|
40
|
-
buffer[o++] = alphabet[x >> 18];
|
41
|
-
buffer[o++] = alphabet[x >> 12 & 0x3F];
|
42
|
-
buffer[o++] = alphabet[x >> 6 & 0x3F];
|
43
|
-
buffer[o++] = padding;
|
44
|
-
break;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
return o;
|
48
|
-
}
|
49
|
-
export function decode(buffer, i, o, alphabet, padding) {
|
50
|
-
for (let x = buffer.length - 2; x < buffer.length; ++x) {
|
51
|
-
if (buffer[x] === padding) {
|
52
|
-
for (let y = x + 1; y < buffer.length; ++y) {
|
53
|
-
if (buffer[y] !== padding) {
|
54
|
-
throw new TypeError(`Cannot decode input as base64: Invalid character (${String.fromCharCode(buffer[y])})`);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
buffer = buffer.subarray(0, x);
|
58
|
-
break;
|
59
|
-
}
|
60
|
-
}
|
61
|
-
if ((buffer.length - o) % 4 === 1) {
|
62
|
-
throw new RangeError(`Cannot decode input as base64: Length (${buffer.length - o}), excluding padding, must not have a remainder of 1 when divided by 4`);
|
63
|
-
}
|
64
|
-
i += 3;
|
65
|
-
for (; i < buffer.length; i += 4) {
|
66
|
-
const x = (getByte(buffer[i - 3], alphabet) << 18) |
|
67
|
-
(getByte(buffer[i - 2], alphabet) << 12) |
|
68
|
-
(getByte(buffer[i - 1], alphabet) << 6) |
|
69
|
-
getByte(buffer[i], alphabet);
|
70
|
-
buffer[o++] = x >> 16;
|
71
|
-
buffer[o++] = x >> 8 & 0xFF;
|
72
|
-
buffer[o++] = x & 0xFF;
|
73
|
-
}
|
74
|
-
switch (i) {
|
75
|
-
case buffer.length + 1: {
|
76
|
-
const x = (getByte(buffer[i - 3], alphabet) << 18) |
|
77
|
-
(getByte(buffer[i - 2], alphabet) << 12);
|
78
|
-
buffer[o++] = x >> 16;
|
79
|
-
break;
|
80
|
-
}
|
81
|
-
case buffer.length: {
|
82
|
-
const x = (getByte(buffer[i - 3], alphabet) << 18) |
|
83
|
-
(getByte(buffer[i - 2], alphabet) << 12) |
|
84
|
-
(getByte(buffer[i - 1], alphabet) << 6);
|
85
|
-
buffer[o++] = x >> 16;
|
86
|
-
buffer[o++] = x >> 8 & 0xFF;
|
87
|
-
break;
|
88
|
-
}
|
89
|
-
}
|
90
|
-
return o;
|
91
|
-
}
|
92
|
-
function getByte(char, alphabet) {
|
93
|
-
const byte = alphabet[char] ?? 64;
|
94
|
-
if (byte === 64) { // alphabet.Base64.length
|
95
|
-
throw new TypeError(`Cannot decode input as base64: Invalid character (${String.fromCharCode(char)})`);
|
96
|
-
}
|
97
|
-
return byte;
|
98
|
-
}
|
@@ -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,82 +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 { calcMax, decode, encode } from "./_common64.js";
|
24
|
-
import { detach } from "./_common_detach.js";
|
25
|
-
const padding = "=".charCodeAt(0);
|
26
|
-
const alphabet = new TextEncoder()
|
27
|
-
.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
28
|
-
const rAlphabet = new Uint8Array(128).fill(64); // alphabet.length
|
29
|
-
alphabet.forEach((byte, i) => rAlphabet[byte] = i);
|
30
|
-
/**
|
31
|
-
* Converts data into a base64-encoded string.
|
32
|
-
*
|
33
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
34
|
-
*
|
35
|
-
* @param data The data to encode.
|
36
|
-
* @returns The base64-encoded string.
|
37
|
-
*
|
38
|
-
* @example Usage
|
39
|
-
* ```ts
|
40
|
-
* import { encodeBase64 } from "@std/encoding/base64";
|
41
|
-
* import { assertEquals } from "@std/assert";
|
42
|
-
*
|
43
|
-
* assertEquals(encodeBase64("foobar"), "Zm9vYmFy");
|
44
|
-
* ```
|
45
|
-
*/
|
46
|
-
export function encodeBase64(data) {
|
47
|
-
if (typeof data === "string") {
|
48
|
-
data = new TextEncoder().encode(data);
|
49
|
-
}
|
50
|
-
else if (data instanceof ArrayBuffer)
|
51
|
-
data = new Uint8Array(data).slice();
|
52
|
-
else
|
53
|
-
data = data.slice();
|
54
|
-
const [output, i] = detach(data, calcMax(data.length));
|
55
|
-
encode(output, i, 0, alphabet, padding);
|
56
|
-
return new TextDecoder().decode(output);
|
57
|
-
}
|
58
|
-
/**
|
59
|
-
* Decodes a base64-encoded string.
|
60
|
-
*
|
61
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
62
|
-
*
|
63
|
-
* @param b64 The base64-encoded string to decode.
|
64
|
-
* @returns The decoded data.
|
65
|
-
*
|
66
|
-
* @example Usage
|
67
|
-
* ```ts
|
68
|
-
* import { decodeBase64 } from "@std/encoding/base64";
|
69
|
-
* import { assertEquals } from "@std/assert";
|
70
|
-
*
|
71
|
-
* assertEquals(
|
72
|
-
* decodeBase64("Zm9vYmFy"),
|
73
|
-
* new TextEncoder().encode("foobar")
|
74
|
-
* );
|
75
|
-
* ```
|
76
|
-
*/
|
77
|
-
export function decodeBase64(b64) {
|
78
|
-
const output = new TextEncoder().encode(b64);
|
79
|
-
// deno-lint-ignore no-explicit-any
|
80
|
-
return new Uint8Array(output.buffer
|
81
|
-
.transfer(decode(output, 0, 0, rAlphabet, padding)));
|
82
|
-
}
|
@@ -1,72 +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 { calcMax, decode, encode } from "./_common64.js";
|
11
|
-
import { detach } from "./_common_detach.js";
|
12
|
-
const padding = "=".charCodeAt(0);
|
13
|
-
const alphabet = new TextEncoder()
|
14
|
-
.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
|
15
|
-
const rAlphabet = new Uint8Array(128).fill(64); // alphabet.length
|
16
|
-
alphabet.forEach((byte, i) => rAlphabet[byte] = i);
|
17
|
-
/**
|
18
|
-
* Convert data into a base64url-encoded string.
|
19
|
-
*
|
20
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-5}
|
21
|
-
*
|
22
|
-
* @param data The data to encode.
|
23
|
-
* @returns The base64url-encoded string.
|
24
|
-
*
|
25
|
-
* @example Usage
|
26
|
-
* ```ts
|
27
|
-
* import { encodeBase64Url } from "@std/encoding/base64url";
|
28
|
-
* import { assertEquals } from "@std/assert";
|
29
|
-
*
|
30
|
-
* assertEquals(encodeBase64Url("foobar"), "Zm9vYmFy");
|
31
|
-
* ```
|
32
|
-
*/
|
33
|
-
export function encodeBase64Url(data) {
|
34
|
-
if (typeof data === "string") {
|
35
|
-
data = new TextEncoder().encode(data);
|
36
|
-
}
|
37
|
-
else if (data instanceof ArrayBuffer)
|
38
|
-
data = new Uint8Array(data).slice();
|
39
|
-
else
|
40
|
-
data = data.slice();
|
41
|
-
const [output, i] = detach(data, calcMax(data.length));
|
42
|
-
let o = encode(output, i, 0, alphabet, padding);
|
43
|
-
o = output.indexOf(padding, o - 2);
|
44
|
-
return new TextDecoder().decode(
|
45
|
-
// deno-lint-ignore no-explicit-any
|
46
|
-
o > 0 ? new Uint8Array(output.buffer.transfer(o)) : output);
|
47
|
-
}
|
48
|
-
/**
|
49
|
-
* Decodes a given base64url-encoded string.
|
50
|
-
*
|
51
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-5}
|
52
|
-
*
|
53
|
-
* @param b64url The base64url-encoded string to decode.
|
54
|
-
* @returns The decoded data.
|
55
|
-
*
|
56
|
-
* @example Usage
|
57
|
-
* ```ts
|
58
|
-
* import { decodeBase64Url } from "@std/encoding/base64url";
|
59
|
-
* import { assertEquals } from "@std/assert";
|
60
|
-
*
|
61
|
-
* assertEquals(
|
62
|
-
* decodeBase64Url("Zm9vYmFy"),
|
63
|
-
* new TextEncoder().encode("foobar")
|
64
|
-
* );
|
65
|
-
* ```
|
66
|
-
*/
|
67
|
-
export function decodeBase64Url(b64url) {
|
68
|
-
const output = new TextEncoder().encode(b64url);
|
69
|
-
// deno-lint-ignore no-explicit-any
|
70
|
-
return new Uint8Array(output.buffer
|
71
|
-
.transfer(decode(output, 0, 0, rAlphabet, padding)));
|
72
|
-
}
|
@@ -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 { calcMax, 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, calcMax(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
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import type { Uint8Array_ } from "./_types.js";
|
2
|
-
export type { Uint8Array_ };
|
3
|
-
/**
|
4
|
-
* Calculate the output size needed to encode a given input size for
|
5
|
-
* {@linkcode encodeRawHex}.
|
6
|
-
*
|
7
|
-
* @param originalSize The size of the input buffer.
|
8
|
-
* @returns The size of the output buffer.
|
9
|
-
*
|
10
|
-
* @example Basic Usage
|
11
|
-
* ```ts
|
12
|
-
* import { assertEquals } from "@std/assert";
|
13
|
-
* import { calcMax } from "@std/encoding/unstable-hex";
|
14
|
-
*
|
15
|
-
* assertEquals(calcMax(1), 2);
|
16
|
-
* ```
|
17
|
-
*/
|
18
|
-
export declare function calcMax(originalSize: number): number;
|
19
|
-
export declare function encode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array): number;
|
20
|
-
export declare function decode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array): number;
|
21
|
-
//# sourceMappingURL=_common16.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"_common16.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/_common16.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,GACnB,MAAM,CAOR;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,GACnB,MAAM,CAeR"}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import type { Uint8Array_ } from "./_types.js";
|
2
|
-
export type { Uint8Array_ };
|
3
|
-
/**
|
4
|
-
* Calculate the output size needed to encode a given input size for
|
5
|
-
* {@linkcode encodeRawBase64}.
|
6
|
-
*
|
7
|
-
* @param originalSize The size of the input buffer.
|
8
|
-
* @returns The size of the output buffer.
|
9
|
-
*
|
10
|
-
* @example Basic Usage
|
11
|
-
* ```ts
|
12
|
-
* import { assertEquals } from "@std/assert";
|
13
|
-
* import { calcMax } from "@std/encoding/unstable-base64";
|
14
|
-
*
|
15
|
-
* assertEquals(calcMax(1), 4);
|
16
|
-
* ```
|
17
|
-
*/
|
18
|
-
export declare function calcMax(originalSize: number): number;
|
19
|
-
export declare function encode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array, padding: number): number;
|
20
|
-
export declare function decode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array, padding: number): number;
|
21
|
-
//# sourceMappingURL=_common64.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"_common64.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/_common64.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CA4BR;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CAmDR"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"_common_detach.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/_common_detach.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,GACd,CAAC,WAAW,EAAE,MAAM,CAAC,CAWvB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/base64.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAQ5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAW5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAKrD"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/base64url.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAQ5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GACtC,MAAM,CAeR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAK3D"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/hex.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAU5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAWxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAKlD"}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|