feat(libSceNpAuth): implement sceNpAuthGetAuthorizationCodeA and sceNpAuthGetIdTokenA #8471

Merged
NoOverflow merged 2 commits from upstream-pr/8471 into main 2026-10-21 13:52:58 +00:00
NoOverflow commented 2026-10-20 13:12:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NoOverflow on 2026-10-20T13:12:44Z.


What

Implements sceNpAuthGetAuthorizationCodeA and sceNpAuthGetIdTokenA in core/libs/prx/libSceNpAuth/Export.cpp:

  • Both forward to their V3 counterparts, which share one implementation in shadPS4, so they follow the library's signed-out request model: null param or output returns ORBIS_NP_AUTH_ERROR_INVALID_ARGUMENT (0x80550301), an unknown request ID returns ORBIS_NP_AUTH_ERROR_REQUEST_NOT_FOUND (0x80550306), an aborted request returns ORBIS_NP_AUTH_ERROR_ABORTED (0x80550304), a sync request fails immediately with SCE_NP_ERROR_SIGNED_OUT and an async one defers it to Poll/Wait.
  • issuer_id stays optional, as in the V3 call.
  • Adds unit tests in core/libs/tests/GuestNpAuth.cpp covering argument validation, the sync and async signed-out flows, unknown request IDs and aborted requests for both calls.
  • Folds the two former entries into the request-model entry in docs/dev/debt/libSceNpAuth.md; the signatures are still not measured on a console.
  • Completes libSceNpAuth exports (14/14, 100.0%).

Tested

  • Linux (Ubuntu 24.04, GCC 13.3): cmake --build build --target libSceNpAuth guest_np_auth_tests guest_np_auth_authorized_app_code_tests guest_np_auth_authorized_app_dialog_tests built cleanly; ctest --test-dir build -R np_auth --output-on-failure passed (3/3: guest_np_auth, guest_np_auth_authorized_app_code, guest_np_auth_authorized_app_dialog).
  • python3 tools/check_conventions.py --base origin/main: passed with 0 violations.
  • python3 tools/pr_overlap.py --branch feat/libSceNpAuth-a-variants: no shared exports or conflicting lines; the uncompared shared files belong to PR 6044 (test reorganization) and PR 6977 (appends a no-argument sceNpAuthGetAuthorizationCode stub on a stale base), which implement neither function.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4936263365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8471). Originally posted by [NoOverflow](https://github.com/NoOverflow) on 2026-10-20T13:12:44Z. --- ### What Implements `sceNpAuthGetAuthorizationCodeA` and `sceNpAuthGetIdTokenA` in `core/libs/prx/libSceNpAuth/Export.cpp`: - Both forward to their V3 counterparts, which share one implementation in shadPS4, so they follow the library's signed-out request model: null `param` or output returns `ORBIS_NP_AUTH_ERROR_INVALID_ARGUMENT` (0x80550301), an unknown request ID returns `ORBIS_NP_AUTH_ERROR_REQUEST_NOT_FOUND` (0x80550306), an aborted request returns `ORBIS_NP_AUTH_ERROR_ABORTED` (0x80550304), a sync request fails immediately with `SCE_NP_ERROR_SIGNED_OUT` and an async one defers it to Poll/Wait. - `issuer_id` stays optional, as in the V3 call. - Adds unit tests in `core/libs/tests/GuestNpAuth.cpp` covering argument validation, the sync and async signed-out flows, unknown request IDs and aborted requests for both calls. - Folds the two former entries into the request-model entry in `docs/dev/debt/libSceNpAuth.md`; the signatures are still not measured on a console. - Completes `libSceNpAuth` exports (14/14, 100.0%). ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Linux (Ubuntu 24.04, GCC 13.3): `cmake --build build --target libSceNpAuth guest_np_auth_tests guest_np_auth_authorized_app_code_tests guest_np_auth_authorized_app_dialog_tests` built cleanly; `ctest --test-dir build -R np_auth --output-on-failure` passed (3/3: guest_np_auth, guest_np_auth_authorized_app_code, guest_np_auth_authorized_app_dialog). - `python3 tools/check_conventions.py --base origin/main`: passed with 0 violations. - `python3 tools/pr_overlap.py --branch feat/libSceNpAuth-a-variants`: no shared exports or conflicting lines; the uncompared shared files belong to PR 6044 (test reorganization) and PR 6977 (appends a no-argument `sceNpAuthGetAuthorizationCode` stub on a stale base), which implement neither function. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-20 13:33:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T13:33:32Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestNpAuth.cpp
PR 6977 core/libs/prx/libSceNpAuth/Export.cpp
PR 9137 core/libs/prx/libSceNpAuth/Export.cpp
core/libs/tests/GuestNpAuth.cpp
docs/dev/debt/libSceNpAuth.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6292089709 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8471#issuecomment-6292089709). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T13:33:32Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestNpAuth.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libSceNpAuth/Export.cpp` | | [PR 9137](https://www.github.com/boykopovar/AnyPS5/pull/9137) | `core/libs/prx/libSceNpAuth/Export.cpp`<br>`core/libs/tests/GuestNpAuth.cpp`<br>`docs/dev/debt/libSceNpAuth.md` |
nikowolf123 commented 2026-10-20 19:05:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T19:05:12Z.


docs/dev/debt/libSceNpAuth.md#L6: the merged entry has only one shadPS4 link, https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/np/np_auth.cpp, and it returns 404. shadPS4#5390 moved the file to np/np_auth/np_auth.cpp on 2026-10-19. This PR deletes the two entries whose shadPS4 links still work. As a result, nobody can check the new clause "the A calls forward to their V3 counterparts, which share one implementation in shadPS4" from the entry.

I'd pin the link to the last version at the old path, db126323. That is the file the link showed when the entry was written, and the A and V3 calls share one helper there too (L170-L180, L266-L274). The longer URL takes the entry from 969 to 1005 characters, which is over the 1000-character debt-length warning in tools/check_conventions.py. With this wording the entry is 997 characters:

follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/db126323b960ba79de6f71e329ebe39be46905a9/src/core/libraries/np/np_auth.cpp) (PS4); the A calls forward to their V3 counterparts, which share one helper in shadPS4;

