@owlmeans/basic-ids 0.1.18-rc.4 → 0.1.18-rc.40

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.
Files changed (49) hide show
  1. package/README.md +5 -5
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/basic-ids/SKILL.md +44 -8
  4. package/build/consts.d.ts +11 -0
  5. package/build/consts.d.ts.map +1 -1
  6. package/build/consts.js +11 -0
  7. package/build/consts.js.map +1 -1
  8. package/build/helper/types.d.ts +25 -0
  9. package/build/helper/types.d.ts.map +1 -0
  10. package/build/helper/types.js +2 -0
  11. package/build/helper/types.js.map +1 -0
  12. package/build/helper.d.ts +8 -3
  13. package/build/helper.d.ts.map +1 -1
  14. package/build/helper.js +30 -16
  15. package/build/helper.js.map +1 -1
  16. package/build/index.d.ts +3 -0
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +2 -0
  19. package/build/index.js.map +1 -1
  20. package/build/random.d.ts +4 -0
  21. package/build/random.d.ts.map +1 -0
  22. package/build/random.js +17 -0
  23. package/build/random.js.map +1 -0
  24. package/build/wordlists/consts.d.ts +25 -0
  25. package/build/wordlists/consts.d.ts.map +1 -0
  26. package/build/wordlists/consts.js +539 -0
  27. package/build/wordlists/consts.js.map +1 -0
  28. package/build/wordlists/list-a.d.ts +13 -0
  29. package/build/wordlists/list-a.d.ts.map +1 -0
  30. package/build/wordlists/list-a.js +270 -0
  31. package/build/wordlists/list-a.js.map +1 -0
  32. package/build/wordlists/list-b.d.ts +13 -0
  33. package/build/wordlists/list-b.d.ts.map +1 -0
  34. package/build/wordlists/list-b.js +270 -0
  35. package/build/wordlists/list-b.js.map +1 -0
  36. package/package.json +6 -6
  37. package/scripts/curate-wordlists.d.ts +2 -0
  38. package/scripts/curate-wordlists.d.ts.map +1 -0
  39. package/scripts/curate-wordlists.js +145 -0
  40. package/scripts/curate-wordlists.js.map +1 -0
  41. package/scripts/curate-wordlists.ts +188 -0
  42. package/src/consts.ts +13 -0
  43. package/src/helper/types.ts +24 -0
  44. package/src/helper.ts +39 -16
  45. package/src/index.ts +3 -0
  46. package/src/random.ts +18 -0
  47. package/src/wordlists/consts.ts +539 -0
  48. package/tests/word-slug.spec.ts +65 -0
  49. package/tsconfig.json +7 -1
package/README.md CHANGED
@@ -11,13 +11,13 @@ Utilities for generating cryptographically secure random IDs and UUIDs.
11
11
  ## Installation
12
12
 
13
13
  ```bash
14
- bun add @owlmeans/basic-ids
14
+ bun add @owlmeans/basic-ids@^0.1.18-rc.40
15
15
  ```
16
16
 
17
17
  ## Usage
18
18
 
19
19
  ```typescript
20
- import { createIdOfLength, createRandomPrefix, uuid } from '@owlmeans/basic-ids'
20
+ import { createIdOfLength, createRandomPrefix, idHelper } from '@owlmeans/basic-ids'
21
21
 
22
22
  // Generate a 12-character Base58 ID (default encoding)
23
23
  const runId = createIdOfLength(12)
@@ -26,7 +26,7 @@ const runId = createIdOfLength(12)
26
26
  const prefix = createRandomPrefix(6)
27
27
 
28
28
  // Standard UUID v4
29
- const id = uuid()
29
+ const id = idHelper.uuid()
30
30
  ```
31
31
 
32
32
  With explicit encoding:
@@ -47,7 +47,7 @@ Returns a random ID of exactly `length` characters (default: 6) in `format` enco
47
47
 
48
48
  Returns a random string encoded from `length` random bytes (default: 6 bytes).
