You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrate native addon from nan to node-addon-api and add a JS wrapper/ESM entry (index.js / index.mjs). Implement genAsync (worker-thread async) and make output length configurable (1–22, default 8) with input validation and a 64KB input limit. Replace hex-path with an optimized Base62 encoder, add thorough OpenSSL return-value checks, and update binding.gyp for N-API and Windows OpenSSL settings.
Add prebuild support (prebuildify + node-gyp-build), a prebuild CI workflow, and integrate prebuild download into the publish workflow so most users won't need a compiler. Expand CI to test Linux/macOS/Windows across Node 20/22/24. Update package.json (version → 1.2.0, exports field, scripts, deps/devDeps) and add bench.js, CLI length/version flags, TypeScript defs (index.d.ts), .editorconfig and ESLint config, README and CHANGELOG entries documenting the changes.
- Async support (`genAsync`) for non-blocking operation
11
+
- Prebuilt binaries for major platforms (no compiler needed)
10
12
- Cryptographically secure using SHA-256
11
-
- Base62 encoding (0-9, a-z, A-Z)
12
-
- Deterministic results - same input produces same output
13
+
- Base62 encoding (0-9, A-Z, a-z)
14
+
- Deterministic results - same input always produces same output
15
+
- ESM and CommonJS support
16
+
- CLI included
13
17
14
18
## Installation
15
19
```bash
16
-
npm install theshortener --save
20
+
npm install theshortener
17
21
```
18
22
23
+
Prebuilt binaries are included for Linux, macOS, and Windows. Falls back to compiling from source if no prebuild is available (requires C++ compiler + OpenSSL dev libraries).
The default 8-character output uses 64 bits of the SHA-256 hash, providing approximately 47.6 bits of entropy in Base62. By the birthday paradox, you can expect a ~50% collision probability after roughly 2³² (~4.3 billion) unique inputs. For fewer collisions, use a longer output length.
121
+
63
122
## Notes
64
123
65
-
-The output is always 8 characters long
124
+
-Uses N-API (Node-API) for ABI stability across Node.js versions
66
125
- Uses OpenSSL for SHA-256 hashing
67
-
- This is a one-way hashing implementation. Reverse lookups (getting original STR from short code) require storing STR-to-hash mappings in a database.
126
+
- This is a one-way hashing implementation. Reverse lookups (getting original string from short code) require storing input-to-code mappings in a database
127
+
- Shorter lengths are prefixes of longer outputs (same input)
0 commit comments