@anizoptera/uuid-slug 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +54 -31
- package/README.md +1052 -261
- package/dist/alphabet.d.ts +5 -17
- package/dist/alphabet.d.ts.map +1 -1
- package/dist/alphabet.js +146 -112
- package/dist/alphabet.js.map +1 -1
- package/dist/base64url-name.d.ts +7 -0
- package/dist/base64url-name.d.ts.map +1 -0
- package/dist/base64url-name.js +8 -0
- package/dist/base64url-name.js.map +1 -0
- package/dist/errors.d.ts +50 -9
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +145 -63
- package/dist/errors.js.map +1 -1
- package/dist/feistel.js +29 -95
- package/dist/feistel.js.map +1 -1
- package/dist/generation-options.js +20 -0
- package/dist/generation-options.js.map +1 -0
- package/dist/index.d.ts +22 -10
- package/dist/index.js +21 -9
- package/dist/instant.js +83 -0
- package/dist/instant.js.map +1 -0
- package/dist/mask-handle.d.ts +16 -0
- package/dist/mask-handle.d.ts.map +1 -0
- package/dist/mask-handle.js +60 -0
- package/dist/mask-handle.js.map +1 -0
- package/dist/mask.d.ts +27 -0
- package/dist/mask.d.ts.map +1 -0
- package/dist/mask.js +151 -95
- package/dist/mask.js.map +1 -1
- package/dist/masking-codec-protocol.js +23 -0
- package/dist/masking-codec-protocol.js.map +1 -0
- package/dist/masking-codec-types.d.ts +245 -0
- package/dist/masking-codec-types.d.ts.map +1 -0
- package/dist/masking-codec.d.ts +19 -0
- package/dist/masking-codec.d.ts.map +1 -0
- package/dist/masking-codec.js +391 -0
- package/dist/masking-codec.js.map +1 -0
- package/dist/migration.js +114 -51
- package/dist/migration.js.map +1 -1
- package/dist/node/runtime.js +39 -0
- package/dist/node/runtime.js.map +1 -0
- package/dist/payload.d.ts +7 -0
- package/dist/payload.d.ts.map +1 -0
- package/dist/payload.js +118 -0
- package/dist/payload.js.map +1 -0
- package/dist/runtime/pool.js +21 -46
- package/dist/runtime/pool.js.map +1 -1
- package/dist/runtime/portable.js +27 -0
- package/dist/runtime/portable.js.map +1 -0
- package/dist/sentinel.js +10 -0
- package/dist/sentinel.js.map +1 -0
- package/dist/siphash.js +20 -99
- package/dist/siphash.js.map +1 -1
- package/dist/slug.d.ts +169 -0
- package/dist/slug.d.ts.map +1 -0
- package/dist/slug.js +268 -0
- package/dist/slug.js.map +1 -0
- package/dist/timestamp.d.ts +19 -0
- package/dist/timestamp.d.ts.map +1 -0
- package/dist/timestamp.js +44 -0
- package/dist/timestamp.js.map +1 -0
- package/dist/types.d.ts +480 -200
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/uuid-value-protocol.js +46 -0
- package/dist/uuid-value-protocol.js.map +1 -0
- package/dist/uuid-value.d.ts +17 -0
- package/dist/uuid-value.d.ts.map +1 -0
- package/dist/uuid-value.js +127 -0
- package/dist/uuid-value.js.map +1 -0
- package/dist/uuid.d.ts +51 -64
- package/dist/uuid.d.ts.map +1 -1
- package/dist/uuid.js +203 -199
- package/dist/uuid.js.map +1 -1
- package/dist/v4-slug.d.ts +16 -0
- package/dist/v4-slug.d.ts.map +1 -0
- package/dist/v4-slug.js +16 -0
- package/dist/v4-slug.js.map +1 -0
- package/dist/v4.d.ts +42 -0
- package/dist/v4.d.ts.map +1 -0
- package/dist/v4.js +85 -0
- package/dist/v4.js.map +1 -0
- package/dist/v7-bounds.d.ts +36 -0
- package/dist/v7-bounds.d.ts.map +1 -0
- package/dist/v7-bounds.js +49 -0
- package/dist/v7-bounds.js.map +1 -0
- package/dist/v7-generator-input.js +75 -0
- package/dist/v7-generator-input.js.map +1 -0
- package/dist/v7-generator.d.ts +43 -0
- package/dist/v7-generator.d.ts.map +1 -0
- package/dist/v7-generator.js +105 -0
- package/dist/v7-generator.js.map +1 -0
- package/dist/v7-keyless.d.ts +46 -0
- package/dist/v7-keyless.d.ts.map +1 -0
- package/dist/v7-keyless.js +106 -0
- package/dist/v7-keyless.js.map +1 -0
- package/dist/v7-payload.js +54 -0
- package/dist/v7-payload.js.map +1 -0
- package/dist/v7-slug.d.ts +46 -0
- package/dist/v7-slug.d.ts.map +1 -0
- package/dist/v7-slug.js +127 -0
- package/dist/v7-slug.js.map +1 -0
- package/dist/v7-timestamp.js +9 -0
- package/dist/v7-timestamp.js.map +1 -0
- package/dist/v7-value-options.js +28 -0
- package/dist/v7-value-options.js.map +1 -0
- package/dist/v7-value.d.ts +23 -0
- package/dist/v7-value.d.ts.map +1 -0
- package/dist/v7-value.js +31 -0
- package/dist/v7-value.js.map +1 -0
- package/dist/v7.js +127 -171
- package/dist/v7.js.map +1 -1
- package/package.json +14 -9
- package/src/alphabet.ts +456 -27
- package/src/base64url-name.ts +5 -0
- package/src/errors.ts +373 -37
- package/src/feistel.ts +69 -56
- package/src/generation-options.ts +48 -0
- package/src/index.ts +134 -80
- package/src/instant.ts +196 -0
- package/src/keyless.ts +7 -134
- package/src/mask-handle.ts +141 -0
- package/src/mask.ts +354 -129
- package/src/masking-codec-protocol.ts +29 -0
- package/src/masking-codec-types.ts +380 -0
- package/src/masking-codec.ts +923 -0
- package/src/migration.ts +195 -42
- package/src/payload.ts +321 -0
- package/src/runtime/bun.ts +30 -49
- package/src/runtime/node.ts +43 -24
- package/src/runtime/pool.ts +49 -21
- package/src/runtime/portable.ts +68 -0
- package/src/runtime/types.ts +23 -35
- package/src/sentinel.ts +13 -0
- package/src/siphash.ts +5 -4
- package/src/slug.ts +884 -0
- package/src/timestamp.ts +122 -0
- package/src/types.ts +759 -205
- package/src/uuid-value-protocol.ts +77 -0
- package/src/uuid-value.ts +341 -0
- package/src/uuid.ts +514 -234
- package/src/v4-slug.ts +27 -0
- package/src/v4.ts +234 -0
- package/src/v7-bounds.ts +171 -0
- package/src/v7-generator-input.ts +169 -0
- package/src/v7-generator.ts +245 -0
- package/src/v7-keyless.ts +354 -0
- package/src/v7-payload.ts +121 -0
- package/src/v7-slug.ts +293 -0
- package/src/v7-timestamp.ts +21 -0
- package/src/v7-value-options.ts +62 -0
- package/src/v7-value.ts +54 -0
- package/src/v7.ts +377 -200
- package/dist/base64url.d.ts +0 -20
- package/dist/base64url.d.ts.map +0 -1
- package/dist/base64url.js +0 -33
- package/dist/base64url.js.map +0 -1
- package/dist/codec.d.ts +0 -17
- package/dist/codec.d.ts.map +0 -1
- package/dist/codec.js +0 -192
- package/dist/codec.js.map +0 -1
- package/dist/keyless.d.ts +0 -31
- package/dist/keyless.d.ts.map +0 -1
- package/dist/keyless.js +0 -93
- package/dist/keyless.js.map +0 -1
- package/dist/legacy-mask.js +0 -55
- package/dist/legacy-mask.js.map +0 -1
- package/dist/node/alphabet.js +0 -130
- package/dist/node/base64url.js +0 -31
- package/dist/node/codec.js +0 -190
- package/dist/node/errors.js +0 -78
- package/dist/node/feistel.js +0 -103
- package/dist/node/index.js +0 -10
- package/dist/node/keyless.js +0 -91
- package/dist/node/legacy-mask.js +0 -53
- package/dist/node/mask.js +0 -106
- package/dist/node/migration.js +0 -64
- package/dist/node/runtime/node.js +0 -33
- package/dist/node/runtime/pool.js +0 -53
- package/dist/node/schema.js +0 -214
- package/dist/node/siphash.js +0 -106
- package/dist/node/uuid.js +0 -226
- package/dist/node/v7.js +0 -185
- package/dist/node/yield.js +0 -20
- package/dist/runtime/web.js +0 -39
- package/dist/runtime/web.js.map +0 -1
- package/dist/schema.d.ts +0 -20
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -216
- package/dist/schema.js.map +0 -1
- package/dist/v7.d.ts +0 -12
- package/dist/v7.d.ts.map +0 -1
- package/dist/yield.js +0 -22
- package/dist/yield.js.map +0 -1
- package/src/base64url.ts +0 -41
- package/src/codec.ts +0 -320
- package/src/legacy-mask.ts +0 -25
- package/src/runtime/web.ts +0 -48
- package/src/schema.ts +0 -300
- package/src/yield.ts +0 -22
package/dist/alphabet.d.ts
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// @anizoptera/uuid-slug 0.
|
|
3
|
-
import {
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { BASE64URL_NAME } from "./base64url-name.js";
|
|
4
4
|
//#region src/alphabet.d.ts
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
* thing that varies between base64url and base32 is the character set and how many bits each
|
|
8
|
-
* character carries — one routine serves both rather than two hand-unrolled loops.
|
|
9
|
-
*/
|
|
10
|
-
interface Alphabet {
|
|
11
|
-
readonly bitsPerChar: number;
|
|
12
|
-
readonly chars: string;
|
|
13
|
-
readonly code: UuidSlugErrorCode;
|
|
14
|
-
/** Character code -> value, `-1` for anything outside the alphabet. */
|
|
15
|
-
readonly decode: Int16Array;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly invalidChars: RegExp;
|
|
18
|
-
}
|
|
5
|
+
/** Select lowercase base32hex slug output. */
|
|
6
|
+
export declare const BASE32HEX_NAME = "base32hex";
|
|
19
7
|
//#endregion
|
|
20
|
-
export {
|
|
8
|
+
export { BASE64URL_NAME };
|
|
21
9
|
//# sourceMappingURL=alphabet.d.ts.map
|
package/dist/alphabet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alphabet.d.ts","names":[],"sources":["../src/alphabet.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"alphabet.d.ts","names":[],"sources":["../src/alphabet.ts"],"mappings":";;;;;qBASa"}
|
package/dist/alphabet.js
CHANGED
|
@@ -1,132 +1,166 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// @anizoptera/uuid-slug 0.
|
|
3
|
-
import { UuidSlugError, checkRange } from "./errors.js";
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { INVALID_BASE32HEX as e, INVALID_BASE64URL as t, UuidSlugError as n, checkRange as r } from "./errors.js";
|
|
4
|
+
import { BASE64URL_NAME as i } from "./base64url-name.js";
|
|
5
|
+
import { runtime as a } from "#runtime";
|
|
4
6
|
//#region src/alphabet.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
for (let
|
|
7
|
+
const o = "base32hex";
|
|
8
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
9
|
+
function alphabet(e, t, n, r = !1) {
|
|
10
|
+
let i = Math.log2(t.length), a = (/* @__PURE__ */ new Int16Array(128)).fill(-1);
|
|
11
|
+
for (let e = 0; e < t.length; e += 1) {
|
|
12
|
+
let n = t.charCodeAt(e);
|
|
13
|
+
a[n] = e, r && n >= 97 && n <= 122 && (a[n - 32] = e);
|
|
14
|
+
}
|
|
15
|
+
let o = `[^${t.replaceAll("-", "\\-")}]`;
|
|
10
16
|
return {
|
|
11
|
-
bitsPerChar,
|
|
12
|
-
chars,
|
|
13
|
-
code,
|
|
14
|
-
decode,
|
|
15
|
-
name,
|
|
16
|
-
invalidChars: new RegExp(
|
|
17
|
+
bitsPerChar: i,
|
|
18
|
+
chars: t,
|
|
19
|
+
code: n,
|
|
20
|
+
decode: a,
|
|
21
|
+
name: e,
|
|
22
|
+
invalidChars: new RegExp(o),
|
|
23
|
+
invalidInputChars: new RegExp(o, r ? "i" : "")
|
|
17
24
|
};
|
|
18
25
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
const s = /*#__PURE__*/ alphabet(i, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", t), c = /*#__PURE__*/ alphabet(o, "0123456789abcdefghijklmnopqrstuv", e, !0), l = globalThis.Deno?.version?.deno, u = Uint8Array.prototype.toBase64, d = l === void 0 ? u : void 0, f = {
|
|
27
|
+
alphabet: i,
|
|
28
|
+
omitPadding: !0
|
|
29
|
+
}, p = a.latin1Scratch;
|
|
30
|
+
let m, h, g, _, v;
|
|
31
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
32
|
+
function characterCodes(e) {
|
|
33
|
+
return Uint8Array.from(e.chars, (e) => e.charCodeAt(0));
|
|
34
|
+
}
|
|
35
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
36
|
+
function spareBits(e, t) {
|
|
37
|
+
let n = t * 8;
|
|
38
|
+
return (e.bitsPerChar - n % e.bitsPerChar) % e.bitsPerChar;
|
|
39
|
+
}
|
|
40
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
41
|
+
function isEncoded(e, t, n, r = !1, i = 0) {
|
|
42
|
+
if (e.length !== Math.ceil((n * 8 + i) / t.bitsPerChar) || (r ? t.invalidInputChars : t.invalidChars).test(e)) return !1;
|
|
43
|
+
let a = (t.bitsPerChar - (n * 8 + i) % t.bitsPerChar) % t.bitsPerChar;
|
|
44
|
+
return a === 0 || !(t.decode[e.charCodeAt(e.length - 1)] & (1 << a) - 1);
|
|
45
|
+
}
|
|
46
|
+
function invalidCharacter(e, t, r) {
|
|
47
|
+
return new n(e.code, `Invalid ${e.name} character ${JSON.stringify(t[r])} at offset ${r}.`);
|
|
48
|
+
}
|
|
49
|
+
function firstInvalidCharacter(e, t) {
|
|
50
|
+
let n = 0;
|
|
51
|
+
for (; n < t.length - 1;) {
|
|
52
|
+
let r = t.charCodeAt(n);
|
|
53
|
+
if (r > 127 || e.decode[r] < 0) break;
|
|
54
|
+
n += 1;
|
|
55
|
+
}
|
|
56
|
+
return invalidCharacter(e, t, n);
|
|
57
|
+
}
|
|
58
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
59
|
+
function encode(e, t, n = 0, r = 0) {
|
|
60
|
+
if (p && e.length === 16) {
|
|
61
|
+
if (t === s && (r === 0 || r === 4)) return encodeBase64urlLatin1(p, e, n);
|
|
62
|
+
if (t === c && (r === 0 || r === 2 || r === 4)) return encodeBase32hexLatin1(p, e, n, r);
|
|
63
|
+
}
|
|
64
|
+
if (e.length === 16) {
|
|
65
|
+
if (t === s && (r === 0 || r === 4)) return /* @__PURE__ */ writeBase64url(e, _ ??= /* @__PURE__ */ characterCodes(s), n);
|
|
66
|
+
if (t === c && (r === 0 || r === 2 || r === 4)) return /* @__PURE__ */ writeBase32hex(e, v ??= /* @__PURE__ */ characterCodes(c), n, r);
|
|
67
|
+
}
|
|
68
|
+
if (d && t === s && r >= 0 && r <= /* @__PURE__ */ spareBits(t, e.length)) {
|
|
69
|
+
let i = d.call(e, f);
|
|
70
|
+
if (r === 0) return i;
|
|
71
|
+
let a = i.length - 1, o = t.decode[i.charCodeAt(a)], s = (n & (1 << r) - 1) << /* @__PURE__ */ spareBits(t, e.length) - r;
|
|
72
|
+
return i.slice(0, a) + t.chars[o | s];
|
|
73
|
+
}
|
|
74
|
+
return /* @__PURE__ */ encodePortable(e, t, n, r);
|
|
45
75
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
76
|
+
function encodeBase64urlLatin1(e, t, n) {
|
|
77
|
+
let r = m ??= e(22), i = _ ??= /* @__PURE__ */ characterCodes(s), a = r.bytes;
|
|
78
|
+
for (let e = 0, n = 0; e < 15; e += 3, n += 4) {
|
|
79
|
+
let r = t[e] << 16 | t[e + 1] << 8 | t[e + 2];
|
|
80
|
+
a[n] = i[r >>> 18], a[n + 1] = i[r >>> 12 & 63], a[n + 2] = i[r >>> 6 & 63], a[n + 3] = i[r & 63];
|
|
81
|
+
}
|
|
82
|
+
let o = t[15];
|
|
83
|
+
return a[20] = i[o >>> 2], a[21] = i[(o & 3) << 4 | n & 15], r.text();
|
|
51
84
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* before the tail existed valid afterwards.
|
|
58
|
-
*/
|
|
59
|
-
function encode(bytes, alpha, tail = 0, tailBits = 0) {
|
|
60
|
-
if (nativeToBase64 && alpha === BASE64URL && tailBits >= 0 && tailBits <= spareBits(alpha, bytes.length)) {
|
|
61
|
-
const encoded = nativeToBase64.call(bytes, BASE64_OPTIONS);
|
|
62
|
-
if (tailBits === 0) return encoded;
|
|
63
|
-
const last = encoded.length - 1;
|
|
64
|
-
const digit = alpha.decode[encoded.charCodeAt(last)];
|
|
65
|
-
const trailing = (tail & (1 << tailBits) - 1) << spareBits(alpha, bytes.length) - tailBits;
|
|
66
|
-
return encoded.slice(0, last) + alpha.chars[digit | trailing];
|
|
85
|
+
function encodeBase32hexLatin1(e, t, n, r) {
|
|
86
|
+
let i = r === 4 ? g ??= e(27) : h ??= e(26), a = v ??= /* @__PURE__ */ characterCodes(c), o = i.bytes;
|
|
87
|
+
for (let e = 0, n = 0; e < 15; e += 5, n += 8) {
|
|
88
|
+
let r = t[e], i = t[e + 1], s = t[e + 2], c = t[e + 3], l = t[e + 4];
|
|
89
|
+
o[n] = a[r >>> 3], o[n + 1] = a[(r & 7) << 2 | i >>> 6], o[n + 2] = a[i >>> 1 & 31], o[n + 3] = a[(i & 1) << 4 | s >>> 4], o[n + 4] = a[(s & 15) << 1 | c >>> 7], o[n + 5] = a[c >>> 2 & 31], o[n + 6] = a[(c & 3) << 3 | l >>> 5], o[n + 7] = a[l & 31];
|
|
67
90
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
out += chars[acc >>> bits & mask];
|
|
91
|
+
let s = t[15];
|
|
92
|
+
return o[24] = a[s >>> 3], r === 4 ? (o[25] = a[(s & 7) << 2 | n >>> 2 & 3], o[26] = a[(n & 3) << 3]) : o[25] = a[(s & 7) << 2 | n & 3], i.text();
|
|
93
|
+
}
|
|
94
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
95
|
+
function encodePortable(e, t, n = 0, r = 0) {
|
|
96
|
+
if (t === s && e.length === 16 && (r === 0 || r === 4)) {
|
|
97
|
+
let r = "";
|
|
98
|
+
for (let n = 0; n < 15; n += 3) {
|
|
99
|
+
let i = e[n] << 16 | e[n + 1] << 8 | e[n + 2];
|
|
100
|
+
r += t.chars[i >>> 18] + t.chars[i >>> 12 & 63] + t.chars[i >>> 6 & 63] + t.chars[i & 63];
|
|
79
101
|
}
|
|
102
|
+
let i = e[15];
|
|
103
|
+
return r + t.chars[i >>> 2] + t.chars[(i & 3) << 4 | n & 15];
|
|
80
104
|
}
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
out += chars[acc >>> bits & mask];
|
|
105
|
+
if (t === c && e.length === 16 && (r === 0 || r === 2 || r === 4)) {
|
|
106
|
+
let i = "", a = t.chars;
|
|
107
|
+
for (let t = 0; t < 15; t += 5) {
|
|
108
|
+
let n = e[t], r = e[t + 1], o = e[t + 2], s = e[t + 3], c = e[t + 4];
|
|
109
|
+
i += a[n >>> 3] + a[(n & 7) << 2 | r >>> 6] + a[r >>> 1 & 31] + a[(r & 1) << 4 | o >>> 4] + a[(o & 15) << 1 | s >>> 7] + a[s >>> 2 & 31] + a[(s & 3) << 3 | c >>> 5] + a[c & 31];
|
|
87
110
|
}
|
|
111
|
+
let o = e[15];
|
|
112
|
+
return r === 4 ? i + a[o >>> 3] + a[(o & 7) << 2 | n >>> 2 & 3] + a[(n & 3) << 3] : i + a[o >>> 3] + a[(o & 7) << 2 | n & 3];
|
|
88
113
|
}
|
|
89
|
-
|
|
90
|
-
|
|
114
|
+
let { bitsPerChar: i, chars: a } = t, o = (1 << i) - 1, l = "", u = 0, d = 0;
|
|
115
|
+
for (let t = 0; t < e.length; t += 1) for (u = u << 8 | e[t], d += 8; d >= i;) d -= i, l += a[u >>> d & o];
|
|
116
|
+
if (r > 0) for (u = u << r | n & (1 << r) - 1, d += r; d >= i;) d -= i, l += a[u >>> d & o];
|
|
117
|
+
return d > 0 && (l += a[u << i - d & o]), l;
|
|
91
118
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const expected = Math.ceil((byteLength * 8 + tailBits) / bitsPerChar);
|
|
103
|
-
if (value.length !== expected) return new UuidSlugError(code, `Expected ${expected} ${name} characters, got ${value.length}.`);
|
|
104
|
-
const badRange = checkRange(out.length, offset, byteLength);
|
|
105
|
-
if (badRange) return badRange;
|
|
106
|
-
let acc = 0;
|
|
107
|
-
let bits = 0;
|
|
108
|
-
let written = 0;
|
|
109
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
110
|
-
const charCode = value.charCodeAt(i);
|
|
111
|
-
const digit = charCode < 128 ? table[charCode] : -1;
|
|
112
|
-
if (digit < 0) return new UuidSlugError(code, `Invalid ${name} character at offset ${i}.`);
|
|
113
|
-
acc = acc << bitsPerChar | digit;
|
|
114
|
-
bits += bitsPerChar;
|
|
115
|
-
while (bits >= 8 && written < byteLength) {
|
|
116
|
-
bits -= 8;
|
|
117
|
-
out[offset + written] = acc >>> bits & 255;
|
|
118
|
-
written += 1;
|
|
119
|
+
function decodeInto(e, t, i, a, o, l = 0) {
|
|
120
|
+
let { bitsPerChar: u, decode: d, code: f, name: p } = t, m = Math.ceil((o * 8 + l) / u);
|
|
121
|
+
if (e.length !== m) return new n(f, `Expected ${m} ${p} characters, got ${e.length}.`);
|
|
122
|
+
let h = /* @__PURE__ */ r(i.length, a, o);
|
|
123
|
+
if (h) return h;
|
|
124
|
+
if (t === s && o === 16 && (l === 0 || l === 4)) {
|
|
125
|
+
let r = 0, o = 0, s = a;
|
|
126
|
+
for (let t = 0; t < 20; t += 4) {
|
|
127
|
+
let n = e.charCodeAt(t), a = e.charCodeAt(t + 1), c = e.charCodeAt(t + 2), l = e.charCodeAt(t + 3), u = d[n & 127] << 18 | d[a & 127] << 12 | d[c & 127] << 6 | d[l & 127];
|
|
128
|
+
r |= n | a | c | l, o |= u, i[s] = u >>> 16, i[s + 1] = u >>> 8, i[s + 2] = u, s += 3;
|
|
119
129
|
}
|
|
130
|
+
let c = e.charCodeAt(20), u = e.charCodeAt(21), m = d[c & 127], h = d[u & 127];
|
|
131
|
+
return (r | c | u) > 127 || (o | m | h) < 0 ? firstInvalidCharacter(t, e) : (i[s] = m << 2 | h >>> 4, l === 4 ? h & 15 : h & 15 ? new n(f, `${p} value has non-canonical trailing bits; a masked slug of this length decodes only through its codec.`) : 0);
|
|
120
132
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
if (t === c && o === 16 && (l === 0 || l === 2 || l === 4)) {
|
|
134
|
+
let r = 0, o = 0, s = a;
|
|
135
|
+
for (let t = 0; t < 24; t += 8) {
|
|
136
|
+
let n = e.charCodeAt(t), a = e.charCodeAt(t + 1), c = e.charCodeAt(t + 2), l = e.charCodeAt(t + 3), u = e.charCodeAt(t + 4), f = e.charCodeAt(t + 5), p = e.charCodeAt(t + 6), m = e.charCodeAt(t + 7);
|
|
137
|
+
r |= n | a | c | l | u | f | p | m;
|
|
138
|
+
let h = d[n & 127], g = d[a & 127], _ = d[c & 127], v = d[l & 127], y = d[u & 127], b = d[f & 127], x = d[p & 127], S = d[m & 127];
|
|
139
|
+
o |= h | g | _ | v | y | b | x | S, i[s] = h << 3 | g >>> 2, i[s + 1] = g << 6 | _ << 1 | v >>> 4, i[s + 2] = v << 4 | y >>> 1, i[s + 3] = y << 7 | b << 2 | x >>> 3, i[s + 4] = x << 5 | S, s += 5;
|
|
140
|
+
}
|
|
141
|
+
let c = e.charCodeAt(24), u = e.charCodeAt(25), m = l === 4 ? e.charCodeAt(26) : 48, h = d[c & 127], g = d[u & 127], _ = d[m & 127];
|
|
142
|
+
return (r | c | u | m) > 127 || (o | h | g | _) < 0 ? firstInvalidCharacter(t, e) : (i[s] = h << 3 | g >>> 2, l === 4 ? _ & 7 ? new n(f, `${p} value has non-canonical trailing bits.`) : (g & 3) << 2 | _ >>> 3 : l === 2 ? g & 3 : g & 3 ? new n(f, `${p} value has non-canonical trailing bits.`) : 0);
|
|
143
|
+
}
|
|
144
|
+
let g = 0, _ = 0, v = 0;
|
|
145
|
+
for (let n = 0; n < e.length; n += 1) {
|
|
146
|
+
let r = e.charCodeAt(n), s = r < 128 ? d[r] : -1;
|
|
147
|
+
if (s < 0) return invalidCharacter(t, e, n);
|
|
148
|
+
for (g = g << u | s, _ += u; _ >= 8 && v < o;) _ -= 8, i[a + v] = g >>> _ & 255, v += 1;
|
|
125
149
|
}
|
|
126
|
-
|
|
127
|
-
return
|
|
150
|
+
let y = 0;
|
|
151
|
+
return l > 0 && (_ -= l, y = g >>> _ & (1 << l) - 1), _ > 0 && g & (1 << _) - 1 ? new n(f, `${p} value has non-canonical trailing bits.`) : y;
|
|
152
|
+
}
|
|
153
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
154
|
+
function writeBase64url(e, t, n) {
|
|
155
|
+
let r = e[0] << 16 | e[1] << 8 | e[2], i = e[3] << 16 | e[4] << 8 | e[5], a = e[6] << 16 | e[7] << 8 | e[8], o = e[9] << 16 | e[10] << 8 | e[11], s = e[12] << 16 | e[13] << 8 | e[14], c = e[15];
|
|
156
|
+
return String.fromCharCode(t[r >>> 18], t[r >>> 12 & 63], t[r >>> 6 & 63], t[r & 63], t[i >>> 18], t[i >>> 12 & 63], t[i >>> 6 & 63], t[i & 63], t[a >>> 18], t[a >>> 12 & 63], t[a >>> 6 & 63], t[a & 63], t[o >>> 18], t[o >>> 12 & 63], t[o >>> 6 & 63], t[o & 63], t[s >>> 18], t[s >>> 12 & 63], t[s >>> 6 & 63], t[s & 63], t[c >>> 2], t[(c & 3) << 4 | n & 15]);
|
|
157
|
+
}
|
|
158
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
159
|
+
function writeBase32hex(e, t, n, r) {
|
|
160
|
+
let i = e[0], a = e[1], o = e[2], s = e[3], c = e[4], l = e[5], u = e[6], d = e[7], f = e[8], p = e[9], m = e[10], h = e[11], g = e[12], _ = e[13], v = e[14], y = e[15], b = t[(y & 7) << 2 | (r === 4 ? n >>> 2 & 3 : n & 3)];
|
|
161
|
+
return r === 4 ? String.fromCharCode(t[i >>> 3], t[(i & 7) << 2 | a >>> 6], t[a >>> 1 & 31], t[(a & 1) << 4 | o >>> 4], t[(o & 15) << 1 | s >>> 7], t[s >>> 2 & 31], t[(s & 3) << 3 | c >>> 5], t[c & 31], t[l >>> 3], t[(l & 7) << 2 | u >>> 6], t[u >>> 1 & 31], t[(u & 1) << 4 | d >>> 4], t[(d & 15) << 1 | f >>> 7], t[f >>> 2 & 31], t[(f & 3) << 3 | p >>> 5], t[p & 31], t[m >>> 3], t[(m & 7) << 2 | h >>> 6], t[h >>> 1 & 31], t[(h & 1) << 4 | g >>> 4], t[(g & 15) << 1 | _ >>> 7], t[_ >>> 2 & 31], t[(_ & 3) << 3 | v >>> 5], t[v & 31], t[y >>> 3], b, t[(n & 3) << 3]) : String.fromCharCode(t[i >>> 3], t[(i & 7) << 2 | a >>> 6], t[a >>> 1 & 31], t[(a & 1) << 4 | o >>> 4], t[(o & 15) << 1 | s >>> 7], t[s >>> 2 & 31], t[(s & 3) << 3 | c >>> 5], t[c & 31], t[l >>> 3], t[(l & 7) << 2 | u >>> 6], t[u >>> 1 & 31], t[(u & 1) << 4 | d >>> 4], t[(d & 15) << 1 | f >>> 7], t[f >>> 2 & 31], t[(f & 3) << 3 | p >>> 5], t[p & 31], t[m >>> 3], t[(m & 7) << 2 | h >>> 6], t[h >>> 1 & 31], t[(h & 1) << 4 | g >>> 4], t[(g & 15) << 1 | _ >>> 7], t[_ >>> 2 & 31], t[(_ & 3) << 3 | v >>> 5], t[v & 31], t[y >>> 3], b);
|
|
128
162
|
}
|
|
129
163
|
//#endregion
|
|
130
|
-
export { BASE32HEX, BASE64URL, decodeInto, encode, isEncoded, spareBits };
|
|
164
|
+
export { c as BASE32HEX, o as BASE32HEX_NAME, s as BASE64URL, i as BASE64URL_NAME, decodeInto, encode, encodePortable, isEncoded, spareBits };
|
|
131
165
|
|
|
132
166
|
//# sourceMappingURL=alphabet.js.map
|
package/dist/alphabet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alphabet.js","names":[],"sources":["../src/alphabet.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport { checkRange, UuidSlugError } from \"./errors\";\nimport type { UuidSlugErrorCode } from \"./errors\";\n\n/**\n * A power-of-two alphabet plus its reverse lookup. Encoding is pure bit packing, so the only\n * thing that varies between base64url and base32 is the character set and how many bits each\n * character carries — one routine serves both rather than two hand-unrolled loops.\n */\nexport interface Alphabet {\n readonly bitsPerChar: number;\n readonly chars: string;\n readonly code: UuidSlugErrorCode;\n /** Character code -> value, `-1` for anything outside the alphabet. */\n readonly decode: Int16Array;\n readonly name: string;\n readonly invalidChars: RegExp;\n}\n\nfunction alphabet(name: string, chars: string, code: UuidSlugErrorCode): Alphabet {\n const bitsPerChar = Math.log2(chars.length);\n if (!Number.isInteger(bitsPerChar)) throw new Error(`${name} alphabet must be a power of two.`);\n const decode = new Int16Array(128).fill(-1);\n for (let i = 0; i < chars.length; i += 1) decode[chars.charCodeAt(i)] = i;\n return {\n bitsPerChar,\n chars,\n code,\n decode,\n name,\n invalidChars: new RegExp(`[^${chars.replaceAll(\"-\", \"\\\\-\")}]`),\n };\n}\n\nexport const BASE64URL: Alphabet = alphabet(\n \"base64url\",\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\",\n \"invalid_base64url\",\n);\n\n/**\n * The RFC 4648 §7 extended-hex digit values, not the §6 alphabet and not Crockford. Chosen because\n * its characters are in ASCII order, so encoded values sort the same way the underlying bytes do —\n * the one property base64url cannot offer, and the reason a second alphabet exists at all.\n *\n * Spelled LOWERCASE where the RFC writes `0-9A-V`, matching how this package renders UUIDs, and\n * decoding accepts only that spelling so an id has exactly one form. The cost is interop: verified\n * 2026-08-12 against CPython, `base64.b32hexdecode` rejects these slugs unless called with\n * `casefold=True`. Upper-case them at the boundary if a strict RFC decoder has to read them.\n */\nexport const BASE32HEX: Alphabet = alphabet(\n \"base32hex\",\n \"0123456789abcdefghijklmnopqrstuv\",\n \"invalid_base32\",\n);\n\n// Native encoding is strict on output; decoding stays here because it must reject aliases,\n// whitespace and nonzero padding that platform decoders may accept.\nconst nativeToBase64 = (\n Uint8Array.prototype as {\n toBase64?: (options: { alphabet: \"base64url\"; omitPadding: boolean }) => string;\n }\n).toBase64;\nconst BASE64_OPTIONS = { alphabet: \"base64url\", omitPadding: true } as const;\n\n/**\n * Bits left over when `byteLength` bytes are written in this alphabet. A slug rounds up to whole\n * characters, so the final character has spare low bits that carry no data: 4 for 16 bytes in\n * base64url (22 chars = 132 bits), 2 in base32hex (26 chars = 130 bits). Callers may spend them\n * on a trailing value at zero cost in length — see `encode`.\n */\nexport function spareBits(alpha: Alphabet, byteLength: number): number {\n const bits = byteLength * 8;\n return (alpha.bitsPerChar - (bits % alpha.bitsPerChar)) % alpha.bitsPerChar;\n}\n\n/** Boolean validation needs no output buffer or diagnostic allocation. */\nexport function isEncoded(value: string, alpha: Alphabet, byteLength: number): boolean {\n if (\n value.length !== Math.ceil((byteLength * 8) / alpha.bitsPerChar) ||\n alpha.invalidChars.test(value)\n )\n return false;\n const spare = spareBits(alpha, byteLength);\n return (\n spare === 0 ||\n ((alpha.decode[value.charCodeAt(value.length - 1)] as number) & ((1 << spare) - 1)) === 0\n );\n}\n\n/**\n * Pack bytes, optionally followed by `tailBits` low bits of `tail`, into `alpha`.\n *\n * `tailBits` MUST NOT exceed `spareBits`, otherwise the result grows a character. Passing\n * `tail = 0` reproduces a plain encoding byte for byte, which is what keeps identifiers issued\n * before the tail existed valid afterwards.\n */\nexport function encode(bytes: Uint8Array, alpha: Alphabet, tail = 0, tailBits = 0): string {\n if (\n nativeToBase64 &&\n alpha === BASE64URL &&\n tailBits >= 0 &&\n tailBits <= spareBits(alpha, bytes.length)\n ) {\n const encoded = nativeToBase64.call(bytes, BASE64_OPTIONS);\n if (tailBits === 0) return encoded;\n // The native result zeroes padding. Spend only those spare low bits on the mask check;\n // replacing the final character leaves the UUID payload and the wire length unchanged.\n const last = encoded.length - 1;\n const digit = alpha.decode[encoded.charCodeAt(last)] as number;\n const trailing = (tail & ((1 << tailBits) - 1)) << (spareBits(alpha, bytes.length) - tailBits);\n return encoded.slice(0, last) + alpha.chars[digit | trailing];\n }\n const { bitsPerChar, chars } = alpha;\n const mask = (1 << bitsPerChar) - 1;\n let out = \"\";\n let acc = 0;\n let bits = 0;\n for (let i = 0; i < bytes.length; i += 1) {\n // At most bitsPerChar-1 bits are held over, so `acc` peaks at 13 bits and stays in int32.\n acc = (acc << 8) | (bytes[i] as number);\n bits += 8;\n while (bits >= bitsPerChar) {\n bits -= bitsPerChar;\n out += chars[(acc >>> bits) & mask];\n }\n }\n if (tailBits > 0) {\n acc = (acc << tailBits) | (tail & ((1 << tailBits) - 1));\n bits += tailBits;\n while (bits >= bitsPerChar) {\n bits -= bitsPerChar;\n out += chars[(acc >>> bits) & mask];\n }\n }\n if (bits > 0) out += chars[(acc << (bitsPerChar - bits)) & mask];\n return out;\n}\n\n/**\n * Inverse of `encode`, writing into a caller-owned buffer so the slug paths need no intermediate\n * allocation. Returns the trailing value (0 when `tailBits` is 0), or an Error.\n *\n * Rejects any character outside the alphabet, and any padding bit that is not zero. Without that\n * last check one identifier would have several valid spellings, so a corrupted slug could decode\n * successfully instead of being refused.\n */\nexport function decodeInto(\n value: string,\n alpha: Alphabet,\n out: Uint8Array,\n offset: number,\n byteLength: number,\n tailBits = 0,\n): UuidSlugError | number {\n const { bitsPerChar, decode: table, code, name } = alpha;\n const expected = Math.ceil((byteLength * 8 + tailBits) / bitsPerChar);\n if (value.length !== expected)\n return new UuidSlugError(code, `Expected ${expected} ${name} characters, got ${value.length}.`);\n const badRange = checkRange(out.length, offset, byteLength);\n if (badRange) return badRange;\n\n let acc = 0;\n let bits = 0;\n let written = 0;\n for (let i = 0; i < value.length; i += 1) {\n const charCode = value.charCodeAt(i);\n const digit = charCode < 128 ? (table[charCode] as number) : -1;\n if (digit < 0) return new UuidSlugError(code, `Invalid ${name} character at offset ${i}.`);\n acc = (acc << bitsPerChar) | digit;\n bits += bitsPerChar;\n while (bits >= 8 && written < byteLength) {\n bits -= 8;\n out[offset + written] = (acc >>> bits) & 0xff;\n written += 1;\n }\n }\n let tail = 0;\n if (tailBits > 0) {\n bits -= tailBits;\n tail = (acc >>> bits) & ((1 << tailBits) - 1);\n }\n if (bits > 0 && (acc & ((1 << bits) - 1)) !== 0)\n return new UuidSlugError(code, `${name} value has non-canonical trailing bits.`);\n return tail;\n}\n"],"mappings":";;;;AAoBA,SAAS,SAAS,MAAc,OAAe,MAAmC;CAChF,MAAM,cAAc,KAAK,KAAK,MAAM,MAAM;CAC1C,IAAI,CAAC,OAAO,UAAU,WAAW,GAAG,MAAM,IAAI,MAAM,GAAG,KAAK,kCAAkC;CAC9F,MAAM,0BAAS,IAAI,WAAW,GAAG,EAAA,CAAE,KAAK,EAAE;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,WAAW,CAAC,KAAK;CACxE,OAAO;EACL;EACA;EACA;EACA;EACA;EACA,cAAc,IAAI,OAAO,KAAK,MAAM,WAAW,KAAK,KAAK,EAAE,EAAE;CAC/D;AACF;AAEA,MAAa,YAAsB,SACjC,aACA,oEACA,mBACF;;;;;;;;;;;AAYA,MAAa,YAAsB,SACjC,aACA,oCACA,gBACF;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abet.js","names":["BASE32HEX_NAME","bitsPerChar","chars","decode","i","charCode","acceptUppercase","invalidCharacterPattern","BASE64URL","BASE64URL_NAME","INVALID_BASE64URL","BASE32HEX","INVALID_BASE32HEX","denoVersion","availableNativeToBase64","nativeToBase64","BASE64_OPTIONS","createLatin1Scratch","runtime","base64urlScratch","base32hexScratch","maskedBase32hexScratch","base64urlCodes","base32hexCodes","alpha","character","bits","byteLength","value","tailBits","acceptsMixedCase","spare","UuidSlugError","offset","bytes","tail","encoded","last","digit","trailing","scratch","create","codes","text","written","block","a","b","c","d","e","mask","out","acc","table","expected","code","name","badRange","digits","start","firstCode","lastCode","first","d0","d1","d2","d3","d4","d5","d6","d7","v0","v1","v2","v3","v4","v5","v6","v7","paddingCode","padding","f","g","h","j","k","l","m","n","o","p"],"sources":["../src/alphabet.ts"],"mappings":";;;;;;AASA,MAAaA,IAAiB;;AAoB9B,SAAS,SACP,GACA,GACA,GACA,IAAkB,IACR;CACV,IAAMC,IAAc,KAAK,KAAKC,EAAM,MAAM,GACpCC,qBAAS,IAAI,WAAW,GAAG,EAAA,CAAE,KAAK,EAAE;CAC1C,KAAK,IAAIC,IAAI,GAAGA,IAAIF,EAAM,QAAQ,KAAK,GAAG;EACxC,IAAMG,IAAWH,EAAM,WAAWE,CAAC;EAEnC,AADA,EAAOC,KAAYD,GACfE,KAAmBD,KAAY,MAAMA,KAAY,QAAK,EAAOA,IAAW,MAAMD;CACpF;CACA,IAAMG,IAA0B,KAAKL,EAAM,WAAW,KAAK,KAAK,EAAE;CAClE,OAAO;EACL;EACA;EACA;EACA;EACA;EACA,cAAc,IAAI,OAAOK,CAAuB;EAChD,mBAAmB,IAAI,OAAOA,GAAyBD,IAAkB,MAAM,EAAE;CACnF;AACF;AAEA,MAAaE,IAAoC,uBAC/CC,GACA,oEACAC,CACF,GAUaC,IAAoC,uBAC/CX,GACA,oCACAY,GACA,EACF,GAIMC,IAAe,WAA0D,MAAM,SAAS,MACxFC,IACJ,WAAW,UAGX,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AI,MAAM,IAAMC,MAAM,IAC9B1C,GAAQ0C,IAAI,OAAO,IAAMhF,MAAM,IAC/BsC,EAAOtC,MAAM,IAAK,KAClBsC,GAAQtC,IAAI,MAAM,IAAMiF,MAAM,IAC9B3C,EAAM2C,IAAI,KACV3C,EAAM4C,MAAM,IACZ5C,GAAQ4C,IAAI,MAAM,IAAMC,MAAM,IAC9B7C,EAAO6C,MAAM,IAAK,KAClB7C,GAAQ6C,IAAI,MAAM,IAAMC,MAAM,IAC9B9C,GAAQ8C,IAAI,OAAO,IAAMC,MAAM,IAC/B/C,EAAO+C,MAAM,IAAK,KAClB/C,GAAQ+C,IAAI,MAAM,IAAMC,MAAM,IAC9BhD,EAAMgD,IAAI,KACVhD,EAAMiD,MAAM,IACZtD,CACF;AACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
//#region src/base64url-name.d.ts
|
|
4
|
+
/** Select unpadded base64url slug output. */
|
|
5
|
+
export declare const BASE64URL_NAME = "base64url";
|
|
6
|
+
//#endregion
|
|
7
|
+
//# sourceMappingURL=base64url-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64url-name.d.ts","names":[],"sources":["../src/base64url-name.ts"],"mappings":";;;;qBAIa"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
//#region src/base64url-name.ts
|
|
4
|
+
const e = "base64url";
|
|
5
|
+
//#endregion
|
|
6
|
+
export { e as BASE64URL_NAME };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=base64url-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64url-name.js","names":["BASE64URL_NAME"],"sources":["../src/base64url-name.ts"],"mappings":";;;AAIA,MAAaA,IAAiB"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,16 +1,57 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// @anizoptera/uuid-slug 0.
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
|
-
/**
|
|
5
|
-
declare const
|
|
6
|
-
|
|
7
|
-
declare
|
|
4
|
+
/** The operation was cancelled through its `AbortSignal`. */
|
|
5
|
+
export declare const ABORTED = "aborted";
|
|
6
|
+
/** The input is not a canonical base32hex UUID slug. */
|
|
7
|
+
export declare const INVALID_BASE32HEX = "invalid_base32hex";
|
|
8
|
+
/** The input is not a canonical base64url UUID slug. */
|
|
9
|
+
export declare const INVALID_BASE64URL = "invalid_base64url";
|
|
10
|
+
/** A byte buffer or offset cannot satisfy the requested operation. */
|
|
11
|
+
export declare const INVALID_BUFFER = "invalid_buffer";
|
|
12
|
+
/** A mask is missing, malformed, or failed its reversible transform. */
|
|
13
|
+
export declare const INVALID_MASK = "invalid_mask";
|
|
14
|
+
/** An options object or one of its values is invalid. */
|
|
15
|
+
export declare const INVALID_OPTIONS = "invalid_options";
|
|
16
|
+
/** A sentinel definition is invalid or conflicts with another sentinel. */
|
|
17
|
+
export declare const INVALID_SENTINEL = "invalid_sentinel";
|
|
18
|
+
/** A timestamp is invalid or outside the selected operation's range. */
|
|
19
|
+
export declare const INVALID_TIMESTAMP = "invalid_timestamp";
|
|
20
|
+
/** The input is not valid UUID text or a valid UUID byte payload. */
|
|
21
|
+
export declare const INVALID_UUID = "invalid_uuid";
|
|
22
|
+
/** The input is not a canonical plain or codec-owned UUID slug. */
|
|
23
|
+
export declare const INVALID_UUID_SLUG = "invalid_uuid_slug";
|
|
24
|
+
/** The UUID version does not satisfy the requested operation. */
|
|
25
|
+
export declare const INVALID_UUID_VERSION = "invalid_uuid_version";
|
|
26
|
+
/** The runtime could not provide cryptographically secure random bytes. */
|
|
27
|
+
export declare const RNG_UNAVAILABLE = "rng_unavailable";
|
|
28
|
+
/** The UUIDv7 timestamp falls outside the caller's validation window. */
|
|
29
|
+
export declare const TIMESTAMP_OUTSIDE_WINDOW = "timestamp_outside_window";
|
|
30
|
+
/** One stable `UuidSlugError.code`; branch on this value and use `message` for diagnostics. */
|
|
31
|
+
export type UuidSlugErrorCode = typeof ABORTED | typeof INVALID_BASE32HEX | typeof INVALID_BASE64URL | typeof INVALID_BUFFER | typeof INVALID_MASK | typeof INVALID_OPTIONS | typeof INVALID_SENTINEL | typeof INVALID_TIMESTAMP | typeof INVALID_UUID | typeof INVALID_UUID_SLUG | typeof INVALID_UUID_VERSION | typeof RNG_UNAVAILABLE | typeof TIMESTAMP_OUTSIDE_WINDOW;
|
|
32
|
+
/**
|
|
33
|
+
* An expected failure returned by package operations. Branch on `code`; `message` explains the
|
|
34
|
+
* failed input or operation, and `cause` retains an underlying runtime or callback failure.
|
|
35
|
+
*/
|
|
36
|
+
export declare class UuidSlugError extends Error {
|
|
37
|
+
/** Stable cross-realm marker used by `isUuidSlugError` and composable package operations. */
|
|
38
|
+
readonly __failure: true;
|
|
39
|
+
/** Stable recovery category; use `message` and `cause` for diagnostics. */
|
|
8
40
|
readonly code: UuidSlugErrorCode;
|
|
41
|
+
/**
|
|
42
|
+
* Create an expected package error.
|
|
43
|
+
*
|
|
44
|
+
* @param code - Stable recovery category.
|
|
45
|
+
* @param message - Input- or operation-specific diagnostic.
|
|
46
|
+
* @param options - Standard error options; use `cause` to retain the underlying failure.
|
|
47
|
+
*/
|
|
9
48
|
constructor(code: UuidSlugErrorCode, message: string, options?: ErrorOptions);
|
|
10
49
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Narrow a returned value to `UuidSlugError`, including errors from another realm or package copy.
|
|
52
|
+
* The package marker is the primary protocol. Existing unmarked package errors use local Error
|
|
53
|
+
* identity before native or portable cross-realm recognition. This does not authenticate data.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isUuidSlugError(value: unknown): value is UuidSlugError;
|
|
14
56
|
//#endregion
|
|
15
|
-
export { UUID_SLUG_ERROR_CODES, UuidRuntimeError, UuidSlugError, UuidSlugErrorCode };
|
|
16
57
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;qBAGa;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;qBAEA;;YAGD,2BACD,iBACA,2BACA,2BACA,wBACA,sBACA,yBACA,0BACA,2BACA,sBACA,2BACA,8BACA,yBACA;;;;;qBAwDE,sBAAsB;;WAEhB;;WAER,MAAM;;;;;;;;EASf,YAAY,MAAM,mBAAmB,iBAAiB,UAAU;;;;;;;wBAqClD,gBAAgB,iBAAiB,SAAS"}
|