@bboss/uuid32 0.1.0 โ†’ 1.0.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.
Files changed (3) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +124 -124
  3. package/package.json +52 -52
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 bigboss.dev (https://github.com/bigbossdev/uuid32)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2025 bigboss.dev (https://github.com/bigbossdev/uuid32)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,125 +1,125 @@
1
- # @bboss/uuid32
2
-
3
- A lightweight TypeScript library for encoding and decoding UUIDs to/from Crockford Base32 strings, designed exclusively for Node.js environments.
4
-
5
- ## Features
6
-
7
- - ๐Ÿš€ **Fast & Lightweight**: Zero dependencies, optimized for performance
8
- - ๐Ÿ”’ **Node.js Only**: Built specifically for server-side applications
9
- - ๐Ÿ“ฆ **TypeScript Native**: Full TypeScript support with type definitions
10
- - ๐Ÿงช **Well Tested**: Comprehensive test suite with high coverage
11
- - ๐Ÿ”ง **Simple API**: Easy-to-use functions for encoding, decoding, and validation
12
- - ๐Ÿ›ก๏ธ **User-Friendly**: Excludes confusing characters (I, L, O, U) to prevent input errors
13
-
14
- ## Use Cases
15
-
16
- - **Product Key Generation**: Software license keys, serial numbers
17
- - **API Key Generation**: Service authentication tokens, access keys
18
- - **Short IDs**: URL shortening, reference codes, tracking IDs
19
- - **Manual Input**: Reduced errors when users need to type keys manually
20
-
21
- ## Installation
22
-
23
- ```bash
24
- # npm
25
- npm install @bboss/uuid32
26
-
27
- # yarn
28
- yarn add @bboss/uuid32
29
- ```
30
-
31
- ## Requirements
32
-
33
- - Node.js 16.0.0 or higher (requires `crypto.randomUUID()`)
34
- - **Node.js only** - not compatible with browser environments
35
-
36
- ## Usage
37
-
38
- ```javascript
39
- import uuid32 from '@bboss/uuid32';
40
- // const uuid32 = require('@bboss/uuid32'); // legacy way
41
-
42
- // Generate a new Base32 UUID
43
- const shortId = uuid32.generateBase32();
44
- console.log(shortId); // โ†’ "29STNWYQG28H4VWA59PD0XYJR8" (random)
45
-
46
- // Encode existing UUID to Base32
47
- const encoded = uuid32.encode('49ceabcf-5e02-4449-be28-a9b341df4b08');
48
- console.log(encoded); // โ†’ "29STNWYQG28H4VWA59PD0XYJR8"
49
-
50
- // Decode Base32 back to standard UUID
51
- const decoded = uuid32.decode('29STNWYQG28H4VWA59PD0XYJR8');
52
- console.log(decoded); // โ†’ "49ceabcf-5e02-4449-be28-a9b341df4b08"
53
-
54
- // Validation
55
- console.log(uuid32.isValidBase32('29STNWYQG28H4VWA59PD0XYJR8')); // โ†’ true
56
- ```
57
-
58
- ## API Reference
59
-
60
- ### `generateBase32(): string`
61
- Generates a new UUID v4 using `crypto.randomUUID()` and encodes it to Crockford Base32.
62
-
63
- **Returns:** Base32 encoded UUID string
64
-
65
- ### `encode(uuid: string): string`
66
- Encodes a standard UUID to Crockford Base32 format.
67
-
68
- **Parameters:**
69
- - `uuid` - Standard UUID string (with or without hyphens)
70
-
71
- **Returns:** Base32 encoded string
72
-
73
- **Throws:** Error if UUID format is invalid
74
-
75
- ### `decode(base32: string): string`
76
- Decodes a Crockford Base32 string back to standard UUID format.
77
-
78
- **Parameters:**
79
- - `base32` - Base32 encoded string
80
-
81
- **Returns:** Standard UUID string with hyphens
82
-
83
- **Throws:** Error if Base32 format is invalid
84
-
85
- ### `isValidBase32(str: string): boolean`
86
- Validates if a string is a valid Crockford Base32 format.
87
-
88
- **Parameters:**
89
- - `str` - String to validate
90
-
91
- **Returns:** `true` if valid Base32, `false` otherwise
92
-
93
- ## Error Handling
94
-
95
- The library throws descriptive errors for invalid inputs:
96
-
97
- ```javascript
98
- try {
99
- uuid32.encode('invalid-uuid');
100
- } catch (error) {
101
- console.log(error.message); // โ†’ "Invalid UUID format"
102
- }
103
-
104
- try {
105
- uuid32.decode('invalid@base32!');
106
- } catch (error) {
107
- console.log(error.message); // โ†’ "Invalid Base32 format"
108
- }
109
- ```
110
-
111
- ## Crockford Base32 Character Set
112
-
113
- Uses the following 32 characters: `0123456789ABCDEFGHJKMNPQRSTVWXYZ`
114
-
115
- **Excluded characters for clarity:**
116
- - `I` (can be confused with `1`)
117
- - `L` (can be confused with `1`)
118
- - `O` (can be confused with `0`)
119
- - `U` (can be confused with `V`)
120
-
121
- This makes the encoded strings more reliable for manual input and reduces transcription errors.
122
-
123
- ## License
124
-
1
+ # @bboss/uuid32
2
+
3
+ A lightweight TypeScript library for encoding and decoding UUIDs to/from Crockford Base32 strings, designed exclusively for Node.js environments.
4
+
5
+ ## Features
6
+
7
+ - ๐Ÿš€ **Fast & Lightweight**: Zero dependencies, optimized for performance
8
+ - ๐Ÿ”’ **Node.js Only**: Built specifically for server-side applications
9
+ - ๐Ÿ“ฆ **TypeScript Native**: Full TypeScript support with type definitions
10
+ - ๐Ÿงช **Well Tested**: Comprehensive test suite with high coverage
11
+ - ๐Ÿ”ง **Simple API**: Easy-to-use functions for encoding, decoding, and validation
12
+ - ๐Ÿ›ก๏ธ **User-Friendly**: Excludes confusing characters (I, L, O, U) to prevent input errors
13
+
14
+ ## Use Cases
15
+
16
+ - **Product Key Generation**: Software license keys, serial numbers
17
+ - **API Key Generation**: Service authentication tokens, access keys
18
+ - **Short IDs**: URL shortening, reference codes, tracking IDs
19
+ - **Manual Input**: Reduced errors when users need to type keys manually
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ # npm
25
+ npm install @bboss/uuid32
26
+
27
+ # yarn
28
+ yarn add @bboss/uuid32
29
+ ```
30
+
31
+ ## Requirements
32
+
33
+ - Node.js 16.0.0 or higher (requires `crypto.randomUUID()`)
34
+ - **Node.js only** - not compatible with browser environments
35
+
36
+ ## Usage
37
+
38
+ ```javascript
39
+ import uuid32 from '@bboss/uuid32';
40
+ // const uuid32 = require('@bboss/uuid32'); // legacy way
41
+
42
+ // Generate a new Base32 UUID
43
+ const shortId = uuid32.generateBase32();
44
+ console.log(shortId); // โ†’ "29STNWYQG28H4VWA59PD0XYJR8" (random)
45
+
46
+ // Encode existing UUID to Base32
47
+ const encoded = uuid32.encode('49ceabcf-5e02-4449-be28-a9b341df4b08');
48
+ console.log(encoded); // โ†’ "29STNWYQG28H4VWA59PD0XYJR8"
49
+
50
+ // Decode Base32 back to standard UUID
51
+ const decoded = uuid32.decode('29STNWYQG28H4VWA59PD0XYJR8');
52
+ console.log(decoded); // โ†’ "49ceabcf-5e02-4449-be28-a9b341df4b08"
53
+
54
+ // Validation
55
+ console.log(uuid32.isValidBase32('29STNWYQG28H4VWA59PD0XYJR8')); // โ†’ true
56
+ ```
57
+
58
+ ## API Reference
59
+
60
+ ### `generateBase32(): string`
61
+ Generates a new UUID v4 using `crypto.randomUUID()` and encodes it to Crockford Base32.
62
+
63
+ **Returns:** Base32 encoded UUID string
64
+
65
+ ### `encode(uuid: string): string`
66
+ Encodes a standard UUID to Crockford Base32 format.
67
+
68
+ **Parameters:**
69
+ - `uuid` - Standard UUID string (with or without hyphens)
70
+
71
+ **Returns:** Base32 encoded string
72
+
73
+ **Throws:** Error if UUID format is invalid
74
+
75
+ ### `decode(base32: string): string`
76
+ Decodes a Crockford Base32 string back to standard UUID format.
77
+
78
+ **Parameters:**
79
+ - `base32` - Base32 encoded string
80
+
81
+ **Returns:** Standard UUID string with hyphens
82
+
83
+ **Throws:** Error if Base32 format is invalid
84
+
85
+ ### `isValidBase32(str: string): boolean`
86
+ Validates if a string is a valid Crockford Base32 format.
87
+
88
+ **Parameters:**
89
+ - `str` - String to validate
90
+
91
+ **Returns:** `true` if valid Base32, `false` otherwise
92
+
93
+ ## Error Handling
94
+
95
+ The library throws descriptive errors for invalid inputs:
96
+
97
+ ```javascript
98
+ try {
99
+ uuid32.encode('invalid-uuid');
100
+ } catch (error) {
101
+ console.log(error.message); // โ†’ "Invalid UUID format"
102
+ }
103
+
104
+ try {
105
+ uuid32.decode('invalid@base32!');
106
+ } catch (error) {
107
+ console.log(error.message); // โ†’ "Invalid Base32 format"
108
+ }
109
+ ```
110
+
111
+ ## Crockford Base32 Character Set
112
+
113
+ Uses the following 32 characters: `0123456789ABCDEFGHJKMNPQRSTVWXYZ`
114
+
115
+ **Excluded characters for clarity:**
116
+ - `I` (can be confused with `1`)
117
+ - `L` (can be confused with `1`)
118
+ - `O` (can be confused with `0`)
119
+ - `U` (can be confused with `V`)
120
+
121
+ This makes the encoded strings more reliable for manual input and reduces transcription errors.
122
+
123
+ ## License
124
+
125
125
  MIT License - see [LICENSE](LICENSE) file for details.
package/package.json CHANGED
@@ -1,52 +1,52 @@
1
- {
2
- "name": "@bboss/uuid32",
3
- "version": "0.1.0",
4
- "description": "UUID to Crockford Base32 encoding/decoding library for Node.js",
5
- "keywords": [
6
- "uuid",
7
- "base32",
8
- "crockford",
9
- "encoding",
10
- "decoding",
11
- "product-key",
12
- "api-key",
13
- "typescript",
14
- "nodejs"
15
- ],
16
- "author": "bigboss.dev",
17
- "license": "MIT",
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/bigbossdev/uuid32.git"
21
- },
22
- "bugs": {
23
- "url": "https://github.com/bigbossdev/uuid32/issues"
24
- },
25
- "homepage": "https://github.com/bigbossdev/uuid32#readme",
26
- "main": "dist/index.js",
27
- "types": "dist/index.d.ts",
28
- "files": [
29
- "dist/**/*",
30
- "README.md",
31
- "LICENSE"
32
- ],
33
- "engines": {
34
- "node": ">=16.0.0"
35
- },
36
- "scripts": {
37
- "build": "rimraf dist && tsc",
38
- "test": "jest",
39
- "test:watch": "jest --watch",
40
- "test:coverage": "jest --coverage",
41
- "prepublishOnly": "npm run build"
42
- },
43
- "devDependencies": {
44
- "@types/jest": "^29.5.14",
45
- "@types/node": "^22.0.0",
46
- "jest": "^29.7.0",
47
- "rimraf": "^6.0.1",
48
- "ts-jest": "^29.4.5",
49
- "typescript": "^5.9.3"
50
- },
51
- "packageManager": "yarn@4.10.3"
52
- }
1
+ {
2
+ "name": "@bboss/uuid32",
3
+ "version": "1.0.0",
4
+ "description": "UUID to Crockford Base32 encoding/decoding library for Node.js",
5
+ "keywords": [
6
+ "uuid",
7
+ "base32",
8
+ "crockford",
9
+ "encoding",
10
+ "decoding",
11
+ "product-key",
12
+ "api-key",
13
+ "typescript",
14
+ "nodejs"
15
+ ],
16
+ "author": "bigboss.dev",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/bigbossdev/uuid32.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/bigbossdev/uuid32/issues"
24
+ },
25
+ "homepage": "https://github.com/bigbossdev/uuid32#readme",
26
+ "main": "dist/index.js",
27
+ "types": "dist/index.d.ts",
28
+ "files": [
29
+ "dist/**/*",
30
+ "README.md",
31
+ "LICENSE"
32
+ ],
33
+ "engines": {
34
+ "node": ">=16.0.0"
35
+ },
36
+ "scripts": {
37
+ "build": "rimraf dist && tsc",
38
+ "test": "jest",
39
+ "test:watch": "jest --watch",
40
+ "test:coverage": "jest --coverage",
41
+ "prepublishOnly": "npm run build"
42
+ },
43
+ "devDependencies": {
44
+ "@types/jest": "^29.5.14",
45
+ "@types/node": "^22.0.0",
46
+ "jest": "^29.7.0",
47
+ "rimraf": "^6.0.1",
48
+ "ts-jest": "^29.4.5",
49
+ "typescript": "^5.9.3"
50
+ },
51
+ "packageManager": "yarn@4.10.3"
52
+ }