49
49
 
50
- ### `uuid(): string`
50
+ ### `idHelper.uuid(): string`
51
51
 
52
52
  Returns a UUID v4 string.
53
53
 
@@ -65,7 +65,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
65
65
  your project's skill store (`.agents/skills/`):
66
66
 
67
67
  ```sh
68
- npx @owlmeans/agent-skills
68
+ npx @owlmeans/agent-skills@^0.1.18-rc.54
69
69
  ```
70
70
 
71
71
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/basic-ids",
4
- "version": "0.1.18-rc.0",
5
- "generatedAt": "2026-08-16T22:20:50.512Z",
4
+ "version": "0.1.18-rc.40",
5
+ "generatedAt": "2026-10-15T10:20:01.309Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: basic-ids
3
- description: How to use @owlmeans/basic-ids — identifier generation helpers (random IDs, namespaced IDs, ULID-like). Auto-invoked when importing ID generation utilities.
3
+ description: How to use @owlmeans/basic-ids — createIdOfLength and createRandomPrefix for random identifiers, idHelper.uuid for v4 UUIDs, and idHelper.generateWordSlug / idHelper.nextSlugCandidate for human-readable two-word slugs. Auto-invoked when importing ID generation utilities or naming a new record, nonce or organization slug.
4
4
  user-invocable: false
5
5
  ---
6
6
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
@@ -8,23 +8,59 @@ user-invocable: false
8
8
  # @owlmeans/basic-ids
9
9
 
10
10
  **Layer:** Core
11
- **Install:** `"@owlmeans/basic-ids": "^0.1.18-rc.0"` in `dependencies`
11
+ **Install:** `"@owlmeans/basic-ids": "^0.1.18-rc.40"` in `dependencies`
12
12
 
13
13
  ## Key Exports
14
14
 
15
15
  | Export | Description |
16
16
  |--------|-------------|
17
- | ID helpers | Generate random/sortable identifiers |
18
- | Constants | Default ID lengths, character sets |
17
+ | `createIdOfLength(length?, style?)` | A random id of exactly `length` characters (default 6) |
18
+ | `createRandomPrefix(bytes?, style?)` | Encode `bytes` random bytes (default 6); length varies with the encoding |
19
+ | `idHelper.uuid()` | A v4 UUID string |
20
+ | `idHelper.generateWordSlug()` | A readable two-word slug — `civil-format`, `raised-earth` |
21
+ | `idHelper.nextSlugCandidate(base, attempt)` | The n-th candidate for an occupied slug — `brisk-otter`, `brisk-otter-2` |
22
+ | `IdStyle` | `Base58` (default) and `Base64` (url-safe, unpadded) |
23
+ | `WORD_SLUG_SEPARATOR` (`'-'`), `WORDLIST_SIZE` (2048) | Slug shape and thesaurus size |
24
+ | `WORDLIST_A` / `WORDLIST_B` | The descriptive and subject halves the slug is drawn from |
19
25
 
20
- ## Usage
26
+ ## Random identifiers
21
27
 
