{"id":36985184,"url":"https://github.com/tacxou/parser_ldap_rfc4512","last_synced_at":"2026-01-20T16:50:36.929Z","repository":{"id":307484146,"uuid":"1029361128","full_name":"tacxou/parser_ldap_rfc4512","owner":"tacxou","description":"A TypeScript parser for LDAP schema definitions based on RFC 4512, using PEG.js grammar.","archived":false,"fork":false,"pushed_at":"2025-12-17T16:40:26.000Z","size":3214,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-20T17:25:11.934Z","etag":null,"topics":["bun","cli","developer-tools","enterprise","ldap","nodejs","parser","parsing","pegjs","rfc4512","schema","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@tacxou/parser_ldap_rfc4512","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tacxou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-30T23:49:29.000Z","updated_at":"2025-12-17T14:51:36.000Z","dependencies_parsed_at":"2025-07-31T15:30:44.305Z","dependency_job_id":"26c5ee50-bdd3-4367-a39b-ae7ae7f415c9","html_url":"https://github.com/tacxou/parser_ldap_rfc4512","commit_stats":null,"previous_names":["the-software-compagny/parser_ldap_rfc4512","tacxou/parser_ldap_rfc4512"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/tacxou/parser_ldap_rfc4512","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacxou%2Fparser_ldap_rfc4512","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacxou%2Fparser_ldap_rfc4512/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacxou%2Fparser_ldap_rfc4512/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacxou%2Fparser_ldap_rfc4512/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tacxou","download_url":"https://codeload.github.com/tacxou/parser_ldap_rfc4512/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacxou%2Fparser_ldap_rfc4512/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28399517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","cli","developer-tools","enterprise","ldap","nodejs","parser","parsing","pegjs","rfc4512","schema","typescript"],"created_at":"2026-01-13T23:00:58.381Z","updated_at":"2026-01-13T23:01:04.515Z","avatar_url":"https://github.com/tacxou.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RFC 4512 LDAP Schema Parser\n\n[![CI](https://github.com/tacxou/parser_ldap_rfc4512/actions/workflows/ci.yml/badge.svg)](https://github.com/tacxou/parser_ldap_rfc4512/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/tacxou/parser_ldap_rfc4512/branch/main/graph/badge.svg)](https://codecov.io/gh/tacxou/parser_ldap_rfc4512)\n![NPM Version](https://img.shields.io/npm/v/%40tacxou%2Fparser_ldap_rfc4512)\n![NPM Downloads](https://img.shields.io/npm/dm/@tacxou/parser_ldap_rfc4512)\n[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n\n![RFC 4512 LDAP Schema Parser banner](static/banner.png)\n\nA robust TypeScript parser for LDAP schema definitions based on RFC 4512, featuring a complete CLI tool and comprehensive parsing capabilities using PEG.js grammar.\n\n## Overview\n\nThis 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.\n\n## ✨ Key Features\n\n### 🔧 Complete RFC 4512 Parser\n- **Full RFC 4512 Compliance**: Strictly follows the official LDAP schema definition format\n- **OpenLDAP cn=config Support**: Automatically handles OpenLDAP index prefixes like `{57}`\n- **Object Class Parsing**: Complete support for STRUCTURAL, AUXILIARY, and ABSTRACT object classes\n- **Attribute Type Parsing**: Comprehensive parsing of attribute types with all their properties\n- **OID Validation**: Robust validation of numeric object identifiers\n- **Multiple Names Support**: Handles single and multiple NAME definitions seamlessly\n\n### 🖥️ Powerful CLI Tool\n- **Global Command**: `rfc4512-parser` command available system-wide after installation\n- **Multiple Input Sources**: Parse from command line arguments or LDIF files\n- **Flexible Output Formats**: Support for JSON, structured text, and custom formatting\n- **Verbose Mode**: Detailed parsing information for debugging and analysis\n- **Error Reporting**: Comprehensive error messages with line and column information\n\n### 📚 Developer-Friendly API\n- **TypeScript First**: Written in TypeScript with complete type definitions\n- **Robust Grammar**: Uses PEG.js for precise and reliable parsing\n- **Error Handling**: Detailed error system with exact error location\n- **Simple Integration**: Easy-to-use `parseSchema()` function\n- **Module Support**: Compatible with both ESM and CommonJS environments\n\n### 🧪 Production Ready\n- **Comprehensive Testing**: ~100% test coverage with real-world LDAP schemas\n- **CI/CD Pipeline**: Automated testing with GitHub Actions\n- **Performance Optimized**: Built with Bun for optimal performance\n- **Well Documented**: Complete documentation with practical examples\n\n## 🚀 Quick Start\n\n### Installation\n\n```bash\n# Install as a library\nnpm install @tacxou/parser_ldap_rfc4512\n\n# Or with Bun\nbun add @tacxou/parser_ldap_rfc4512\n\n# Install globally for CLI usage\nnpm install -g @tacxou/parser_ldap_rfc4512\n```\n\n### Basic Usage\n\n```typescript\nimport { parseSchema } from '@tacxou/parser_ldap_rfc4512'\n\n// Parse an object class definition\ntry {\n  const result = parseSchema(`\n    ( 2.5.6.6\n      NAME 'person'\n      DESC 'RFC2256: a person'\n      SUP top\n      STRUCTURAL\n      MUST ( sn $ cn )\n      MAY ( userPassword $ telephoneNumber $ description )\n    )\n  `)\n\n  console.log('✅ Successfully parsed:', result)\n  // Output:\n  // {\n  //   oid: '2.5.6.6',\n  //   name: 'person',\n  //   desc: 'RFC2256: a person',\n  //   sup: 'top',\n  //   type: 'STRUCTURAL',\n  //   must: ['sn', 'cn'],\n  //   may: ['userPassword', 'telephoneNumber', 'description']\n  // }\n} catch (error) {\n  console.error('❌ Parse error:', error.message)\n}\n```\n\n## 💻 Command Line Interface\n\nThe CLI provides a powerful way to parse LDAP schemas directly from the terminal.\n\n### Basic CLI Usage\n\n```bash\n# Parse a schema definition directly\nrfc4512-parser \"( 2.5.6.6 NAME 'person' SUP top STRUCTURAL )\"\n\n# Parse from a file\nrfc4512-parser --input schema.ldif\n\n# Output as formatted JSON\nrfc4512-parser --input schema.ldif --format json\n\n# Save results to a file\nrfc4512-parser --input schema.ldif --output parsed-schema.json\n\n# Verbose mode with detailed information\nrfc4512-parser --input schema.ldif --verbose\n```\n\n### Advanced CLI Features\n\n```bash\n# Parse multiple schema definitions from a file\nrfc4512-parser --input multiple-schemas.ldif --format json\n\n# Validate schema syntax without output\nrfc4512-parser --input schema.ldif --validate-only\n\n# Parse with custom error formatting\nrfc4512-parser --input schema.ldif --verbose --format json\n```\n\n📖 **For complete CLI documentation, see [CLI_USAGE.md](CLI_USAGE.md)**\n\n## 📋 Supported Schema Components\n\n### Object Classes\nThe parser handles all RFC 4512 object class components:\n\n- **OID**: Numeric object identifier (e.g., `2.5.6.6`)\n- **NAME**: Single name (`'person'`) or multiple names (`( 'person' 'user' )`)\n- **DESC**: Descriptive text in quotes\n- **SUP**: Superior object class (inheritance)\n- **Object Class Types**: \n  - `STRUCTURAL` - Standard object classes\n  - `AUXILIARY` - Additional attribute sets\n  - `ABSTRACT` - Base classes for inheritance\n- **MUST**: Required attributes list\n- **MAY**: Optional attributes list\n\n### Attribute Types\nComplete support for attribute type definitions:\n\n- **OID**: Unique numeric identifier\n- **NAME**: Single or multiple attribute names\n- **DESC**: Human-readable description\n- **SUP**: Superior attribute type\n- **EQUALITY**: Equality matching rule\n- **ORDERING**: Ordering matching rule\n- **SUBSTR**: Substring matching rule\n- **SYNTAX**: Attribute syntax OID\n- **SINGLE-VALUE**: Single value constraint\n- **COLLECTIVE**: Collective attribute marker\n- **NO-USER-MODIFICATION**: System-only attributes\n\n### Example Schemas\n\n#### Object Class Example\n```ldap\n( 2.5.6.7\n  NAME ( 'organizationalPerson' 'orgPerson' )\n  DESC 'RFC2256: an organizational person'\n  SUP person\n  STRUCTURAL\n  MAY ( title $ x121Address $ registeredAddress $ destinationIndicator $\n        preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $\n        telephoneNumber $ internationaliSDNNumber $ facsimileTelephoneNumber $\n        street $ postOfficeBox $ postalCode $ postalAddress $\n        physicalDeliveryOfficeName $ ou $ st $ l )\n)\n```\n\n#### Attribute Type Example\n```ldap\n( 2.5.4.3\n  NAME ( 'cn' 'commonName' )\n  DESC 'RFC2256: common name(s) for which the entity is known by'\n  SUP name\n)\n```\n\n## 🔧 OpenLDAP cn=config Support\n\nThe parser includes built-in support for OpenLDAP's `cn=config` format, which uses index prefixes to maintain ordering of multi-valued attributes like `olcAttributeTypes` and `olcObjectClasses`.\n\n### Index Prefix Support\n\nOpenLDAP uses numeric prefixes in curly braces to maintain the order of schema definitions:\n\n```ldap\n# OpenLDAP cn=config format with index prefix\n{57}( 1.3.6.1.4.1.7165.2.1.80 NAME 'sambaSupportedEncryptionTypes' \n      DESC 'Supported encryption types of a trust' \n      EQUALITY integerMatch \n      SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 \n      SINGLE-VALUE )\n\n# Equivalent RFC 4512 pure format (without prefix)\n( 1.3.6.1.4.1.7165.2.1.80 NAME 'sambaSupportedEncryptionTypes' \n  DESC 'Supported encryption types of a trust' \n  EQUALITY integerMatch \n  SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 \n  SINGLE-VALUE )\n```\n\n### Automatic Prefix Removal\n\nThe parser automatically detects and removes OpenLDAP index prefixes:\n\n```typescript\nimport { parseSchema } from '@tacxou/parser_ldap_rfc4512'\n\n// Both formats parse to identical results\nconst openLdapFormat = '{57}( 2.5.4.3 NAME \\'cn\\' DESC \\'Common Name\\' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )'\nconst rfc4512Format = '( 2.5.4.3 NAME \\'cn\\' DESC \\'Common Name\\' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )'\n\nconst result1 = parseSchema(openLdapFormat)\nconst result2 = parseSchema(rfc4512Format)\n\nconsole.log(result1 === result2) // true - identical results\n```\n\n### Supported Prefix Patterns\n\nThe parser handles various OpenLDAP prefix formats:\n\n- **Basic format**: `{0}`, `{57}`, `{123}`\n- **With whitespace**: `  {0}  `, `\\t{57}\\t`\n- **Leading spaces**: `   {0}(definition...)`\n- **Any numeric index**: `{0}` to `{99999}` and beyond\n\n### CLI Support for OpenLDAP Format\n\nThe CLI tool seamlessly handles OpenLDAP exports:\n\n```bash\n# Parse OpenLDAP cn=config exports directly\nrfc4512-parser --input openldap-export.ldif --format json\n\n# Example OpenLDAP export file content:\n# {0}( 2.5.4.3 NAME 'cn' DESC 'Common Name' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )\n# {1}( 2.5.4.4 NAME 'sn' DESC 'Surname' SUP name )\n```\n\n## 🏗️ Project Architecture\n\n```bash\n.\n├── .github/                               # GitHub workflows and CI/CD configuration\n│   └── workflows/                         # Automated testing and build pipelines\n├── .vscode/                               # VS Code workspace settings and tasks\n├── dist/                                  # Compiled output (generated)\n├── src/                                   # Source code\n│   ├── _grammars/                         # PEG.js grammar definitions\n│   ├── errors/                            # Error handling system\n│   ├── functions/                         # Core parsing logic\n│   ├── interfaces/                        # TypeScript interfaces\n│   ├── types/                             # Type definitions\n├── test/                                  # Comprehensive test suite\n.\n```\n\n## 🔧 Technical Details\n\n### Grammar Engine\n- **PEG.js Parser**: Uses Parsing Expression Grammar for precise, unambiguous parsing\n- **Error Recovery**: Provides detailed error messages with line and column information\n- **Whitespace Handling**: Robust handling of LDAP schema formatting variations\n- **Performance**: Optimized grammar rules for fast parsing of large schema files\n\n### Type System\n- **Strict TypeScript**: Complete type coverage for all LDAP components\n- **Interface-Driven**: Well-defined interfaces for extensibility\n- **Error Types**: Comprehensive error type system for debugging\n- **Runtime Validation**: Schema validation beyond syntax checking\n\n### Build System\n- **Bun Runtime**: Fast JavaScript runtime for optimal performance\n- **Tree Shaking**: Optimized builds with unused code elimination\n- **Dual Output**: Both ESM and CommonJS compatible builds\n- **CLI Bundling**: Self-contained CLI executable\n\n## 🧪 Testing \u0026 Quality\n\n### Comprehensive Test Suite\n- **Unit Tests**: Complete coverage of all parsing components\n- **Integration Tests**: End-to-end testing with real LDAP schemas\n- **CLI Tests**: Command-line interface testing with various scenarios\n- **Error Handling Tests**: Comprehensive error condition testing\n\n### Real-World Validation\n- **OpenLDAP Schemas**: Tested against actual OpenLDAP schema definitions\n- **RFC Compliance**: Validated against RFC 4512 specifications\n- **Edge Cases**: Extensive testing of formatting variations and edge cases\n\n### Quality Metrics\n- **Code Coverage**: ~100% test coverage on core components\n- **CI/CD**: Automated testing on multiple Node.js versions\n- **Code Quality**: ESLint and Prettier for consistent code style\n- **Performance**: Benchmarked against large schema files\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our contributing guidelines for details on:\n\n- Setting up the development environment\n- Running tests and building the project\n- Code style and formatting requirements\n- Submitting pull requests\n\n### Development Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/tacxou/parser_ldap_rfc4512.git\ncd parser_ldap_rfc4512\n\n# Install dependencies\nbun install\n\n# Run tests\nbun test\n\n# Build the project\nbun run build\n\n# Test CLI locally\nbun run test:cli\n```\n\n## 📄 License\n\nThis project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.\n\n## 🔗 Links\n\n- **NPM Package**: [@tacxou/parser_ldap_rfc4512](https://www.npmjs.com/package/@tacxou/parser_ldap_rfc4512)\n- **GitHub Repository**: [parser_ldap_rfc4512](https://github.com/tacxou/parser_ldap_rfc4512)\n- **Issue Tracker**: [GitHub Issues](https://github.com/tacxou/parser_ldap_rfc4512/issues)\n- **CI/CD Pipeline**: [GitHub Actions](https://github.com/tacxou/parser_ldap_rfc4512/actions)\n- **Code Coverage**: [Codecov](https://codecov.io/gh/tacxou/parser_ldap_rfc4512)\n\n## 📚 Related Resources\n\n- [RFC 4512 - LDAP Directory Information Models](https://tools.ietf.org/html/rfc4512)\n- [OpenLDAP Schema Documentation](https://www.openldap.org/doc/admin24/schema.html)\n- [PEG.js Documentation](https://pegjs.org/documentation)\n\n---\n\nMade with ❤️ by [The Software Compagny](https://github.com/tacxou)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftacxou%2Fparser_ldap_rfc4512","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftacxou%2Fparser_ldap_rfc4512","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftacxou%2Fparser_ldap_rfc4512/lists"}