@owlmeans/basic-ids 0.1.18-rc.36 → 0.1.18-rc.37
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/README.md +5 -5
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/basic-ids/SKILL.md +17 -15
- package/build/helper/types.d.ts +25 -0
- package/build/helper/types.d.ts.map +1 -0
- package/build/helper/types.js +2 -0
- package/build/helper/types.js.map +1 -0
- package/build/helper.d.ts +6 -20
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +29 -51
- package/build/helper.js.map +1 -1
- package/build/index.d.ts +3 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/random.d.ts +4 -0
- package/build/random.d.ts.map +1 -0
- package/build/random.js +17 -0
- package/build/random.js.map +1 -0
- package/build/wordlists/consts.d.ts +25 -0
- package/build/wordlists/consts.d.ts.map +1 -0
- package/build/wordlists/{list-a.js → consts.js} +270 -1
- package/build/wordlists/consts.js.map +1 -0
- package/package.json +1 -1
- package/scripts/curate-wordlists.ts +30 -4
- package/src/helper/types.ts +24 -0
- package/src/helper.ts +34 -53
- package/src/index.ts +3 -2
- package/src/random.ts +18 -0
- package/src/wordlists/{list-a.ts → consts.ts} +270 -0
- package/tests/word-slug.spec.ts +8 -9
- package/build/wordlists/list-a.d.ts +0 -13
- package/build/wordlists/list-a.d.ts.map +0 -1
- package/build/wordlists/list-a.js.map +0 -1
- package/build/wordlists/list-b.d.ts +0 -13
- package/build/wordlists/list-b.d.ts.map +0 -1
- package/build/wordlists/list-b.js +0 -270
- package/build/wordlists/list-b.js.map +0 -1
- package/src/wordlists/list-b.ts +0 -269
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@^0.1.18-rc.
|
|
14
|
+
bun add @owlmeans/basic-ids@^0.1.18-rc.37
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import { createIdOfLength, createRandomPrefix,
|
|
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@^0.1.18-rc.
|
|
68
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.49
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/basic-ids",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.37",
|
|
5
|
+
"generatedAt": "2026-10-05T21:03:06.408Z",
|
|
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 — createIdOfLength and createRandomPrefix for random identifiers, uuid for v4 UUIDs, and generateWordSlug / nextSlugCandidate for human-readable two-word slugs. Auto-invoked when importing ID generation utilities or naming a new record, nonce or organization slug.
|
|
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,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/basic-ids
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/basic-ids": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/basic-ids": "^0.1.18-rc.37"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
## Key Exports
|
|
14
14
|
|
|
@@ -16,9 +16,9 @@ user-invocable: false
|
|
|
16
16
|
|--------|-------------|
|
|
17
17
|
| `createIdOfLength(length?, style?)` | A random id of exactly `length` characters (default 6) |
|
|
18
18
|
| `createRandomPrefix(bytes?, style?)` | Encode `bytes` random bytes (default 6); length varies with the encoding |
|
|
19
|
-
| `uuid()` | A v4 UUID string |
|
|
20
|
-
| `generateWordSlug()` | A readable two-word slug — `civil-format`, `raised-earth` |
|
|
21
|
-
| `nextSlugCandidate(base, attempt)` | The n-th candidate for an occupied slug — `brisk-otter`, `brisk-otter-2` |
|
|
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
22
|
| `IdStyle` | `Base58` (default) and `Base64` (url-safe, unpadded) |
|
|
23
23
|
| `WORD_SLUG_SEPARATOR` (`'-'`), `WORDLIST_SIZE` (2048) | Slug shape and thesaurus size |
|
|
24
24
|
| `WORDLIST_A` / `WORDLIST_B` | The descriptive and subject halves the slug is drawn from |
|
|
@@ -26,11 +26,11 @@ user-invocable: false
|
|
|
26
26
|
## Random identifiers
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
|
-
import { createIdOfLength, IdStyle,
|
|
29
|
+
import { createIdOfLength, IdStyle, idHelper } from '@owlmeans/basic-ids'
|
|
30
30
|
|
|
31
31
|
const id = createIdOfLength(16) // 16 Base58 chars
|
|
32
32
|
const nonce = createIdOfLength(32, IdStyle.Base64) // 32 url-safe Base64 chars
|
|
33
|
-
const recordId = uuid()
|
|
33
|
+
const recordId = idHelper.uuid()
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
`createIdOfLength` asks for twice the bytes and truncates, so the result is exactly the requested
|
|
@@ -40,21 +40,23 @@ however many characters that produced.
|
|
|
40
40
|
|
|
41
41
|
## Readable slugs
|
|
42
42
|
|
|
43
|
-
`generateWordSlug` picks one descriptive word and one subject word out of 2048 each,
|
|
44
|
-
hyphen. The result is a valid DNS label and a valid Kubernetes object-name segment, so
|
|
45
|
-
value can address a host, a namespace and an OIDC client without a second sanitising
|
|
46
|
-
is why an organization entity's `entitySlug` is generated this way rather than as a
|
|
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.
|
|
47
48
|
|
|
48
49
|
Two words carry 22 bits of entropy. That is **not** enough to be unguessable, and deliberately so:
|
|
49
50
|
uniqueness is settled by a unique index or a registry claim, never by entropy. Walk
|
|
50
|
-
`nextSlugCandidate` until the store accepts one, and never use a slug where a secret is
|
|
51
|
+
`idHelper.nextSlugCandidate` until the store accepts one, and never use a slug where a secret is
|
|
52
|
+
needed.
|
|
51
53
|
|
|
52
54
|
```typescript
|
|
53
|
-
import {
|
|
55
|
+
import { idHelper } from '@owlmeans/basic-ids'
|
|
54
56
|
|
|
55
|
-
const base = generateWordSlug()
|
|
57
|
+
const base = idHelper.generateWordSlug()
|
|
56
58
|
for (let attempt = 1; attempt <= 10; ++attempt) {
|
|
57
|
-
const candidate = nextSlugCandidate(base, attempt) // attempt 1 is the bare name
|
|
59
|
+
const candidate = idHelper.nextSlugCandidate(base, attempt) // attempt 1 is the bare name
|
|
58
60
|
if (await claim(candidate)) return candidate
|
|
59
61
|
}
|
|
60
62
|
```
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/helper/types.ts"],"names":[],"mappings":""}
|
package/build/helper.d.ts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
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;
|
|
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
|
-
*/
|
|
6
|
+
/** @deprecated compat:factory-refactor — use `idHelper.generateWordSlug()` */
|
|
15
7
|
export declare const 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
|
-
*/
|
|
8
|
+
/** @deprecated compat:factory-refactor — use `idHelper.nextSlugCandidate(…)` */
|
|
23
9
|
export declare const nextSlugCandidate: (base: string, attempt: number) => string;
|
|
24
10
|
//# sourceMappingURL=helper.d.ts.map
|
package/build/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"
|
|
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,55 +1,33 @@
|
|
|
1
1
|
import { randomBytes } from '@noble/hashes/utils.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { WORDLIST_A } from './wordlists/list-a.js';
|
|
5
|
-
import { WORDLIST_B } from './wordlists/list-b.js';
|
|
2
|
+
import { WORDLIST_SIZE, WORD_SLUG_SEPARATOR } from './consts.js';
|
|
3
|
+
import { WORDLIST_A, WORDLIST_B } from './wordlists/consts.js';
|
|
6
4
|
import { v4 } from 'uuid';
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* of entropy — far short of a secret, and deliberately so: uniqueness here is settled by a unique
|
|
28
|
-
* index and `nextSlugCandidate`, not by entropy. Never use this for anything that must be
|
|
29
|
-
* unguessable (nonces, secrets, tokens) — `createIdOfLength` is that function.
|
|
30
|
-
*/
|
|
31
|
-
export const generateWordSlug = () => {
|
|
32
|
-
const [a, b] = pickWords(2);
|
|
33
|
-
return `${WORDLIST_A[a]}${WORD_SLUG_SEPARATOR}${WORDLIST_B[b]}`;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The n-th candidate for an occupied slug: `brisk-otter`, `brisk-otter-2`, `brisk-otter-3`.
|
|
37
|
-
*
|
|
38
|
-
* The first attempt is the bare name — a suffix appears only once something already answers to it,
|
|
39
|
-
* so the common case keeps the name it was given. Callers own the availability test (a unique
|
|
40
|
-
* index, a registry claim) and walk this until one is free.
|
|
41
|
-
*/
|
|
42
|
-
export const nextSlugCandidate = (base, attempt) => attempt < 2 ? base : `${base}${WORD_SLUG_SEPARATOR}${attempt}`;
|
|
43
|
-
/**
|
|
44
|
-
* Uniform indices into a 2048-entry list. 2048 is a power of two, so masking 16 random bits down
|
|
45
|
-
* to 11 is unbiased — no rejection loop, and no modulo skew toward the front of the list.
|
|
46
|
-
*/
|
|
47
|
-
const pickWords = (count) => {
|
|
48
|
-
const bytes = randomBytes(count * 2);
|
|
49
|
-
const indices = [];
|
|
50
|
-
for (let i = 0; i < count; ++i) {
|
|
51
|
-
indices.push(((bytes[i * 2] << 8) | bytes[i * 2 + 1]) & (WORDLIST_SIZE - 1));
|
|
52
|
-
}
|
|
53
|
-
return indices;
|
|
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 };
|
|
54
25
|
};
|
|
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);
|
|
55
33
|
//# sourceMappingURL=helper.js.map
|
package/build/helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"
|
|
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,5 +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';
|
|
3
|
-
export * from './wordlists/
|
|
4
|
-
export * from './wordlists/list-b.js';
|
|
5
|
+
export * from './wordlists/consts.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,
|
|
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
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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 @@
|
|
|
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"}
|
package/build/random.js
ADDED
|
@@ -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"}
|