22
28
  ```typescript
23
- import { randomId } from '@owlmeans/basic-ids'
29
+ import { createIdOfLength, IdStyle, idHelper } from '@owlmeans/basic-ids'
24
30
 
25
- const id = randomId() // → e.g. '01HQ9MZ3...'
31
+ const id = createIdOfLength(16) // 16 Base58 chars
32
+ const nonce = createIdOfLength(32, IdStyle.Base64) // 32 url-safe Base64 chars
33
+ const recordId = idHelper.uuid()
34
+ ```
35
+
36
+ `createIdOfLength` asks for twice the bytes and truncates, so the result is exactly the requested
37
+ number of characters whatever the encoding — this is the function to use for anything that must be
38
+ unguessable. `createRandomPrefix` is the raw form: it encodes the bytes it was given and returns
39
+ however many characters that produced.
40
+
41
+ ## Readable slugs
42
+
43
+ `idHelper.generateWordSlug` picks one descriptive word and one subject word out of 2048 each,
44
+ joined by a hyphen. The result is a valid DNS label and a valid Kubernetes object-name segment, so
45
+ the same value can address a host, a namespace and an OIDC client without a second sanitising
46
+ pass — which is why an organization entity's `entitySlug` is generated this way rather than as a
47
+ random string.
48
+
49
+ Two words carry 22 bits of entropy. That is **not** enough to be unguessable, and deliberately so:
50
+ uniqueness is settled by a unique index or a registry claim, never by entropy. Walk
51
+ `idHelper.nextSlugCandidate` until the store accepts one, and never use a slug where a secret is
52
+ needed.
53
+
54
+ ```typescript
55
+ import { idHelper } from '@owlmeans/basic-ids'
56
+
57
+ const base = idHelper.generateWordSlug()
58
+ for (let attempt = 1; attempt <= 10; ++attempt) {
59
+ const candidate = idHelper.nextSlugCandidate(base, attempt) // attempt 1 is the bare name
60
+ if (await claim(candidate)) return candidate
61
+ }
26
62
  ```
27
63
 
28
64
  ## Depends On
29
65
 
30
- - None at runtime
66
+ - `@noble/hashes` (randomness), `@scure/base` (Base58 / Base64), `uuid`
package/build/consts.d.ts CHANGED
@@ -2,4 +2,15 @@ export declare enum IdStyle {
2
2
  Base58 = "base58",
3
3
  Base64 = "base64"
4
4
  }
5
+ /**
6
+ * Word-slug shape: two lowercase words joined by a hyphen, optionally carrying a numeric
7
+ * disambiguation suffix (`brisk-otter`, `brisk-otter-2`).
8
+ *
9
+ * A slug generated this way is a valid DNS label and a valid Kubernetes object-name segment,
10
+ * which is the whole point of preferring it over a random string: the same value can address a
11
+ * host, a namespace and an OIDC client without a second sanitising pass.
12
+ */
13
+ export declare const WORD_SLUG_SEPARATOR = "-";
14
+ /** Words per thesaurus. A power of two so an index costs exactly 11 unbiased bits. */
15
+ export declare const WORDLIST_SIZE = 2048;
5
16
  //# sourceMappingURL=consts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,oBAAY,OAAO;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,oBAAY,OAAO;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC,sFAAsF;AACtF,eAAO,MAAM,aAAa,OAAO,CAAA"}
package/build/consts.js CHANGED
@@ -3,4 +3,15 @@ export var IdStyle;
3
3
  IdStyle["Base58"] = "base58";
4
4
  IdStyle["Base64"] = "base64";
5
5
  })(IdStyle || (IdStyle = {}));