Line 7 (sceNpAuthSetTimeout) has the same dead link. Pinning it to db126323 also keeps its "which only stubs it" true (L276-L280). The rewritten file checks the timeouts and the request ID (L201-L224), so it no longer backs that sentence.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298917092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8471#issuecomment-6298917092). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T19:05:12Z. --- **[docs/dev/debt/libSceNpAuth.md#L6](https://github.com/boykopovar/AnyPS5/blob/eb6630530c78d67d4cbfbf4695e5f04022932fb7/docs/dev/debt/libSceNpAuth.md#L6)**: the merged entry has only one shadPS4 link, `https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/np/np_auth.cpp`, and it returns 404. [shadPS4#5390](https://github.com/shadps4-emu/shadPS4/pull/5390) moved the file to `np/np_auth/np_auth.cpp` on 2026-10-19. This PR deletes the two entries whose shadPS4 links still work. As a result, nobody can check the new clause "the A calls forward to their V3 counterparts, which share one implementation in shadPS4" from the entry. I'd pin the link to the last version at the old path, [db126323](https://github.com/shadps4-emu/shadPS4/blob/db126323b960ba79de6f71e329ebe39be46905a9/src/core/libraries/np/np_auth.cpp). That is the file the link showed when the entry was written, and the A and V3 calls share one helper there too ([L170-L180](https://github.com/shadps4-emu/shadPS4/blob/db126323b960ba79de6f71e329ebe39be46905a9/src/core/libraries/np/np_auth.cpp#L170-L180), [L266-L274](https://github.com/shadps4-emu/shadPS4/blob/db126323b960ba79de6f71e329ebe39be46905a9/src/core/libraries/np/np_auth.cpp#L266-L274)). The longer URL takes the entry from 969 to 1005 characters, which is over the 1000-character `debt-length` warning in `tools/check_conventions.py`. With this wording the entry is 997 characters: ```markdown follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/db126323b960ba79de6f71e329ebe39be46905a9/src/core/libraries/np/np_auth.cpp) (PS4); the A calls forward to their V3 counterparts, which share one helper in shadPS4; ``` Line 7 (`sceNpAuthSetTimeout`) has the same dead link. Pinning it to db126323 also keeps its "which only stubs it" true ([L276-L280](https://github.com/shadps4-emu/shadPS4/blob/db126323b960ba79de6f71e329ebe39be46905a9/src/core/libraries/np/np_auth.cpp#L276-L280)). The rewritten file checks the timeouts and the request ID ([L201-L224](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/np/np_auth/np_auth.cpp#L201-L224)), so it no longer backs that sentence.
oneandonlydean commented 2026-10-21 02:56:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T02:56:47Z.


