Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 3.31 KB

File metadata and controls

46 lines (30 loc) · 3.31 KB

Extraction and refactoring plan

Minimal-change behavior

  • Preserve JWT header, claims, 60-second backdate, ten-minute lifetime, base64url encoding, and OpenSSL SHA-256 signing.
  • Preserve inline, escaped-newline, base64, and path-based private-key support.
  • Preserve GitHub API headers, endpoints, Bearer scheme, JSON dispatch shape, no-cache semantics, and no retries.
  • Preserve GitHub status/message/request-ID context for failed installation-token requests.

Required refactoring

  • Replace Carbon with Psr\Clock\ClockInterface and a small internal system clock.
  • Replace Laravel configuration with immutable typed configuration plus centralized getenv(), $_ENV, and $_SERVER fallback.
  • Replace Laravel HTTP with injected PSR-18/PSR-17 abstractions.
  • Replace RuntimeException strings with a focused, sanitizing exception hierarchy.
  • Replace implicit response JSON parsing with strict decoding and field validation.
  • Return an InstallationToken value containing token and parsed expiration.
  • Replace Laravel logging with optional PSR-3 logging that contains metadata only.

Application code that remains

All Artisan commands, queue scheduling, cache deduplication, model reloads, approval triggers, static-site rules, feature enablement, delay configuration, application short-code normalization, forced app input, configuration health UI, and translation strings remain in LEM Legalmaster.

Compatibility risks

  • Exact exception classes and sanitized messages differ from generic runtime exceptions and raw response output.
  • Repository/workflow path components are validated and encoded.
  • Installation-token expiration is now mandatory because GitHub's documented response and the requested package contract require it; a missing or invalid value fails clearly.
  • PSR-18 clients do not share Laravel's implicit defaults. The consuming application controls transport timeouts and TLS settings.
  • The package cannot preserve config('app.name'); callers must provide a non-empty User-Agent.

Migration boundary

The Laravel application can later bind a configured GitHubAppClient, replace the support classes and HTTP portions of DispatchGithubWorkflow, and keep its commands, scheduling, job, cache, and UI intact. No application changes are part of this extraction.

Test conversion

Original missing-config tests become configuration exception tests. Private-key health tests become key-format and validation tests. New deterministic behavioral tests cover JWT claims/signature, environment precedence/sources, exact PSR requests, response validation, transport failures, logging sanitation, and workflow status handling. Scheduling/job tests remain in Laravel because they test excluded behavior.

Dependency substitutions

Laravel HTTP becomes PSR-18 plus PSR-17. Carbon becomes PSR Clock. Laravel Log becomes PSR-3. OpenSSL remains the signing engine. PHPUnit, Nyholm PSR-7, PHPStan, and PHP-CS-Fixer are development-only.

Clarification and licensing

No behavior decision is blocked by repository evidence. Licensing remains unresolved: the source application declares a proprietary license and the request does not establish authority to relicense copied source. The new implementation will therefore remain untagged and marked proprietary pending an explicit license decision; no original source file is copied verbatim.