@byline/admin 2.4.0 → 2.4.2
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/dist/abilities.js +5 -24
- package/dist/index.js +8 -30
- package/dist/lib/assert-admin-actor.js +13 -74
- package/dist/lib/create-command.js +6 -16
- package/dist/modules/admin-account/commands.js +35 -24
- package/dist/modules/admin-account/components/change-password.d.ts +8 -0
- package/dist/modules/admin-account/components/change-password.js +192 -0
- package/dist/modules/admin-account/components/change-password.module.js +8 -0
- package/dist/modules/admin-account/components/change-password_module.css +27 -0
- package/dist/modules/admin-account/components/container.d.ts +29 -0
- package/dist/modules/admin-account/components/container.js +298 -0
- package/dist/modules/admin-account/components/container.module.js +28 -0
- package/dist/modules/admin-account/components/container_module.css +106 -0
- package/dist/modules/admin-account/components/update.d.ts +8 -0
- package/dist/modules/admin-account/components/update.js +207 -0
- package/dist/modules/admin-account/components/update.module.js +8 -0
- package/dist/modules/admin-account/components/update_module.css +27 -0
- package/dist/modules/admin-account/errors.js +14 -45
- package/dist/modules/admin-account/index.js +4 -34
- package/dist/modules/admin-account/schemas.js +25 -59
- package/dist/modules/admin-account/service.js +56 -61
- package/dist/modules/admin-permissions/abilities.js +6 -24
- package/dist/modules/admin-permissions/commands.js +42 -28
- package/dist/modules/admin-permissions/components/inspector.d.ts +4 -0
- package/dist/modules/admin-permissions/components/inspector.js +284 -0
- package/dist/modules/admin-permissions/components/inspector.module.js +56 -0
- package/dist/modules/admin-permissions/components/inspector_module.css +238 -0
- package/dist/modules/admin-permissions/dto.js +3 -16
- package/dist/modules/admin-permissions/errors.js +14 -27
- package/dist/modules/admin-permissions/index.js +6 -26
- package/dist/modules/admin-permissions/repository.js +1 -8
- package/dist/modules/admin-permissions/schemas.js +33 -70
- package/dist/modules/admin-permissions/service.js +88 -92
- package/dist/modules/admin-roles/abilities.js +8 -30
- package/dist/modules/admin-roles/commands.js +89 -55
- package/dist/modules/admin-roles/components/create.d.ts +7 -0
- package/dist/modules/admin-roles/components/create.js +177 -0
- package/dist/modules/admin-roles/components/create.module.js +8 -0
- package/dist/modules/admin-roles/components/create_module.css +27 -0
- package/dist/modules/admin-roles/components/permissions.d.ts +10 -0
- package/dist/modules/admin-roles/components/permissions.js +303 -0
- package/dist/modules/admin-roles/components/permissions.module.js +44 -0
- package/dist/modules/admin-roles/components/permissions_module.css +192 -0
- package/dist/modules/admin-roles/components/update.d.ts +8 -0
- package/dist/modules/admin-roles/components/update.js +166 -0
- package/dist/modules/admin-roles/components/update.module.js +8 -0
- package/dist/modules/admin-roles/components/update_module.css +27 -0
- package/dist/modules/admin-roles/dto.js +3 -16
- package/dist/modules/admin-roles/errors.js +16 -40
- package/dist/modules/admin-roles/index.js +6 -26
- package/dist/modules/admin-roles/repository.js +1 -8
- package/dist/modules/admin-roles/schemas.js +41 -71
- package/dist/modules/admin-roles/service.js +79 -82
- package/dist/modules/admin-users/abilities.js +9 -38
- package/dist/modules/admin-users/commands.js +92 -50
- package/dist/modules/admin-users/components/create.d.ts +8 -0
- package/dist/modules/admin-users/components/create.js +268 -0
- package/dist/modules/admin-users/components/create.module.js +10 -0
- package/dist/modules/admin-users/components/create_module.css +45 -0
- package/dist/modules/admin-users/components/roles.d.ts +11 -0
- package/dist/modules/admin-users/components/roles.js +148 -0
- package/dist/modules/admin-users/components/roles.module.js +18 -0
- package/dist/modules/admin-users/components/roles_module.css +75 -0
- package/dist/modules/admin-users/components/set-password.d.ts +8 -0
- package/dist/modules/admin-users/components/set-password.js +170 -0
- package/dist/modules/admin-users/components/set-password.module.js +9 -0
- package/dist/modules/admin-users/components/set-password_module.css +31 -0
- package/dist/modules/admin-users/components/update.d.ts +8 -0
- package/dist/modules/admin-users/components/update.js +254 -0
- package/dist/modules/admin-users/components/update.module.js +9 -0
- package/dist/modules/admin-users/components/update_module.css +34 -0
- package/dist/modules/admin-users/dto.js +3 -18
- package/dist/modules/admin-users/errors.js +17 -43
- package/dist/modules/admin-users/index.js +7 -27
- package/dist/modules/admin-users/repository.js +1 -8
- package/dist/modules/admin-users/schemas.js +44 -75
- package/dist/modules/admin-users/seed-super-admin.js +9 -34
- package/dist/modules/admin-users/service.js +76 -91
- package/dist/modules/auth/components/sign-in-form.d.ts +12 -0
- package/dist/modules/auth/components/sign-in-form.js +115 -0
- package/dist/modules/auth/components/sign-in-form.module.js +12 -0
- package/dist/modules/auth/components/sign-in-form_module.css +41 -0
- package/dist/modules/auth/index.js +3 -24
- package/dist/modules/auth/jwt-session-provider.js +179 -149
- package/dist/modules/auth/password.js +11 -53
- package/dist/modules/auth/phc.js +21 -54
- package/dist/modules/auth/refresh-tokens-repository.js +1 -8
- package/dist/modules/auth/resolve-actor.js +6 -28
- package/dist/services/admin-services-context.d.ts +16 -0
- package/dist/services/admin-services-context.js +13 -0
- package/dist/services/admin-services-types.d.ts +129 -0
- package/dist/services/admin-services-types.js +1 -0
- package/dist/store.js +1 -8
- package/dist/vendor/noble-argon2/_blake.js +277 -45
- package/dist/vendor/noble-argon2/_md.js +81 -136
- package/dist/vendor/noble-argon2/_u64.js +65 -67
- package/dist/vendor/noble-argon2/argon2.js +181 -342
- package/dist/vendor/noble-argon2/blake2.js +252 -327
- package/dist/vendor/noble-argon2/utils.js +110 -490
- package/dist/vendor/noble-argon2/utils.js.LICENSE.txt +1 -0
- package/package.json +89 -10
- package/src/abilities.ts +32 -0
- package/src/declarations.d.ts +4 -0
- package/src/index.ts +39 -0
- package/src/lib/assert-admin-actor.ts +90 -0
- package/src/lib/create-command.ts +109 -0
- package/src/modules/admin-account/commands.ts +76 -0
- package/src/modules/admin-account/components/change-password.module.css +40 -0
- package/src/modules/admin-account/components/change-password.tsx +232 -0
- package/src/modules/admin-account/components/container.module.css +158 -0
- package/src/modules/admin-account/components/container.tsx +229 -0
- package/src/modules/admin-account/components/update.module.css +40 -0
- package/src/modules/admin-account/components/update.tsx +263 -0
- package/src/modules/admin-account/errors.ts +75 -0
- package/src/modules/admin-account/index.ts +60 -0
- package/src/modules/admin-account/schemas.ts +84 -0
- package/src/modules/admin-account/service.ts +92 -0
- package/src/modules/admin-permissions/abilities.ts +46 -0
- package/src/modules/admin-permissions/commands.ts +103 -0
- package/src/modules/admin-permissions/components/inspector.module.css +326 -0
- package/src/modules/admin-permissions/components/inspector.tsx +298 -0
- package/src/modules/admin-permissions/dto.ts +28 -0
- package/src/modules/admin-permissions/errors.ts +57 -0
- package/src/modules/admin-permissions/index.ts +72 -0
- package/src/modules/admin-permissions/repository.ts +49 -0
- package/src/modules/admin-permissions/schemas.ts +128 -0
- package/src/modules/admin-permissions/service.ts +137 -0
- package/src/modules/admin-roles/abilities.ts +62 -0
- package/src/modules/admin-roles/commands.ts +161 -0
- package/src/modules/admin-roles/components/create.module.css +40 -0
- package/src/modules/admin-roles/components/create.tsx +218 -0
- package/src/modules/admin-roles/components/permissions.module.css +279 -0
- package/src/modules/admin-roles/components/permissions.tsx +396 -0
- package/src/modules/admin-roles/components/update.module.css +40 -0
- package/src/modules/admin-roles/components/update.tsx +218 -0
- package/src/modules/admin-roles/dto.ts +30 -0
- package/src/modules/admin-roles/errors.ts +76 -0
- package/src/modules/admin-roles/index.ts +81 -0
- package/src/modules/admin-roles/repository.ts +96 -0
- package/src/modules/admin-roles/schemas.ts +139 -0
- package/src/modules/admin-roles/service.ts +136 -0
- package/src/modules/admin-users/abilities.ts +76 -0
- package/src/modules/admin-users/commands.ts +157 -0
- package/src/modules/admin-users/components/create.module.css +63 -0
- package/src/modules/admin-users/components/create.tsx +323 -0
- package/src/modules/admin-users/components/roles.module.css +119 -0
- package/src/modules/admin-users/components/roles.tsx +172 -0
- package/src/modules/admin-users/components/set-password.module.css +46 -0
- package/src/modules/admin-users/components/set-password.tsx +199 -0
- package/src/modules/admin-users/components/update.module.css +49 -0
- package/src/modules/admin-users/components/update.tsx +328 -0
- package/src/modules/admin-users/dto.ts +39 -0
- package/src/modules/admin-users/errors.ts +84 -0
- package/src/modules/admin-users/index.ts +91 -0
- package/src/modules/admin-users/repository.ts +161 -0
- package/src/modules/admin-users/schemas.ts +168 -0
- package/src/modules/admin-users/seed-super-admin.ts +102 -0
- package/src/modules/admin-users/service.ts +166 -0
- package/src/modules/auth/components/sign-in-form.module.css +62 -0
- package/src/modules/auth/components/sign-in-form.tsx +132 -0
- package/src/modules/auth/index.ts +31 -0
- package/src/modules/auth/jwt-session-provider.ts +301 -0
- package/src/modules/auth/password.ts +94 -0
- package/src/modules/auth/phc.ts +121 -0
- package/src/modules/auth/refresh-tokens-repository.ts +74 -0
- package/src/modules/auth/resolve-actor.ts +42 -0
- package/src/services/admin-services-context.tsx +52 -0
- package/src/services/admin-services-types.ts +177 -0
- package/src/store.ts +32 -0
- package/src/vendor/noble-argon2/LICENSE +21 -0
- package/src/vendor/noble-argon2/README.md +87 -0
- package/src/vendor/noble-argon2/_blake.ts +58 -0
- package/src/vendor/noble-argon2/_md.ts +223 -0
- package/src/vendor/noble-argon2/_u64.ts +118 -0
- package/src/vendor/noble-argon2/argon2.ts +668 -0
- package/src/vendor/noble-argon2/blake2.ts +583 -0
- package/src/vendor/noble-argon2/utils.ts +849 -0
|
@@ -1,38 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @returns `true` when the value is a Uint8Array-compatible view.
|
|
5
|
-
* @example
|
|
6
|
-
* Check whether a value is a Uint8Array-compatible view.
|
|
7
|
-
* ```ts
|
|
8
|
-
* isBytes(new Uint8Array([1, 2, 3]));
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
export function isBytes(a) {
|
|
12
|
-
// Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases.
|
|
13
|
-
// The fallback still requires a real ArrayBuffer view, so plain
|
|
14
|
-
// JSON-deserialized `{ constructor: ... }` spoofing is rejected, and
|
|
15
|
-
// `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.
|
|
16
|
-
return (a instanceof Uint8Array ||
|
|
17
|
-
(ArrayBuffer.isView(a) &&
|
|
18
|
-
a.constructor.name === 'Uint8Array' &&
|
|
19
|
-
'BYTES_PER_ELEMENT' in a &&
|
|
20
|
-
a.BYTES_PER_ELEMENT === 1));
|
|
1
|
+
/*! LICENSE: utils.js.LICENSE.txt */
|
|
2
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ function isBytes(a) {
|
|
3
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && 'Uint8Array' === a.constructor.name && 'BYTES_PER_ELEMENT' in a && 1 === a.BYTES_PER_ELEMENT;
|
|
21
4
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* @param n - number to validate
|
|
25
|
-
* @param title - label included in thrown errors
|
|
26
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
27
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
28
|
-
* @example
|
|
29
|
-
* Validate a non-negative integer option.
|
|
30
|
-
* ```ts
|
|
31
|
-
* anumber(32, 'length');
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export function anumber(n, title = '') {
|
|
35
|
-
if (typeof n !== 'number') {
|
|
5
|
+
function anumber(n, title = '') {
|
|
6
|
+
if ('number' != typeof n) {
|
|
36
7
|
const prefix = title && `"${title}" `;
|
|
37
8
|
throw new TypeError(`${prefix}expected number, got ${typeof n}`);
|
|
38
9
|
}
|
|
@@ -41,537 +12,186 @@ export function anumber(n, title = '') {
|
|
|
41
12
|
throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
|
|
42
13
|
}
|
|
43
14
|
}
|
|
44
|
-
|
|
45
|
-
* Asserts something is Uint8Array.
|
|
46
|
-
* @param value - value to validate
|
|
47
|
-
* @param length - optional exact length constraint
|
|
48
|
-
* @param title - label included in thrown errors
|
|
49
|
-
* @returns The validated byte array.
|
|
50
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
51
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
52
|
-
* @example
|
|
53
|
-
* Validate that a value is a byte array.
|
|
54
|
-
* ```ts
|
|
55
|
-
* abytes(new Uint8Array([1, 2, 3]));
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export function abytes(value, length, title = '') {
|
|
15
|
+
function abytes(value, length, title = '') {
|
|
59
16
|
const bytes = isBytes(value);
|
|
60
17
|
const len = value?.length;
|
|
61
|
-
const needsLen =
|
|
62
|
-
if (!bytes ||
|
|
18
|
+
const needsLen = void 0 !== length;
|
|
19
|
+
if (!bytes || needsLen && len !== length) {
|
|
63
20
|
const prefix = title && `"${title}" `;
|
|
64
21
|
const ofLen = needsLen ? ` of length ${length}` : '';
|
|
65
22
|
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
66
23
|
const message = prefix + 'expected Uint8Array' + ofLen + ', got ' + got;
|
|
67
|
-
if (!bytes)
|
|
68
|
-
throw new TypeError(message);
|
|
24
|
+
if (!bytes) throw new TypeError(message);
|
|
69
25
|
throw new RangeError(message);
|
|
70
26
|
}
|
|
71
27
|
return value;
|
|
72
28
|
}
|
|
73
|
-
|
|
74
|
-
* Copies bytes into a fresh Uint8Array.
|
|
75
|
-
* Buffer-style slices can alias the same backing store, so callers that need ownership should copy.
|
|
76
|
-
* @param bytes - source bytes to clone
|
|
77
|
-
* @returns Freshly allocated copy of `bytes`.
|
|
78
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
79
|
-
* @example
|
|
80
|
-
* Clone a byte array before mutating it.
|
|
81
|
-
* ```ts
|
|
82
|
-
* const copy = copyBytes(new Uint8Array([1, 2, 3]));
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export function copyBytes(bytes) {
|
|
86
|
-
// `Uint8Array.from(...)` would also accept arrays / other typed arrays. Keep this helper strict
|
|
87
|
-
// because callers use it at byte-validation boundaries before mutating the detached copy.
|
|
29
|
+
function copyBytes(bytes) {
|
|
88
30
|
return Uint8Array.from(abytes(bytes));
|
|
89
31
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* @param h - hash constructor to validate
|
|
93
|
-
* @throws On wrong argument types or invalid hash wrapper shape. {@link TypeError}
|
|
94
|
-
* @throws On invalid hash metadata ranges or values. {@link RangeError}
|
|
95
|
-
* @throws If the hash metadata allows empty outputs or block sizes. {@link Error}
|
|
96
|
-
* @example
|
|
97
|
-
* Validate a callable hash wrapper.
|
|
98
|
-
* ```ts
|
|
99
|
-
* import { ahash } from '@noble/hashes/utils.js';
|
|
100
|
-
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
101
|
-
* ahash(sha256);
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
export function ahash(h) {
|
|
105
|
-
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
106
|
-
throw new TypeError('Hash must wrapped by utils.createHasher');
|
|
32
|
+
function ahash(h) {
|
|
33
|
+
if ('function' != typeof h || 'function' != typeof h.create) throw new TypeError('Hash must wrapped by utils.createHasher');
|
|
107
34
|
anumber(h.outputLen);
|
|
108
35
|
anumber(h.blockLen);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (h.outputLen < 1)
|
|
112
|
-
throw new Error('"outputLen" must be >= 1');
|
|
113
|
-
if (h.blockLen < 1)
|
|
114
|
-
throw new Error('"blockLen" must be >= 1');
|
|
36
|
+
if (h.outputLen < 1) throw new Error('"outputLen" must be >= 1');
|
|
37
|
+
if (h.blockLen < 1) throw new Error('"blockLen" must be >= 1');
|
|
115
38
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
* @param checkFinished - whether to reject finalized instances
|
|
120
|
-
* @throws If the hash instance has already been destroyed or finalized. {@link Error}
|
|
121
|
-
* @example
|
|
122
|
-
* Validate that a hash instance is still usable.
|
|
123
|
-
* ```ts
|
|
124
|
-
* import { aexists } from '@noble/hashes/utils.js';
|
|
125
|
-
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
126
|
-
* const hash = sha256.create();
|
|
127
|
-
* aexists(hash);
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
export function aexists(instance, checkFinished = true) {
|
|
131
|
-
if (instance.destroyed)
|
|
132
|
-
throw new Error('Hash instance has been destroyed');
|
|
133
|
-
if (checkFinished && instance.finished)
|
|
134
|
-
throw new Error('Hash#digest() has already been called');
|
|
39
|
+
function aexists(instance, checkFinished = true) {
|
|
40
|
+
if (instance.destroyed) throw new Error('Hash instance has been destroyed');
|
|
41
|
+
if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');
|
|
135
42
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
* @param out - destination buffer
|
|
139
|
-
* @param instance - hash instance providing output length
|
|
140
|
-
* Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.
|
|
141
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
142
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
143
|
-
* @example
|
|
144
|
-
* Validate a caller-provided digest buffer.
|
|
145
|
-
* ```ts
|
|
146
|
-
* import { aoutput } from '@noble/hashes/utils.js';
|
|
147
|
-
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
148
|
-
* const hash = sha256.create();
|
|
149
|
-
* aoutput(new Uint8Array(hash.outputLen), hash);
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
export function aoutput(out, instance) {
|
|
153
|
-
abytes(out, undefined, 'digestInto() output');
|
|
43
|
+
function aoutput(out, instance) {
|
|
44
|
+
abytes(out, void 0, 'digestInto() output');
|
|
154
45
|
const min = instance.outputLen;
|
|
155
|
-
if (out.length < min)
|
|
156
|
-
throw new RangeError('"digestInto() output" expected to be of length >=' + min);
|
|
157
|
-
}
|
|
46
|
+
if (out.length < min) throw new RangeError('"digestInto() output" expected to be of length >=' + min);
|
|
158
47
|
}
|
|
159
|
-
|
|
160
|
-
* Casts a typed array view to Uint8Array.
|
|
161
|
-
* @param arr - source typed array
|
|
162
|
-
* @returns Uint8Array view over the same buffer.
|
|
163
|
-
* @example
|
|
164
|
-
* Reinterpret a typed array as bytes.
|
|
165
|
-
* ```ts
|
|
166
|
-
* u8(new Uint32Array([1, 2]));
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
export function u8(arr) {
|
|
48
|
+
function u8(arr) {
|
|
170
49
|
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
171
50
|
}
|
|
172
|
-
|
|
173
|
-
* Casts a typed array view to Uint32Array.
|
|
174
|
-
* `arr.byteOffset` must already be 4-byte aligned or the platform
|
|
175
|
-
* Uint32Array constructor will throw.
|
|
176
|
-
* @param arr - source typed array
|
|
177
|
-
* @returns Uint32Array view over the same buffer.
|
|
178
|
-
* @example
|
|
179
|
-
* Reinterpret a byte array as 32-bit words.
|
|
180
|
-
* ```ts
|
|
181
|
-
* u32(new Uint8Array(8));
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
export function u32(arr) {
|
|
51
|
+
function u32(arr) {
|
|
185
52
|
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
186
53
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
* @param arrays - arrays to overwrite with zeros
|
|
190
|
-
* @example
|
|
191
|
-
* Zeroize sensitive buffers in place.
|
|
192
|
-
* ```ts
|
|
193
|
-
* clean(new Uint8Array([1, 2, 3]));
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
export function clean(...arrays) {
|
|
197
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
198
|
-
arrays[i].fill(0);
|
|
199
|
-
}
|
|
54
|
+
function clean(...arrays) {
|
|
55
|
+
for(let i = 0; i < arrays.length; i++)arrays[i].fill(0);
|
|
200
56
|
}
|
|
201
|
-
|
|
202
|
-
* Creates a DataView for byte-level manipulation.
|
|
203
|
-
* @param arr - source typed array
|
|
204
|
-
* @returns DataView over the same buffer region.
|
|
205
|
-
* @example
|
|
206
|
-
* Create a DataView over an existing buffer.
|
|
207
|
-
* ```ts
|
|
208
|
-
* createView(new Uint8Array(4));
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
export function createView(arr) {
|
|
57
|
+
function createView(arr) {
|
|
212
58
|
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
213
59
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* @param word - source word
|
|
217
|
-
* @param shift - shift amount in bits
|
|
218
|
-
* @returns Rotated word.
|
|
219
|
-
* @example
|
|
220
|
-
* Rotate a 32-bit word to the right.
|
|
221
|
-
* ```ts
|
|
222
|
-
* rotr(0x12345678, 8);
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
225
|
-
export function rotr(word, shift) {
|
|
226
|
-
return (word << (32 - shift)) | (word >>> shift);
|
|
60
|
+
function rotr(word, shift) {
|
|
61
|
+
return word << 32 - shift | word >>> shift;
|
|
227
62
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
* @param word - source word
|
|
231
|
-
* @param shift - shift amount in bits
|
|
232
|
-
* @returns Rotated word.
|
|
233
|
-
* @example
|
|
234
|
-
* Rotate a 32-bit word to the left.
|
|
235
|
-
* ```ts
|
|
236
|
-
* rotl(0x12345678, 8);
|
|
237
|
-
* ```
|
|
238
|
-
*/
|
|
239
|
-
export function rotl(word, shift) {
|
|
240
|
-
return (word << shift) | ((word >>> (32 - shift)) >>> 0);
|
|
63
|
+
function rotl(word, shift) {
|
|
64
|
+
return word << shift | word >>> 32 - shift >>> 0;
|
|
241
65
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
* @returns Word with reversed byte order.
|
|
248
|
-
* @example
|
|
249
|
-
* Reverse the byte order of a 32-bit word.
|
|
250
|
-
* ```ts
|
|
251
|
-
* byteSwap(0x11223344);
|
|
252
|
-
* ```
|
|
253
|
-
*/
|
|
254
|
-
export function byteSwap(word) {
|
|
255
|
-
return (((word << 24) & 0xff000000) |
|
|
256
|
-
((word << 8) & 0xff0000) |
|
|
257
|
-
((word >>> 8) & 0xff00) |
|
|
258
|
-
((word >>> 24) & 0xff));
|
|
66
|
+
const isLE = /* @__PURE__ */ (()=>0x44 === new Uint8Array(new Uint32Array([
|
|
67
|
+
0x11223344
|
|
68
|
+
]).buffer)[0])();
|
|
69
|
+
function byteSwap(word) {
|
|
70
|
+
return word << 24 & 0xff000000 | word << 8 & 0xff0000 | word >>> 8 & 0xff00 | word >>> 24 & 0xff;
|
|
259
71
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
* @returns Original or byte-swapped word depending on platform endianness.
|
|
264
|
-
* @example
|
|
265
|
-
* Normalize a 32-bit word for host endianness.
|
|
266
|
-
* ```ts
|
|
267
|
-
* swap8IfBE(0x11223344);
|
|
268
|
-
* ```
|
|
269
|
-
*/
|
|
270
|
-
export const swap8IfBE = isLE
|
|
271
|
-
? (n) => n
|
|
272
|
-
: (n) => byteSwap(n) >>> 0;
|
|
273
|
-
/**
|
|
274
|
-
* Byte-swaps every word of a Uint32Array in place.
|
|
275
|
-
* @param arr - array to mutate
|
|
276
|
-
* @returns The same array after mutation; callers pass live state arrays here.
|
|
277
|
-
* @example
|
|
278
|
-
* Reverse the byte order of every word in place.
|
|
279
|
-
* ```ts
|
|
280
|
-
* byteSwap32(new Uint32Array([0x11223344]));
|
|
281
|
-
* ```
|
|
282
|
-
*/
|
|
283
|
-
export function byteSwap32(arr) {
|
|
284
|
-
for (let i = 0; i < arr.length; i++) {
|
|
285
|
-
arr[i] = byteSwap(arr[i]);
|
|
286
|
-
}
|
|
72
|
+
const swap8IfBE = isLE ? (n)=>n : (n)=>byteSwap(n) >>> 0;
|
|
73
|
+
function byteSwap32(arr) {
|
|
74
|
+
for(let i = 0; i < arr.length; i++)arr[i] = byteSwap(arr[i]);
|
|
287
75
|
return arr;
|
|
288
76
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
* Normalize a word array for host endianness.
|
|
296
|
-
* ```ts
|
|
297
|
-
* swap32IfBE(new Uint32Array([0x11223344]));
|
|
298
|
-
* ```
|
|
299
|
-
*/
|
|
300
|
-
export const swap32IfBE = isLE
|
|
301
|
-
? (u) => u
|
|
302
|
-
: byteSwap32;
|
|
303
|
-
// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
|
|
304
|
-
const hasHexBuiltin = /* @__PURE__ */ (() =>
|
|
305
|
-
// @ts-ignore
|
|
306
|
-
typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();
|
|
307
|
-
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
308
|
-
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
309
|
-
/**
|
|
310
|
-
* Convert byte array to hex string.
|
|
311
|
-
* Uses the built-in function when available and assumes it matches the tested
|
|
312
|
-
* fallback semantics.
|
|
313
|
-
* @param bytes - bytes to encode
|
|
314
|
-
* @returns Lowercase hexadecimal string.
|
|
315
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
316
|
-
* @example
|
|
317
|
-
* Convert bytes to lowercase hexadecimal.
|
|
318
|
-
* ```ts
|
|
319
|
-
* bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'
|
|
320
|
-
* ```
|
|
321
|
-
*/
|
|
322
|
-
export function bytesToHex(bytes) {
|
|
77
|
+
const swap32IfBE = isLE ? (u)=>u : byteSwap32;
|
|
78
|
+
const hasHexBuiltin = /* @__PURE__ */ (()=>'function' == typeof Uint8Array.from([]).toHex && 'function' == typeof Uint8Array.fromHex)();
|
|
79
|
+
const hexes = /* @__PURE__ */ Array.from({
|
|
80
|
+
length: 256
|
|
81
|
+
}, (_, i)=>i.toString(16).padStart(2, '0'));
|
|
82
|
+
function bytesToHex(bytes) {
|
|
323
83
|
abytes(bytes);
|
|
324
|
-
|
|
325
|
-
if (hasHexBuiltin)
|
|
326
|
-
return bytes.toHex();
|
|
327
|
-
// pre-caching improves the speed 6x
|
|
84
|
+
if (hasHexBuiltin) return bytes.toHex();
|
|
328
85
|
let hex = '';
|
|
329
|
-
for
|
|
330
|
-
hex += hexes[bytes[i]];
|
|
331
|
-
}
|
|
86
|
+
for(let i = 0; i < bytes.length; i++)hex += hexes[bytes[i]];
|
|
332
87
|
return hex;
|
|
333
88
|
}
|
|
334
|
-
|
|
335
|
-
|
|
89
|
+
const asciis = {
|
|
90
|
+
_0: 48,
|
|
91
|
+
_9: 57,
|
|
92
|
+
A: 65,
|
|
93
|
+
F: 70,
|
|
94
|
+
a: 97,
|
|
95
|
+
f: 102
|
|
96
|
+
};
|
|
336
97
|
function asciiToBase16(ch) {
|
|
337
|
-
if (ch >= asciis._0 && ch <= asciis._9)
|
|
338
|
-
|
|
339
|
-
if (ch >= asciis.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
* @returns Decoded bytes.
|
|
349
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
350
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
351
|
-
* @example
|
|
352
|
-
* Decode lowercase hexadecimal into bytes.
|
|
353
|
-
* ```ts
|
|
354
|
-
* hexToBytes('cafe0123'); // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
export function hexToBytes(hex) {
|
|
358
|
-
if (typeof hex !== 'string')
|
|
359
|
-
throw new TypeError('hex string expected, got ' + typeof hex);
|
|
360
|
-
if (hasHexBuiltin) {
|
|
361
|
-
try {
|
|
362
|
-
return Uint8Array.fromHex(hex);
|
|
363
|
-
}
|
|
364
|
-
catch (error) {
|
|
365
|
-
if (error instanceof SyntaxError)
|
|
366
|
-
throw new RangeError(error.message);
|
|
367
|
-
throw error;
|
|
368
|
-
}
|
|
98
|
+
if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0;
|
|
99
|
+
if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10);
|
|
100
|
+
if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10);
|
|
101
|
+
}
|
|
102
|
+
function hexToBytes(hex) {
|
|
103
|
+
if ('string' != typeof hex) throw new TypeError('hex string expected, got ' + typeof hex);
|
|
104
|
+
if (hasHexBuiltin) try {
|
|
105
|
+
return Uint8Array.fromHex(hex);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error instanceof SyntaxError) throw new RangeError(error.message);
|
|
108
|
+
throw error;
|
|
369
109
|
}
|
|
370
110
|
const hl = hex.length;
|
|
371
111
|
const al = hl / 2;
|
|
372
|
-
if (hl % 2)
|
|
373
|
-
throw new RangeError('hex string expected, got unpadded hex of length ' + hl);
|
|
112
|
+
if (hl % 2) throw new RangeError('hex string expected, got unpadded hex of length ' + hl);
|
|
374
113
|
const array = new Uint8Array(al);
|
|
375
|
-
for
|
|
114
|
+
for(let ai = 0, hi = 0; ai < al; ai++, hi += 2){
|
|
376
115
|
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
377
116
|
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
378
|
-
if (
|
|
117
|
+
if (void 0 === n1 || void 0 === n2) {
|
|
379
118
|
const char = hex[hi] + hex[hi + 1];
|
|
380
119
|
throw new RangeError('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
381
120
|
}
|
|
382
|
-
array[ai] =
|
|
121
|
+
array[ai] = 16 * n1 + n2;
|
|
383
122
|
}
|
|
384
123
|
return array;
|
|
385
124
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
* This yields to the Promise/microtask scheduler queue, not to timers or the
|
|
389
|
-
* full macrotask event loop.
|
|
390
|
-
* @example
|
|
391
|
-
* Yield to the next scheduler tick.
|
|
392
|
-
* ```ts
|
|
393
|
-
* await nextTick();
|
|
394
|
-
* ```
|
|
395
|
-
*/
|
|
396
|
-
export const nextTick = async () => { };
|
|
397
|
-
/**
|
|
398
|
-
* Returns control to the Promise/microtask scheduler every `tick`
|
|
399
|
-
* milliseconds to avoid blocking long loops.
|
|
400
|
-
* @param iters - number of loop iterations to run
|
|
401
|
-
* @param tick - maximum time slice in milliseconds
|
|
402
|
-
* @param cb - callback executed on each iteration
|
|
403
|
-
* @example
|
|
404
|
-
* Run a loop that periodically yields back to the event loop.
|
|
405
|
-
* ```ts
|
|
406
|
-
* await asyncLoop(2, 0, () => {});
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
409
|
-
export async function asyncLoop(iters, tick, cb) {
|
|
125
|
+
const nextTick = async ()=>{};
|
|
126
|
+
async function asyncLoop(iters, tick, cb) {
|
|
410
127
|
let ts = Date.now();
|
|
411
|
-
for
|
|
128
|
+
for(let i = 0; i < iters; i++){
|
|
412
129
|
cb(i);
|
|
413
|
-
// Date.now() is not monotonic, so in case if clock goes backwards we return return control too
|
|
414
130
|
const diff = Date.now() - ts;
|
|
415
|
-
if (diff >= 0
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
131
|
+
if (!(diff >= 0) || !(diff < tick)) {
|
|
132
|
+
await nextTick();
|
|
133
|
+
ts += diff;
|
|
134
|
+
}
|
|
419
135
|
}
|
|
420
136
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
* Non-ASCII details are delegated to the platform `TextEncoder`.
|
|
425
|
-
* @param str - string to encode
|
|
426
|
-
* @returns UTF-8 encoded bytes.
|
|
427
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
428
|
-
* @example
|
|
429
|
-
* Encode a string as UTF-8 bytes.
|
|
430
|
-
* ```ts
|
|
431
|
-
* utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99])
|
|
432
|
-
* ```
|
|
433
|
-
*/
|
|
434
|
-
export function utf8ToBytes(str) {
|
|
435
|
-
if (typeof str !== 'string')
|
|
436
|
-
throw new TypeError('string expected');
|
|
437
|
-
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
137
|
+
function utf8ToBytes(str) {
|
|
138
|
+
if ('string' != typeof str) throw new TypeError('string expected');
|
|
139
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
438
140
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
* @param data - user-provided KDF input
|
|
443
|
-
* @param errorTitle - label included in thrown errors
|
|
444
|
-
* @returns Byte representation of the input.
|
|
445
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
446
|
-
* @example
|
|
447
|
-
* Normalize KDF input to bytes.
|
|
448
|
-
* ```ts
|
|
449
|
-
* kdfInputToBytes('password');
|
|
450
|
-
* ```
|
|
451
|
-
*/
|
|
452
|
-
export function kdfInputToBytes(data, errorTitle = '') {
|
|
453
|
-
if (typeof data === 'string')
|
|
454
|
-
return utf8ToBytes(data);
|
|
455
|
-
return abytes(data, undefined, errorTitle);
|
|
141
|
+
function kdfInputToBytes(data, errorTitle = '') {
|
|
142
|
+
if ('string' == typeof data) return utf8ToBytes(data);
|
|
143
|
+
return abytes(data, void 0, errorTitle);
|
|
456
144
|
}
|
|
457
|
-
|
|
458
|
-
* Copies several Uint8Arrays into one.
|
|
459
|
-
* @param arrays - arrays to concatenate
|
|
460
|
-
* @returns Concatenated byte array.
|
|
461
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
462
|
-
* @example
|
|
463
|
-
* Concatenate multiple byte arrays.
|
|
464
|
-
* ```ts
|
|
465
|
-
* concatBytes(new Uint8Array([1]), new Uint8Array([2]));
|
|
466
|
-
* ```
|
|
467
|
-
*/
|
|
468
|
-
export function concatBytes(...arrays) {
|
|
145
|
+
function concatBytes(...arrays) {
|
|
469
146
|
let sum = 0;
|
|
470
|
-
for
|
|
147
|
+
for(let i = 0; i < arrays.length; i++){
|
|
471
148
|
const a = arrays[i];
|
|
472
149
|
abytes(a);
|
|
473
150
|
sum += a.length;
|
|
474
151
|
}
|
|
475
152
|
const res = new Uint8Array(sum);
|
|
476
|
-
for
|
|
153
|
+
for(let i = 0, pad = 0; i < arrays.length; i++){
|
|
477
154
|
const a = arrays[i];
|
|
478
155
|
res.set(a, pad);
|
|
479
156
|
pad += a.length;
|
|
480
157
|
}
|
|
481
158
|
return res;
|
|
482
159
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
* @param defaults - base option object
|
|
486
|
-
* @param opts - user overrides
|
|
487
|
-
* @returns Merged option object. The merge mutates `defaults` in place.
|
|
488
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
489
|
-
* @example
|
|
490
|
-
* Merge user overrides onto default options.
|
|
491
|
-
* ```ts
|
|
492
|
-
* checkOpts({ dkLen: 32 }, { asyncTick: 10 });
|
|
493
|
-
* ```
|
|
494
|
-
*/
|
|
495
|
-
export function checkOpts(defaults, opts) {
|
|
496
|
-
if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
|
|
497
|
-
throw new TypeError('options must be object or undefined');
|
|
160
|
+
function checkOpts(defaults, opts) {
|
|
161
|
+
if (void 0 !== opts && '[object Object]' !== ({}).toString.call(opts)) throw new TypeError('options must be object or undefined');
|
|
498
162
|
const merged = Object.assign(defaults, opts);
|
|
499
163
|
return merged;
|
|
500
164
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
* @param info - optional metadata such as DER OID
|
|
505
|
-
* @returns Frozen callable hash wrapper with `.create()`.
|
|
506
|
-
* Wrapper construction eagerly calls `hashCons(undefined)` once to read
|
|
507
|
-
* `outputLen` / `blockLen`, so constructor side effects happen at module
|
|
508
|
-
* init time.
|
|
509
|
-
* @example
|
|
510
|
-
* Wrap a stateful hash constructor into a callable helper.
|
|
511
|
-
* ```ts
|
|
512
|
-
* import { createHasher } from '@noble/hashes/utils.js';
|
|
513
|
-
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
514
|
-
* const wrapped = createHasher(sha256.create, { oid: sha256.oid });
|
|
515
|
-
* wrapped(new Uint8Array([1]));
|
|
516
|
-
* ```
|
|
517
|
-
*/
|
|
518
|
-
export function createHasher(hashCons, info = {}) {
|
|
519
|
-
const hashC = (msg, opts) => hashCons(opts)
|
|
520
|
-
.update(msg)
|
|
521
|
-
.digest();
|
|
522
|
-
const tmp = hashCons(undefined);
|
|
165
|
+
function createHasher(hashCons, info = {}) {
|
|
166
|
+
const hashC = (msg, opts)=>hashCons(opts).update(msg).digest();
|
|
167
|
+
const tmp = hashCons(void 0);
|
|
523
168
|
hashC.outputLen = tmp.outputLen;
|
|
524
169
|
hashC.blockLen = tmp.blockLen;
|
|
525
170
|
hashC.canXOF = tmp.canXOF;
|
|
526
|
-
hashC.create = (opts)
|
|
171
|
+
hashC.create = (opts)=>hashCons(opts);
|
|
527
172
|
Object.assign(hashC, info);
|
|
528
173
|
return Object.freeze(hashC);
|
|
529
174
|
}
|
|
530
|
-
|
|
531
|
-
* Cryptographically secure PRNG backed by `crypto.getRandomValues`.
|
|
532
|
-
* @param bytesLength - number of random bytes to generate
|
|
533
|
-
* @returns Random bytes.
|
|
534
|
-
* The platform `getRandomValues()` implementation still defines any
|
|
535
|
-
* single-call length cap, and this helper rejects oversize requests
|
|
536
|
-
* with a stable library `RangeError` instead of host-specific errors.
|
|
537
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
538
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
539
|
-
* @throws If the current runtime does not provide `crypto.getRandomValues`. {@link Error}
|
|
540
|
-
* @example
|
|
541
|
-
* Generate a fresh random key or nonce.
|
|
542
|
-
* ```ts
|
|
543
|
-
* const key = randomBytes(16);
|
|
544
|
-
* ```
|
|
545
|
-
*/
|
|
546
|
-
export function randomBytes(bytesLength = 32) {
|
|
547
|
-
// Match the repo's other length-taking helpers instead of relying on Uint8Array coercion.
|
|
175
|
+
function randomBytes(bytesLength = 32) {
|
|
548
176
|
anumber(bytesLength, 'bytesLength');
|
|
549
|
-
const cr = typeof globalThis
|
|
550
|
-
if (typeof cr?.getRandomValues
|
|
551
|
-
|
|
552
|
-
// Web Cryptography API Level 2 §10.1.1:
|
|
553
|
-
// if `byteLength > 65536`, throw `QuotaExceededError`.
|
|
554
|
-
// Keep the guard explicit so callers can see the quota in code
|
|
555
|
-
// instead of discovering it by reading the spec or host errors.
|
|
556
|
-
// This wrapper surfaces the same quota as a stable library RangeError.
|
|
557
|
-
if (bytesLength > 65536)
|
|
558
|
-
throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
177
|
+
const cr = 'object' == typeof globalThis ? globalThis.crypto : null;
|
|
178
|
+
if ('function' != typeof cr?.getRandomValues) throw new Error('crypto.getRandomValues must be defined');
|
|
179
|
+
if (bytesLength > 65536) throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
559
180
|
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
560
181
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
});
|
|
182
|
+
const oidNist = (suffix)=>({
|
|
183
|
+
oid: Uint8Array.from([
|
|
184
|
+
0x06,
|
|
185
|
+
0x09,
|
|
186
|
+
0x60,
|
|
187
|
+
0x86,
|
|
188
|
+
0x48,
|
|
189
|
+
0x01,
|
|
190
|
+
0x65,
|
|
191
|
+
0x03,
|
|
192
|
+
0x04,
|
|
193
|
+
0x02,
|
|
194
|
+
suffix
|
|
195
|
+
])
|
|
196
|
+
});
|
|
197
|
+
export { abytes, aexists, ahash, anumber, aoutput, asyncLoop, byteSwap, byteSwap32, bytesToHex, checkOpts, clean, concatBytes, copyBytes, createHasher, createView, hexToBytes, isBytes, isLE, kdfInputToBytes, nextTick, oidNist, randomBytes, rotl, rotr, swap32IfBE, swap8IfBE, u32, u8, utf8ToBytes };
|