@NoOverflow the forwards and tests look good. Two small things before merge:

  1. As noted above, the shadPS4 link in the merged docs/dev/debt/libSceNpAuth.md entry 404s since shadPS4#5390 moved the file to src/core/libraries/np/np_auth/np_auth.cpp. Please point it at the new path, ideally pinned to a commit, so the "A calls forward to V3" statement can be checked.
  2. The two return sceNpAuth...V3(...) lines are indented by one space; the rest of Export.cpp uses four.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6306890293 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8471#issuecomment-6306890293). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T02:56:47Z. --- @NoOverflow the forwards and tests look good. Two small things before merge: 1. As noted above, the shadPS4 link in the merged `docs/dev/debt/libSceNpAuth.md` entry 404s since shadPS4#5390 moved the file to `src/core/libraries/np/np_auth/np_auth.cpp`. Please point it at the new path, ideally pinned to a commit, so the "A calls forward to V3" statement can be checked. 2. The two `return sceNpAuth...V3(...)` lines are indented by one space; the rest of `Export.cpp` uses four.
xXPBSXx commented 2026-10-21 04:47:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T04:47:56Z.


Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main is clean. I built only guest_np_auth_tests; ctest -N -R guest_np_auth lists exactly one test.

Results (3 runs each):

  • PR head: guest_np_auth passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/libs/prx/libSceNpAuth/Export.cpp with the version from the PR's merge base (44e3389c88), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.

Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308292761 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8471#issuecomment-6308292761). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T04:47:56Z. --- Independent Windows run of this PR (data only). **Environment:** Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against `main` is clean. I built only `guest_np_auth_tests`; `ctest -N -R guest_np_auth` lists exactly one test. **Results (3 runs each):** - PR head: `guest_np_auth` passes 3/3. - Baseline: I kept the PR's test and replaced only `core/libs/prx/libSceNpAuth/Export.cpp` with the version from the PR's merge base (`44e3389c88`), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards. **Not run:** other platforms, the other tests in the same family, the full repository CTest, and any title or console run. AI-assisted (Claude Code).
github-actions[bot] commented 2026-10-21 11:28:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T11:28:35Z.


Progress report (3e91c8e → 488da17)

📈 System libraries: 48.8% (+0.02%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceNpAuth sceNpAuthGetAuthorizationCodeA
libSceNpAuth sceNpAuthGetIdTokenA
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6314799287 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8471#issuecomment-6314799287). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T11:28:35Z. --- <!-- progress-report --> ### Progress report (3e91c8e → 488da17) 📈 **System libraries**: 48.8% (+0.02%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libSceNpAuth | `sceNpAuthGetAuthorizationCodeA` | | libSceNpAuth | `sceNpAuthGetIdTokenA` | </details>
adriadam10 commented 2026-10-21 13:53:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T13:53:08Z.


Thanks, @oneandonlydean and @nikowolf123. Both points are done as a commit on the branch:

  • The two return sceNpAuth...V3(...) lines in Export.cpp are indented with four spaces.
  • The merged entry in docs/dev/debt/libSceNpAuth.md now links shadPS4 at f68923fe, under np/np_auth/np_auth.cpp, with line ranges for the A and V3 variants of both calls. They call the same helper and differ only in a version flag.

Checked the forwards against shadPS4, the tests (they fail on the old throwing stubs, as @xXPBSXx's Windows run shows) and the scoped ctest; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6317800898 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8471#issuecomment-6317800898). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T13:53:08Z. --- Thanks, @oneandonlydean and @nikowolf123. Both points are done as a commit on the branch: - The two `return sceNpAuth...V3(...)` lines in `Export.cpp` are indented with four spaces. - The merged entry in `docs/dev/debt/libSceNpAuth.md` now links shadPS4 at `f68923fe`, under `np/np_auth/np_auth.cpp`, with line ranges for the A and V3 variants of both calls. They call the same helper and differ only in a version flag. Checked the forwards against shadPS4, the tests (they fail on the old throwing stubs, as @xXPBSXx's Windows run shows) and the scoped ctest; merged.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8471
No description provided.