@auto-engineer/id 1.148.0 → 1.150.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +33 -0
- package/README.md +44 -41
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/id@1.
|
|
2
|
+
> @auto-engineer/id@1.149.0 test /home/runner/work/auto-engineer/auto-engineer/packages/id
|
|
3
3
|
> vitest run --reporter=dot
|
|
4
4
|
|
|
5
5
|
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
11
11
|
[2m Tests [22m [1m[32m2 passed[39m[22m[90m (2)[39m
|
|
12
|
-
[2m Start at [22m
|
|
13
|
-
[2m Duration [22m 2.
|
|
12
|
+
[2m Start at [22m 12:20:40
|
|
13
|
+
[2m Duration [22m 2.04s[2m (transform 321ms, setup 0ms, collect 331ms, tests 36ms, environment 0ms, prepare 561ms)[22m
|
|
14
14
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @auto-engineer/id
|
|
2
2
|
|
|
3
|
+
## 1.150.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a502d47`](https://github.com/BeOnAuto/auto-engineer/commit/a502d472df528a1c5d53905898220c2a3a49d8a5) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
8
|
+
|
|
9
|
+
- [`c96a70e`](https://github.com/BeOnAuto/auto-engineer/commit/c96a70e49f9f64213450d0b9840bc9a8b2b1d77d) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
10
|
+
|
|
11
|
+
- [`4343bca`](https://github.com/BeOnAuto/auto-engineer/commit/4343bcaa2576703ae578fd9b7f5ec5b9776702a9) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
12
|
+
|
|
13
|
+
- [`28ffce9`](https://github.com/BeOnAuto/auto-engineer/commit/28ffce9c8b95f0c3ca61728bd1f667fa9416d461) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
14
|
+
|
|
15
|
+
- [`3fd5dbf`](https://github.com/BeOnAuto/auto-engineer/commit/3fd5dbfbfb4f7a5fe71ae53105b31a1b0f30f911) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`41f3df3`](https://github.com/BeOnAuto/auto-engineer/commit/41f3df3025445ba92208c2b007b8e29a40489309) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **global**: version packages
|
|
20
|
+
- **global**: major refresh to all the docs
|
|
21
|
+
|
|
22
|
+
## 1.149.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- [`e1eebbd`](https://github.com/BeOnAuto/auto-engineer/commit/e1eebbdf4f209780e790094d2e6887c4fa809f98) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: add Given state ref hints to state.ts.ejs
|
|
27
|
+
- **server-generator-apollo-emmett**: context-aware nonCommandField instructions
|
|
28
|
+
- **server-generator-apollo-emmett**: add state context instruction
|
|
29
|
+
- **server-generator-apollo-emmett**: extract shared template helpers
|
|
30
|
+
- **server-generator-apollo-emmett**: filter state refs from hasGivenEvents in decide.ts.ejs
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [`d38c81e`](https://github.com/BeOnAuto/auto-engineer/commit/d38c81e7bb442a39626564cf4f6d8d55b60d0a38) Thanks [@SamHatoum](https://github.com/SamHatoum)! -
|
|
35
|
+
|
|
3
36
|
## 1.148.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -8,7 +8,14 @@ Generate cryptographically secure, URL-safe, unbiased base-62 identifiers.
|
|
|
8
8
|
|
|
9
9
|
Without `@auto-engineer/id`, you would have to implement your own ID generation with proper cryptographic security, handle modulo bias in random number generation, and ensure URL-safe character encoding.
|
|
10
10
|
|
|
11
|
-
This package provides compact, URL-safe identifiers using base-62 encoding with cryptographically secure random values. The implementation uses rejection sampling to
|
|
11
|
+
This package provides compact, URL-safe identifiers using base-62 encoding (`A-Za-z0-9`) with cryptographically secure random values. The implementation uses rejection sampling to eliminate modulo bias, ensuring uniform distribution across all 62 characters.
|
|
12
|
+
|
|
13
|
+
## Key Concepts
|
|
14
|
+
|
|
15
|
+
- **Base-62 Encoding** -- Uses `A-Z`, `a-z`, `0-9` (62 characters) to produce identifiers that are safe in URLs, filenames, and HTML attributes without escaping.
|
|
16
|
+
- **Rejection Sampling** -- Random bytes outside an evenly divisible range are discarded, preventing modulo bias that would make some characters more likely than others.
|
|
17
|
+
- **Cryptographic Security** -- Built on `crypto.getRandomValues()` (Web Crypto API), not `Math.random()`.
|
|
18
|
+
- **Entropy** -- A default 9-character token yields 62^9 (~13.5 quadrillion) combinations, approximately 53.6 bits of entropy.
|
|
12
19
|
|
|
13
20
|
---
|
|
14
21
|
|
|
@@ -24,8 +31,7 @@ pnpm add @auto-engineer/id
|
|
|
24
31
|
import { generateId } from '@auto-engineer/id';
|
|
25
32
|
|
|
26
33
|
const id = generateId();
|
|
27
|
-
|
|
28
|
-
// → "aP9ZfWcLQ"
|
|
34
|
+
// → "aP9ZfWcLQ" (9-character base-62 token)
|
|
29
35
|
```
|
|
30
36
|
|
|
31
37
|
---
|
|
@@ -38,10 +44,12 @@ console.log(id);
|
|
|
38
44
|
import { generateId } from '@auto-engineer/id';
|
|
39
45
|
|
|
40
46
|
const id = generateId();
|
|
41
|
-
// 9-character base-62 token
|
|
47
|
+
// 9-character base-62 token, no prefix
|
|
42
48
|
```
|
|
43
49
|
|
|
44
|
-
### Generate with Prefix
|
|
50
|
+
### Generate with a Prefix
|
|
51
|
+
|
|
52
|
+
Prefixes must be URL-safe (`A-Za-z0-9_-`). A trailing `-` is allowed as a separator.
|
|
45
53
|
|
|
46
54
|
```typescript
|
|
47
55
|
import { generateId } from '@auto-engineer/id';
|
|
@@ -50,16 +58,16 @@ const userId = generateId({ prefix: 'user-' });
|
|
|
50
58
|
// → "user-xYz7GhtR2"
|
|
51
59
|
```
|
|
52
60
|
|
|
53
|
-
### Generate with Custom Length
|
|
61
|
+
### Generate with a Custom Length
|
|
54
62
|
|
|
55
63
|
```typescript
|
|
56
64
|
import { generateId } from '@auto-engineer/id';
|
|
57
65
|
|
|
58
|
-
const
|
|
59
|
-
// → "
|
|
66
|
+
const shortId = generateId({ length: 6 });
|
|
67
|
+
// → "Ab3Xyz"
|
|
60
68
|
```
|
|
61
69
|
|
|
62
|
-
### Combine
|
|
70
|
+
### Combine Prefix and Length
|
|
63
71
|
|
|
64
72
|
```typescript
|
|
65
73
|
import { generateId } from '@auto-engineer/id';
|
|
@@ -76,63 +84,58 @@ const orderId = generateId({ prefix: 'ord-', length: 6 });
|
|
|
76
84
|
|
|
77
85
|
```typescript
|
|
78
86
|
import { generateId, type GenerateIdOptions } from '@auto-engineer/id';
|
|
79
|
-
|
|
80
|
-
import { BASE62_ALPHABET, BASE62_TOKEN_REGEX, SAFE_PREFIX_REGEX } from '@auto-engineer/id/constants';
|
|
81
|
-
|
|
82
|
-
import { generateBase62Token, assertSafePrefix } from '@auto-engineer/id/core';
|
|
83
87
|
```
|
|
84
88
|
|
|
85
89
|
### Functions
|
|
86
90
|
|
|
87
91
|
#### `generateId(options?: GenerateIdOptions): string`
|
|
88
92
|
|
|
89
|
-
Generate a unique identifier with optional prefix and length.
|
|
93
|
+
Generate a unique identifier with an optional prefix and configurable token length.
|
|
94
|
+
|
|
95
|
+
| Parameter | Type | Default | Description |
|
|
96
|
+
|-----------|----------|---------|----------------------------------------------------|
|
|
97
|
+
| `prefix` | `string` | `''` | String prepended to the token (must be URL-safe) |
|
|
98
|
+
| `length` | `number` | `9` | Length of the random base-62 token portion |
|
|
90
99
|
|
|
91
|
-
|
|
92
|
-
|-----------|------|---------|-------------|
|
|
93
|
-
| `prefix` | `string` | - | String to prepend (must be URL-safe) |
|
|
94
|
-
| `length` | `number` | 9 | Token length |
|
|
100
|
+
**Returns:** `string` -- the concatenation of `prefix` and the generated token.
|
|
95
101
|
|
|
96
|
-
|
|
102
|
+
**Throws:** `Error` if `prefix` contains characters outside `A-Za-z0-9_-`.
|
|
103
|
+
|
|
104
|
+
### Interfaces
|
|
105
|
+
|
|
106
|
+
#### `GenerateIdOptions`
|
|
97
107
|
|
|
98
108
|
```typescript
|
|
99
109
|
type GenerateIdOptions = {
|
|
110
|
+
/** Optional string to prepend before the token. (URL-safe; trailing '-' ok) */
|
|
100
111
|
prefix?: string;
|
|
112
|
+
/** Token length; default 9 (base-62). */
|
|
101
113
|
length?: number;
|
|
102
114
|
};
|
|
103
115
|
```
|
|
104
116
|
|
|
105
|
-
### Constants
|
|
106
|
-
|
|
107
|
-
| Constant | Value | Description |
|
|
108
|
-
|----------|-------|-------------|
|
|
109
|
-
| `BASE62_ALPHABET` | A-Za-z0-9 | 62-character alphabet |
|
|
110
|
-
| `BASE62_TOKEN_REGEX` | `/^[A-Za-z0-9]+$/` | Token validation |
|
|
111
|
-
| `SAFE_PREFIX_REGEX` | `/^[A-Za-z0-9_-]+$/` | Prefix validation |
|
|
112
|
-
|
|
113
117
|
---
|
|
114
118
|
|
|
115
119
|
## Architecture
|
|
116
120
|
|
|
117
121
|
```
|
|
118
122
|
src/
|
|
119
|
-
├── index.ts
|
|
120
|
-
├── core.ts
|
|
121
|
-
└── constants.ts
|
|
123
|
+
├── index.ts # Public API: generateId, GenerateIdOptions
|
|
124
|
+
├── core.ts # assertSafePrefix, generateBase62Token (rejection sampling)
|
|
125
|
+
└── constants.ts # BASE62_ALPHABET, regex patterns
|
|
122
126
|
```
|
|
123
127
|
|
|
124
|
-
###
|
|
125
|
-
|
|
126
|
-
- **Base-62 Encoding**: Uses A-Z, a-z, 0-9 for URL-safe identifiers
|
|
127
|
-
- **Rejection Sampling**: Ensures unbiased character distribution
|
|
128
|
-
- **Cryptographic Security**: Uses `crypto.getRandomValues()`
|
|
129
|
-
|
|
130
|
-
### Entropy Analysis
|
|
128
|
+
### Internal Modules
|
|
131
129
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
-
|
|
130
|
+
| File | Responsibility |
|
|
131
|
+
|----------------|-------------------------------------------------------------|
|
|
132
|
+
| `constants.ts` | Defines the 62-char alphabet and validation regexes |
|
|
133
|
+
| `core.ts` | Prefix validation and unbiased token generation |
|
|
134
|
+
| `index.ts` | Composes `core` functions into the public `generateId` API |
|
|
135
135
|
|
|
136
136
|
### Dependencies
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
| Dependency | Kind | Purpose |
|
|
139
|
+
|------------|----------|--------------------------------|
|
|
140
|
+
| `nanoid` | Runtime | Listed in `dependencies` (unused in current source; reserved) |
|
|
141
|
+
| `vitest` | Dev-only | Test runner |
|