Ajit/fix fetch auth config#2068
Conversation
…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.
Greptile SummaryThis PR refactors the auth system from a custom-header XHR flow to a cookie-based scheme: a new
Confidence Score: 3/5Not 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.
|
| 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
Reviews (2): Last reviewed commit: "fix: update cookie settings to include H..." | Re-trigger Greptile
This comment was marked as outdated.
This comment was marked as outdated.
* 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 ---------
* 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>
This comment has been minimized.
This comment has been minimized.
|
Preview Release for this, has been built. |
- 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.
…-Foundation/Acode into ajit/fix-fetch-auth-config
No description provided.