URI handler (2/3): extract shared auth/environment service#1629
Open
amitjoshi438 wants to merge 1 commit into
Open
URI handler (2/3): extract shared auth/environment service#1629amitjoshi438 wants to merge 1 commit into
amitjoshi438 wants to merge 1 commit into
Conversation
This was referenced Jul 21, 2026
Move the PAC CLI authentication, environment-selection, and process-reset logic out of the `UriHandler` class into a new `utils/authEnvironment.ts` `AuthEnvironmentService` that takes a `PacWrapper`. `UriHandler` now composes the service and delegates: - `handleOpenPowerPages` (`/open`) calls `authEnvironmentService.prepareAuthenticationAndEnvironment(...)` - `executeDownload` calls `authEnvironmentService.resetPacProcessSafely(...)` This is a behavior-preserving refactor: the moved methods (`prepareAuthenticationAndEnvironment`, `ensureAuthentication`, `ensureCorrectEnvironment`, `resetPacProcessAndThrow`, `resetPacProcessSafely`) keep identical logic, telemetry, prompts, and error handling. Extracting them lets the upcoming `/pacCreate` and `/agenticCreate` handlers reuse the exact same auth/environment flow instead of duplicating it. Adds an integration test (`test/integration/authEnvironment.test.ts`) covering the no-prompt happy path, the environment-switch path, and the reset-safely / reset-and-throw error behaviors with a stubbed PacWrapper. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
amitjoshi438
force-pushed
the
amitjoshi-power-pages-uri-handlers-pr2
branch
from
July 22, 2026 11:32
2c5d46e to
a93ae2f
Compare
amitjoshi438
marked this pull request as ready for review
July 22, 2026 11:32
Contributor
Author
|
Rebased onto latest main; now shows only its focus commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 2 of 3 - Phase 0-1 foundation. Behavior-preserving refactor. Stacked on PR 1 (base branch =
amitjoshi-power-pages-uri-handlers), so the diff shows only this PR's commit.Focus commit
2c5d46e2- Extract shared PAC auth/environment helpers intoAuthEnvironmentService.What changed
Moves
prepareAuthenticationAndEnvironment/ensureAuthentication/ensureCorrectEnvironment/resetPacProcess*out ofuriHandler.tsinto a new reusableuriHandler/utils/authEnvironment.tsservice, and refactorsuriHandler.tsto compose/delegate to it. Verbatim moves - the auth/environment behavior of/openis unchanged. This service is what the new create handlers (PR 3) will reuse in later phases.Tests
test/integration/authEnvironment.test.ts(new) - covers the extracted service.Validation
gulp lintclean;compile-testsclean;npm test106 passing;npm run buildOK.Stack
mainamitjoshi-power-pages-uri-handlers(auto-retargets tomainwhen PR 1 merges)Merge after PR 1.
Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com