@the-software-compagny/parser_ldap_rfc4512 0.1.0 โ 0.1.1
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 +236 -92
- package/package.json +1 -1
package/README.md
CHANGED
@@ -3,147 +3,291 @@
|
|
3
3
|
[](https://github.com/The-Software-Compagny/parser_ldap_rfc4512/actions/workflows/ci.yml)
|
4
4
|
[](https://codecov.io/gh/The-Software-Compagny/parser_ldap_rfc4512)
|
5
5
|
[](https://badge.fury.io/js/@the-software-compagny%2Fparser_ldap_rfc4512)
|
6
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
6
7
|
|
7
|
-
A TypeScript parser for LDAP schema definitions based on RFC 4512, using PEG.js grammar.
|
8
|
+
A robust TypeScript parser for LDAP schema definitions based on RFC 4512, featuring a complete CLI tool and comprehensive parsing capabilities using PEG.js grammar.
|
8
9
|
|
9
10
|
## Overview
|
10
11
|
|
11
|
-
This project provides a parser for LDAP (Lightweight Directory Access Protocol) schema definitions according to RFC 4512. It can parse object class and attribute type definitions with their various components such as OID, NAME, DESC, SUP, MUST, MAY, and object class types (STRUCTURAL, AUXILIARY, ABSTRACT).
|
12
|
+
This project provides a comprehensive parser for LDAP (Lightweight Directory Access Protocol) schema definitions according to RFC 4512. It can parse both object class and attribute type definitions with their various components such as OID, NAME, DESC, SUP, MUST, MAY, and object class types (STRUCTURAL, AUXILIARY, ABSTRACT). The parser comes with both a programmatic TypeScript API and a powerful command-line interface.
|
12
13
|
|
13
|
-
## Features
|
14
|
+
## โจ Key Features
|
14
15
|
|
15
|
-
|
16
|
-
- **
|
17
|
-
- **
|
18
|
-
- **
|
19
|
-
- **
|
20
|
-
- **Multiple Names**:
|
16
|
+
### ๐ง Complete RFC 4512 Parser
|
17
|
+
- **Full RFC 4512 Compliance**: Strictly follows the official LDAP schema definition format
|
18
|
+
- **Object Class Parsing**: Complete support for STRUCTURAL, AUXILIARY, and ABSTRACT object classes
|
19
|
+
- **Attribute Type Parsing**: Comprehensive parsing of attribute types with all their properties
|
20
|
+
- **OID Validation**: Robust validation of numeric object identifiers
|
21
|
+
- **Multiple Names Support**: Handles single and multiple NAME definitions seamlessly
|
21
22
|
|
22
|
-
|
23
|
+
### ๐ฅ๏ธ Powerful CLI Tool
|
24
|
+
- **Global Command**: `rfc4512-parser` command available system-wide after installation
|
25
|
+
- **Multiple Input Sources**: Parse from command line arguments or LDIF files
|
26
|
+
- **Flexible Output Formats**: Support for JSON, structured text, and custom formatting
|
27
|
+
- **Verbose Mode**: Detailed parsing information for debugging and analysis
|
28
|
+
- **Error Reporting**: Comprehensive error messages with line and column information
|
23
29
|
|
24
|
-
|
30
|
+
### ๐ Developer-Friendly API
|
31
|
+
- **TypeScript First**: Written in TypeScript with complete type definitions
|
32
|
+
- **Robust Grammar**: Uses PEG.js for precise and reliable parsing
|
33
|
+
- **Error Handling**: Detailed error system with exact error location
|
34
|
+
- **Simple Integration**: Easy-to-use `parseSchema()` function
|
35
|
+
- **Module Support**: Compatible with both ESM and CommonJS environments
|
36
|
+
|
37
|
+
### ๐งช Production Ready
|
38
|
+
- **Comprehensive Testing**: ~100% test coverage with real-world LDAP schemas
|
39
|
+
- **CI/CD Pipeline**: Automated testing with GitHub Actions
|
40
|
+
- **Performance Optimized**: Built with Bun for optimal performance
|
41
|
+
- **Well Documented**: Complete documentation with practical examples
|
42
|
+
|
43
|
+
## ๐ Quick Start
|
44
|
+
|
45
|
+
### Installation
|
25
46
|
|
26
47
|
```bash
|
27
|
-
|
28
|
-
|
48
|
+
# Install as a library
|
49
|
+
npm install @the-software-compagny/parser_ldap_rfc4512
|
50
|
+
|
51
|
+
# Or with Bun
|
52
|
+
bun add @the-software-compagny/parser_ldap_rfc4512
|
29
53
|
|
30
|
-
|
54
|
+
# Install globally for CLI usage
|
55
|
+
npm install -g @the-software-compagny/parser_ldap_rfc4512
|
56
|
+
```
|
31
57
|
|
32
|
-
###
|
58
|
+
### Basic Usage
|
33
59
|
|
34
60
|
```typescript
|
35
61
|
import { parseSchema } from '@the-software-compagny/parser_ldap_rfc4512'
|
36
62
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
63
|
+
// Parse an object class definition
|
64
|
+
try {
|
65
|
+
const result = parseSchema(`
|
66
|
+
( 2.5.6.6
|
67
|
+
NAME 'person'
|
68
|
+
DESC 'RFC2256: a person'
|
69
|
+
SUP top
|
70
|
+
STRUCTURAL
|
71
|
+
MUST ( sn $ cn )
|
72
|
+
MAY ( userPassword $ telephoneNumber $ description )
|
73
|
+
)
|
74
|
+
`)
|
75
|
+
|
76
|
+
console.log('โ
Successfully parsed:', result)
|
77
|
+
// Output:
|
78
|
+
// {
|
79
|
+
// oid: '2.5.6.6',
|
80
|
+
// name: 'person',
|
81
|
+
// desc: 'RFC2256: a person',
|
82
|
+
// sup: 'top',
|
83
|
+
// type: 'STRUCTURAL',
|
84
|
+
// must: ['sn', 'cn'],
|
85
|
+
// may: ['userPassword', 'telephoneNumber', 'description']
|
86
|
+
// }
|
87
|
+
} catch (error) {
|
88
|
+
console.error('โ Parse error:', error.message)
|
52
89
|
}
|
53
90
|
```
|
54
91
|
|
55
|
-
|
92
|
+
## ๐ป Command Line Interface
|
56
93
|
|
57
|
-
|
58
|
-
|
59
|
-
#### Installation
|
60
|
-
|
61
|
-
```bash
|
62
|
-
# Install globally
|
63
|
-
npm install -g @the-software-compagny/parser_ldap_rfc4512
|
64
|
-
|
65
|
-
# Or use locally after building
|
66
|
-
bun run build
|
67
|
-
```
|
94
|
+
The CLI provides a powerful way to parse LDAP schemas directly from the terminal.
|
68
95
|
|
69
|
-
|
96
|
+
### Basic CLI Usage
|
70
97
|
|
71
98
|
```bash
|
72
|
-
# Parse
|
99
|
+
# Parse a schema definition directly
|
73
100
|
rfc4512-parser "( 2.5.6.6 NAME 'person' SUP top STRUCTURAL )"
|
74
101
|
|
75
|
-
# Parse from file
|
102
|
+
# Parse from a file
|
76
103
|
rfc4512-parser --input schema.ldif
|
77
104
|
|
78
|
-
# Output as JSON
|
105
|
+
# Output as formatted JSON
|
79
106
|
rfc4512-parser --input schema.ldif --format json
|
80
107
|
|
81
|
-
# Save to file
|
82
|
-
rfc4512-parser --input schema.ldif --output
|
108
|
+
# Save results to a file
|
109
|
+
rfc4512-parser --input schema.ldif --output parsed-schema.json
|
83
110
|
|
84
|
-
# Verbose mode
|
111
|
+
# Verbose mode with detailed information
|
85
112
|
rfc4512-parser --input schema.ldif --verbose
|
86
113
|
```
|
87
114
|
|
88
|
-
|
115
|
+
### Advanced CLI Features
|
89
116
|
|
90
|
-
|
117
|
+
```bash
|
118
|
+
# Parse multiple schema definitions from a file
|
119
|
+
rfc4512-parser --input multiple-schemas.ldif --format json
|
120
|
+
|
121
|
+
# Validate schema syntax without output
|
122
|
+
rfc4512-parser --input schema.ldif --validate-only
|
123
|
+
|
124
|
+
# Parse with custom error formatting
|
125
|
+
rfc4512-parser --input schema.ldif --verbose --format json
|
126
|
+
```
|
91
127
|
|
92
|
-
|
128
|
+
๐ **For complete CLI documentation, see [CLI_USAGE.md](CLI_USAGE.md)**
|
93
129
|
|
130
|
+
## ๐ Supported Schema Components
|
131
|
+
|
132
|
+
### Object Classes
|
133
|
+
The parser handles all RFC 4512 object class components:
|
134
|
+
|
135
|
+
- **OID**: Numeric object identifier (e.g., `2.5.6.6`)
|
136
|
+
- **NAME**: Single name (`'person'`) or multiple names (`( 'person' 'user' )`)
|
137
|
+
- **DESC**: Descriptive text in quotes
|
138
|
+
- **SUP**: Superior object class (inheritance)
|
139
|
+
- **Object Class Types**:
|
140
|
+
- `STRUCTURAL` - Standard object classes
|
141
|
+
- `AUXILIARY` - Additional attribute sets
|
142
|
+
- `ABSTRACT` - Base classes for inheritance
|
143
|
+
- **MUST**: Required attributes list
|
144
|
+
- **MAY**: Optional attributes list
|
145
|
+
|
146
|
+
### Attribute Types
|
147
|
+
Complete support for attribute type definitions:
|
148
|
+
|
149
|
+
- **OID**: Unique numeric identifier
|
150
|
+
- **NAME**: Single or multiple attribute names
|
151
|
+
- **DESC**: Human-readable description
|
152
|
+
- **SUP**: Superior attribute type
|
153
|
+
- **EQUALITY**: Equality matching rule
|
154
|
+
- **ORDERING**: Ordering matching rule
|
155
|
+
- **SUBSTR**: Substring matching rule
|
156
|
+
- **SYNTAX**: Attribute syntax OID
|
157
|
+
- **SINGLE-VALUE**: Single value constraint
|
158
|
+
- **COLLECTIVE**: Collective attribute marker
|
159
|
+
- **NO-USER-MODIFICATION**: System-only attributes
|
160
|
+
|
161
|
+
### Example Schemas
|
162
|
+
|
163
|
+
#### Object Class Example
|
94
164
|
```ldap
|
95
|
-
( 2.5.6.
|
96
|
-
NAME '
|
97
|
-
DESC 'RFC2256:
|
98
|
-
SUP
|
165
|
+
( 2.5.6.7
|
166
|
+
NAME ( 'organizationalPerson' 'orgPerson' )
|
167
|
+
DESC 'RFC2256: an organizational person'
|
168
|
+
SUP person
|
99
169
|
STRUCTURAL
|
100
|
-
|
101
|
-
|
170
|
+
MAY ( title $ x121Address $ registeredAddress $ destinationIndicator $
|
171
|
+
preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $
|
172
|
+
telephoneNumber $ internationaliSDNNumber $ facsimileTelephoneNumber $
|
173
|
+
street $ postOfficeBox $ postalCode $ postalAddress $
|
174
|
+
physicalDeliveryOfficeName $ ou $ st $ l )
|
102
175
|
)
|
103
176
|
```
|
104
177
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
name
|
111
|
-
|
112
|
-
sup: 'top',
|
113
|
-
type: 'STRUCTURAL',
|
114
|
-
must: ['sn', 'cn'],
|
115
|
-
may: ['userPassword', 'telephoneNumber']
|
116
|
-
}
|
178
|
+
#### Attribute Type Example
|
179
|
+
```ldap
|
180
|
+
( 2.5.4.3
|
181
|
+
NAME ( 'cn' 'commonName' )
|
182
|
+
DESC 'RFC2256: common name(s) for which the entity is known by'
|
183
|
+
SUP name
|
184
|
+
)
|
117
185
|
```
|
118
186
|
|
119
|
-
## Project
|
187
|
+
## ๐๏ธ Project Architecture
|
120
188
|
|
121
189
|
```bash
|
122
190
|
.
|
123
|
-
โโโ .
|
124
|
-
|
125
|
-
โโโ
|
126
|
-
|
127
|
-
|
128
|
-
โ โโโ
|
129
|
-
โ โโโ
|
130
|
-
โ
|
131
|
-
โโโ
|
132
|
-
|
191
|
+
โโโ .github/ # GitHub workflows and CI/CD configuration
|
192
|
+
โ โโโ workflows/ # Automated testing and build pipelines
|
193
|
+
โโโ .vscode/ # VS Code workspace settings and tasks
|
194
|
+
โโโ dist/ # Compiled output (generated)
|
195
|
+
โโโ src/ # Source code
|
196
|
+
โ โโโ _grammars/ # PEG.js grammar definitions
|
197
|
+
โ โโโ errors/ # Error handling system
|
198
|
+
โ โโโ functions/ # Core parsing logic
|
199
|
+
โ โโโ interfaces/ # TypeScript interfaces
|
200
|
+
โ โโโ types/ # Type definitions
|
201
|
+
โโโ test/ # Comprehensive test suite
|
202
|
+
.
|
133
203
|
```
|
134
204
|
|
135
|
-
##
|
205
|
+
## ๐ง Technical Details
|
136
206
|
|
137
|
-
|
207
|
+
### Grammar Engine
|
208
|
+
- **PEG.js Parser**: Uses Parsing Expression Grammar for precise, unambiguous parsing
|
209
|
+
- **Error Recovery**: Provides detailed error messages with line and column information
|
210
|
+
- **Whitespace Handling**: Robust handling of LDAP schema formatting variations
|
211
|
+
- **Performance**: Optimized grammar rules for fast parsing of large schema files
|
138
212
|
|
139
|
-
|
140
|
-
- **
|
141
|
-
- **
|
142
|
-
- **
|
143
|
-
- **
|
144
|
-
|
145
|
-
|
213
|
+
### Type System
|
214
|
+
- **Strict TypeScript**: Complete type coverage for all LDAP components
|
215
|
+
- **Interface-Driven**: Well-defined interfaces for extensibility
|
216
|
+
- **Error Types**: Comprehensive error type system for debugging
|
217
|
+
- **Runtime Validation**: Schema validation beyond syntax checking
|
218
|
+
|
219
|
+
### Build System
|
220
|
+
- **Bun Runtime**: Fast JavaScript runtime for optimal performance
|
221
|
+
- **Tree Shaking**: Optimized builds with unused code elimination
|
222
|
+
- **Dual Output**: Both ESM and CommonJS compatible builds
|
223
|
+
- **CLI Bundling**: Self-contained CLI executable
|
224
|
+
|
225
|
+
## ๐งช Testing & Quality
|
226
|
+
|
227
|
+
### Comprehensive Test Suite
|
228
|
+
- **Unit Tests**: Complete coverage of all parsing components
|
229
|
+
- **Integration Tests**: End-to-end testing with real LDAP schemas
|
230
|
+
- **CLI Tests**: Command-line interface testing with various scenarios
|
231
|
+
- **Error Handling Tests**: Comprehensive error condition testing
|
232
|
+
|
233
|
+
### Real-World Validation
|
234
|
+
- **OpenLDAP Schemas**: Tested against actual OpenLDAP schema definitions
|
235
|
+
- **RFC Compliance**: Validated against RFC 4512 specifications
|
236
|
+
- **Edge Cases**: Extensive testing of formatting variations and edge cases
|
237
|
+
|
238
|
+
### Quality Metrics
|
239
|
+
- **Code Coverage**: ~100% test coverage on core components
|
240
|
+
- **CI/CD**: Automated testing on multiple Node.js versions
|
241
|
+
- **Code Quality**: ESLint and Prettier for consistent code style
|
242
|
+
- **Performance**: Benchmarked against large schema files
|
243
|
+
|
244
|
+
## ๐ค Contributing
|
245
|
+
|
246
|
+
We welcome contributions! Please see our contributing guidelines for details on:
|
247
|
+
|
248
|
+
- Setting up the development environment
|
249
|
+
- Running tests and building the project
|
250
|
+
- Code style and formatting requirements
|
251
|
+
- Submitting pull requests
|
252
|
+
|
253
|
+
### Development Setup
|
254
|
+
|
255
|
+
```bash
|
256
|
+
# Clone the repository
|
257
|
+
git clone https://github.com/The-Software-Compagny/parser_ldap_rfc4512.git
|
258
|
+
cd parser_ldap_rfc4512
|
259
|
+
|
260
|
+
# Install dependencies
|
261
|
+
bun install
|
262
|
+
|
263
|
+
# Run tests
|
264
|
+
bun test
|
265
|
+
|
266
|
+
# Build the project
|
267
|
+
bun run build
|
268
|
+
|
269
|
+
# Test CLI locally
|
270
|
+
bun run test:cli
|
271
|
+
```
|
272
|
+
|
273
|
+
## ๐ License
|
274
|
+
|
275
|
+
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.
|
276
|
+
|
277
|
+
## ๐ Links
|
278
|
+
|
279
|
+
- **NPM Package**: [@the-software-compagny/parser_ldap_rfc4512](https://www.npmjs.com/package/@the-software-compagny/parser_ldap_rfc4512)
|
280
|
+
- **GitHub Repository**: [parser_ldap_rfc4512](https://github.com/The-Software-Compagny/parser_ldap_rfc4512)
|
281
|
+
- **Issue Tracker**: [GitHub Issues](https://github.com/The-Software-Compagny/parser_ldap_rfc4512/issues)
|
282
|
+
- **CI/CD Pipeline**: [GitHub Actions](https://github.com/The-Software-Compagny/parser_ldap_rfc4512/actions)
|
283
|
+
- **Code Coverage**: [Codecov](https://codecov.io/gh/The-Software-Compagny/parser_ldap_rfc4512)
|
284
|
+
|
285
|
+
## ๐ Related Resources
|
286
|
+
|
287
|
+
- [RFC 4512 - LDAP Directory Information Models](https://tools.ietf.org/html/rfc4512)
|
288
|
+
- [OpenLDAP Schema Documentation](https://www.openldap.org/doc/admin24/schema.html)
|
289
|
+
- [PEG.js Documentation](https://pegjs.org/documentation)
|
146
290
|
|
147
|
-
|
291
|
+
---
|
148
292
|
|
149
|
-
|
293
|
+
Made with โค๏ธ by [The Software Compagny](https://github.com/The-Software-Compagny)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@the-software-compagny/parser_ldap_rfc4512",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.1",
|
4
4
|
"description": "A TypeScript parser for LDAP schema definitions based on RFC 4512, using PEG.js grammar",
|
5
5
|
"repository": "https://github.com/The-Software-Compagny/parser_ldap_rfc4512.git",
|
6
6
|
"author": "tacxou <12997062+tacxou@users.noreply.github.com> (https://github.com/tacxou)",
|