@owlmeans/basic-ids 0.1.18-rc.8 → 0.1.18-rc.9
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
CHANGED
|
@@ -11,7 +11,7 @@ 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.8
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
@@ -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.12
|
|
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-09-
|
|
4
|
+
"version": "0.1.18-rc.9",
|
|
5
|
+
"generatedAt": "2026-09-04T22:43:25.449Z",
|
|
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 —
|
|
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.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
@@ -8,23 +8,57 @@ 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.9"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
## Key Exports
|
|
14
14
|
|
|
15
15
|
| Export | Description |
|
|
16
16
|
|--------|-------------|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
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
|
+
| `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` |
|
|
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
|
-
##
|
|
26
|
+
## Random identifiers
|
|
21
27
|
|
|
22
28
|
```typescript
|
|
23
|
-
import {
|
|
29
|
+
import { createIdOfLength, IdStyle, uuid } from '@owlmeans/basic-ids'
|
|
24
30
|
|
|
25
|
-
const id =
|
|
31
|
+
const id = createIdOfLength(16) // 16 Base58 chars
|
|
32
|
+
const nonce = createIdOfLength(32, IdStyle.Base64) // 32 url-safe Base64 chars
|
|
33
|
+
const recordId = 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
|
+
`generateWordSlug` picks one descriptive word and one subject word out of 2048 each, joined by a
|
|
44
|
+
hyphen. The result is a valid DNS label and a valid Kubernetes object-name segment, so the same
|
|
45
|
+
value can address a host, a namespace and an OIDC client without a second sanitising pass — which
|
|
46
|
+
is why an organization entity's `entitySlug` is generated this way rather than as a random string.
|
|
47
|
+
|
|
48
|
+
Two words carry 22 bits of entropy. That is **not** enough to be unguessable, and deliberately so:
|
|
49
|
+
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 needed.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { generateWordSlug, nextSlugCandidate } from '@owlmeans/basic-ids'
|
|
54
|
+
|
|
55
|
+
const base = generateWordSlug()
|
|
56
|
+
for (let attempt = 1; attempt <= 10; ++attempt) {
|
|
57
|
+
const candidate = nextSlugCandidate(base, attempt) // attempt 1 is the bare name
|
|
58
|
+
if (await claim(candidate)) return candidate
|
|
59
|
+
}
|
|
26
60
|
```
|
|
27
61
|
|
|
28
62
|
## Depends On
|
|
29
63
|
|
|
30
|
-
-
|
|
64
|
+
- `@noble/hashes` (randomness), `@scure/base` (Base58 / Base64), `uuid`
|
package/build/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAsC,MAAM,aAAa,CAAA;AAKzE,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAsC,MAAM,aAAa,CAAA;AAKzE,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;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,QAAO,MAInC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,WAAW,MAAM,KAAG,MACF,CAAA"}
|
package/build/helper.js.map
CHANGED
|
@@ -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,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AAEzB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,
|
|
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,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,UAAU,EA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