Skip to content

Ajit/fix fetch auth config#2068

Merged
deadlyjack merged 19 commits into
mainfrom
ajit/fix-fetch-auth-config
May 11, 2026
Merged

Ajit/fix fetch auth config#2068
deadlyjack merged 19 commits into
mainfrom
ajit/fix-fetch-auth-config

Conversation

@deadlyjack
Copy link
Copy Markdown
Member

No description provided.

Ajit Kumar added 2 commits April 28, 2026 18:31
…ion imports

- Replaced ajax calls with fetch in sponsor, sponsors, and themeSetting pages.
- Updated constants import to config in various files for better configuration management.
- Improved error handling for API responses.
- Adjusted logic for premium theme checks based on new config settings.
- Enhanced cookie management in the Authenticator plugin for better security.
- Fixed minor typos and improved code readability across multiple files.
@github-actions github-actions Bot added the translations Anything related to Translations Whether a Issue or PR label Apr 28, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR refactors the auth system from a custom-header XHR flow to a cookie-based scheme: a new Authenticator.java injects the auth token into Android's CookieManager with HttpOnly; Secure; SameSite=None, and a local ajax.js replaces the @deadlyjack/ajax package with withCredentials = true configured globally in main.js for XHR calls. A new config.js consolidates the old constants.js.

  • P1 — Core login fetch lacks credentials: 'include': getLoggedInUser() in auth.js fetches GET /api/login without credentials: \"include\", so the auth cookie is never sent; the server always returns 401 and the user appears permanently logged out.
  • P1 — Server-side logout not invalidated: logout() sends DELETE /login without credentials, leaving the server-side session alive after local logout.
  • P1 — Sponsor purchase fetch unauthenticated: The POST to /api/sponsor in sponsor.js also lacks credentials: \"include\".

Confidence Score: 3/5

Not safe to merge — multiple P1 issues mean the new cookie-based auth flow is broken end-to-end in the Cordova WebView.

Three independent P1 findings across the core login check, logout, and sponsor purchase all using fetch without credentials:include, making the new cookie auth scheme non-functional for critical paths.

src/lib/auth.js (core login/logout fetch calls), src/pages/sponsor/sponsor.js (purchase POST), and previously-flagged plugin purchase/refund fetch calls.

Security Review

  • Stale server-side session on logout (src/lib/auth.js): logout() sends DELETE /login without credentials: \"include\", so the auth cookie is never forwarded to the server. The server-side session is not invalidated; only the local cookie/cache is cleared.
  • Unauthenticated core API calls (src/lib/auth.js, src/pages/sponsor/sponsor.js): getLoggedInUser(), logout(), and the sponsor purchase POST all use fetch without credentials: \"include\", breaking the intended cookie-based auth scheme.

Important Files Changed

Filename Overview
src/lib/auth.js Core auth refactored to cookie-based flow via fetch; both getLoggedInUser() and logout() fetch calls are missing credentials: 'include', breaking login detection and server-side logout.
src/lib/ajax.js New local XHR-based ajax utility replacing @deadlyjack/ajax; withCredentials is wired up via ajax.configure in main.js.
src/lib/config.js New config module consolidating constants.js; includes HAS_PRO getter/setter replacing IS_FREE_VERSION global.
src/lib/adRewards.js getRewardIdentity references undefined user variable (previously flagged); canShowAds/isRewardedSupported correctly migrated to config.HAS_PRO.
src/plugins/auth/src/android/Authenticator.java Refactored to inject auth cookie via CookieManager with HttpOnly; Secure; SameSite=None — addresses previous HttpOnly finding.
src/pages/plugin/plugin.js Migrated from ajax to fetch for order/refund calls; credentials: 'include' still missing (previously flagged).
src/main.js Correctly wires ajax.configure with withCredentials=true for API XHR calls; migrates IS_FREE_VERSION to config.HAS_PRO.
src/pages/sponsor/sponsor.js POST to /api/sponsor is missing credentials: 'include', so the server receives an unauthenticated purchase confirmation.
src/lib/checkPluginsUpdate.js Correctly migrated from ajax to fetch with proper res.ok check and JSON parsing; previous options-object bug is fixed.

Sequence Diagram

sequenceDiagram
    participant App as JS WebView
    participant CM as CookieManager
    participant Server as API Server

    Note over App,CM: Login
    App->>CM: saveToken via cordova.exec
    CM->>CM: setCookie with HttpOnly Secure SameSite=None
    CM-->>App: success

    Note over App,Server: Auth check - getLoggedInUser
    App->>Server: fetch GET /login - no credentials include
    Server-->>App: 401 Unauthorized - cookie not forwarded

    Note over App,Server: XHR path via ajax utility
    App->>Server: XHR with withCredentials true
    Server-->>App: 200 OK - cookie forwarded correctly

    Note over App,Server: Logout
    App->>Server: fetch DELETE /login - no credentials include
    Server-->>App: request without session - session NOT cleared
    App->>CM: clearTokenCookie via cordova.exec
    CM-->>App: local cookie cleared only
Loading

Reviews (2): Last reviewed commit: "fix: update cookie settings to include H..." | Re-trigger Greptile

Comment thread src/lib/checkPluginsUpdate.js Outdated
Comment thread src/lib/adRewards.js Outdated
Comment thread src/plugins/auth/src/android/Authenticator.java
@deadlyjack

This comment was marked as outdated.

Comment thread src/lib/auth.js
Comment thread src/lib/auth.js
Comment thread src/pages/sponsor/sponsor.js
* fix: hooks not working on free version

* Update hooks/post-process.js

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Update post-process.js

---------
Copy link
Copy Markdown
Member

@RohitKushvaha01 RohitKushvaha01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

UnschooledGamer and others added 7 commits May 2, 2026 12:30
* feat: IAP_AVAILABLE

* fix: removed useless logs
* feat: added web redirect

* fix: removed useless code

* fix: removed useless code

* fix: added try/catch

* fix: check owned before launching webpage

* feat: added api to get installer package

* feat: added installer check

* format

* fix: undefined error

* Update src/lib/config.js

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@RohitKushvaha01 RohitKushvaha01 added the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label May 10, 2026
@github-actions github-actions Bot removed the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label May 10, 2026
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

Preview Release for this, has been built.

Click here to view that github actions build

Ajit Kumar and others added 6 commits May 11, 2026 05:03
- Enhanced HandleIntent function to validate plugin installation requests.
- Modified getLoggedInUser method to return a Promise.
- Removed IAP_AVAILABLE from config and adjusted related logic.
- Improved main.js to handle app installation source and define appInstallSource.
- Refactored plugin page to streamline plugin installation and purchase logic.
- Added external purchase handling in plugin view and buttons.
- Updated IAP plugin to track availability status.
- Enhanced ListItem component to manage plugin installation and purchase flow.
- Introduced shouldAllowExternalPurchase helper function for better purchase logic.
@deadlyjack deadlyjack merged commit 81b8ff8 into main May 11, 2026
9 checks passed
@deadlyjack deadlyjack deleted the ajit/fix-fetch-auth-config branch May 11, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

translations Anything related to Translations Whether a Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants