Skip to content

feat(resource-id): implement deterministic resource identifier codec with namespace isolation - #408

Merged
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
ValJnr-dev1:feat/resource-identifier-codec-388
Aug 31, 2026
Merged

feat(resource-id): implement deterministic resource identifier codec with namespace isolation#408
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
ValJnr-dev1:feat/resource-identifier-codec-388

Conversation

@ValJnr-dev1

Copy link
Copy Markdown
Contributor

Description

Implements a deterministic resource identifier codec with namespace isolation for GuildPass access control systems.

Changes

  • New Package: @guildpass/resource-id with complete TypeScript implementation
  • Core Interface: ResourceIdentifier with namespace and segments structure
  • Parsing Logic: parseResourceId with comprehensive validation
  • Formatting Logic: formatResourceId producing canonical representation
  • Security Features:
    • Percent-encoding for reserved delimiters (:, /, %)
    • Path traversal prevention (., .., \)
    • Configurable length limits and segment validation
  • Utility Functions: Equality comparison, lexicographic ordering, safe constructors
  • Comprehensive Testing: 38 unit tests covering Unicode, edge cases, security validation

Implementation Details

The codec uses : as namespace delimiter and / as segment delimiter, with percent-encoding for reserved characters. All validation is deterministic and security-focused:

  • Namespace: alphanumeric, underscore, hyphen only (max 32 chars)
  • Segments: reject empty segments and path traversal patterns (max 64 chars each, max 8 segments)
  • Total identifier length: max 512 characters
  • Round-trip parse/format consistency guaranteed

Testing

  • ✅ All 38 unit tests pass
  • pnpm typecheck passes
  • pnpm build passes
  • ✅ Full test coverage including Unicode, malformed encoding, boundary conditions

Acceptance Criteria Met

✅ Valid identifiers parse into expected namespace and segments
✅ Formatting produces canonical representation
✅ Parse/format round trips succeed
✅ Empty namespaces and segments rejected
✅ Reserved delimiter handling explicit and tested
✅ Oversized identifiers rejected
✅ Malformed escaping/encoding rejected safely
✅ Canonically equivalent identifiers compare equally
✅ Comprehensive unit tests cover all edge cases
✅ Independent implementation (no external dependencies)

Closes #388

…with namespace isolation

- Add ResourceIdentifier interface with namespace and segments
- Implement parseResourceId with comprehensive validation
- Implement formatResourceId producing canonical representation
- Add percent-encoding for reserved delimiters (: / %)
- Validate namespace syntax (alphanumeric, underscore, hyphen)
- Reject empty segments and path traversal patterns
- Impose configurable length limits for security
- Support round-trip parse/format consistency
- Add equality and lexicographic comparison helpers
- Include 38 comprehensive unit tests covering Unicode, encoding, edge cases
- All validation requirements per issue Adamantine-guild#388

Closes Adamantine-guild#388
@Lakes41
Lakes41 merged commit b556f6c into Adamantine-guild:main Aug 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a deterministic resource identifier codec with namespace isolation

2 participants