@skmtc/core 0.0.245 → 0.0.246
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/esm/context/CoreContext.d.ts +1 -1
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +2 -2
- package/esm/context/RenderContext.d.ts +1 -1
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +6 -33
- package/esm/generate/generate.d.ts +1 -1
- package/esm/generate/generate.d.ts.map +1 -1
- package/esm/generate/generate.js +2 -2
- package/esm/server/createServer.js +2 -2
- package/package.json +1 -2
- package/script/context/CoreContext.d.ts +1 -1
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +2 -2
- package/script/context/RenderContext.d.ts +1 -1
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +9 -36
- package/script/generate/generate.d.ts +1 -1
- package/script/generate/generate.d.ts.map +1 -1
- package/script/generate/generate.js +2 -2
- package/script/server/createServer.js +2 -2
- package/esm/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.d.ts +0 -2
- package/esm/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.js +0 -26
- package/esm/deps/jsr.io/@std/encoding/1.0.1/ascii85.d.ts +0 -59
- package/esm/deps/jsr.io/@std/encoding/1.0.1/ascii85.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/ascii85.js +0 -152
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base32.d.ts +0 -38
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base32.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base32.js +0 -224
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base58.d.ts +0 -38
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base58.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base58.js +0 -131
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base64.d.ts +0 -38
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base64.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base64.js +0 -163
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base64url.d.ts +0 -38
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base64url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/base64url.js +0 -81
- package/esm/deps/jsr.io/@std/encoding/1.0.1/hex.d.ts +0 -37
- package/esm/deps/jsr.io/@std/encoding/1.0.1/hex.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/hex.js +0 -109
- package/esm/deps/jsr.io/@std/encoding/1.0.1/mod.d.ts +0 -22
- package/esm/deps/jsr.io/@std/encoding/1.0.1/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/mod.js +0 -22
- package/esm/deps/jsr.io/@std/encoding/1.0.1/varint.d.ts +0 -118
- package/esm/deps/jsr.io/@std/encoding/1.0.1/varint.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.1/varint.js +0 -206
- package/script/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.d.ts +0 -2
- package/script/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.js +0 -29
- package/script/deps/jsr.io/@std/encoding/1.0.1/ascii85.d.ts +0 -59
- package/script/deps/jsr.io/@std/encoding/1.0.1/ascii85.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/ascii85.js +0 -156
- package/script/deps/jsr.io/@std/encoding/1.0.1/base32.d.ts +0 -38
- package/script/deps/jsr.io/@std/encoding/1.0.1/base32.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/base32.js +0 -228
- package/script/deps/jsr.io/@std/encoding/1.0.1/base58.d.ts +0 -38
- package/script/deps/jsr.io/@std/encoding/1.0.1/base58.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/base58.js +0 -135
- package/script/deps/jsr.io/@std/encoding/1.0.1/base64.d.ts +0 -38
- package/script/deps/jsr.io/@std/encoding/1.0.1/base64.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/base64.js +0 -167
- package/script/deps/jsr.io/@std/encoding/1.0.1/base64url.d.ts +0 -38
- package/script/deps/jsr.io/@std/encoding/1.0.1/base64url.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/base64url.js +0 -108
- package/script/deps/jsr.io/@std/encoding/1.0.1/hex.d.ts +0 -37
- package/script/deps/jsr.io/@std/encoding/1.0.1/hex.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/hex.js +0 -113
- package/script/deps/jsr.io/@std/encoding/1.0.1/mod.d.ts +0 -22
- package/script/deps/jsr.io/@std/encoding/1.0.1/mod.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/mod.js +0 -38
- package/script/deps/jsr.io/@std/encoding/1.0.1/varint.d.ts +0 -118
- package/script/deps/jsr.io/@std/encoding/1.0.1/varint.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.1/varint.js +0 -212
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
3
|
-
// Copyright (c) 2014 Jameson Little. MIT License.
|
|
4
|
-
// This module is browser compatible.
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.decodeBase32 = decodeBase32;
|
|
7
|
-
exports.encodeBase32 = encodeBase32;
|
|
8
|
-
/**
|
|
9
|
-
* Utilities for
|
|
10
|
-
* {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6 | base32}
|
|
11
|
-
* encoding and decoding.
|
|
12
|
-
*
|
|
13
|
-
* Modified from {@link https://github.com/beatgammit/base64-js}.
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { encodeBase32, decodeBase32 } from "@std/encoding/base32";
|
|
17
|
-
* import { assertEquals } from "@std/assert";
|
|
18
|
-
*
|
|
19
|
-
* assertEquals(encodeBase32("foobar"), "MZXW6YTBOI======");
|
|
20
|
-
*
|
|
21
|
-
* assertEquals(
|
|
22
|
-
* decodeBase32("MZXW6YTBOI======"),
|
|
23
|
-
* new TextEncoder().encode("foobar")
|
|
24
|
-
* );
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @module
|
|
28
|
-
*/
|
|
29
|
-
const _validate_binary_like_js_1 = require("./_validate_binary_like.js");
|
|
30
|
-
const lookup = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split("");
|
|
31
|
-
const revLookup = [];
|
|
32
|
-
lookup.forEach((c, i) => revLookup[c.charCodeAt(0)] = i);
|
|
33
|
-
const placeHolderPadLookup = [0, 1, , 2, 3, , 4];
|
|
34
|
-
function getPadLength(placeHoldersLen) {
|
|
35
|
-
const maybeLen = placeHolderPadLookup[placeHoldersLen];
|
|
36
|
-
if (typeof maybeLen !== "number") {
|
|
37
|
-
throw new Error("Invalid pad length");
|
|
38
|
-
}
|
|
39
|
-
return maybeLen;
|
|
40
|
-
}
|
|
41
|
-
function getLens(b32) {
|
|
42
|
-
const len = b32.length;
|
|
43
|
-
if (len % 8 > 0) {
|
|
44
|
-
throw new Error("Invalid string. Length must be a multiple of 8");
|
|
45
|
-
}
|
|
46
|
-
let validLen = b32.indexOf("=");
|
|
47
|
-
if (validLen === -1)
|
|
48
|
-
validLen = len;
|
|
49
|
-
const placeHoldersLen = validLen === len ? 0 : 8 - (validLen % 8);
|
|
50
|
-
return [validLen, placeHoldersLen];
|
|
51
|
-
}
|
|
52
|
-
function getByteLength(validLen, placeHoldersLen) {
|
|
53
|
-
return ((validLen + placeHoldersLen) * 5) / 8 - getPadLength(placeHoldersLen);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Decodes a base32-encoded string.
|
|
57
|
-
*
|
|
58
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
|
|
59
|
-
*
|
|
60
|
-
* @param b32 The base32-encoded string to decode.
|
|
61
|
-
* @returns The decoded data.
|
|
62
|
-
*
|
|
63
|
-
* @example Usage
|
|
64
|
-
* ```ts
|
|
65
|
-
* import { decodeBase32 } from "@std/encoding/base32";
|
|
66
|
-
* import { assertEquals } from "@std/assert";
|
|
67
|
-
*
|
|
68
|
-
* assertEquals(
|
|
69
|
-
* decodeBase32("GZRTMMDDGA======"),
|
|
70
|
-
* new TextEncoder().encode("6c60c0"),
|
|
71
|
-
* );
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
function decodeBase32(b32) {
|
|
75
|
-
let tmp;
|
|
76
|
-
const [validLen, placeHoldersLen] = getLens(b32);
|
|
77
|
-
const arr = new Uint8Array(getByteLength(validLen, placeHoldersLen));
|
|
78
|
-
let curByte = 0;
|
|
79
|
-
// if there are placeholders, only get up to the last complete 8 chars
|
|
80
|
-
const len = placeHoldersLen > 0 ? validLen - 8 : validLen;
|
|
81
|
-
let i;
|
|
82
|
-
for (i = 0; i < len; i += 8) {
|
|
83
|
-
tmp = (revLookup[b32.charCodeAt(i)] << 20) |
|
|
84
|
-
(revLookup[b32.charCodeAt(i + 1)] << 15) |
|
|
85
|
-
(revLookup[b32.charCodeAt(i + 2)] << 10) |
|
|
86
|
-
(revLookup[b32.charCodeAt(i + 3)] << 5) |
|
|
87
|
-
revLookup[b32.charCodeAt(i + 4)];
|
|
88
|
-
arr[curByte++] = (tmp >> 17) & 0xff;
|
|
89
|
-
arr[curByte++] = (tmp >> 9) & 0xff;
|
|
90
|
-
arr[curByte++] = (tmp >> 1) & 0xff;
|
|
91
|
-
tmp = ((tmp & 1) << 15) |
|
|
92
|
-
(revLookup[b32.charCodeAt(i + 5)] << 10) |
|
|
93
|
-
(revLookup[b32.charCodeAt(i + 6)] << 5) |
|
|
94
|
-
revLookup[b32.charCodeAt(i + 7)];
|
|
95
|
-
arr[curByte++] = (tmp >> 8) & 0xff;
|
|
96
|
-
arr[curByte++] = tmp & 0xff;
|
|
97
|
-
}
|
|
98
|
-
if (placeHoldersLen === 1) {
|
|
99
|
-
tmp = (revLookup[b32.charCodeAt(i)] << 20) |
|
|
100
|
-
(revLookup[b32.charCodeAt(i + 1)] << 15) |
|
|
101
|
-
(revLookup[b32.charCodeAt(i + 2)] << 10) |
|
|
102
|
-
(revLookup[b32.charCodeAt(i + 3)] << 5) |
|
|
103
|
-
revLookup[b32.charCodeAt(i + 4)];
|
|
104
|
-
arr[curByte++] = (tmp >> 17) & 0xff;
|
|
105
|
-
arr[curByte++] = (tmp >> 9) & 0xff;
|
|
106
|
-
arr[curByte++] = (tmp >> 1) & 0xff;
|
|
107
|
-
tmp = ((tmp & 1) << 7) |
|
|
108
|
-
(revLookup[b32.charCodeAt(i + 5)] << 2) |
|
|
109
|
-
(revLookup[b32.charCodeAt(i + 6)] >> 3);
|
|
110
|
-
arr[curByte++] = tmp & 0xff;
|
|
111
|
-
}
|
|
112
|
-
else if (placeHoldersLen === 3) {
|
|
113
|
-
tmp = (revLookup[b32.charCodeAt(i)] << 19) |
|
|
114
|
-
(revLookup[b32.charCodeAt(i + 1)] << 14) |
|
|
115
|
-
(revLookup[b32.charCodeAt(i + 2)] << 9) |
|
|
116
|
-
(revLookup[b32.charCodeAt(i + 3)] << 4) |
|
|
117
|
-
(revLookup[b32.charCodeAt(i + 4)] >> 1);
|
|
118
|
-
arr[curByte++] = (tmp >> 16) & 0xff;
|
|
119
|
-
arr[curByte++] = (tmp >> 8) & 0xff;
|
|
120
|
-
arr[curByte++] = tmp & 0xff;
|
|
121
|
-
}
|
|
122
|
-
else if (placeHoldersLen === 4) {
|
|
123
|
-
tmp = (revLookup[b32.charCodeAt(i)] << 11) |
|
|
124
|
-
(revLookup[b32.charCodeAt(i + 1)] << 6) |
|
|
125
|
-
(revLookup[b32.charCodeAt(i + 2)] << 1) |
|
|
126
|
-
(revLookup[b32.charCodeAt(i + 3)] >> 4);
|
|
127
|
-
arr[curByte++] = (tmp >> 8) & 0xff;
|
|
128
|
-
arr[curByte++] = tmp & 0xff;
|
|
129
|
-
}
|
|
130
|
-
else if (placeHoldersLen === 6) {
|
|
131
|
-
tmp = (revLookup[b32.charCodeAt(i)] << 3) |
|
|
132
|
-
(revLookup[b32.charCodeAt(i + 1)] >> 2);
|
|
133
|
-
arr[curByte++] = tmp & 0xff;
|
|
134
|
-
}
|
|
135
|
-
return arr;
|
|
136
|
-
}
|
|
137
|
-
function encodeChunk(uint8, start, end) {
|
|
138
|
-
let tmp;
|
|
139
|
-
const output = [];
|
|
140
|
-
for (let i = start; i < end; i += 5) {
|
|
141
|
-
tmp = ((uint8[i] << 16) & 0xff0000) |
|
|
142
|
-
((uint8[i + 1] << 8) & 0xff00) |
|
|
143
|
-
(uint8[i + 2] & 0xff);
|
|
144
|
-
output.push(lookup[(tmp >> 19) & 0x1f]);
|
|
145
|
-
output.push(lookup[(tmp >> 14) & 0x1f]);
|
|
146
|
-
output.push(lookup[(tmp >> 9) & 0x1f]);
|
|
147
|
-
output.push(lookup[(tmp >> 4) & 0x1f]);
|
|
148
|
-
tmp = ((tmp & 0xf) << 16) |
|
|
149
|
-
((uint8[i + 3] << 8) & 0xff00) |
|
|
150
|
-
(uint8[i + 4] & 0xff);
|
|
151
|
-
output.push(lookup[(tmp >> 15) & 0x1f]);
|
|
152
|
-
output.push(lookup[(tmp >> 10) & 0x1f]);
|
|
153
|
-
output.push(lookup[(tmp >> 5) & 0x1f]);
|
|
154
|
-
output.push(lookup[tmp & 0x1f]);
|
|
155
|
-
}
|
|
156
|
-
return output.join("");
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Converts data into a base32-encoded string.
|
|
160
|
-
*
|
|
161
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
|
|
162
|
-
*
|
|
163
|
-
* @param data The data to encode.
|
|
164
|
-
* @returns The base32-encoded string.
|
|
165
|
-
*
|
|
166
|
-
* @example Usage
|
|
167
|
-
* ```ts
|
|
168
|
-
* import { encodeBase32 } from "@std/encoding/base32";
|
|
169
|
-
* import { assertEquals } from "@std/assert";
|
|
170
|
-
*
|
|
171
|
-
* assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
function encodeBase32(data) {
|
|
175
|
-
const uint8 = (0, _validate_binary_like_js_1.validateBinaryLike)(data);
|
|
176
|
-
let tmp;
|
|
177
|
-
const len = uint8.length;
|
|
178
|
-
const extraBytes = len % 5;
|
|
179
|
-
const parts = [];
|
|
180
|
-
const maxChunkLength = 16385; // must be multiple of 5
|
|
181
|
-
const len2 = len - extraBytes;
|
|
182
|
-
// go through the array every 5 bytes, we'll deal with trailing stuff later
|
|
183
|
-
for (let i = 0; i < len2; i += maxChunkLength) {
|
|
184
|
-
parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
|
|
185
|
-
}
|
|
186
|
-
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
187
|
-
if (extraBytes === 4) {
|
|
188
|
-
tmp = ((uint8[len2] & 0xff) << 16) |
|
|
189
|
-
((uint8[len2 + 1] & 0xff) << 8) |
|
|
190
|
-
(uint8[len2 + 2] & 0xff);
|
|
191
|
-
parts.push(lookup[(tmp >> 19) & 0x1f]);
|
|
192
|
-
parts.push(lookup[(tmp >> 14) & 0x1f]);
|
|
193
|
-
parts.push(lookup[(tmp >> 9) & 0x1f]);
|
|
194
|
-
parts.push(lookup[(tmp >> 4) & 0x1f]);
|
|
195
|
-
tmp = ((tmp & 0xf) << 11) | (uint8[len2 + 3] << 3);
|
|
196
|
-
parts.push(lookup[(tmp >> 10) & 0x1f]);
|
|
197
|
-
parts.push(lookup[(tmp >> 5) & 0x1f]);
|
|
198
|
-
parts.push(lookup[tmp & 0x1f]);
|
|
199
|
-
parts.push("=");
|
|
200
|
-
}
|
|
201
|
-
else if (extraBytes === 3) {
|
|
202
|
-
tmp = ((uint8[len2] & 0xff) << 17) |
|
|
203
|
-
((uint8[len2 + 1] & 0xff) << 9) |
|
|
204
|
-
((uint8[len2 + 2] & 0xff) << 1);
|
|
205
|
-
parts.push(lookup[(tmp >> 20) & 0x1f]);
|
|
206
|
-
parts.push(lookup[(tmp >> 15) & 0x1f]);
|
|
207
|
-
parts.push(lookup[(tmp >> 10) & 0x1f]);
|
|
208
|
-
parts.push(lookup[(tmp >> 5) & 0x1f]);
|
|
209
|
-
parts.push(lookup[tmp & 0x1f]);
|
|
210
|
-
parts.push("===");
|
|
211
|
-
}
|
|
212
|
-
else if (extraBytes === 2) {
|
|
213
|
-
tmp = ((uint8[len2] & 0xff) << 12) |
|
|
214
|
-
((uint8[len2 + 1] & 0xff) << 4);
|
|
215
|
-
parts.push(lookup[(tmp >> 15) & 0x1f]);
|
|
216
|
-
parts.push(lookup[(tmp >> 10) & 0x1f]);
|
|
217
|
-
parts.push(lookup[(tmp >> 5) & 0x1f]);
|
|
218
|
-
parts.push(lookup[tmp & 0x1f]);
|
|
219
|
-
parts.push("====");
|
|
220
|
-
}
|
|
221
|
-
else if (extraBytes === 1) {
|
|
222
|
-
tmp = (uint8[len2] & 0xff) << 2;
|
|
223
|
-
parts.push(lookup[(tmp >> 5) & 0x1f]);
|
|
224
|
-
parts.push(lookup[tmp & 0x1f]);
|
|
225
|
-
parts.push("======");
|
|
226
|
-
}
|
|
227
|
-
return parts.join("");
|
|
228
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts data into a base58-encoded string.
|
|
3
|
-
*
|
|
4
|
-
* @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-3}
|
|
5
|
-
*
|
|
6
|
-
* @param data The data to encode.
|
|
7
|
-
* @returns The base58-encoded string.
|
|
8
|
-
*
|
|
9
|
-
* @example Usage
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { encodeBase58 } from "@std/encoding/base58";
|
|
12
|
-
* import { assertEquals } from "@std/assert";
|
|
13
|
-
*
|
|
14
|
-
* assertEquals(encodeBase58("Hello World!"), "2NEpo7TZRRrLZSi2U");
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function encodeBase58(data: ArrayBuffer | Uint8Array | string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Decodes a base58-encoded string.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-4}
|
|
22
|
-
*
|
|
23
|
-
* @param b58 The base58-encoded string to decode.
|
|
24
|
-
* @returns The decoded data.
|
|
25
|
-
*
|
|
26
|
-
* @example Usage
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { decodeBase58 } from "@std/encoding/base58";
|
|
29
|
-
* import { assertEquals } from "@std/assert";
|
|
30
|
-
*
|
|
31
|
-
* assertEquals(
|
|
32
|
-
* decodeBase58("2NEpo7TZRRrLZSi2U"),
|
|
33
|
-
* new TextEncoder().encode("Hello World!")
|
|
34
|
-
* );
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function decodeBase58(b58: string): Uint8Array;
|
|
38
|
-
//# sourceMappingURL=base58.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.1/base58.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAgD5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAkDpD"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
3
|
-
// This module is browser compatible.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.encodeBase58 = encodeBase58;
|
|
6
|
-
exports.decodeBase58 = decodeBase58;
|
|
7
|
-
/**
|
|
8
|
-
* Utilities for
|
|
9
|
-
* {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03 | base58}
|
|
10
|
-
* encoding and decoding.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { encodeBase58, decodeBase58 } from "@std/encoding/base58";
|
|
14
|
-
* import { assertEquals } from "@std/assert";
|
|
15
|
-
*
|
|
16
|
-
* const hello = new TextEncoder().encode("Hello World!");
|
|
17
|
-
*
|
|
18
|
-
* assertEquals(encodeBase58(hello), "2NEpo7TZRRrLZSi2U");
|
|
19
|
-
*
|
|
20
|
-
* assertEquals(decodeBase58("2NEpo7TZRRrLZSi2U"), hello);
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @module
|
|
24
|
-
*/
|
|
25
|
-
const _validate_binary_like_js_1 = require("./_validate_binary_like.js");
|
|
26
|
-
// deno-fmt-ignore
|
|
27
|
-
const mapBase58 = {
|
|
28
|
-
"1": 0, "2": 1, "3": 2, "4": 3, "5": 4, "6": 5, "7": 6, "8": 7, "9": 8, A: 9,
|
|
29
|
-
B: 10, C: 11, D: 12, E: 13, F: 14, G: 15, H: 16, J: 17, K: 18, L: 19, M: 20,
|
|
30
|
-
N: 21, P: 22, Q: 23, R: 24, S: 25, T: 26, U: 27, V: 28, W: 29, X: 30, Y: 31,
|
|
31
|
-
Z: 32, a: 33, b: 34, c: 35, d: 36, e: 37, f: 38, g: 39, h: 40, i: 41, j: 42,
|
|
32
|
-
k: 43, m: 44, n: 45, o: 46, p: 47, q: 48, r: 49, s: 50, t: 51, u: 52, v: 53,
|
|
33
|
-
w: 54, x: 55, y: 56, z: 57
|
|
34
|
-
};
|
|
35
|
-
const base58alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split("");
|
|
36
|
-
/**
|
|
37
|
-
* Converts data into a base58-encoded string.
|
|
38
|
-
*
|
|
39
|
-
* @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-3}
|
|
40
|
-
*
|
|
41
|
-
* @param data The data to encode.
|
|
42
|
-
* @returns The base58-encoded string.
|
|
43
|
-
*
|
|
44
|
-
* @example Usage
|
|
45
|
-
* ```ts
|
|
46
|
-
* import { encodeBase58 } from "@std/encoding/base58";
|
|
47
|
-
* import { assertEquals } from "@std/assert";
|
|
48
|
-
*
|
|
49
|
-
* assertEquals(encodeBase58("Hello World!"), "2NEpo7TZRRrLZSi2U");
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
function encodeBase58(data) {
|
|
53
|
-
const uint8tData = (0, _validate_binary_like_js_1.validateBinaryLike)(data);
|
|
54
|
-
let length = 0;
|
|
55
|
-
let zeroes = 0;
|
|
56
|
-
// Counting leading zeroes
|
|
57
|
-
let index = 0;
|
|
58
|
-
while (uint8tData[index] === 0) {
|
|
59
|
-
zeroes++;
|
|
60
|
-
index++;
|
|
61
|
-
}
|
|
62
|
-
const notZeroUint8Data = uint8tData.slice(index);
|
|
63
|
-
const size = Math.round((uint8tData.length * 138) / 100 + 1);
|
|
64
|
-
const b58Encoding = [];
|
|
65
|
-
notZeroUint8Data.forEach((byte) => {
|
|
66
|
-
let i = 0;
|
|
67
|
-
let carry = byte;
|
|
68
|
-
for (let reverseIterator = size - 1; (carry > 0 || i < length) && reverseIterator !== -1; reverseIterator--, i++) {
|
|
69
|
-
carry += (b58Encoding[reverseIterator] || 0) * 256;
|
|
70
|
-
b58Encoding[reverseIterator] = Math.round(carry % 58);
|
|
71
|
-
carry = Math.floor(carry / 58);
|
|
72
|
-
}
|
|
73
|
-
length = i;
|
|
74
|
-
});
|
|
75
|
-
const strResult = Array.from({
|
|
76
|
-
length: b58Encoding.length + zeroes,
|
|
77
|
-
});
|
|
78
|
-
if (zeroes > 0) {
|
|
79
|
-
strResult.fill("1", 0, zeroes);
|
|
80
|
-
}
|
|
81
|
-
b58Encoding.forEach((byteValue) => strResult.push(base58alphabet[byteValue]));
|
|
82
|
-
return strResult.join("");
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Decodes a base58-encoded string.
|
|
86
|
-
*
|
|
87
|
-
* @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-4}
|
|
88
|
-
*
|
|
89
|
-
* @param b58 The base58-encoded string to decode.
|
|
90
|
-
* @returns The decoded data.
|
|
91
|
-
*
|
|
92
|
-
* @example Usage
|
|
93
|
-
* ```ts
|
|
94
|
-
* import { decodeBase58 } from "@std/encoding/base58";
|
|
95
|
-
* import { assertEquals } from "@std/assert";
|
|
96
|
-
*
|
|
97
|
-
* assertEquals(
|
|
98
|
-
* decodeBase58("2NEpo7TZRRrLZSi2U"),
|
|
99
|
-
* new TextEncoder().encode("Hello World!")
|
|
100
|
-
* );
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
function decodeBase58(b58) {
|
|
104
|
-
const splitInput = b58.trim().split("");
|
|
105
|
-
let length = 0;
|
|
106
|
-
let ones = 0;
|
|
107
|
-
// Counting leading ones
|
|
108
|
-
let index = 0;
|
|
109
|
-
while (splitInput[index] === "1") {
|
|
110
|
-
ones++;
|
|
111
|
-
index++;
|
|
112
|
-
}
|
|
113
|
-
const notZeroData = splitInput.slice(index);
|
|
114
|
-
const size = Math.round((b58.length * 733) / 1000 + 1);
|
|
115
|
-
const output = [];
|
|
116
|
-
notZeroData.forEach((char, idx) => {
|
|
117
|
-
let carry = mapBase58[char];
|
|
118
|
-
let i = 0;
|
|
119
|
-
if (carry === undefined) {
|
|
120
|
-
throw new TypeError(`Invalid base58 char at index ${idx} with value ${char}`);
|
|
121
|
-
}
|
|
122
|
-
for (let reverseIterator = size - 1; (carry > 0 || i < length) && reverseIterator !== -1; reverseIterator--, i++) {
|
|
123
|
-
carry += 58 * (output[reverseIterator] || 0);
|
|
124
|
-
output[reverseIterator] = Math.round(carry % 256);
|
|
125
|
-
carry = Math.floor(carry / 256);
|
|
126
|
-
}
|
|
127
|
-
length = i;
|
|
128
|
-
});
|
|
129
|
-
const validOutput = output.filter((item) => item !== undefined);
|
|
130
|
-
if (ones > 0) {
|
|
131
|
-
const onesResult = Array.from({ length: ones }).fill(0, 0, ones);
|
|
132
|
-
return new Uint8Array([...onesResult, ...validOutput]);
|
|
133
|
-
}
|
|
134
|
-
return new Uint8Array(validOutput);
|
|
135
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts data into a base64-encoded string.
|
|
3
|
-
*
|
|
4
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
5
|
-
*
|
|
6
|
-
* @param data The data to encode.
|
|
7
|
-
* @returns The base64-encoded string.
|
|
8
|
-
*
|
|
9
|
-
* @example Usage
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { encodeBase64 } from "@std/encoding/base64";
|
|
12
|
-
* import { assertEquals } from "@std/assert";
|
|
13
|
-
*
|
|
14
|
-
* assertEquals(encodeBase64("foobar"), "Zm9vYmFy");
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function encodeBase64(data: ArrayBuffer | Uint8Array | string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Decodes a base64-encoded string.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
22
|
-
*
|
|
23
|
-
* @param b64 The base64-encoded string to decode.
|
|
24
|
-
* @returns The decoded data.
|
|
25
|
-
*
|
|
26
|
-
* @example Usage
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { decodeBase64 } from "@std/encoding/base64";
|
|
29
|
-
* import { assertEquals } from "@std/assert";
|
|
30
|
-
*
|
|
31
|
-
* assertEquals(
|
|
32
|
-
* decodeBase64("Zm9vYmFy"),
|
|
33
|
-
* new TextEncoder().encode("foobar")
|
|
34
|
-
* );
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function decodeBase64(b64: string): Uint8Array;
|
|
38
|
-
//# sourceMappingURL=base64.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.1/base64.ts"],"names":[],"mappings":"AA6FA;;;;;;;;;;;;;;;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,UAAU,CAQpD"}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
3
|
-
// This module is browser compatible.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.encodeBase64 = encodeBase64;
|
|
6
|
-
exports.decodeBase64 = decodeBase64;
|
|
7
|
-
/**
|
|
8
|
-
* Utilities for
|
|
9
|
-
* {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4 | base64}
|
|
10
|
-
* encoding and decoding.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* import {
|
|
14
|
-
* encodeBase64,
|
|
15
|
-
* decodeBase64,
|
|
16
|
-
* } from "@std/encoding/base64";
|
|
17
|
-
* import { assertEquals } from "@std/assert";
|
|
18
|
-
*
|
|
19
|
-
* const foobar = new TextEncoder().encode("foobar");
|
|
20
|
-
*
|
|
21
|
-
* assertEquals(encodeBase64(foobar), "Zm9vYmFy");
|
|
22
|
-
* assertEquals(decodeBase64("Zm9vYmFy"), foobar);
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @module
|
|
26
|
-
*/
|
|
27
|
-
const _validate_binary_like_js_1 = require("./_validate_binary_like.js");
|
|
28
|
-
const base64abc = [
|
|
29
|
-
"A",
|
|
30
|
-
"B",
|
|
31
|
-
"C",
|
|
32
|
-
"D",
|
|
33
|
-
"E",
|
|
34
|
-
"F",
|
|
35
|
-
"G",
|
|
36
|
-
"H",
|
|
37
|
-
"I",
|
|
38
|
-
"J",
|
|
39
|
-
"K",
|
|
40
|
-
"L",
|
|
41
|
-
"M",
|
|
42
|
-
"N",
|
|
43
|
-
"O",
|
|
44
|
-
"P",
|
|
45
|
-
"Q",
|
|
46
|
-
"R",
|
|
47
|
-
"S",
|
|
48
|
-
"T",
|
|
49
|
-
"U",
|
|
50
|
-
"V",
|
|
51
|
-
"W",
|
|
52
|
-
"X",
|
|
53
|
-
"Y",
|
|
54
|
-
"Z",
|
|
55
|
-
"a",
|
|
56
|
-
"b",
|
|
57
|
-
"c",
|
|
58
|
-
"d",
|
|
59
|
-
"e",
|
|
60
|
-
"f",
|
|
61
|
-
"g",
|
|
62
|
-
"h",
|
|
63
|
-
"i",
|
|
64
|
-
"j",
|
|
65
|
-
"k",
|
|
66
|
-
"l",
|
|
67
|
-
"m",
|
|
68
|
-
"n",
|
|
69
|
-
"o",
|
|
70
|
-
"p",
|
|
71
|
-
"q",
|
|
72
|
-
"r",
|
|
73
|
-
"s",
|
|
74
|
-
"t",
|
|
75
|
-
"u",
|
|
76
|
-
"v",
|
|
77
|
-
"w",
|
|
78
|
-
"x",
|
|
79
|
-
"y",
|
|
80
|
-
"z",
|
|
81
|
-
"0",
|
|
82
|
-
"1",
|
|
83
|
-
"2",
|
|
84
|
-
"3",
|
|
85
|
-
"4",
|
|
86
|
-
"5",
|
|
87
|
-
"6",
|
|
88
|
-
"7",
|
|
89
|
-
"8",
|
|
90
|
-
"9",
|
|
91
|
-
"+",
|
|
92
|
-
"/",
|
|
93
|
-
];
|
|
94
|
-
/**
|
|
95
|
-
* Converts data into a base64-encoded string.
|
|
96
|
-
*
|
|
97
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
98
|
-
*
|
|
99
|
-
* @param data The data to encode.
|
|
100
|
-
* @returns The base64-encoded string.
|
|
101
|
-
*
|
|
102
|
-
* @example Usage
|
|
103
|
-
* ```ts
|
|
104
|
-
* import { encodeBase64 } from "@std/encoding/base64";
|
|
105
|
-
* import { assertEquals } from "@std/assert";
|
|
106
|
-
*
|
|
107
|
-
* assertEquals(encodeBase64("foobar"), "Zm9vYmFy");
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
function encodeBase64(data) {
|
|
111
|
-
// CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
|
|
112
|
-
const uint8 = (0, _validate_binary_like_js_1.validateBinaryLike)(data);
|
|
113
|
-
let result = "";
|
|
114
|
-
let i;
|
|
115
|
-
const l = uint8.length;
|
|
116
|
-
for (i = 2; i < l; i += 3) {
|
|
117
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
118
|
-
result += base64abc[(((uint8[i - 2]) & 0x03) << 4) |
|
|
119
|
-
((uint8[i - 1]) >> 4)];
|
|
120
|
-
result += base64abc[(((uint8[i - 1]) & 0x0f) << 2) |
|
|
121
|
-
((uint8[i]) >> 6)];
|
|
122
|
-
result += base64abc[(uint8[i]) & 0x3f];
|
|
123
|
-
}
|
|
124
|
-
if (i === l + 1) {
|
|
125
|
-
// 1 octet yet to write
|
|
126
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
127
|
-
result += base64abc[((uint8[i - 2]) & 0x03) << 4];
|
|
128
|
-
result += "==";
|
|
129
|
-
}
|
|
130
|
-
if (i === l) {
|
|
131
|
-
// 2 octets yet to write
|
|
132
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
133
|
-
result += base64abc[(((uint8[i - 2]) & 0x03) << 4) |
|
|
134
|
-
((uint8[i - 1]) >> 4)];
|
|
135
|
-
result += base64abc[((uint8[i - 1]) & 0x0f) << 2];
|
|
136
|
-
result += "=";
|
|
137
|
-
}
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Decodes a base64-encoded string.
|
|
142
|
-
*
|
|
143
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
144
|
-
*
|
|
145
|
-
* @param b64 The base64-encoded string to decode.
|
|
146
|
-
* @returns The decoded data.
|
|
147
|
-
*
|
|
148
|
-
* @example Usage
|
|
149
|
-
* ```ts
|
|
150
|
-
* import { decodeBase64 } from "@std/encoding/base64";
|
|
151
|
-
* import { assertEquals } from "@std/assert";
|
|
152
|
-
*
|
|
153
|
-
* assertEquals(
|
|
154
|
-
* decodeBase64("Zm9vYmFy"),
|
|
155
|
-
* new TextEncoder().encode("foobar")
|
|
156
|
-
* );
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
function decodeBase64(b64) {
|
|
160
|
-
const binString = atob(b64);
|
|
161
|
-
const size = binString.length;
|
|
162
|
-
const bytes = new Uint8Array(size);
|
|
163
|
-
for (let i = 0; i < size; i++) {
|
|
164
|
-
bytes[i] = binString.charCodeAt(i);
|
|
165
|
-
}
|
|
166
|
-
return bytes;
|
|
167
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert data into a base64url-encoded string.
|
|
3
|
-
*
|
|
4
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-5}
|
|
5
|
-
*
|
|
6
|
-
* @param data The data to encode.
|
|
7
|
-
* @returns The base64url-encoded string.
|
|
8
|
-
*
|
|
9
|
-
* @example Usage
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { encodeBase64Url } from "@std/encoding/base64url";
|
|
12
|
-
* import { assertEquals } from "@std/assert";
|
|
13
|
-
*
|
|
14
|
-
* assertEquals(encodeBase64Url("foobar"), "Zm9vYmFy");
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function encodeBase64Url(data: ArrayBuffer | Uint8Array | string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Decodes a given base64url-encoded string.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-5}
|
|
22
|
-
*
|
|
23
|
-
* @param b64url The base64url-encoded string to decode.
|
|
24
|
-
* @returns The decoded data.
|
|
25
|
-
*
|
|
26
|
-
* @example Usage
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { decodeBase64Url } from "@std/encoding/base64url";
|
|
29
|
-
* import { assertEquals } from "@std/assert";
|
|
30
|
-
*
|
|
31
|
-
* assertEquals(
|
|
32
|
-
* decodeBase64Url("Zm9vYmFy"),
|
|
33
|
-
* new TextEncoder().encode("foobar")
|
|
34
|
-
* );
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function decodeBase64Url(b64url: string): Uint8Array;
|
|
38
|
-
//# sourceMappingURL=base64url.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.1/base64url.ts"],"names":[],"mappings":"AA4CA;;;;;;;;;;;;;;;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,UAAU,CAE1D"}
|