@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/errors.js
CHANGED
|
@@ -1,80 +1,162 @@
|
|
|
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.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
const e = "aborted", t = "invalid_base32hex", n = "invalid_base64url", r = "invalid_buffer", i = "invalid_mask", a = "invalid_options", o = "invalid_sentinel", s = "invalid_timestamp", c = "invalid_uuid", l = "invalid_uuid_slug", u = "invalid_uuid_version", d = "rng_unavailable", f = "timestamp_outside_window", p = /*#__PURE__*/ Object.freeze([
|
|
5
|
+
e,
|
|
6
|
+
t,
|
|
7
|
+
n,
|
|
8
|
+
r,
|
|
9
|
+
i,
|
|
10
|
+
a,
|
|
11
|
+
o,
|
|
12
|
+
s,
|
|
13
|
+
c,
|
|
14
|
+
l,
|
|
15
|
+
u,
|
|
16
|
+
d,
|
|
17
|
+
f
|
|
18
|
+
]), m = /*#__PURE__*/ new Set(p), h = "UuidSlugError", g = "__failure", _ = "object", v = "byteLength", y = "Random byte generation failed.", b = Error.isError, x = /*#__PURE__*/ Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag), S = /*#__PURE__*/ Object.getOwnPropertyDescriptor(DataView.prototype, v), C = /*#__PURE__*/ Object.getOwnPropertyDescriptor(DataView.prototype, "byteOffset"), w = /*#__PURE__*/ Object.getOwnPropertyDescriptor(DataView.prototype, "buffer"), T = /*#__PURE__*/ Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, v);
|
|
18
19
|
var UuidSlugError = class extends Error {
|
|
19
20
|
code;
|
|
20
|
-
constructor(
|
|
21
|
-
super(
|
|
22
|
-
this.name = "UuidSlugError";
|
|
23
|
-
this.code = code;
|
|
21
|
+
constructor(e, t, n) {
|
|
22
|
+
super(t, n), this.name = h, this.code = e;
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
Object.defineProperty(UuidSlugError.prototype, g, { value: !0 });
|
|
26
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
27
|
+
function hasErrorBrand(e) {
|
|
28
|
+
try {
|
|
29
|
+
if (e instanceof Error) return !0;
|
|
30
|
+
} catch {}
|
|
31
|
+
try {
|
|
32
|
+
return b ? b(e) : Object.prototype.toString.call(e) === "[object Error]";
|
|
33
|
+
} catch {
|
|
34
|
+
return !1;
|
|
30
35
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
return value;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The one range check for every entry point that reads or writes a caller's buffer at an offset.
|
|
44
|
-
*
|
|
45
|
-
* `Number.isInteger` is the load-bearing half and the reason this is shared rather than repeated.
|
|
46
|
-
* The obvious spelling — `offset < 0 || offset + need > capacity` — passes a fractional or
|
|
47
|
-
* NaN offset, because both of its comparisons are false for NaN and neither notices `0.5`. What
|
|
48
|
-
* follows is worse than a wrong answer: `bytes[0.5] = x` is not a store, so the write SILENTLY does
|
|
49
|
-
* nothing while the guard reports success, and an id can come back half-written with the caller's
|
|
50
|
-
* stale bytes in the rest of it. A string offset defeats the same test from the other side, by
|
|
51
|
-
* concatenation: `"4" + 16` is `"416"`, which is not greater than any plausible length.
|
|
52
|
-
*
|
|
53
|
-
* Seven near-identical copies of that test existed across this package and not one checked
|
|
54
|
-
* integrality — the copying is why. One copy is what stops the class returning.
|
|
55
|
-
*/
|
|
56
|
-
function checkRange(capacity, offset, need) {
|
|
57
|
-
if (!Number.isInteger(offset)) return new UuidSlugError("invalid_buffer", `Buffer offset must be a whole number, got ${typeof offset} ${String(offset)}.`);
|
|
58
|
-
if (offset < 0 || offset + need > capacity) return new UuidSlugError("invalid_buffer", `Buffer needs ${need} bytes at offset ${offset}, but holds ${capacity}.`);
|
|
59
|
-
}
|
|
60
|
-
/** Preserve failures from an injected or platform entropy source without changing successful draws. */
|
|
61
|
-
function fillRandomBytes(fill, bytes) {
|
|
36
|
+
}
|
|
37
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
38
|
+
function isUuidSlugError(e) {
|
|
39
|
+
if (typeof e != _ || e === null) return !1;
|
|
40
|
+
let t = e;
|
|
41
|
+
try {
|
|
42
|
+
if (t.__failure === !0) return !0;
|
|
43
|
+
} catch {}
|
|
44
|
+
if (!/* @__PURE__ */ hasErrorBrand(t)) return !1;
|
|
62
45
|
try {
|
|
63
|
-
|
|
46
|
+
return Reflect.get(t, "name") === h && m.has(Reflect.get(t, "code"));
|
|
47
|
+
} catch {
|
|
48
|
+
return !1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
52
|
+
function exactLocalUuidBytes(e) {
|
|
53
|
+
try {
|
|
54
|
+
return e instanceof Uint8Array && e.length === 16 ? e : void 0;
|
|
55
|
+
} catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
60
|
+
function isError(e) {
|
|
61
|
+
return typeof e != _ || e === null ? !1 : /* @__PURE__ */ hasErrorBrand(e);
|
|
62
|
+
}
|
|
63
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
64
|
+
function isTagged(e, t) {
|
|
65
|
+
return Object.prototype.toString.call(e) === t || typeof e == "object" && !!e && Object.hasOwn(e, Symbol.toStringTag);
|
|
66
|
+
}
|
|
67
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
68
|
+
function stringInput(e) {
|
|
69
|
+
if (typeof e == "string") return e;
|
|
70
|
+
if (typeof e == "object" && e) try {
|
|
71
|
+
return String.prototype.valueOf.call(e);
|
|
72
|
+
} catch {
|
|
64
73
|
return;
|
|
65
|
-
} catch (cause) {
|
|
66
|
-
return new UuidRuntimeError("Random byte generation failed.", { cause });
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
function normalizeUuidStringInput(e) {
|
|
77
|
+
return typeof e == "string" ? e : /* @__PURE__ */ stringInput(e) ?? /* @__PURE__ */ invalidUuidStringInput(e);
|
|
78
|
+
}
|
|
79
|
+
function normalizeUuidSlugInput(e) {
|
|
80
|
+
return typeof e == "string" ? e : /* @__PURE__ */ stringInput(e) ?? /* @__PURE__ */ invalidUuidSlugInput(e);
|
|
81
|
+
}
|
|
82
|
+
function diagnosticValue(e) {
|
|
83
|
+
return typeof e == "string" ? e : typeof e == "number" || typeof e == "bigint" || typeof e == "boolean" || typeof e == "symbol" ? String(e) : e === null ? "null" : typeof e;
|
|
84
|
+
}
|
|
85
|
+
function isPlainRecord(e) {
|
|
86
|
+
if (Array.isArray(e)) return !1;
|
|
87
|
+
let t = Object.getPrototypeOf(e);
|
|
88
|
+
return t === null || Object.getPrototypeOf(t) === null;
|
|
89
|
+
}
|
|
90
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
91
|
+
function isUint8Array(e) {
|
|
92
|
+
return ArrayBuffer.isView(e) && (e instanceof Uint8Array || x?.get?.call(e) === "Uint8Array");
|
|
93
|
+
}
|
|
94
|
+
function isSuccessfulUuidBytes(e) {
|
|
95
|
+
if (!ArrayBuffer.isView(e)) return !1;
|
|
96
|
+
try {
|
|
97
|
+
return e[g] !== !0;
|
|
98
|
+
} catch {
|
|
99
|
+
return !0;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function uuidByteView(e) {
|
|
103
|
+
if (/* @__PURE__ */ isUint8Array(e)) return e;
|
|
104
|
+
try {
|
|
105
|
+
if (ArrayBuffer.isView(e) && (e instanceof DataView || /* @__PURE__ */ isTagged(e, "[object DataView]")) && S?.get?.call(e) !== void 0) return new Uint8Array(w?.get?.call(e), C?.get?.call(e), S.get.call(e));
|
|
106
|
+
if ((e instanceof ArrayBuffer || /* @__PURE__ */ isTagged(e, "[object ArrayBuffer]")) && T?.get?.call(e) !== void 0) return new Uint8Array(e);
|
|
107
|
+
} catch {}
|
|
108
|
+
}
|
|
109
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
110
|
+
function findUnknownOption(e, t) {
|
|
111
|
+
for (let n of Object.keys(e)) if (!Object.hasOwn(t, n)) return n;
|
|
112
|
+
}
|
|
113
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
114
|
+
function checkRange(e, t, n) {
|
|
115
|
+
if (!Number.isInteger(t)) return new UuidSlugError(r, `Buffer offset must be a whole number, got ${typeof t} ${diagnosticValue(t)}.`);
|
|
116
|
+
if (t < 0 || t + n > e) return new UuidSlugError(r, `Buffer needs ${n} bytes at offset ${t}, but holds ${e}.`);
|
|
117
|
+
}
|
|
118
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
119
|
+
function checkByteRange(e, t, n) {
|
|
120
|
+
return /* @__PURE__ */ isUint8Array(e) ? /* @__PURE__ */ checkRange(e.length, t, n) : /* @__PURE__ */ isUuidSlugError(e) ? e : new UuidSlugError(r, "Buffer must be a Uint8Array.");
|
|
121
|
+
}
|
|
122
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
123
|
+
function invalidUuidStringInput(e) {
|
|
124
|
+
return /* @__PURE__ */ isUuidSlugError(e) ? e : new UuidSlugError(c, "UUID must be text.");
|
|
125
|
+
}
|
|
126
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
127
|
+
function invalidUuidSlugInput(e) {
|
|
128
|
+
return /* @__PURE__ */ isUuidSlugError(e) ? e : new UuidSlugError(l, "UUID slug must be a string.");
|
|
129
|
+
}
|
|
130
|
+
const randomFailure = /* @__NO_SIDE_EFFECTS__ */ (e) => {
|
|
131
|
+
if (e !== void 0) return /* @__PURE__ */ isUuidSlugError(e) ? e : /* @__PURE__ */ isError(e) ? new UuidSlugError(d, y, { cause: e }) : void 0;
|
|
132
|
+
};
|
|
133
|
+
function fillRandomBytes(e, t) {
|
|
134
|
+
try {
|
|
135
|
+
return /* @__PURE__ */ randomFailure(e(t));
|
|
136
|
+
} catch (e) {
|
|
137
|
+
return new UuidSlugError(d, y, { cause: e });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function generatedOrThrow(e) {
|
|
141
|
+
if (e instanceof Error) throw e;
|
|
142
|
+
return e;
|
|
143
|
+
}
|
|
144
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
145
|
+
function failedFallback(e, t, n) {
|
|
146
|
+
return new UuidSlugError(t.code, t.message, { cause: AggregateError([e, t], n) });
|
|
147
|
+
}
|
|
148
|
+
function portableAfterNative(e, t, n, r) {
|
|
149
|
+
let i = t(n);
|
|
150
|
+
return i instanceof Error ? /* @__PURE__ */ failedFallback(e, i, `Native and portable ${r} failed.`) : i;
|
|
151
|
+
}
|
|
152
|
+
function readClock(e) {
|
|
71
153
|
try {
|
|
72
|
-
return
|
|
73
|
-
} catch (
|
|
74
|
-
return new UuidSlugError(
|
|
154
|
+
return e();
|
|
155
|
+
} catch (e) {
|
|
156
|
+
return new UuidSlugError(s, "Clock reading failed.", { cause: e });
|
|
75
157
|
}
|
|
76
158
|
}
|
|
77
159
|
//#endregion
|
|
78
|
-
export {
|
|
160
|
+
export { e as ABORTED, p as ERROR_CODES, g as ERROR_MARKER, t as INVALID_BASE32HEX, n as INVALID_BASE64URL, r as INVALID_BUFFER, i as INVALID_MASK, a as INVALID_OPTIONS, o as INVALID_SENTINEL, s as INVALID_TIMESTAMP, c as INVALID_UUID, l as INVALID_UUID_SLUG, u as INVALID_UUID_VERSION, d as RNG_UNAVAILABLE, f as TIMESTAMP_OUTSIDE_WINDOW, UuidSlugError, checkByteRange, checkRange, diagnosticValue, exactLocalUuidBytes, failedFallback, fillRandomBytes, findUnknownOption, generatedOrThrow, invalidUuidSlugInput, invalidUuidStringInput, isError, isPlainRecord, isSuccessfulUuidBytes, isUint8Array, isUuidSlugError, normalizeUuidSlugInput, normalizeUuidStringInput, portableAfterNative, randomFailure, readClock, stringInput, uuidByteView };
|
|
79
161
|
|
|
80
162
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[
|
|
1
|
+
{"version":3,"file":"errors.js","names":["ABORTED","INVALID_BASE32HEX","INVALID_BASE64URL","INVALID_BUFFER","INVALID_MASK","INVALID_OPTIONS","INVALID_SENTINEL","INVALID_TIMESTAMP","INVALID_UUID","INVALID_UUID_SLUG","INVALID_UUID_VERSION","RNG_UNAVAILABLE","TIMESTAMP_OUTSIDE_WINDOW","ERROR_CODES","ERROR_CODE_SET","ERROR_NAME","ERROR_MARKER","OBJECT_TYPE","BYTE_LENGTH_PROPERTY","RANDOM_FAILURE_MESSAGE","nativeIsError","typedArrayTagDescriptor","dataViewByteLengthDescriptor","dataViewByteOffsetDescriptor","dataViewBufferDescriptor","arrayBufferByteLengthDescriptor","message","options","code","candidate","value","\"__failure\"","tag","prototype","option","accepted","offset","need","capacity","bytes","fill","cause","result","fallback","nativeCause","fallbackArgument","operation","clock"],"sources":["../src/errors.ts"],"mappings":";;;AAGA,MAAaA,IAAU,WAEVC,IAAoB,qBAEpBC,IAAoB,qBAEpBC,IAAiB,kBAEjBC,IAAe,gBAEfC,IAAkB,mBAElBC,IAAmB,oBAEnBC,IAAoB,qBAEpBC,IAAe,gBAEfC,IAAoB,qBAEpBC,IAAuB,wBAEvBC,IAAkB,mBAElBC,IAA2B,4BAkB3BC,IAA0D,qBAAO,OAAO;CACnFb;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;AACF,CAAC,GAEKE,kBAAqD,IAAI,IAAID,CAAW,GACxEE,IAAa,iBAENC,IAAe,aACtBC,IAAc,UAIdC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;AAC9F;;AAIA,SAAgB,qBAAqB,GAA+B;CAClE,OAAO,gCAAgBsB,CAAK,IACxBA,IACA,IAAI,cAAcrB,GAAmB,6BAA6B;AACxE;AAGA,MAAa,4CACX,MAC8B;CAC9B,IAAIqB,MAAU,KAAA,GAEd,OADI,gCAAgBA,CAAK,IAAUA,IAC5B,wBAAQA,CAAK,IAChB,IAAI,cAAcnB,GAAiBQ,GAAwB,EAAE,OAAOW,EAAM,CAAC,IAC3E,KAAA;AACN;AAEA,SAAgB,gBACd,GACA,GAC2B;CAC3B,IAAI;EACF,OAAO,8BAAcU,EAAKD,CAAK,CAAC;CAClC,SAASE,GAAO;EACd,OAAO,IAAI,cAAc9B,GAAiBQ,GAAwB,EAAE,SAAM,CAAC;CAC7E;AACF;AAOA,SAAgB,iBAAwB,GAAsC;CAC5E,IAAIuB,aAAkB,OAAO,MAAMA;CACnC,OAAOA;AACT;;AAIA,SAAgB,eACd,GACA,GACA,GACe;CACf,OAAO,IAAI,cAAcC,EAAS,MAAMA,EAAS,SAAS,EACxD,OAAW,eAAe,CAACC,GAAaD,CAAQ,GAAGjB,CAAO,EAC5D,CAAC;AACH;AAGA,SAAgB,oBACd,GACA,GACA,GACA,GACwB;CACxB,IAAMgB,IAASC,EAASE,CAAgB;CACxC,OAAOH,aAAkB,QACrB,+BAAeE,GAAaF,GAAQ,uBAAuBI,EAAU,SAAS,IAC9EJ;AACN;AAGA,SAAgB,UAAU,GAA6C;CACrE,IAAI;EACF,OAAOK,EAAM;CACf,SAASN,GAAO;EACd,OAAO,IAAI,cAAclC,GAAmB,yBAAyB,EAAE,SAAM,CAAC;CAChF;AACF"}
|
package/dist/feistel.js
CHANGED
|
@@ -1,103 +1,37 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// @anizoptera/uuid-slug 0.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* Why a Feistel rather than the byte permutation plus XOR it replaces: that construction is a
|
|
9
|
-
* monoalphabetic substitution — one output byte per input byte — so bytes the inputs share, the
|
|
10
|
-
* outputs share too. Measured over 3000 ids, masked slugs of UUIDv7s created in the same second
|
|
11
|
-
* held 4 of 16 bytes constant, the same hour 3, the same day 2. The timestamp the mask exists to
|
|
12
|
-
* hide was still legible in the output. A Feistel diffuses every input bit across the whole
|
|
13
|
-
* block, so no output byte is a function of one input byte: the same measurement yields 0 of 16.
|
|
14
|
-
*
|
|
15
|
-
* The bijection is the property being bought, and it holds whatever the round function does: 16
|
|
16
|
-
* bytes map to 16 bytes and the inverse is the same routine with the round keys reversed, so
|
|
17
|
-
* `mask` and `unmask` cannot drift apart.
|
|
18
|
-
*
|
|
19
|
-
* The round function is HalfSipHash-2-4 keyed per round. What that fixes: the previous round
|
|
20
|
-
* function was `mix32(word ^ roundKey)` — a FIXED, PUBLIC, UNKEYED bijection with the key merely
|
|
21
|
-
* XORed in front, so an attacker inverts it and reads `word ^ roundKey` directly. Luby-Rackoff
|
|
22
|
-
* makes a four-round Feistel a strong pseudorandom permutation only when the round functions are
|
|
23
|
-
* pseudorandom functions, which `mix32` is not, so the theorem said nothing about what shipped and
|
|
24
|
-
* an earlier version of this comment cited it wrongly. A keyed PRF meets that hypothesis in kind,
|
|
25
|
-
* which is what makes ROUNDS = 4 a justified number rather than an unexamined margin. It is still
|
|
26
|
-
* NOT a proof about what ships: the theorem wants four INDEPENDENTLY sampled round functions, and
|
|
27
|
-
* `schema.ts` derives all four key pairs from one 128-bit key. Read it as the design rationale it
|
|
28
|
-
* is, and see `docs/design.md` for what masking does and does not promise.
|
|
29
|
-
*
|
|
30
|
-
* Measured 2026-08-12 on Bun, both directions, medians of 9: the swap costs 2.5x on the mixing step
|
|
31
|
-
* alone (30.85M -> 12.43M mixes/s) and about a quarter of end-to-end masking throughput, because
|
|
32
|
-
* mixing is roughly a fifth of a mask. HalfSipHash is FASTER per round than `mix32` — pure
|
|
33
|
-
* add/xor/rotate against two `Math.imul` calls — and loses only by doing 14 rounds where the old
|
|
34
|
-
* function did the equivalent of 4.
|
|
35
|
-
*
|
|
36
|
-
* Nor does any measurement in this repository grade the round count or the round function. Strict
|
|
37
|
-
* avalanche across all input/output bit pairs, a same-millisecond burst where only a 12-bit counter
|
|
38
|
-
* varies, and a single-difference differential all PASS a TWO-round network, so none of them can
|
|
39
|
-
* separate a weak setting from a strong one. Their agreement is evidence about the instruments.
|
|
40
|
-
* `test/siphash.test.ts` is the exception and the reason a published primitive was worth taking:
|
|
41
|
-
* it checks the round function against 64 vectors somebody else computed, and that CAN fail.
|
|
42
|
-
*/
|
|
43
|
-
/**
|
|
44
|
-
* Round count. Wire-format-bearing: changing it changes every masked slug this package has ever
|
|
45
|
-
* issued, so it moves only alongside a deliberate format change. Four is Luby-Rackoff's number,
|
|
46
|
-
* which the round function now makes relevant — see the note above for why that is a rationale
|
|
47
|
-
* rather than a proof.
|
|
48
|
-
*/
|
|
49
|
-
const ROUNDS = 4;
|
|
50
|
-
/**
|
|
51
|
-
* The `lowbias32` finalizer: an integer hash with near-ideal avalanche for its size. No longer the
|
|
52
|
-
* round function — see above — but still what `mask.ts` derives its check tag with, where the input
|
|
53
|
-
* is public and an unkeyed mixer is the right tool.
|
|
54
|
-
*/
|
|
55
|
-
function mix32(value) {
|
|
56
|
-
let x = (value ^ value >>> 16) >>> 0;
|
|
57
|
-
x = Math.imul(x, 2146121005);
|
|
58
|
-
x = (x ^ x >>> 15) >>> 0;
|
|
59
|
-
x = Math.imul(x, 2221713035);
|
|
60
|
-
return (x ^ x >>> 16) >>> 0;
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
4
|
+
function mix32(e) {
|
|
5
|
+
let t = (e ^ e >>> 16) >>> 0;
|
|
6
|
+
return t = Math.imul(t, 2146121005), t = (t ^ t >>> 15) >>> 0, t = Math.imul(t, 2221713035), (t ^ t >>> 16) >>> 0;
|
|
61
7
|
}
|
|
62
|
-
|
|
63
|
-
function read32(
|
|
64
|
-
return
|
|
8
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
9
|
+
function read32(e, t) {
|
|
10
|
+
return e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3];
|
|
65
11
|
}
|
|
66
|
-
function write32(
|
|
67
|
-
|
|
68
|
-
bytes[offset + 1] = value >>> 16 & 255;
|
|
69
|
-
bytes[offset + 2] = value >>> 8 & 255;
|
|
70
|
-
bytes[offset + 3] = value & 255;
|
|
12
|
+
function write32(e, t, n) {
|
|
13
|
+
e[t] = n >>> 24, e[t + 1] = n >>> 16 & 255, e[t + 2] = n >>> 8 & 255, e[t + 3] = n & 255;
|
|
71
14
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const next0 = left0 ^ roundOutput[0];
|
|
91
|
-
const next1 = left1 ^ roundOutput[1];
|
|
92
|
-
left0 = right0;
|
|
93
|
-
left1 = right1;
|
|
94
|
-
right0 = next0;
|
|
95
|
-
right1 = next1;
|
|
15
|
+
function feistel16(e, t, n, r, i, a) {
|
|
16
|
+
let o = /* @__PURE__ */ read32(e, t), s = /* @__PURE__ */ read32(e, t + 4), c = /* @__PURE__ */ read32(e, t + 8), l = /* @__PURE__ */ read32(e, t + 12);
|
|
17
|
+
for (let e = 0; e < 4; e += 1) {
|
|
18
|
+
let t = (r === "mask" ? e : 3 - e) * 2, i = n[t], a = n[t + 1], u = i | 0, d = a ^ 238, f = i ^ 1819895653, p = a ^ 1952801890;
|
|
19
|
+
for (let e = 0; e < 3; e += 1) {
|
|
20
|
+
let t = e === 0 ? c : e === 1 ? l : 8 << 24;
|
|
21
|
+
p ^= t;
|
|
22
|
+
for (let e = 0; e < 2; e += 1) u = u + d | 0, d = d << 5 | d >>> 27, d ^= u, u = u << 16 | u >>> 16, f = f + p | 0, p = p << 8 | p >>> 24, p ^= f, u = u + p | 0, p = p << 7 | p >>> 25, p ^= u, f = f + d | 0, d = d << 13 | d >>> 19, d ^= f, f = f << 16 | f >>> 16;
|
|
23
|
+
u ^= t;
|
|
24
|
+
}
|
|
25
|
+
f ^= 238;
|
|
26
|
+
let m = 0;
|
|
27
|
+
for (let e = 0; e < 2; e += 1) {
|
|
28
|
+
for (let e = 0; e < 4; e += 1) u = u + d | 0, d = d << 5 | d >>> 27, d ^= u, u = u << 16 | u >>> 16, f = f + p | 0, p = p << 8 | p >>> 24, p ^= f, u = u + p | 0, p = p << 7 | p >>> 25, p ^= u, f = f + d | 0, d = d << 13 | d >>> 19, d ^= f, f = f << 16 | f >>> 16;
|
|
29
|
+
e === 0 && (m = d ^ p, d ^= 221);
|
|
30
|
+
}
|
|
31
|
+
let h = o ^ m, g = s ^ d ^ p;
|
|
32
|
+
o = c, s = l, c = h, l = g;
|
|
96
33
|
}
|
|
97
|
-
write32(
|
|
98
|
-
write32(output, outputOffset + 4, right1);
|
|
99
|
-
write32(output, outputOffset + 8, left0);
|
|
100
|
-
write32(output, outputOffset + 12, left1);
|
|
34
|
+
write32(i, a, c), write32(i, a + 4, l), write32(i, a + 8, o), write32(i, a + 12, s);
|
|
101
35
|
}
|
|
102
36
|
//#endregion
|
|
103
37
|
export { feistel16, mix32, read32 };
|
package/dist/feistel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feistel.js","names":[
|
|
1
|
+
{"version":3,"file":"feistel.js","names":["x","value","bytes","offset","left0","input","inputOffset","left1","right0","right1","round","key","direction","key0","keys","key1","v0","v1","v2","v3","block","m","sipRound","hash0","half","next0","next1","output","outputOffset"],"sources":["../src/feistel.ts"],"mappings":";;;AAuBA,SAAg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-2.0
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { INVALID_OPTIONS as e, UuidSlugError as t, findUnknownOption as n, isPlainRecord as r } from "./errors.js";
|
|
4
|
+
//#region src/generation-options.ts
|
|
5
|
+
function readGenerationOptions(i, a, o) {
|
|
6
|
+
if (typeof i != "object" || !i) return new t(e, `${o} options must be a plain object.`);
|
|
7
|
+
try {
|
|
8
|
+
if (!r(i)) return new t(e, `${o} options must be a plain object.`);
|
|
9
|
+
let s = /* @__PURE__ */ n(i, a);
|
|
10
|
+
if (s !== void 0) return new t(e, `Unknown ${o} option: ${s}.`);
|
|
11
|
+
let c = i, l = {};
|
|
12
|
+
return a.alphabet && Object.hasOwn(c, "alphabet") && (l.alphabet = c.alphabet), a.at && Object.hasOwn(c, "at") && (l.at = c.at), a.generator && Object.hasOwn(c, "generator") && (l.generator = c.generator), a.maskingCodec && Object.hasOwn(c, "maskingCodec") && (l.maskingCodec = c.maskingCodec), a.output && Object.hasOwn(c, "output") && (l.output = c.output), a.outputOffset && Object.hasOwn(c, "outputOffset") && (l.outputOffset = c.outputOffset), a.textCase && Object.hasOwn(c, "textCase") && (l.textCase = c.textCase), l;
|
|
13
|
+
} catch (n) {
|
|
14
|
+
return new t(e, `Reading ${o} options failed.`, { cause: n });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { readGenerationOptions };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=generation-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-options.js","names":["options","UuidSlugError","INVALID_OPTIONS","operation","isPlainRecord","unknown","accepted","source","values","cause"],"sources":["../src/generation-options.ts"],"mappings":";;;;AAeA,SAAgB,sBACd,GACA,GACA,GACwC;CACxC,IAAwB,OAAOA,KAAY,aAAvCA,GACF,OAAO,IAAIC,EAAcC,GAAiB,GAAGC,EAAU,iCAAiC;CAC1F,IAAI;EACF,IAAI,CAACC,EAAcJ,CAAO,GACxB,OAAO,IAAIC,EAAcC,GAAiB,GAAGC,EAAU,iCAAiC;EAC1F,IAAME,IAAU,kBAAkBL,GAASM,CAAQ;EACnD,IAAID,MAAY,KAAA,GACd,OAAO,IAAIJ,EAAcC,GAAiB,WAAWC,EAAU,WAAWE,EAAQ,EAAE;EACtF,IAAME,IAASP,GAITQ,IAAuE,CAAC;EAW9E,OAVIF,EAAS,YAAY,OAAO,OAAOC,GAAQ,UAAU,MAAG,EAAO,WAAWA,EAAO,WACjFD,EAAS,MAAM,OAAO,OAAOC,GAAQ,IAAI,MAAG,EAAO,KAAKA,EAAO,KAC/DD,EAAS,aAAa,OAAO,OAAOC,GAAQ,WAAW,MACzD,EAAO,YAAYA,EAAO,YACxBD,EAAS,gBAAgB,OAAO,OAAOC,GAAQ,cAAc,MAC/D,EAAO,eAAeA,EAAO,eAC3BD,EAAS,UAAU,OAAO,OAAOC,GAAQ,QAAQ,MAAG,EAAO,SAASA,EAAO,SAC3ED,EAAS,gBAAgB,OAAO,OAAOC,GAAQ,cAAc,MAC/D,EAAO,eAAeA,EAAO,eAC3BD,EAAS,YAAY,OAAO,OAAOC,GAAQ,UAAU,MAAG,EAAO,WAAWA,EAAO,WAC9EC;CACT,SAASC,GAAO;EACd,OAAO,IAAIR,EAAcC,GAAiB,WAAWC,EAAU,mBAAmB,EAAE,SAAM,CAAC;CAC7F;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// @anizoptera/uuid-slug 0.
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { ABORTED, INVALID_BASE32HEX, INVALID_BASE64URL, INVALID_BUFFER, INVALID_MASK, INVALID_OPTIONS, INVALID_SENTINEL, INVALID_TIMESTAMP, INVALID_UUID, INVALID_UUID_SLUG, INVALID_UUID_VERSION, RNG_UNAVAILABLE, TIMESTAMP_OUTSIDE_WINDOW, UuidSlugError, UuidSlugErrorCode, isUuidSlugError } from "./errors.js";
|
|
4
|
+
import { BASE64URL_NAME } from "./base64url-name.js";
|
|
5
|
+
import { BASE32HEX_NAME } from "./alphabet.js";
|
|
6
|
+
import { SlugAlphabet, extractUuidV7Payload, extractUuidV7UnixMs, extractUuidVersion, isPlainUuidSlug, isPlainUuidV4Slug, isPlainUuidV7Slug, plainSlugToUuidBytes, plainSlugToUuidString, uuidBytesToPlainSlug, uuidStringToPlainSlug, uuidToBytes, uuidToPlainSlug, uuidToString, validatePlainUuidV7SlugUnixMs } from "./slug.js";
|
|
7
|
+
import { UuidV7MaskingCodec, UuidV7MaskingCodecOptions, UuidV7PreviousMask } from "./masking-codec-types.js";
|
|
8
|
+
import { AsyncUuidV7MaskOptions, CustomUuidV7MaskOptions, FIXED_MASK_FORMAT, GeneratePlainUuidV7SlugOptions, GenerateUuidV7BytesIntoOptions, GenerateUuidV7BytesOptions, GenerateUuidV7Options, GenerateUuidV7WithMaskedSlugOptions, GenerateUuidV7WithPlainSlugOptions, GeneratedUuidV7, MaskedOrSentinelUuidV7Slug, MaskedUuidV7Slug, PLAIN_SLUG_FORMAT, PlainUuidSlug, PlainUuidSlugResult, PlainUuidV4Slug, PlainUuidV7Slug, SEEDED_MASK_FORMAT, SentinelUuidV7Slug, UUID_TEXT_LOWERCASE, UUID_TEXT_UPPERCASE, UUID_V7_ROLLBACK_ERROR, UUID_V7_ROLLBACK_PRESERVE, UUID_V7_ROLLBACK_RESET, UUID_VARIANT_FUTURE, UUID_VARIANT_MICROSOFT, UUID_VARIANT_NCS, UUID_VARIANT_RFC, UppercaseUuidString, UppercaseUuidV4String, UppercaseUuidV7String, Uuid, UuidByteInput, UuidBytes, UuidBytesResult, UuidInput, UuidInspection, UuidRandomFill, UuidSlugMigrationDecoder, UuidSlugMigrationFormat, UuidSlugMigrationOptions, UuidString, UuidStringFor, UuidStringResult, UuidText, UuidTextCase, UuidV4Bytes, UuidV4String, UuidV4StringFor, UuidV4Text, UuidV7Bounds, UuidV7Bytes, UuidV7ClockRollbackPolicy, UuidV7Generator, UuidV7GeneratorValueOptions, UuidV7Instant, UuidV7Mask, UuidV7MaskOptions, UuidV7MaskingCodecValueOptions, UuidV7Payload, UuidV7PayloadLayout, UuidV7Sentinel, UuidV7SentinelConfig, UuidV7String, UuidV7StringFor, UuidV7Text, UuidV7TimestampWindow, UuidV7ValueOptions, UuidVariant, UuidVersion } from "./types.js";
|
|
9
|
+
import { createUuidV7MaskingCodec } from "./masking-codec.js";
|
|
10
|
+
import { MAX_MASKED_UUID_V7_TIMESTAMP_OFFSET_MS } from "./payload.js";
|
|
11
|
+
import { validateUuidV7StringUnixMs } from "./timestamp.js";
|
|
12
|
+
import { UUID_V7_TEST_MASK, deriveUuidV7Mask, deriveUuidV7MaskAsync } from "./mask.js";
|
|
13
|
+
import { createCustomUuidV7Mask } from "./mask-handle.js";
|
|
14
|
+
import { uuidV7ByteBounds, uuidV7StringBounds } from "./v7-bounds.js";
|
|
15
|
+
import { MAX_UUID, NIL_UUID, bytesToUuidString, isUuidBytes, isUuidString, isUuidText, isUuidV4Bytes, isUuidV4String, isUuidV4Text, isUuidV7Bytes, isUuidV7String, isUuidV7Text, uuidStringToBytes } from "./uuid.js";
|
|
16
|
+
import { parseUuid } from "./uuid-value.js";
|
|
17
|
+
import { UuidV7GeneratorOptions, createUuidV7Generator, createUuidV7GeneratorWithRandomFill } from "./v7-generator.js";
|
|
18
|
+
import { generateUuidV4, generateUuidV4Bytes, generateUuidV4WithRandomFill } from "./v4.js";
|
|
19
|
+
import { generateUuidV7, generateUuidV7Bytes } from "./v7-keyless.js";
|
|
20
|
+
import { generateUuidV7Value } from "./v7-value.js";
|
|
21
|
+
import { generatePlainUuidV4Slug } from "./v4-slug.js";
|
|
22
|
+
import { generatePlainUuidV7Slug, generateUuidV7WithPlainSlug } from "./v7-slug.js";
|
|
23
|
+
export { ABORTED, type AsyncUuidV7MaskOptions, BASE32HEX_NAME as BASE32HEX, BASE64URL_NAME as BASE64URL, type CustomUuidV7MaskOptions, FIXED_MASK_FORMAT, type GeneratePlainUuidV7SlugOptions, type GenerateUuidV7BytesIntoOptions, type GenerateUuidV7BytesOptions, type GenerateUuidV7Options, type GenerateUuidV7WithMaskedSlugOptions, type GenerateUuidV7WithPlainSlugOptions, type GeneratedUuidV7, INVALID_BASE32HEX, INVALID_BASE64URL, INVALID_BUFFER, INVALID_MASK, INVALID_OPTIONS, INVALID_SENTINEL, INVALID_TIMESTAMP, INVALID_UUID, INVALID_UUID_SLUG, INVALID_UUID_VERSION, MAX_MASKED_UUID_V7_TIMESTAMP_OFFSET_MS, MAX_UUID, type MaskedOrSentinelUuidV7Slug, type MaskedUuidV7Slug, NIL_UUID, PLAIN_SLUG_FORMAT, type PlainUuidSlug, type PlainUuidSlugResult, type PlainUuidV4Slug, type PlainUuidV7Slug, RNG_UNAVAILABLE, SEEDED_MASK_FORMAT, type SentinelUuidV7Slug, type SlugAlphabet, TIMESTAMP_OUTSIDE_WINDOW, UUID_TEXT_LOWERCASE, UUID_TEXT_UPPERCASE, UUID_V7_ROLLBACK_ERROR, UUID_V7_ROLLBACK_PRESERVE, UUID_V7_ROLLBACK_RESET, UUID_V7_TEST_MASK, UUID_VARIANT_FUTURE, UUID_VARIANT_MICROSOFT, UUID_VARIANT_NCS, UUID_VARIANT_RFC, type UppercaseUuidString, type UppercaseUuidV4String, type UppercaseUuidV7String, type Uuid, type UuidByteInput, type UuidBytes, type UuidBytesResult, type UuidInput, type UuidInspection, type UuidRandomFill, UuidSlugError, type UuidSlugErrorCode, type UuidSlugMigrationDecoder, type UuidSlugMigrationFormat, type UuidSlugMigrationOptions, type UuidString, type UuidStringFor, type UuidStringResult, type UuidText, type UuidTextCase, type UuidV4Bytes, type UuidV4String, type UuidV4StringFor, type UuidV4Text, type UuidV7Bounds, type UuidV7Bytes, type UuidV7ClockRollbackPolicy, type UuidV7Generator, type UuidV7GeneratorOptions, type UuidV7GeneratorValueOptions, type UuidV7Instant, type UuidV7Mask, type UuidV7MaskOptions, type UuidV7MaskingCodec, type UuidV7MaskingCodecOptions, type UuidV7MaskingCodecValueOptions, type UuidV7Payload, type UuidV7PayloadLayout, type UuidV7PreviousMask, type UuidV7Sentinel, type UuidV7SentinelConfig, type UuidV7String, type UuidV7StringFor, type UuidV7Text, type UuidV7TimestampWindow, type UuidV7ValueOptions, type UuidVariant, type UuidVersion, bytesToUuidString, createCustomUuidV7Mask, createUuidV7Generator, createUuidV7GeneratorWithRandomFill, createUuidV7MaskingCodec, deriveUuidV7Mask, deriveUuidV7MaskAsync, extractUuidV7Payload, extractUuidV7UnixMs, extractUuidVersion, generatePlainUuidV4Slug, generatePlainUuidV7Slug, generateUuidV4, generateUuidV4Bytes, generateUuidV4WithRandomFill, generateUuidV7, generateUuidV7Bytes, generateUuidV7Value, generateUuidV7WithPlainSlug, isPlainUuidSlug, isPlainUuidV4Slug, isPlainUuidV7Slug, isUuidBytes, isUuidSlugError, isUuidString, isUuidText, isUuidV4Bytes, isUuidV4String, isUuidV4Text, isUuidV7Bytes, isUuidV7String, isUuidV7Text, parseUuid, plainSlugToUuidBytes, plainSlugToUuidString, uuidBytesToPlainSlug, uuidStringToBytes, uuidStringToPlainSlug, uuidToBytes, uuidToPlainSlug, uuidToString, uuidV7ByteBounds, uuidV7StringBounds, validatePlainUuidV7SlugUnixMs, validateUuidV7StringUnixMs };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// @anizoptera/uuid-slug 0.
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { ABORTED as e, INVALID_BASE32HEX as t, INVALID_BASE64URL as n, INVALID_BUFFER as r, INVALID_MASK as i, INVALID_OPTIONS as a, INVALID_SENTINEL as o, INVALID_TIMESTAMP as s, INVALID_UUID as c, INVALID_UUID_SLUG as l, INVALID_UUID_VERSION as u, RNG_UNAVAILABLE as d, TIMESTAMP_OUTSIDE_WINDOW as f, UuidSlugError as p, isUuidSlugError as m } from "./errors.js";
|
|
4
|
+
import { BASE64URL_NAME as h } from "./base64url-name.js";
|
|
5
|
+
import { BASE32HEX_NAME as g } from "./alphabet.js";
|
|
6
|
+
import { FIXED_MASK_FORMAT as _, PLAIN_SLUG_FORMAT as v, SEEDED_MASK_FORMAT as y, UUID_TEXT_LOWERCASE as b, UUID_TEXT_UPPERCASE as x, UUID_V7_ROLLBACK_ERROR as S, UUID_V7_ROLLBACK_PRESERVE as C, UUID_V7_ROLLBACK_RESET as w, UUID_VARIANT_FUTURE as T, UUID_VARIANT_MICROSOFT as E, UUID_VARIANT_NCS as D, UUID_VARIANT_RFC as O } from "./types.js";
|
|
7
|
+
import { MAX_UUID as k, NIL_UUID as A, bytesToUuidString as j, isUuidBytes as M, isUuidString as N, isUuidText as P, isUuidV4Bytes as F, isUuidV4String as I, isUuidV4Text as L, isUuidV7Bytes as R, isUuidV7String as z, isUuidV7Text as B, uuidStringToBytes as V } from "./uuid.js";
|
|
8
|
+
import { generateUuidV7 as H, generateUuidV7Bytes as U } from "./v7-keyless.js";
|
|
9
|
+
import { createCustomUuidV7Mask as W } from "./mask-handle.js";
|
|
10
|
+
import { MAX_MASKED_UUID_V7_TIMESTAMP_OFFSET_MS as G } from "./payload.js";
|
|
11
|
+
import { UUID_V7_TEST_MASK as K, deriveUuidV7Mask as q, deriveUuidV7MaskAsync as J } from "./mask.js";
|
|
12
|
+
import { validateUuidV7StringUnixMs as Y } from "./timestamp.js";
|
|
13
|
+
import { extractUuidV7Payload as X, extractUuidV7UnixMs as Z, extractUuidVersion as Q, isPlainUuidSlug as $, isPlainUuidV4Slug as ee, isPlainUuidV7Slug as te, plainSlugToUuidBytes as ne, plainSlugToUuidString as re, uuidBytesToPlainSlug as ie, uuidStringToPlainSlug as ae, uuidToBytes as oe, uuidToPlainSlug as se, uuidToString as ce, validatePlainUuidV7SlugUnixMs as le } from "./slug.js";
|
|
14
|
+
import { parseUuid as ue } from "./uuid-value.js";
|
|
15
|
+
import { createUuidV7MaskingCodec as de } from "./masking-codec.js";
|
|
16
|
+
import { uuidV7ByteBounds as fe, uuidV7StringBounds as pe } from "./v7-bounds.js";
|
|
17
|
+
import { generatePlainUuidV7Slug as me, generateUuidV7WithPlainSlug as he } from "./v7-slug.js";
|
|
18
|
+
import { createUuidV7Generator as ge, createUuidV7GeneratorWithRandomFill as _e } from "./v7-generator.js";
|
|
19
|
+
import { generateUuidV4 as ve, generateUuidV4Bytes as ye, generateUuidV4WithRandomFill as be } from "./v4.js";
|
|
20
|
+
import { generateUuidV7Value as xe } from "./v7-value.js";
|
|
21
|
+
import { generatePlainUuidV4Slug as Se } from "./v4-slug.js";
|
|
22
|
+
export { e as ABORTED, g as BASE32HEX, h as BASE64URL, _ as FIXED_MASK_FORMAT, t as INVALID_BASE32HEX, n as INVALID_BASE64URL, r as INVALID_BUFFER, i as INVALID_MASK, a as INVALID_OPTIONS, o as INVALID_SENTINEL, s as INVALID_TIMESTAMP, c as INVALID_UUID, l as INVALID_UUID_SLUG, u as INVALID_UUID_VERSION, G as MAX_MASKED_UUID_V7_TIMESTAMP_OFFSET_MS, k as MAX_UUID, A as NIL_UUID, v as PLAIN_SLUG_FORMAT, d as RNG_UNAVAILABLE, y as SEEDED_MASK_FORMAT, f as TIMESTAMP_OUTSIDE_WINDOW, b as UUID_TEXT_LOWERCASE, x as UUID_TEXT_UPPERCASE, S as UUID_V7_ROLLBACK_ERROR, C as UUID_V7_ROLLBACK_PRESERVE, w as UUID_V7_ROLLBACK_RESET, K as UUID_V7_TEST_MASK, T as UUID_VARIANT_FUTURE, E as UUID_VARIANT_MICROSOFT, D as UUID_VARIANT_NCS, O as UUID_VARIANT_RFC, p as UuidSlugError, j as bytesToUuidString, W as createCustomUuidV7Mask, ge as createUuidV7Generator, _e as createUuidV7GeneratorWithRandomFill, de as createUuidV7MaskingCodec, q as deriveUuidV7Mask, J as deriveUuidV7MaskAsync, X as extractUuidV7Payload, Z as extractUuidV7UnixMs, Q as extractUuidVersion, Se as generatePlainUuidV4Slug, me as generatePlainUuidV7Slug, ve as generateUuidV4, ye as generateUuidV4Bytes, be as generateUuidV4WithRandomFill, H as generateUuidV7, U as generateUuidV7Bytes, xe as generateUuidV7Value, he as generateUuidV7WithPlainSlug, $ as isPlainUuidSlug, ee as isPlainUuidV4Slug, te as isPlainUuidV7Slug, M as isUuidBytes, m as isUuidSlugError, N as isUuidString, P as isUuidText, F as isUuidV4Bytes, I as isUuidV4String, L as isUuidV4Text, R as isUuidV7Bytes, z as isUuidV7String, B as isUuidV7Text, ue as parseUuid, ne as plainSlugToUuidBytes, re as plainSlugToUuidString, ie as uuidBytesToPlainSlug, V as uuidStringToBytes, ae as uuidStringToPlainSlug, oe as uuidToBytes, se as uuidToPlainSlug, ce as uuidToString, fe as uuidV7ByteBounds, pe as uuidV7StringBounds, le as validatePlainUuidV7SlugUnixMs, Y as validateUuidV7StringUnixMs };
|