6
+ /**
7
+ * Word-slug shape: two lowercase words joined by a hyphen, optionally carrying a numeric
8
+ * disambiguation suffix (`brisk-otter`, `brisk-otter-2`).
9
+ *
10
+ * A slug generated this way is a valid DNS label and a valid Kubernetes object-name segment,
11
+ * which is the whole point of preferring it over a random string: the same value can address a
12
+ * host, a namespace and an OIDC client without a second sanitising pass.
13
+ */
14
+ export const WORD_SLUG_SEPARATOR = '-';
15
+ /** Words per thesaurus. A power of two so an index costs exactly 11 unbiased bits. */
16
+ export const WORDLIST_SIZE = 2048;
6
17
  //# sourceMappingURL=consts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,4BAAiB,CAAA;IACjB,4BAAiB,CAAA;AACnB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB"}
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,4BAAiB,CAAA;IACjB,4BAAiB,CAAA;AACnB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAEtC,sFAAsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAA"}
@@ -0,0 +1,25 @@
1
+ /** Identifiers read by people and machines: UUIDs and human-readable word slugs. */
2
+ export interface IdHelper {
3
+ /** A UUID v4. */
4
+ uuid: () => string;
5
+ /**
6
+ * A human-readable slug: one descriptive word, one subject word — `civil-format`, `raised-earth`.
7
+ *
8
+ * This exists because the values it replaces are read by people. An organization slug turns up in
9
+ * hostnames, OIDC client ids and support conversations, and a 16-character Base58 string is
10
+ * unquotable over the phone and unrecognisable in a list. Two words out of 2048 each give 22 bits
11
+ * of entropy — far short of a secret, and deliberately so: uniqueness here is settled by a unique
12
+ * index and `nextSlugCandidate`, not by entropy. Never use this for anything that must be
13
+ * unguessable (nonces, secrets, tokens) — `createIdOfLength` is that function.
14
+ */
15
+ generateWordSlug: () => string;
16
+ /**
17
+ * The n-th candidate for an occupied slug: `brisk-otter`, `brisk-otter-2`, `brisk-otter-3`.
18
+ *
19
+ * The first attempt is the bare name — a suffix appears only once something already answers to it,
20
+ * so the common case keeps the name it was given. Callers own the availability test (a unique
21
+ * index, a registry claim) and walk this until one is free.
22
+ */
23
+ nextSlugCandidate: (base: string, attempt: number) => string;
24
+ }
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/helper/types.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,WAAW,QAAQ;IACvB,iBAAiB;IACjB,IAAI,EAAE,MAAM,MAAM,CAAA;IAClB;;;;;;;;;OASG;IACH,gBAAgB,EAAE,MAAM,MAAM,CAAA;IAC9B;;;;;;OAMG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;CAC7D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/helper/types.ts"],"names":[],"mappings":""}
package/build/helper.d.ts CHANGED
@@ -1,5 +1,10 @@
1
- import { IdStyle } from './consts.js';
2
- export declare const createRandomPrefix: (length?: number, format?: IdStyle) => string;
3
- export declare const createIdOfLength: (length?: number, format?: IdStyle) => string;
1
+ import type { IdHelper } from './helper/types.js';
2
+ export declare const createIdHelper: () => IdHelper;
3
+ export declare const idHelper: IdHelper;
4
+ /** @deprecated compat:factory-refactor — use `idHelper.uuid()` */
4
5
  export declare const uuid: () => string;
6
+ /** @deprecated compat:factory-refactor — use `idHelper.generateWordSlug()` */
7
+ export declare const generateWordSlug: () => string;
8
+ /** @deprecated compat:factory-refactor — use `idHelper.nextSlugCandidate(…)` */
9
+ export declare const nextSlugCandidate: (base: string, attempt: number) => string;
5
10
  //# sourceMappingURL=helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAGrC,eAAO,MAAM,kBAAkB,YAAY,MAAM,WAAc,OAAO,KAAoB,MASzF,CAAA;AAED,eAAO,MAAM,gBAAgB,YAAY,MAAM,WAAc,OAAO,KAAoB,MAEvF,CAAA;AAED,eAAO,MAAM,IAAI,QAAO,MAAc,CAAA"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,eAAO,MAAM,cAAc,QAAO,QA2BjC,CAAA;AAED,eAAO,MAAM,QAAQ,UAAmB,CAAA;AAExC,kEAAkE;AAClE,eAAO,MAAM,IAAI,QAAO,MAAyB,CAAA;AAEjD,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,QAAO,MAAqC,CAAA;AAEzE,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,SAAU,MAAM,WAAW,MAAM,KAAG,MAAmD,CAAA"}
package/build/helper.js CHANGED
@@ -1,19 +1,33 @@
1
- import { randomBytes } from '@noble/hashes/utils';
2
- import { base58, base64urlnopad } from '@scure/base';
3
- import { IdStyle } from './consts.js';
1
+ import { randomBytes } from '@noble/hashes/utils.js';
2
+ import { WORDLIST_SIZE, WORD_SLUG_SEPARATOR } from './consts.js';
3
+ import { WORDLIST_A, WORDLIST_B } from './wordlists/consts.js';
4
4
  import { v4 } from 'uuid';
