@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/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"s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GnC,YAAA,UAAU,gBAAgB,WACvB,UAAU,sBAAsB,QAClC,cAAc,QAAQ;EACzB,qBAAqB,uBAAuB,eAAA,YAE1C,UAAU,gBAAgB,QAC1B,QAAQ,qBACP,aAAa;EAChB,qBAAqB,uBAAuB,eAAe,aAAa,cAEtE,YAAA,UAAU,gBAAgB,QAC1B,QAAQ,QACR,UAAU,OACT,cAAc,QAAQ;;;;;;;;;;;EAWzB,+BACE,uBAAuB,eACvB,aAAa,sBAAsB,qBAGnC,YAAA,UAAU,gBAAgB,WACvB,UAAU,sBAAsB,iBACzB,cAAc,UAAU;EACpC,+BAA+B,uBAAuB,eAAA,YAEpD,UAAU,gBAAgB,QAC1B,QAAQ,8BACE,eAAe;EAC3B,+BAA+B,uBAAuB,eAAe,aAAa,cAEhF,YAAA,UAAU,gBAAgB,QAC1B,QAAQ,QACR,UAAU,gBACA,cAAc,UAAU"}
|
package/dist/types.js
ADDED
|
@@ -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/types.ts
|
|
4
|
+
const e = "lowercase", t = "uppercase", n = "preserve", r = "reset", i = "error", a = "ncs", o = "rfc", s = "microsoft", c = "future", l = "seeded-mask", u = "fixed-mask", d = "plain-slug";
|
|
5
|
+
//#endregion
|
|
6
|
+
export { u as FIXED_MASK_FORMAT, d as PLAIN_SLUG_FORMAT, l as SEEDED_MASK_FORMAT, e as UUID_TEXT_LOWERCASE, t as UUID_TEXT_UPPERCASE, i as UUID_V7_ROLLBACK_ERROR, n as UUID_V7_ROLLBACK_PRESERVE, r as UUID_V7_ROLLBACK_RESET, c as UUID_VARIANT_FUTURE, s as UUID_VARIANT_MICROSOFT, a as UUID_VARIANT_NCS, o as UUID_VARIANT_RFC };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["UUID_TEXT_LOWERCASE","UUID_TEXT_UPPERCASE","UUID_V7_ROLLBACK_PRESERVE","UUID_V7_ROLLBACK_RESET","UUID_V7_ROLLBACK_ERROR","UUID_VARIANT_NCS","UUID_VARIANT_RFC","UUID_VARIANT_MICROSOFT","UUID_VARIANT_FUTURE","SEEDED_MASK_FORMAT","FIXED_MASK_FORMAT","PLAIN_SLUG_FORMAT"],"sources":["../src/types.ts"],"mappings":";;;AAiBA,MAAaA,IAAsB,aAEtBC,IAAsB,aAEtBC,IAA4B,YAE5BC,IAAyB,SAEzBC,IAAyB,SAmBzBC,IAAmB,OAEnBC,IAAmB,OAEnBC,IAAyB,aAEzBC,IAAsB,UAypBtBC,IAAqB,eAErBC,IAAoB,cAEpBC,IAAoB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { isUint8Array as e } from "./errors.js";
|
|
4
|
+
//#region src/uuid-value-protocol.ts
|
|
5
|
+
const t = Symbol.for("@anizoptera/uuid-slug.uuid-value-bytes"), n = Symbol.for("@anizoptera/uuid-slug.uuid-value-context");
|
|
6
|
+
var LocalUuidValue = class {
|
|
7
|
+
#e;
|
|
8
|
+
#t;
|
|
9
|
+
#n;
|
|
10
|
+
constructor(e, t, n) {
|
|
11
|
+
this.#e = e, this.#t = t, this.#n = n;
|
|
12
|
+
}
|
|
13
|
+
static is(e) {
|
|
14
|
+
return typeof e == "object" && !!e && #e in e;
|
|
15
|
+
}
|
|
16
|
+
static ownBytes(e) {
|
|
17
|
+
return e.#e;
|
|
18
|
+
}
|
|
19
|
+
static ownMaskingCodec(e) {
|
|
20
|
+
return e.#t;
|
|
21
|
+
}
|
|
22
|
+
static ownPayloadLayout(e) {
|
|
23
|
+
return e.#n;
|
|
24
|
+
}
|
|
25
|
+
[n]() {
|
|
26
|
+
return {
|
|
27
|
+
maskingCodec: this.#t,
|
|
28
|
+
payloadLayout: this.#n && { ...this.#n }
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function uuidValueBytes(n) {
|
|
33
|
+
if (LocalUuidValue.is(n)) return LocalUuidValue.ownBytes(n);
|
|
34
|
+
if (typeof n == "object" && n) try {
|
|
35
|
+
let r = Reflect.get(n, t);
|
|
36
|
+
if (typeof r != "function") return;
|
|
37
|
+
let i = Reflect.apply(r, n, []);
|
|
38
|
+
return /* @__PURE__ */ e(i) && i.length === 16 ? i : void 0;
|
|
39
|
+
} catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { LocalUuidValue, t as UUID_VALUE_BYTES, n as UUID_VALUE_CONTEXT, uuidValueBytes };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=uuid-value-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid-value-protocol.js","names":["UUID_VALUE_BYTES","UUID_VALUE_CONTEXT","#bytes","bytes","#maskingCodec","maskingCodec","#payloadLayout","payloadLayout","value","read"],"sources":["../src/uuid-value-protocol.ts"],"mappings":";;;;AAKA,MAAaA,IAAmB,OAAO,IAAI,wCAAwC,GACtEC,IAAqB,OAAO,IAAI,0CAA0C;AAUvF,IAAa,iBAAb,MAA4B;CAC1B;CACA;CACA;CAMA,YACE,GACA,GACA,GACA;EAGA,AAFA,KAAKC,KAASC,GACd,KAAKC,KAAgBC,GACrB,KAAKC,KAAiBC;CACxB;CAGA,OAAO,GAAG,GAAyC;EACjD,OAAO,OAAOC,KAAU,cAAYA,KAAkB,MAAUA;CAClE;CAIA,OAAO,SAAS,GAAmC;EACjD,OAAOA,EAAMN;CACf;CAEA,OAAO,gBAAgB,GAAuD;EAC5E,OAAOM,EAAMJ;CACf;CAEA,OAAO,iBAAiB,GAAwD;EAC9E,OAAOI,EAAMF;CACf;CAEA,CAACL,KAAsB;EAGrB,OAAO;GACL,cAAc,KAAKG;GACnB,eAAe,KAAKE,MAAkB,EAAE,GAAG,KAAKA,GAAe;EACjE;CACF;AACF;AAGA,SAAgB,eAAe,GAAwC;CACrE,IAAI,eAAe,GAAGE,CAAK,GAAG,OAAO,eAAe,SAASA,CAAK;CAClE,IAAI,OAAOA,KAAU,YAAYA,GACjC,IAAI;EACF,IAAMC,IAAO,QAAQ,IAAID,GAAOR,CAAgB;EAChD,IAAI,OAAOS,KAAS,YAAY;EAChC,IAAMN,IAAQ,QAAQ,MAAMM,GAAMD,GAAO,CAAC,CAAC;EAC3C,OAAO,kBAAaL,CAAK,KAAKA,EAAM,WAAW,KAAKA,IAAQ,KAAA;CAC9D,QAAQ;EACN;CACF;AACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { UuidSlugError } from "./errors.js";
|
|
4
|
+
import { UuidV7MaskingCodec } from "./masking-codec-types.js";
|
|
5
|
+
import { KeylessUuidInput, ParsedUuidResult, UuidInput } from "./types.js";
|
|
6
|
+
//#region src/uuid-value.d.ts
|
|
7
|
+
/** Parse any keyless UUID form once; an existing UUID retains its codec and payload-layout presets. */
|
|
8
|
+
export declare function parseUuid<Input extends UuidInput>(uuid: KeylessUuidInput<Input>): ParsedUuidResult<Input> | UuidSlugError;
|
|
9
|
+
/**
|
|
10
|
+
* Parse through a masking codec, replacing any preset codec and retaining an existing payload layout.
|
|
11
|
+
* A plain UUIDv4 slug can resolve to UUIDv7 when the codec's mask check passes.
|
|
12
|
+
* External codec bytes are validated and copied. Malformed results return `invalid_options`;
|
|
13
|
+
* thrown exceptions remain available as the error's `cause`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseUuid<Input extends UuidInput>(uuid: Input, maskingCodec: UuidV7MaskingCodec): ParsedUuidResult<Input, true> | UuidSlugError;
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=uuid-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid-value.d.ts","names":[],"sources":["../src/uuid-value.ts"],"mappings":";;;;;;;wBA+QgB,UAAU,cAAc,WACtC,MAAM,iBAAiB,SACtB,iBAAiB,SAAS;;;;;;;wBAOb,UAAU,cAAc,WACtC,MAAM,OACN,cAAc,qBACb,iBAAiB,eAAe"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { INVALID_OPTIONS as e, INVALID_UUID_VERSION as t, UuidSlugError as n, checkByteRange as r, isUint8Array as i, isUuidSlugError as a } from "./errors.js";
|
|
4
|
+
import { BASE64URL_NAME as o } from "./base64url-name.js";
|
|
5
|
+
import { BASE32HEX as s, BASE64URL as c, encode as l, isEncoded as u } from "./alphabet.js";
|
|
6
|
+
import { UUID_TEXT_LOWERCASE as d, UUID_VARIANT_FUTURE as f, UUID_VARIANT_MICROSOFT as p } from "./types.js";
|
|
7
|
+
import { formatUuidBytesUnchecked as m, isUuidV7Bytes as h, resolveUuidTextCase as g, uuidTimestampFromBytesUnchecked as _, uuidVersion as v } from "./uuid.js";
|
|
8
|
+
import { readUuidV7PayloadLayout as y } from "./v7-payload.js";
|
|
9
|
+
import { isLocalMaskingCodec as b } from "./masking-codec-protocol.js";
|
|
10
|
+
import { LocalUuidValue as x, UUID_VALUE_BYTES as S, UUID_VALUE_CONTEXT as C } from "./uuid-value-protocol.js";
|
|
11
|
+
import { decodeKeylessUuid as w, extractUuidV7Payload as T, resolveSlugAlphabet as E } from "./slug.js";
|
|
12
|
+
//#region src/uuid-value.ts
|
|
13
|
+
const D = "A masking codec is required for masked UUID output.";
|
|
14
|
+
function variantOf(e) {
|
|
15
|
+
let t = e[8];
|
|
16
|
+
return t & 128 ? (t & 192) == 128 ? "rfc" : (t & 224) == 192 ? p : f : "ncs";
|
|
17
|
+
}
|
|
18
|
+
var ParsedUuidValue = class extends x {
|
|
19
|
+
get version() {
|
|
20
|
+
return /* @__PURE__ */ v(x.ownBytes(this), 0);
|
|
21
|
+
}
|
|
22
|
+
inspect() {
|
|
23
|
+
let e = x.ownBytes(this), t = /* @__PURE__ */ v(e, 0), n = variantOf(e), r = !0, i = !0;
|
|
24
|
+
for (let t = 0; t < 16; t += 1) {
|
|
25
|
+
let n = e[t];
|
|
26
|
+
r &&= n === 0, i &&= n === 255;
|
|
27
|
+
}
|
|
28
|
+
return Object.freeze({
|
|
29
|
+
uuid: /* @__PURE__ */ m(e),
|
|
30
|
+
version: t,
|
|
31
|
+
variant: n,
|
|
32
|
+
unixMs: t === 7 && n === "rfc" ? /* @__PURE__ */ _(e, 0) : void 0,
|
|
33
|
+
isNil: r,
|
|
34
|
+
isMax: i
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
toString(e = d) {
|
|
38
|
+
let t = g(e);
|
|
39
|
+
return t instanceof Error ? t : /* @__PURE__ */ m(x.ownBytes(this), 0, t);
|
|
40
|
+
}
|
|
41
|
+
toBytes(e, t = 0) {
|
|
42
|
+
let n = x.ownBytes(this);
|
|
43
|
+
return e ? /* @__PURE__ */ r(e, t, 16) || (e.set(n, t), e) : new Uint8Array(n);
|
|
44
|
+
}
|
|
45
|
+
toPlainSlug(e = o) {
|
|
46
|
+
let t = /* @__PURE__ */ E(e);
|
|
47
|
+
return t instanceof Error ? t : /* @__PURE__ */ l(x.ownBytes(this), t);
|
|
48
|
+
}
|
|
49
|
+
toMaskedSlug(...r) {
|
|
50
|
+
let i = x.ownBytes(this), o = r[0] ?? x.ownMaskingCodec(this);
|
|
51
|
+
if (!o) return new n(e, D);
|
|
52
|
+
if (b(o)) return o.uuidToMaskedSlug(i);
|
|
53
|
+
if (!/* @__PURE__ */ h(i)) return new n(t, "Masked output requires RFC-variant UUIDv7 bytes.");
|
|
54
|
+
try {
|
|
55
|
+
let t = o.uuidToMaskedSlug;
|
|
56
|
+
if (typeof t != "function") return new n(e, D);
|
|
57
|
+
let r = Reflect.apply(t, void 0, [new Uint8Array(i)]);
|
|
58
|
+
return /* @__PURE__ */ a(r) || typeof r == "string" && (/* @__PURE__ */ u(r, c, 16, !1, 4) || /* @__PURE__ */ u(r, s, 16, !1, 4) || /* @__PURE__ */ u(r, s, 16)) ? r : new n(e, "Masking codec must return a canonical masked slug or sentinel.");
|
|
59
|
+
} catch (t) {
|
|
60
|
+
return new n(e, "Masking codec UUID encoding failed.", { cause: t });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
extractV7Payload(...t) {
|
|
64
|
+
let r = x.ownBytes(this), i = t[0] ?? x.ownPayloadLayout(this);
|
|
65
|
+
return i ? /* @__PURE__ */ T(r, i) : new n(e, "A UUIDv7 payload layout is required.");
|
|
66
|
+
}
|
|
67
|
+
toJSON() {
|
|
68
|
+
return /* @__PURE__ */ m(x.ownBytes(this));
|
|
69
|
+
}
|
|
70
|
+
[S]() {
|
|
71
|
+
return this.toBytes();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
Object.freeze(ParsedUuidValue.prototype), Object.freeze(x.prototype);
|
|
75
|
+
function createUuidValue(e, t, n) {
|
|
76
|
+
return Object.freeze(new ParsedUuidValue(e, t, n));
|
|
77
|
+
}
|
|
78
|
+
function readForeignUuidContext(t) {
|
|
79
|
+
if (typeof t == "object" && t) try {
|
|
80
|
+
let r = Reflect.get(t, C);
|
|
81
|
+
if (typeof r != "function") return;
|
|
82
|
+
let i = Reflect.apply(r, t, []);
|
|
83
|
+
if (typeof i != "object" || !i) return new n(e, "UUID construction context must be an object.");
|
|
84
|
+
let a = i, o = a.maskingCodec;
|
|
85
|
+
if (o !== void 0 && (typeof o != "object" || !o || typeof o.uuidToMaskedSlug != "function")) return new n(e, D);
|
|
86
|
+
let s = a.payloadLayout, c = s === void 0 ? void 0 : y(s);
|
|
87
|
+
return c instanceof Error ? c : {
|
|
88
|
+
maskingCodec: o,
|
|
89
|
+
payloadLayout: c
|
|
90
|
+
};
|
|
91
|
+
} catch (t) {
|
|
92
|
+
return new n(e, "Reading UUID construction context failed.", { cause: t });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function parseUuid(t, r) {
|
|
96
|
+
let o = x.is(t) ? t : void 0;
|
|
97
|
+
if (o && (!r || x.ownMaskingCodec(o) === r)) return t;
|
|
98
|
+
let s;
|
|
99
|
+
if (!r) s = w(t);
|
|
100
|
+
else {
|
|
101
|
+
let o = b(r);
|
|
102
|
+
if (!o && /* @__PURE__ */ a(t)) return t;
|
|
103
|
+
let c;
|
|
104
|
+
try {
|
|
105
|
+
c = r.uuidToBytes;
|
|
106
|
+
} catch (t) {
|
|
107
|
+
return new n(e, "Reading masking codec failed.", { cause: t });
|
|
108
|
+
}
|
|
109
|
+
if (typeof c != "function") return new n(e, "maskingCodec must be a UUIDv7 masking codec.");
|
|
110
|
+
try {
|
|
111
|
+
if (s = Reflect.apply(c, void 0, [t]), /* @__PURE__ */ i(s) && s.length === 16) o || (s = new Uint8Array(s));
|
|
112
|
+
else if (!/* @__PURE__ */ a(s)) return new n(e, "Masking codec must return exactly 16 UUID bytes.");
|
|
113
|
+
} catch (t) {
|
|
114
|
+
return new n(e, "Masking codec UUID parsing failed.", { cause: t });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (/* @__PURE__ */ a(s)) return s;
|
|
118
|
+
let c = o || s === t || typeof t == "string" ? void 0 : readForeignUuidContext(t);
|
|
119
|
+
return c instanceof Error ? c : createUuidValue(r || typeof t == "string" ? s : new Uint8Array(s), r ?? c?.maskingCodec, o ? x.ownPayloadLayout(o) : c?.payloadLayout);
|
|
120
|
+
}
|
|
121
|
+
function parseUuidWithCodec(e, t) {
|
|
122
|
+
return parseUuid(e, t);
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { createUuidValue, parseUuid, parseUuidWithCodec };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=uuid-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid-value.js","names":["MASKING_CODEC_REQUIRED","field","bytes","UUID_VARIANT_MICROSOFT","UUID_VARIANT_FUTURE","LocalUuidValue","version","variant","isNil","isMax","index","byte","UUID_TEXT_LOWERCASE","selectedCase","resolveUuidTextCase","textCase","output","checkByteRange","outputOffset","BASE64URL_NAME","selectedAlphabet","alphabet","codecArgument","codec","UuidSlugError","INVALID_OPTIONS","isLocalMaskingCodec","INVALID_UUID_VERSION","encode","result","BASE64URL","BASE32HEX","cause","layoutArgument","layout","UUID_VALUE_BYTES","maskingCodec","payloadLayout","value","read","UUID_VALUE_CONTEXT","context","source","readUuidV7PayloadLayout","existing","uuid","parsed","decodeKeylessUuid","localCodec","decode","foreignContext"],"sources":["../src/uuid-value.ts"],"mappings":";;;;;;;;;;;;AAwDA,MAAMA,IAAyB;AAG/B,SAAS,UAAU,GAAgC;CACjD,IAAMC,IAAQC,EAAM;CAGpB,OAFKD,IAAQ,OACRA,IAAQ,QAAU,MAAM,SACrBA,IAAQ,QAAU,MAAOE,IAAyBC,IAFhC;AAG5B;AAEA,IAAM,kBAAN,cAKUC,EAEV;CAIE,IAAI,UAAmB;EACrB,OAAO,kBAAYA,EAAe,SAAS,IAAI,GAAG,CAAC;CACrD;CAEA,UAAmC;EACjC,IAAMH,IAAQG,EAAe,SAAS,IAAI,GACpCC,IAAU,kBAAYJ,GAAO,CAAC,GAC9BK,IAAU,UAAUL,CAAK,GAC3BM,IAAQ,IACRC,IAAQ;EACZ,KAAK,IAAIC,IAAQ,GAAGA,IAAQ,IAAI,KAAS,GAAG;GAC1C,IAAMC,IAAOT,EAAMQ;GAEnB,AADA,MAAUC,MAAS,GACnB,MAAUA,MAAS;EACrB;EACA,OAAO,OAAO,OAAO;GACnB,MAAM,k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vC,EAAe,iBAAiBuC,CAAQ,IAAIM,GAAgB,aACzE;AACF;AAGA,SAAgB,mBACd,GACA,GAC+C;CAC/C,OAAO,UAAUL,GAAMT,CAAY;AACrC"}
|
package/dist/uuid.d.ts
CHANGED
|
@@ -1,78 +1,65 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// @anizoptera/uuid-slug 0.
|
|
3
|
-
import { UuidSlugError } from "./errors.js";
|
|
4
|
-
import {
|
|
5
|
-
import { UuidSlug, UuidString, UuidV4Slug, UuidV4String, UuidV7Slug, UuidV7String } from "./types.js";
|
|
2
|
+
// @anizoptera/uuid-slug 0.4.0 | https://github.com/Anizoptera/uuid-slug#readme
|
|
3
|
+
import { UuidSlugError, UuidSlugErrorCode, isUuidSlugError } from "./errors.js";
|
|
4
|
+
import { PreserveUuidVersion, UUID_TEXT_LOWERCASE, UuidByteInput, UuidBytes, UuidOutput, UuidString, UuidStringFor, UuidStringInput, UuidText, UuidTextCase, UuidTextCaseArguments, UuidV4Bytes, UuidV4String, UuidV4Text, UuidV7Bytes, UuidV7String, UuidV7Text } from "./types.js";
|
|
6
5
|
//#region src/uuid.d.ts
|
|
6
|
+
/** The canonical all-zero UUID value, without a version or issuance claim. */
|
|
7
|
+
export declare const NIL_UUID: UuidString;
|
|
8
|
+
/** The canonical all-one UUID value, without a version or issuance claim. */
|
|
9
|
+
export declare const MAX_UUID: UuidString;
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* strings. Only the lowercase spelling decodes — the table is built from `chars` — so slugs have
|
|
12
|
-
* no second spelling, as everywhere else in this format.
|
|
11
|
+
* Parse accepted mixed-case UUID text into a new plain 16-byte `Uint8Array`. Accept canonical or
|
|
12
|
+
* compact text, a UUID URN, or brace-wrapped canonical text. Known slug values are rejected by
|
|
13
|
+
* TypeScript; invalid text returns `UuidSlugError`. A preceding `UuidSlugError` is returned unchanged.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
* ciphertext, which carries nothing, so the extra characters would buy only the case-insensitivity.
|
|
15
|
+
* @param uuid - UUID text in an accepted spelling. JavaScript also accepts a genuine `String` object.
|
|
16
16
|
*/
|
|
17
|
-
declare
|
|
18
|
-
base32hex: Alphabet;
|
|
19
|
-
base64url: Alphabet;
|
|
20
|
-
};
|
|
17
|
+
export declare function uuidStringToBytes<Input extends string | UuidSlugError>(uuid: UuidStringInput<Input>): PreserveUuidVersion<Input, UuidBytes, UuidV4Bytes, UuidV7Bytes> | UuidSlugError;
|
|
21
18
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
declare function parseUuid(uuid: string, out?: Uint8Array, offset?: number): UuidSlugError | Uint8Array;
|
|
30
|
-
declare function formatUuid(bytes: Uint8Array, offset?: number): UuidSlugError | UuidString;
|
|
31
|
-
declare function isUuidString(uuid: null | string | undefined): uuid is UuidString;
|
|
32
|
-
declare function isUuidV4String(uuid: null | string | undefined): uuid is UuidV4String;
|
|
33
|
-
declare function isUuidV7String(uuid: null | string | undefined): uuid is UuidV7String;
|
|
34
|
-
/**
|
|
35
|
-
* The only BYTE-level predicate, and the asymmetry against `isUuidV4String` is deliberate: masking
|
|
36
|
-
* accepts v7 alone, so a caller holding raw bytes has a reason to ask this and none to ask the v4
|
|
37
|
-
* question. `isUuidV4Bytes` is absent because nothing needs it, not because it was overlooked —
|
|
38
|
-
* add it when a caller appears, never for symmetry, since an export is permanent surface.
|
|
19
|
+
* Parse accepted mixed-case UUID text into caller-owned storage after validating the full input.
|
|
20
|
+
* A preceding `UuidSlugError` is returned unchanged without writing.
|
|
21
|
+
*
|
|
22
|
+
* @param uuid - UUID text in an accepted spelling. JavaScript also accepts a genuine `String` object.
|
|
23
|
+
* @param output - Caller-owned array that receives the 16 UUID bytes.
|
|
24
|
+
* @param outputOffset - Zero-based index where writing starts. Omit to start at index 0. Bytes
|
|
25
|
+
* outside the written range stay unchanged.
|
|
39
26
|
*/
|
|
40
|
-
declare function
|
|
41
|
-
declare function formatUuidSlug(bytes: Uint8Array, offset?: number, alphabet?: SlugAlphabet): UuidSlugError | UuidSlug;
|
|
42
|
-
/** Accepts either alphabet; the length says which, so there is nothing to pass and nothing to get wrong. */
|
|
43
|
-
declare function parseUuidSlug(slug: string, out?: Uint8Array, offset?: number): UuidSlugError | Uint8Array;
|
|
44
|
-
declare function uuidToSlug(uuid: string, alphabet?: SlugAlphabet): UuidSlugError | UuidSlug;
|
|
45
|
-
declare function slugToUuid(slug: string): UuidSlugError | UuidString;
|
|
46
|
-
declare function isUuidSlug(slug: null | string | undefined): slug is UuidSlug;
|
|
47
|
-
declare function isUuidV4Slug(slug: null | string | undefined): slug is UuidV4Slug;
|
|
48
|
-
declare function isUuidV7Slug(slug: null | string | undefined): slug is UuidV7Slug;
|
|
27
|
+
export declare function uuidStringToBytes<Input extends string | UuidSlugError, Output extends Uint8Array>(uuid: UuidStringInput<Input>, output: Output, outputOffset?: number): UuidOutput<Output> | UuidSlugError;
|
|
49
28
|
/**
|
|
50
|
-
*
|
|
29
|
+
* Format 16 bytes as standard hyphenated UUID text without assigning a version. A standalone
|
|
30
|
+
* `ArrayBuffer` uses its whole contents; a `DataView` uses its declared range. Only `Uint8Array`
|
|
31
|
+
* input accepts an explicit offset. Invalid input returns `invalid_buffer`, and a preceding
|
|
32
|
+
* `UuidSlugError` is returned unchanged.
|
|
51
33
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* Short input is reported separately from wrong version, because `uuidVersion` reads a missing byte
|
|
58
|
-
* as zero and would otherwise blame a truncated buffer for holding a v0.
|
|
34
|
+
* @param bytes - One supported UUID byte source.
|
|
35
|
+
* @param textCase - Built-in output spelling. Omit for lowercase.
|
|
36
|
+
* @defaultValue `UUID_TEXT_LOWERCASE`
|
|
37
|
+
* @param byteOffset - Zero-based index where the UUID starts. Omit for a standalone UUID.
|
|
59
38
|
*/
|
|
60
|
-
declare function
|
|
39
|
+
export declare function bytesToUuidString<Case extends UuidTextCase = typeof UUID_TEXT_LOWERCASE>(bytes: UuidByteInput | UuidSlugError, ...textCase: UuidTextCaseArguments<Case>): UuidStringFor<Case> | UuidSlugError;
|
|
40
|
+
export declare function bytesToUuidString<Case extends UuidTextCase = typeof UUID_TEXT_LOWERCASE>(bytes: Uint8Array | UuidSlugError, byteOffset: number, ...textCase: UuidTextCaseArguments<Case>): UuidStringFor<Case> | UuidSlugError;
|
|
41
|
+
/** Check accepted UUID text without claiming a version, variant, or issuance. */
|
|
42
|
+
export declare function isUuidText(value: unknown): value is UuidText;
|
|
43
|
+
/** Check accepted UUID text with version 4 and RFC variant bits. */
|
|
44
|
+
export declare function isUuidV4Text(value: unknown): value is UuidV4Text;
|
|
45
|
+
/** Check accepted UUID text with version 7 and RFC variant bits. */
|
|
46
|
+
export declare function isUuidV7Text(value: unknown): value is UuidV7Text;
|
|
47
|
+
/** Check canonical lowercase UUID text without claiming a version, variant, or issuance. */
|
|
48
|
+
export declare function isUuidString(value: unknown): value is UuidString;
|
|
49
|
+
/** Check canonical lowercase UUIDv4 text with RFC variant bits. */
|
|
50
|
+
export declare function isUuidV4String(value: unknown): value is UuidV4String;
|
|
51
|
+
/** Check canonical lowercase UUIDv7 text with RFC variant bits. */
|
|
52
|
+
export declare function isUuidV7String(value: unknown): value is UuidV7String;
|
|
53
|
+
/** Check for a 16-byte `Uint8Array` without claiming a UUID version or issuance. */
|
|
54
|
+
export declare function isUuidBytes(value: unknown): value is UuidBytes;
|
|
55
|
+
/** Check for exactly 16 UUIDv4 bytes with the RFC variant required by generation. */
|
|
56
|
+
export declare function isUuidV4Bytes(value: unknown): value is UuidV4Bytes;
|
|
61
57
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* Out of range answers `false`, and the direction is the whole point. Without the check the reads
|
|
66
|
-
* below fall through `?? 0`, so a missing byte is indistinguishable from a zero byte and only ever
|
|
67
|
-
* in the reassuring direction: a short buffer reported entropy PRESENT, and an offset past the end
|
|
68
|
-
* reported the degenerate case for data that was never examined. Both are answers about bytes the
|
|
69
|
-
* caller does not have. `false` is the honest one — it means "cannot be shown to carry entropy",
|
|
70
|
-
* which is what a caller acts on, and it is what a truly degenerate id gets too.
|
|
71
|
-
*
|
|
72
|
-
* Boolean rather than `UuidSlugError | boolean` because the sole use is a guard in a condition; an error
|
|
73
|
-
* return would have every call site unwrap a value it is already treating as a yes/no.
|
|
58
|
+
* Check for exactly 16 UUIDv7 bytes with the RFC variant required by masking and timestamps.
|
|
59
|
+
* General byte input can use `bytesToUuidString`; this narrower predicate proves the version those
|
|
60
|
+
* v7-only operations require.
|
|
74
61
|
*/
|
|
75
|
-
declare function
|
|
62
|
+
export declare function isUuidV7Bytes(value: unknown): value is UuidV7Bytes;
|
|
76
63
|
//#endregion
|
|
77
|
-
export {
|
|
64
|
+
export { UuidSlugError };
|
|
78
65
|
//# sourceMappingURL=uuid.d.ts.map
|
package/dist/uuid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","names":[],"sources":["../src/uuid.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","names":[],"sources":["../src/uuid.ts"],"mappings":";;;;;;qBAwDa,UAAqD;;qBAErD,UAAqD;;;;;;;;wBAmKlD,kBAAkB,uBAAuB,eACvD,MAAM,gBAAgB,SACrB,oBAAoB,OAAO,WAAW,aAAa,eAAe;;;;;;;;;;wBAUrD,kBAAkB,uBAAuB,eAAe,eAAe,YACrF,MAAM,gBAAgB,QACtB,QAAQ,QACR,wBACC,WAAW,UAAU;;;;;;;;;;;;wBAuFR,kBAAkB,aAAa,sBAAsB,qBACnE,OAAO,gBAAgB,kBACpB,UAAU,sBAAsB,QAClC,cAAc,QAAQ;wBACT,kBAAkB,aAAa,sBAAsB,qBACnE,OAAO,aAAa,eACpB,uBACG,UAAU,sBAAsB,QAClC,cAAc,QAAQ;;wBAiIT,WAAW,iBAAiB,SAAS;;wBAsCrC,aAAa,iBAAiB,SAAS;;wBAiBvC,aAAa,iBAAiB,SAAS;;wBAoBvC,aAAa,iBAAiB,SAAS;;wBAIvC,eAAe,iBAAiB,SAAS;;wBAIzC,eAAe,iBAAiB,SAAS;;wBAMzC,YAAY,iBAAiB,SAAS;;wBAMtC,cAAc,iBAAiB,SAAS;;;;;;wBAUxC,cAAc,iBAAiB,SAAS"}
|