5
- export const createRandomPrefix = (length = 6, format = IdStyle.Base58) => {
6
- const rand = randomBytes(length);
7
- switch (format) {
8
- case IdStyle.Base64:
9
- return base64urlnopad.encode(rand);
10
- case IdStyle.Base58:
11
- default:
12
- return base58.encode(rand);
13
- }
5
+ export const createIdHelper = () => {
6
+ /**
7
+ * Uniform indices into a 2048-entry list. 2048 is a power of two, so masking 16 random bits down
8
+ * to 11 is unbiased — no rejection loop, and no modulo skew toward the front of the list.
9
+ */
10
+ const pickWords = (count) => {
11
+ const bytes = randomBytes(count * 2);
12
+ const indices = [];
13
+ for (let i = 0; i < count; ++i) {
14
+ indices.push(((bytes[i * 2] << 8) | bytes[i * 2 + 1]) & (WORDLIST_SIZE - 1));
15
+ }
16
+ return indices;
17
+ };
18
+ const uuid = () => v4();
19
+ const generateWordSlug = () => {
20
+ const [a, b] = pickWords(2);
21
+ return `${WORDLIST_A[a]}${WORD_SLUG_SEPARATOR}${WORDLIST_B[b]}`;
22
+ };
23
+ const nextSlugCandidate = (base, attempt) => attempt < 2 ? base : `${base}${WORD_SLUG_SEPARATOR}${attempt}`;
24
+ return { uuid, generateWordSlug, nextSlugCandidate };
14
25
  };
15
- export const createIdOfLength = (length = 6, format = IdStyle.Base58) => {
16
- return createRandomPrefix(length * 2, format).slice(0, length);
17
- };
18
- export const uuid = () => v4();
26
+ export const idHelper = createIdHelper();
27
+ /** @deprecated compat:factory-refactor — use `idHelper.uuid()` */
28
+ export const uuid = () => idHelper.uuid();
29
+ /** @deprecated compat:factory-refactor — use `idHelper.generateWordSlug()` */
30
+ export const generateWordSlug = () => idHelper.generateWordSlug();
31
+ /** @deprecated compat:factory-refactor — use `idHelper.nextSlugCandidate(…)` */
32
+ export const nextSlugCandidate = (base, attempt) => idHelper.nextSlugCandidate(base, attempt);
19
33
  //# sourceMappingURL=helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AAEzB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAM,GAAW,CAAC,EAAE,MAAM,GAAY,OAAO,CAAC,MAAM,EAAU,EAAE;IACjG,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAChC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,OAAO,CAAC,MAAM;YACjB,OAAO,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACpC,KAAK,OAAO,CAAC,MAAM,CAAC;QACpB;YACE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,GAAW,CAAC,EAAE,MAAM,GAAY,OAAO,CAAC,MAAM,EAAU,EAAE;IAC/F,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAChE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,GAAW,EAAE,CAAC,EAAE,EAAE,CAAA"}
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AAGzB,MAAM,CAAC,MAAM,cAAc,GAAG,GAAa,EAAE;IAC3C;;;OAGG;IACH,MAAM,SAAS,GAAG,CAAC,KAAa,EAAY,EAAE;QAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;QACpC,MAAM,OAAO,GAAa,EAAE,CAAA;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAA;QAC9E,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAA;IAED,MAAM,IAAI,GAAG,GAAW,EAAE,CAAC,EAAE,EAAE,CAAA;IAE/B,MAAM,gBAAgB,GAAG,GAAW,EAAE;QACpC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;QAE3B,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,mBAAmB,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAA;IACjE,CAAC,CAAA;IAED,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,OAAe,EAAU,EAAE,CAClE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,mBAAmB,GAAG,OAAO,EAAE,CAAA;IAEhE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAA;AACtD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAA;AAExC,kEAAkE;AAClE,MAAM,CAAC,MAAM,IAAI,GAAG,GAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;AAEjD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAW,EAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAA;AAEzE,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,OAAe,EAAU,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA"}
package/build/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export type * from './helper/types.js';
1
2
  export * from './helper.js';
3
+ export * from './random.js';
2
4
  export * from './consts.js';
5
+ export * from './wordlists/consts.js';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,mBAAmB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA"}
package/build/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './helper.js';
2
+ export * from './random.js';
2
3
  export * from './consts.js';
4
+ export * from './wordlists/consts.js';
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { IdStyle } from './consts.js';
2
+ export declare const createRandomPrefix: (length?: number, format?: IdStyle) => string;
3
+ export declare const createIdOfLength: (length?: number, format?: IdStyle) => string;
4
+ //# sourceMappingURL=random.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,eAAO,MAAM,kBAAkB,YAAY,MAAM,WAAc,OAAO,KAAoB,MASzF,CAAA;AAED,eAAO,MAAM,gBAAgB,YAAY,MAAM,WAAc,OAAO,KAAoB,MAEvF,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { randomBytes } from '@noble/hashes/utils.js';
2
+ import { base58, base64urlnopad } from '@scure/base';
3
+ import { IdStyle } from './consts.js';
4
+ export const createRandomPrefix = (length = 6, format = IdStyle.Base58) => {
5
+ const rand = randomBytes(length);
6
+ switch (format) {
7
+ case IdStyle.Base64:
8
+ return base64urlnopad.encode(rand);
9
+ case IdStyle.Base58:
10
+ default:
11
+ return base58.encode(rand);
12
+ }
13
+ };
14
+ export const createIdOfLength = (length = 6, format = IdStyle.Base58) => {
15
+ return createRandomPrefix(length * 2, format).slice(0, length);
16
+ };
17
+ //# sourceMappingURL=random.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.js","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAM,GAAW,CAAC,EAAE,MAAM,GAAY,OAAO,CAAC,MAAM,EAAU,EAAE;IACjG,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAChC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,OAAO,CAAC,MAAM;YACjB,OAAO,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACpC,KAAK,OAAO,CAAC,MAAM,CAAC;QACpB;YACE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,GAAW,CAAC,EAAE,MAAM,GAAY,OAAO,CAAC,MAAM,EAAU,EAAE;IAC/F,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAChE,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Descriptive half of a word slug — adjectives and adverbs.
3
+ *
4
+ * Exactly 2048 words (11 bits of entropy per pick), each lowercase ASCII, 3-8 characters, and
5
+ * unique within this list. The two lists share no word, so the halves of a slug can never repeat.
6
+ *
7
+ * Curated by `scripts/curate-wordlists.ts` from the Moby part-of-speech list, screened against
8
+ * profanity, stopword, negative-sentiment and proper-noun sources. Regenerate with that script
9
+ * rather than editing by hand: `tests/word-slug.spec.ts` enforces the invariants above, and a
10
+ * hand-edit that breaks the 2048 count silently biases slug generation.
11
+ */
12
+ export declare const WORDLIST_A: string[];
13
+ /**
14
+ * Subject half of a word slug — verbs and nouns.
15
+ *
16
+ * Exactly 2048 words (11 bits of entropy per pick), each lowercase ASCII, 3-8 characters, and
17
+ * unique within this list. The two lists share no word, so the halves of a slug can never repeat.
18
+ *
19
+ * Curated by `scripts/curate-wordlists.ts` from the Moby part-of-speech list, screened against
20
+ * profanity, stopword, negative-sentiment and proper-noun sources. Regenerate with that script
21
+ * rather than editing by hand: `tests/word-slug.spec.ts` enforces the invariants above, and a
22
+ * hand-edit that breaks the 2048 count silently biases slug generation.
23
+ */
24
+ export declare const WORDLIST_B: string[];
25
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/wordlists/consts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,EAiQ9B,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,EAiQ9B,CAAA"}