Skip to content

Feature/auth fixes and react sdk tests#242

Merged
yash-pouranik merged 16 commits into
mainfrom
feature/auth-fixes-and-react-sdk-tests
May 31, 2026
Merged

Feature/auth fixes and react sdk tests#242
yash-pouranik merged 16 commits into
mainfrom
feature/auth-fixes-and-react-sdk-tests

Conversation

@yash-pouranik
Copy link
Copy Markdown
Collaborator

@yash-pouranik yash-pouranik commented May 31, 2026

📝 Summary

This PR addresses critical vulnerabilities in the authentication flows, patches a concurrency race condition in the OAuth exchange, stabilizes the @urbackend/react SDK by completing its social auth flow, and introduces comprehensive unit testing for the React components. Furthermore, all SDKs and repository documentation have been updated to reflect the latest state.

🐛 Bug Fixes & Security Patches

  • [Security] Prevent Account Enumeration: Fixed a vulnerability in the password reset endpoint where soft-deleted accounts returned a distinct 403 status. The endpoint now returns a generic success response for soft-deleted users, perfectly mimicking non-existent accounts to prevent enumeration attacks.
  • [Concurrency] Atomic OAuth Token Exchange: Resolved a critical race condition in the social auth token exchange endpoint (userAuth.controller.js). Replaced the sequential redis.get() and redis.del() logic with an atomic redis.getdel() operation to prevent replay attacks during concurrent requests.
  • [React SDK] Complete Social Exchange Flow: Fixed an issue in the <UrProvider /> where rtCode was ignored. The provider now correctly extracts rtCode from query parameters and token from the URL fragment, executing auth.socialExchange({ token, rtCode }) to ensure long-lived sessions are reliably established even in strict cross-site cookie environments.

✨ Enhancements & Testing

  • React SDK Unit Tests: Added robust Vitest/JSDOM testing coverage for the @urbackend/react SDK, specifically targeting context.test.tsx (Logic & Auth flows) and UrAuth.test.tsx (UI behavior). All tests are passing.
  • Documentation Alignment:
    • Updated Python SDK docs (README.md & auth.py) to correctly reflect that the social auth token relies in the URL fragment (#token=...), not the query string.
    • Corrected JSDoc payload descriptions in the JS/TS @urbackend/sdk (auth.ts).
    • Modernized AGENTS.md with the new SDK ecosystem, testing commands, and atomic Redis patterns.

📦 Chore / Release

  • Version Bumps: Bumped versions across packages/*, apps/*, and @urbackend/sdk.
  • Reset @urbackend/react version to v0.1.0 following standard urBackend naming conventions for new packages.
  • Bumped Python SDK (urbackend) to v0.1.1.

⚠️ Deployment Notes

  • Redis Requirement: The backend now relies on the GETDEL command. Please ensure the production Redis instance is running Version 6.2.0 or higher before deploying this PR. No database schema migrations are required.

Summary by CodeRabbit

  • New Features

    • Added React SDK (provider, hooks, themed auth UI, Toast) and a React demo app with full auth flows.
    • Key creation modal now shows key with a dedicated copy button.
  • Bug Fixes

    • Better parsing of API error messages.
    • Authentication now blocks soft-deleted accounts across auth and profile flows.
    • Social refresh exchange now consumes one-time tokens atomically.
  • Documentation

    • Updated Python SDK social auth guidance and SDK listings.
  • Style

    • Refined dashboard visuals (glass-card blur, navbar, hover/press).
  • Tests

    • Added/tests expanded for React SDK, social auth, and refresh flows.
  • Chores

    • Version bumps across packages.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Review Change Stack

Warning

Review limit reached

@yash-pouranik, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 minutes and 15 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f4c9a2c7-e6fb-4430-8ca4-419aae836a02

📥 Commits

Reviewing files that changed from the base of the PR and between 972a3c6 and 135f776.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • sdks/urbackend-react/package.json
  • sdks/urbackend-react/src/context.tsx
  • sdks/urbackend-sdk/package.json
  • sdks/urbackend-sdk/src/errors.ts
  • sdks/urbackend-sdk/src/modules/auth.ts
📝 Walkthrough

Walkthrough

Adds soft-delete denial across auth endpoints and makes social exchange atomic via redis.getdel (tests updated); improves SDK error parsing and client init; introduces a React SDK (provider, hooks, UrAuth/Toast, tests) and a Vite+TS demo; updates dashboard styles, copy-key UX, and workspace/package versions.

Changes

Auth Security & Social Token Exchange

Layer / File(s) Summary
Soft-deleted user blocking across auth flows
apps/public-api/src/controllers/userAuth.controller.js
checkUserSoftDeleted helper blocks soft-deleted users (403 + scheduled-deletion message) for signup, login, me, publicProfile, refreshToken, reset/update/change password, and social user resolution.
Atomic social token exchange with getdel
apps/public-api/src/controllers/userAuth.controller.js, apps/public-api/src/__tests__/userAuth.social.test.js
exchangeSocialRefreshToken consumes exchange data with redis.getdel; tests updated to mock/assert getdel and removed explicit get/del expectations.
Refresh revoke on soft-delete
apps/public-api/src/controllers/userAuth.controller.js, apps/public-api/src/__tests__/userAuth.refresh.test.js
refreshToken denies soft-deleted users with 403, revokes refresh session chain, and clears refresh cookie; tests assert 403 and cleared cookie.

SDK Error Handling & Docs

Layer / File(s) Summary
parseApiError, client init, and docs
sdks/urbackend-sdk/src/errors.ts, sdks/urbackend-sdk/src/client.ts, sdks/urbackend-sdk/src/modules/auth.ts, sdks/urbackend-python/src/urbackend/auth.py, sdks/urbackend-python/README.md, AGENTS.md
parseApiError now prefers error (string/array) and falls back to message; UrBackendClient enforces apiKey and bumps User-Agent; socialExchange docs and Python examples updated to treat rtCode in query and token in URL fragment; AGENTS.md documents SDKs and social refresh exchange pattern and test commands.

React SDK & Demo Application

Layer / File(s) Summary
React SDK context, hooks, and core exports
sdks/urbackend-react/src/context.tsx, sdks/urbackend-react/src/hooks.ts, sdks/urbackend-react/src/index.ts, sdks/urbackend-react/package.json, sdks/urbackend-react/tests/context.test.tsx
Adds UrProvider wiring UrBackendClient and modules, auth init logic handling social callbacks and refresh, useAuth/useDb/useStorage hooks with memoized actions and state, and context tests.
React SDK Toast and UrAuth UI components
sdks/urbackend-react/src/components/Toast.tsx, sdks/urbackend-react/src/components/UrAuth.tsx, sdks/urbackend-react/tests/UrAuth.test.tsx
Adds Toast (auto-dismiss animations) and UrAuth (signin/signup/forgot/reset UI, provider buttons, theme-aware inline styles) plus component tests.
React demo application with infrastructure and bootstrap
examples/react-sdk-demo/*
Adds Vite+TS demo app using UrProvider/useAuth, TypeScript configs, ESLint, Vitest setup, package.json linking local SDKs, HTML/CSS/README and bootstrap main.tsx.

Dashboard UI & Metadata Updates

Layer / File(s) Summary
Dashboard styling and key copy feature
apps/web-dashboard/src/index.css, apps/web-dashboard/src/pages/ProjectDetails.jsx
Tweaks dark glassmorphism variables and .glass-card hover behavior; New Key modal renders key with a copy button that uses navigator.clipboard.writeText and shows success/error toasts.
Package version updates
root and workspace manifests (package.json, packages/common/package.json, sdks/urbackend-sdk/package.json, sdks/urbackend-python/pyproject.toml, apps/*/package.json)
Bumps root and multiple workspace package versions and SDK package versions; minor lint-staged edit.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant UrProvider
  participant AuthModule
  participant Redis
  Browser->>UrProvider: page load (location.search / location.hash)
  UrProvider->>AuthModule: setToken(token) (if token in hash)
  UrProvider->>AuthModule: socialExchange({token, rtCode}) (if rtCode present)
  AuthModule->>Redis: getdel(exchangeKey) (atomic)
  Redis-->>AuthModule: exchangePayload or null
  alt payload exists and matches
    AuthModule->>UrProvider: set session / issue refresh
    UrProvider-->>Browser: render authenticated UI
  else missing/invalid
    AuthModule-->>UrProvider: error -> show redirect/error
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

feature, backend, frontend, type:security, type:refactor, quality:clean, mentor:yash-pouranik, level3

"🐰 I hopped through code to mend and fix,
I guarded tokens and ensured no mix.
React SDK blooms and toasts take flight,
Docs and demos ready — build tonight!"

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Feature/auth fixes and react sdk tests' is vague and overly broad, using non-descriptive terms that don't convey the main change clearly enough for scanning commit history. Use a more specific title that highlights the primary change. Consider: 'Add React SDK with social auth support and fix auth race conditions' or 'Implement @urbackend/react SDK and replace redis.get+del with atomic getdel'.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auth-fixes-and-react-sdk-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@yash-pouranik
Copy link
Copy Markdown
Collaborator Author

@coderabbitai
review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

@yash-pouranik: Sure! Kicking off a review of PR #242 now.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yash-pouranik
Copy link
Copy Markdown
Collaborator Author

are u doing/? @coderabbitai

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Tip

For best results, initiate chat on the files or code changes.

@yash-pouranik Yes, the review is underway! I triggered it in my previous response. Results will be posted shortly once the analysis is complete. 🐇

@yash-pouranik
Copy link
Copy Markdown
Collaborator Author

@coderabbitai
not done yet??

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the current status of PR `#242` reviews and comments
gh pr view 242 --repo geturbackend/urBackend --json reviews,state,title,headRefName 2>&1

Length of output: 750


🏁 Script executed:

#!/bin/bash
# Check recent review comments on PR `#242`
gh api repos/geturbackend/urBackend/pulls/242/reviews 2>&1 | jq '[.[] | {id: .id, user: .user.login, state: .state, submitted_at: .submitted_at, body: .body[:200]}]' 2>&1

Length of output: 555



@yash-pouranik Sorry about the wait! It looks like my review hasn't posted yet — only a Copilot review attempt (which errored) shows up. Let me kick it off again right now! 🐇 /(•ω•)\

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 13

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/public-api/src/controllers/userAuth.controller.js (1)

903-952: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Normalize the exchange endpoint's error contract and stop leaking backend errors.

The success path uses { success, data, message }, but the error branches omit data, and the catch block forwards raw err.message. That breaks the controller contract and can expose Redis/internal failure details to clients. This endpoint should return the same envelope on every branch and map unexpected failures to a generic AppError/message.

As per coding guidelines: "All API endpoints must return { success: bool, data: {}, message: "" } format. Use AppError class for errors—never raw throw and never expose MongoDB errors to client."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/public-api/src/controllers/userAuth.controller.js` around lines 903 -
952, The exchangeSocialRefreshToken handler currently returns different response
shapes and leaks err.message; update all branches (including the early 400/403
returns and the catch) to always return the envelope { success: bool, data: {},
message: "" } (e.g., data: {} for error paths) and replace any raw backend error
text with a generic message or an AppError instance; specifically, in
exchangeSocialRefreshToken adjust the responses for missing rtCode/token,
invalid/expired rawExchange (from redis.getdel), malformed JSON, and invalid
payload (parsedExchange) to include data: {} and a clear client-facing message,
and in the catch block do not forward err.message—return status 500 with data:
{} and a generic "Internal server error" (or an AppError) so Redis/internal
errors are never exposed.
sdks/urbackend-python/README.md (1)

148-158: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Clarify client-side token extraction from URL fragment.

The example shows parse_fragment(request).get("token") to extract the token from the URL fragment, but URL fragments are never sent to the server in HTTP requests—they're client-side only.

The backend cannot directly parse #token=... from an incoming request. This token must be extracted in the browser (using JavaScript like new URLSearchParams(window.location.hash.slice(1))) and then passed to the backend via a separate request parameter, request body, or header.

📝 Suggested documentation fix
-# 2. After the user returns to <siteUrl>/auth/callback?rtCode=...#token=...
-#    exchange BOTH the rtCode and the one-time token (backend requires both)
-rt_code = request.GET.get("rtCode")
-# Token must be parsed from the URL fragment (`#token`=...), not query string
-token   = parse_fragment(request).get("token")
-session = client.auth.social_exchange(rt_code, token)
+# 2. After the user returns to <siteUrl>/auth/callback?rtCode=...#token=...
+#    The rtCode is in the query string, but the token is in the URL fragment.
+#    URL fragments are client-side only and never sent to the server.
+#    
+#    Client-side (JavaScript):
+#      const params = new URLSearchParams(window.location.search);
+#      const rtCode = params.get("rtCode");
+#      const token = new URLSearchParams(window.location.hash.slice(1)).get("token");
+#      // Send both to your backend endpoint via POST or query params
+#    
+#    Backend (Python):
+rt_code = request.GET.get("rtCode")  # or from POST body
+token = request.GET.get("token")      # or from POST body (sent by client-side JS)
+session = client.auth.social_exchange(rt_code, token)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/urbackend-python/README.md` around lines 148 - 158, The README example
incorrectly suggests extracting a one-time token from the URL fragment on the
server using parse_fragment(request); fragments are never sent to the server.
Update the docs to instruct developers to extract the token client-side (e.g.,
from window.location.hash) and then send it to the backend (as a POST
body/query/header) so the backend endpoint can call
client.auth.social_exchange(rt_code, token); mention parse_fragment only for
client-side helpers or remove it and show that the server receives token via an
explicit parameter before calling client.auth.social_exchange and then
client.auth.refresh_token/session handling.
🧹 Nitpick comments (3)
apps/web-dashboard/src/index.css (1)

194-205: ⚡ Quick win

Deduplicate .glass-card style blocks to avoid divergence.

The same selector is defined twice with overlapping declarations and split hover behavior. Consolidating into a single block will prevent accidental drift.

Proposed consolidation
-.glass-card {
-  background: var(--color-glass-card-bg);
-  backdrop-filter: var(--glass-backdrop);
-  border: 1px solid var(--color-glass-card-border);
-  box-shadow: 0 4px 24px -8px rgba(0, 0, 0, 0.5);
-  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
-}
-
-.glass-card:hover {
-  border-color: rgba(255, 255, 255, 0.12);
-  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
-}
@@
 .glass-card {
   background: var(--color-glass-card-bg);
   backdrop-filter: var(--glass-backdrop);
   border: 1px solid var(--color-glass-card-border);
   box-shadow: 0 4px 24px -8px rgba(0, 0, 0, 0.5);
   transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
 }
 
 .glass-card:hover {
   border-color: rgba(255, 255, 255, 0.12);
   box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
   transform: translateY(-2px);
 }

Also applies to: 222-234

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web-dashboard/src/index.css` around lines 194 - 205, The .glass-card
styles are duplicated across multiple blocks, which can cause the base and hover
declarations to drift apart. Consolidate the repeated .glass-card and
.glass-card:hover rules into a single definition in index.css, keeping all
shared properties together and preserving the hover state in one place so future
changes only need to be made once.
apps/public-api/src/__tests__/userAuth.social.test.js (1)

444-507: ⚡ Quick win

Add regression coverage for soft-deleted social users.

These updates cover the getdel swap, but the new 403 branches in findOrCreateSocialUser still aren't protected by tests for either provider-ID lookup or verified-email lookup. A couple of focused cases here would keep the auth-hardening change from silently regressing.

Based on learnings: "When changing public auth behavior, verify changes in userAuth.controller.js, userAuth.js routes, refreshToken.js, and corresponding test files."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/public-api/src/__tests__/userAuth.social.test.js` around lines 444 -
507, Add targeted tests that assert findOrCreateSocialUser returns the 403
branches for soft-deleted social users by simulating both provider-id lookup and
verified-email lookup paths: create two new test cases that mock the user lookup
methods used by findOrCreateSocialUser (the provider ID lookup and the
verifiedEmail lookup) to return a user object marked as soft-deleted, mock
redis.getdel as needed, call controller.exchangeSocialRefreshToken (or directly
call findOrCreateSocialUser if exported) with matching rtCode/token payloads,
and assert the response status is 403 and the JSON matches the 'Invalid refresh
token exchange payload' message; ensure mocks correspond to the same unique
symbols in the diff (exchangeSocialRefreshToken and findOrCreateSocialUser) so
the tests cover both provider-id and verified-email code paths to prevent
regressions.
sdks/urbackend-react/tests/context.test.tsx (1)

65-75: ⚡ Quick win

Avoid reassigning window.location in this test.

window.location is read-only/non-configurable in many JSDOM setups, so delete window.location makes this test fragile. history.replaceState() can set the same pathname/search/hash values without patching browser globals.

💡 Proposed fix
-    const originalLocation = window.location;
-    // `@ts-ignore`
-    delete window.location;
-    window.location = {
-      ...originalLocation,
-      search: '?rtCode=test-rt-code',
-      hash: '`#token`=test-temp-token',
-      pathname: '/auth/callback',
-      replaceState: vi.fn(),
-    } as any;
+    const originalUrl =
+      window.location.pathname + window.location.search + window.location.hash;
+    window.history.replaceState(
+      {},
+      '',
+      '/auth/callback?rtCode=test-rt-code#token=test-temp-token'
+    );
@@
-    // Restore window.location
-    window.location = originalLocation;
+    window.history.replaceState({}, '', originalUrl);

Also applies to: 102-103

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/urbackend-react/tests/context.test.tsx` around lines 65 - 75, Don't
delete or reassign window.location; instead save originalLocation, use
history.replaceState(null, '',
'/auth/callback?rtCode=test-rt-code#token=test-temp-token') to set
pathname/search/hash for the test (and revert with history.replaceState back to
originalLocation.href afterwards), and remove the vi.fn replacement of
window.location.replaceState; apply the same change to the other case that
currently mutates window.location (the block using originalLocation and vi.fn).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/public-api/src/controllers/userAuth.controller.js`:
- Around line 26-34: The helper checkUserSoftDeleted only blocks
signup/login/public profile/social lookup; you must apply the same soft-delete
guard wherever code resolves an authenticated user: add checks in the
controllers/middleware used by refreshToken, me, updateProfile,
changePasswordUser, and resetPasswordUser so they call
checkUserSoftDeleted(user) (or inline equivalent) and return the deletion
message/error when a user.isDeleted is true; additionally, update the
refreshToken flow (refreshToken.js and its route in userAuth.js) to revoke the
entire session/token chain (invalidate refresh tokens and associated session
records) when a deleted user attempts refresh so existing sessions are
immediately terminated; update related tests to cover refresh attempts and
authorized mutations by soft-deleted users.

In `@apps/web-dashboard/src/pages/ProjectDetails.jsx`:
- Around line 96-103: The click handler currently calls
navigator.clipboard.writeText(newKey.key) without awaiting or handling errors,
then always shows toast.success; update the onClick handler used in the button
to await navigator.clipboard.writeText(newKey.key) inside a try/catch and call
toast.success(...) only on success and toast.error(...) in the catch with a
helpful message; keep the same button UI and title, but change the inline arrow
function to an async function that tries await
navigator.clipboard.writeText(newKey.key) and handles failures with toast.error.

In `@examples/react-sdk-demo/src/App.tsx`:
- Around line 7-8: The loading branch that checks isInitializing returns white
text on a white background making the app appear blank; update the JSX returned
when isInitializing (the inline-styled <div> currently showing "Loading
urBackend...") to use a readable combination—either set a contrasting background
(e.g., dark) or change the text color to a dark value and optionally add
accessible attributes (role="status", aria-live) so the loader is visible and
announced.

In `@examples/react-sdk-demo/src/main.tsx`:
- Around line 7-12: The app currently passes import.meta.env.VITE_UR_PUBLIC_KEY
and VITE_UR_BASE_URL directly into UrProvider which can produce cryptic runtime
errors if those env vars are missing; add an early check before calling
ReactDOM.createRoot/UrProvider to validate import.meta.env.VITE_UR_PUBLIC_KEY
and import.meta.env.VITE_UR_BASE_URL are present and non-empty, and if not, log
an explicit error (or throw) and stop initialization so the failure is fast and
actionable (update the code around ReactDOM.createRoot and the UrProvider
initialization to perform this guard).
- Line 1: The React import should be kept because <React.StrictMode> references
React; do not remove the line importing React in
examples/react-sdk-demo/src/main.tsx. Add a runtime guard in main.tsx to
validate import.meta.env.VITE_UR_PUBLIC_KEY before creating the UrProvider
(check for undefined/empty and show a clear error or prevent app bootstrap), and
add validation inside UrBackendClient (validate the apiKey in its constructor or
setter and throw a clear error if missing/empty) so UrProviderProps.apiKey:
string is enforced at runtime and missing envs fail fast with a helpful message;
reference the React import line, <React.StrictMode>, UrProviderProps,
UrBackendClient, and import.meta.env.VITE_UR_PUBLIC_KEY when making these
changes.

In `@sdks/urbackend-python/src/urbackend/auth.py`:
- Around line 405-410: The example in the auth callback docs incorrectly
attempts to read the fragment parameter on the server (request.GET.get("token"))
even though the fragment (token) is not sent to the server; update the example
in the docstring around rtCode/token so that it either (a) shows a client-side
fragment parser (e.g., parsing location.hash in JS and POSTing or redirecting
the token to the server callback) or (b) explains an explicit frontend handoff
step that reads the token from the fragment and forwards it to the server
endpoint that handles rtCode; ensure the text references the rtCode query param
and the token fragment and replace any server-side call like
request.GET.get("token") with the client-side handoff approach.

In `@sdks/urbackend-react/package.json`:
- Line 16: The package.json in sdks/urbackend-react currently pins the
dependency "`@urbackend/sdk`" to a local file path ("file:../urbackend-sdk");
replace that entry with the published semver version (e.g. "`@urbackend/sdk`":
"^0.4.2") so consumers can resolve the package outside this repo—update the
dependency string in sdks/urbackend-react/package.json and ensure package-lock
or yarn lock is updated accordingly.

In `@sdks/urbackend-react/src/components/Toast.tsx`:
- Around line 20-26: The nested exit timeout created inside the Toast component
(the inner setTimeout that calls onClose after 300ms) isn't being cleared on
unmount; change the effect so you store both timers (outer and inner) in
variables or refs (e.g., outerTimer and exitTimer) and clear both in the cleanup
function; specifically update the effect that calls setIsLeaving and
setTimeout(onClose, 300) to assign the inner timer to exitTimer and call
clearTimeout(outerTimer) and clearTimeout(exitTimer) in the return cleanup,
ensuring onClose cannot run after unmount.

In `@sdks/urbackend-react/src/components/UrAuth.tsx`:
- Around line 331-333: Replace the non-semantic clickable <span> elements used
for "Forgot password?" and the other clickable text in UrAuth.tsx with semantic
<button type="button"> elements so they are keyboard-accessible and focusable;
update the elements that call setMode('forgot') and clearError() (and the other
handlers using onClick) to use buttons, preserve the existing styles via the
styles.forgotLink class, and add an appropriate aria-label if the visible text
isn't fully descriptive to maintain accessibility.
- Around line 12-13: The default providers array in UrAuth.tsx currently
includes 'apple' even though the Apple flow is not implemented (the sign-in path
shows only an alert in the handler around the signIn/signInWithProvider code),
which ships a broken default; remove 'apple' from the default providers list
(providers = ['google', 'github']) and/or add a proper implementation for the
Apple flow where the current alert is shown (the handler around the
signInWithProvider / onClick for provider buttons). Update any related UI/prop
defaults that reference the same default (the block handling providers and the
provider button rendering around the current alert) so Apple is not advertised
or is wired to a real sign-in function. Ensure references to the provider names
(e.g., providers prop and the provider button renderer) are consistent after the
change.

In `@sdks/urbackend-react/src/context.tsx`:
- Around line 63-69: The catch for auth.socialExchange in the rtCode branch
currently swallows errors; change it so the error is propagated to fail the
callback flow (e.g., after logging rethrow the error or return a rejected
Promise) so the code does not continue with auth.me() using a short-lived
fragment token. Locate the rtCode handling where auth.socialExchange({ token,
rtCode }) is called and replace the silent catch with an error propagation
(throw err) or otherwise stop execution so the persistent refresh session
failure prevents the misleading “logged in until reload” state.

In `@sdks/urbackend-sdk/src/errors.ts`:
- Around line 57-78: The current 'error' branch in errors.ts (the block that
inspects errData.error and assigns to message) can assign unhelpful values like
"[]", "null" or JSON blobs and hide a useful errData.message; modify the 'error'
handling so you first derive the candidate string (same mapping logic for
string/array/object), then only set message = candidate if it's a non-empty
meaningful string (e.g. after String(...).trim() has length > 0 and is not the
literal "[]" or "null"); otherwise skip using errData.error and allow the
existing 'message' branch to run and provide the fallback. Ensure you keep the
same symbols (errData, message) and the existing mapping logic but gate
assignment on candidate validity.

In `@sdks/urbackend-sdk/src/modules/auth.ts`:
- Around line 504-513: The example for socialExchange is misleading because
auth.socialExchange returns a one-time refresh token payload (rtToken), not an
access token; update the example to read and use the returned refresh token
(e.g., response.rtToken or whatever key the API returns) and then call the SDK's
refresh flow (auth.refreshToken(...)) to obtain an access token; locate the
example block referencing auth.socialExchange and change the console.log and
subsequent usage to consume the refresh token and call auth.refreshToken with
that token.

---

Outside diff comments:
In `@apps/public-api/src/controllers/userAuth.controller.js`:
- Around line 903-952: The exchangeSocialRefreshToken handler currently returns
different response shapes and leaks err.message; update all branches (including
the early 400/403 returns and the catch) to always return the envelope {
success: bool, data: {}, message: "" } (e.g., data: {} for error paths) and
replace any raw backend error text with a generic message or an AppError
instance; specifically, in exchangeSocialRefreshToken adjust the responses for
missing rtCode/token, invalid/expired rawExchange (from redis.getdel), malformed
JSON, and invalid payload (parsedExchange) to include data: {} and a clear
client-facing message, and in the catch block do not forward err.message—return
status 500 with data: {} and a generic "Internal server error" (or an AppError)
so Redis/internal errors are never exposed.

In `@sdks/urbackend-python/README.md`:
- Around line 148-158: The README example incorrectly suggests extracting a
one-time token from the URL fragment on the server using
parse_fragment(request); fragments are never sent to the server. Update the docs
to instruct developers to extract the token client-side (e.g., from
window.location.hash) and then send it to the backend (as a POST
body/query/header) so the backend endpoint can call
client.auth.social_exchange(rt_code, token); mention parse_fragment only for
client-side helpers or remove it and show that the server receives token via an
explicit parameter before calling client.auth.social_exchange and then
client.auth.refresh_token/session handling.

---

Nitpick comments:
In `@apps/public-api/src/__tests__/userAuth.social.test.js`:
- Around line 444-507: Add targeted tests that assert findOrCreateSocialUser
returns the 403 branches for soft-deleted social users by simulating both
provider-id lookup and verified-email lookup paths: create two new test cases
that mock the user lookup methods used by findOrCreateSocialUser (the provider
ID lookup and the verifiedEmail lookup) to return a user object marked as
soft-deleted, mock redis.getdel as needed, call
controller.exchangeSocialRefreshToken (or directly call findOrCreateSocialUser
if exported) with matching rtCode/token payloads, and assert the response status
is 403 and the JSON matches the 'Invalid refresh token exchange payload'
message; ensure mocks correspond to the same unique symbols in the diff
(exchangeSocialRefreshToken and findOrCreateSocialUser) so the tests cover both
provider-id and verified-email code paths to prevent regressions.

In `@apps/web-dashboard/src/index.css`:
- Around line 194-205: The .glass-card styles are duplicated across multiple
blocks, which can cause the base and hover declarations to drift apart.
Consolidate the repeated .glass-card and .glass-card:hover rules into a single
definition in index.css, keeping all shared properties together and preserving
the hover state in one place so future changes only need to be made once.

In `@sdks/urbackend-react/tests/context.test.tsx`:
- Around line 65-75: Don't delete or reassign window.location; instead save
originalLocation, use history.replaceState(null, '',
'/auth/callback?rtCode=test-rt-code#token=test-temp-token') to set
pathname/search/hash for the test (and revert with history.replaceState back to
originalLocation.href afterwards), and remove the vi.fn replacement of
window.location.replaceState; apply the same change to the other case that
currently mutates window.location (the block using originalLocation and vi.fn).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 669f888a-928f-4a15-911f-58fdaf690aaf

📥 Commits

Reviewing files that changed from the base of the PR and between 87730ce and 498d041.

⛔ Files ignored due to path filters (14)
  • examples/react-sdk-demo/package-lock.json is excluded by !**/package-lock.json
  • examples/react-sdk-demo/public/favicon.svg is excluded by !**/*.svg
  • examples/react-sdk-demo/public/icons.svg is excluded by !**/*.svg
  • examples/react-sdk-demo/src/assets/hero.png is excluded by !**/*.png
  • examples/react-sdk-demo/src/assets/react.svg is excluded by !**/*.svg
  • examples/react-sdk-demo/src/assets/vite.svg is excluded by !**/*.svg
  • package-lock.json is excluded by !**/package-lock.json
  • sdks/urbackend-react/dist/index.d.mts is excluded by !**/dist/**
  • sdks/urbackend-react/dist/index.d.ts is excluded by !**/dist/**
  • sdks/urbackend-react/dist/index.js is excluded by !**/dist/**
  • sdks/urbackend-react/dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • sdks/urbackend-react/dist/index.mjs is excluded by !**/dist/**
  • sdks/urbackend-react/dist/index.mjs.map is excluded by !**/dist/**, !**/*.map
  • sdks/urbackend-sdk/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (42)
  • AGENTS.md
  • apps/consumer/package.json
  • apps/dashboard-api/package.json
  • apps/public-api/package.json
  • apps/public-api/src/__tests__/userAuth.social.test.js
  • apps/public-api/src/controllers/userAuth.controller.js
  • apps/web-dashboard/package.json
  • apps/web-dashboard/src/index.css
  • apps/web-dashboard/src/pages/ProjectDetails.jsx
  • examples/react-sdk-demo/.gitignore
  • examples/react-sdk-demo/README.md
  • examples/react-sdk-demo/eslint.config.js
  • examples/react-sdk-demo/index.html
  • examples/react-sdk-demo/package.json
  • examples/react-sdk-demo/src/App.css
  • examples/react-sdk-demo/src/App.tsx
  • examples/react-sdk-demo/src/index.css
  • examples/react-sdk-demo/src/main.tsx
  • examples/react-sdk-demo/tsconfig.app.json
  • examples/react-sdk-demo/tsconfig.json
  • examples/react-sdk-demo/tsconfig.node.json
  • examples/react-sdk-demo/vite.config.ts
  • package.json
  • packages/common/package.json
  • sdks/urbackend-python/README.md
  • sdks/urbackend-python/pyproject.toml
  • sdks/urbackend-python/src/urbackend/auth.py
  • sdks/urbackend-react/package.json
  • sdks/urbackend-react/src/components/Toast.tsx
  • sdks/urbackend-react/src/components/UrAuth.tsx
  • sdks/urbackend-react/src/context.tsx
  • sdks/urbackend-react/src/hooks.ts
  • sdks/urbackend-react/src/index.ts
  • sdks/urbackend-react/tests/UrAuth.test.tsx
  • sdks/urbackend-react/tests/context.test.tsx
  • sdks/urbackend-react/tests/setupTests.ts
  • sdks/urbackend-react/tsconfig.json
  • sdks/urbackend-react/tsup.config.ts
  • sdks/urbackend-react/vitest.config.ts
  • sdks/urbackend-sdk/package.json
  • sdks/urbackend-sdk/src/errors.ts
  • sdks/urbackend-sdk/src/modules/auth.ts

Comment thread apps/public-api/src/controllers/userAuth.controller.js
Comment thread apps/web-dashboard/src/pages/ProjectDetails.jsx
Comment thread examples/react-sdk-demo/src/App.tsx Outdated
Comment thread examples/react-sdk-demo/src/main.tsx
Comment on lines +7 to +12
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<UrProvider
apiKey={import.meta.env.VITE_UR_PUBLIC_KEY}
baseUrl={import.meta.env.VITE_UR_BASE_URL}
>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fail fast when required env vars are missing.

If either Vite variable is unset, UrProvider is initialized with invalid config and the demo fails later with a much less actionable error.

🛡️ Proposed fix
+const apiKey = import.meta.env.VITE_UR_PUBLIC_KEY
+const baseUrl = import.meta.env.VITE_UR_BASE_URL
+
+if (!apiKey || !baseUrl) {
+  throw new Error('Missing VITE_UR_PUBLIC_KEY or VITE_UR_BASE_URL')
+}
+
 ReactDOM.createRoot(document.getElementById('root')!).render(
   <React.StrictMode>
     <UrProvider 
-      apiKey={import.meta.env.VITE_UR_PUBLIC_KEY} 
-      baseUrl={import.meta.env.VITE_UR_BASE_URL}
+      apiKey={apiKey}
+      baseUrl={baseUrl}
     >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<UrProvider
apiKey={import.meta.env.VITE_UR_PUBLIC_KEY}
baseUrl={import.meta.env.VITE_UR_BASE_URL}
>
const apiKey = import.meta.env.VITE_UR_PUBLIC_KEY
const baseUrl = import.meta.env.VITE_UR_BASE_URL
if (!apiKey || !baseUrl) {
throw new Error('Missing VITE_UR_PUBLIC_KEY or VITE_UR_BASE_URL')
}
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<UrProvider
apiKey={apiKey}
baseUrl={baseUrl}
>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/react-sdk-demo/src/main.tsx` around lines 7 - 12, The app currently
passes import.meta.env.VITE_UR_PUBLIC_KEY and VITE_UR_BASE_URL directly into
UrProvider which can produce cryptic runtime errors if those env vars are
missing; add an early check before calling ReactDOM.createRoot/UrProvider to
validate import.meta.env.VITE_UR_PUBLIC_KEY and import.meta.env.VITE_UR_BASE_URL
are present and non-empty, and if not, log an explicit error (or throw) and stop
initialization so the failure is fast and actionable (update the code around
ReactDOM.createRoot and the UrProvider initialization to perform this guard).

Comment thread sdks/urbackend-react/src/components/UrAuth.tsx Outdated
Comment thread sdks/urbackend-react/src/components/UrAuth.tsx Outdated
Comment thread sdks/urbackend-react/src/context.tsx
Comment thread sdks/urbackend-sdk/src/errors.ts
Comment thread sdks/urbackend-sdk/src/modules/auth.ts
- Add soft-delete guards to userAuth controllers and refresh flows
- Update React SDK UrAuth semantics and Context error handling
- Clarify Python SDK token fragment parsing example
- Fix clipboard lint errors in Dashboard and consolidate CSS
- Update React SDK dependencies and improve demo loading state
@yash-pouranik
Copy link
Copy Markdown
Collaborator Author

all done??
@coderabbitai

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
gh api repos/geturbackend/urBackend/pulls/242/reviews 2>&1 | jq '[.[] | {id: .id, user: .user.login, state: .state, submitted_at: .submitted_at, body: .body[:300]}]' 2>&1

Length of output: 973



@yash-pouranik Yes, all done! ✅ The review was posted with 13 actionable comments. You can find them in the "Files changed" tab of the PR. Let me know if you have any questions about the findings! 🐇

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sdks/urbackend-react/tests/context.test.tsx (1)

65-81: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Always restore mocked browser globals.

If this test fails before Line 110, the mocked window.location/window.history leak into later tests and can cause cascading failures. Wrap the override block in try/finally so cleanup always runs.

Proposed fix
   const originalLocation = window.location;
   // `@ts-ignore`
   delete window.location;
   window.location = {
     ...originalLocation,
     search: '?rtCode=test-rt-code',
     hash: '`#token`=test-temp-token',
     pathname: '/auth/callback',
   } as any;

   const originalHistory = window.history;
   // `@ts-ignore`
   delete window.history;
   window.history = {
     ...originalHistory,
     replaceState: vi.fn(),
   } as any;
-
-  const TestComponent = () => {
-    const { isInitializing } = useUrContext();
-    if (isInitializing) return <div>Loading...</div>;
-    return <div>Ready</div>;
-  };
-
-  render(
-    <UrProvider apiKey="test-key" baseUrl="http://localhost:3000">
-      <TestComponent />
-    </UrProvider>
-  );
-
-  await waitFor(() => {
-    expect(screen.getByText('Ready')).toBeInTheDocument();
-  });
-
-  const mockAuthInstance = vi.mocked(AuthModule).mock.results[0]?.value;
-  if (mockAuthInstance) {
-    expect(mockAuthInstance.setToken).toHaveBeenCalledWith('test-temp-token');
-    expect(mockAuthInstance.socialExchange).toHaveBeenCalledWith({ token: 'test-temp-token', rtCode: 'test-rt-code' });
-  }
-
-  window.location = originalLocation;
-  window.history = originalHistory;
+  try {
+    const TestComponent = () => {
+      const { isInitializing } = useUrContext();
+      if (isInitializing) return <div>Loading...</div>;
+      return <div>Ready</div>;
+    };
+
+    render(
+      <UrProvider apiKey="test-key" baseUrl="http://localhost:3000">
+        <TestComponent />
+      </UrProvider>
+    );
+
+    await waitFor(() => {
+      expect(screen.getByText('Ready')).toBeInTheDocument();
+    });
+
+    const mockAuthInstance = vi.mocked(AuthModule).mock.results[0]?.value;
+    if (mockAuthInstance) {
+      expect(mockAuthInstance.setToken).toHaveBeenCalledWith('test-temp-token');
+      expect(mockAuthInstance.socialExchange).toHaveBeenCalledWith({ token: 'test-temp-token', rtCode: 'test-rt-code' });
+    }
+  } finally {
+    window.location = originalLocation;
+    window.history = originalHistory;
+  }

Also applies to: 109-111

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/urbackend-react/tests/context.test.tsx` around lines 65 - 81, The test
temporarily overwrites window.location and window.history (using
originalLocation and originalHistory and setting history.replaceState to
vi.fn()) but does not guarantee restoration on failure; wrap the override block
in a try/finally so the finally always restores window.location =
originalLocation and window.history = originalHistory (and any mutated
properties) to prevent leaks into other tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/public-api/src/controllers/userAuth.controller.js`:
- Around line 1690-1705: The refresh-token user query (Model.findOne in the
refresh path) only projects {_id, isDeleted} but checkUserSoftDeleted(user)
requires user.deletedAt to compute the real deletion deadline; update the
projection in the Model.findOne call used in the refresh flow to include
deletedAt (e.g., { _id: 1, isDeleted: 1, deletedAt: 1 }) so checkUserSoftDeleted
returns the actual scheduled date and downstream logic (revokeSessionChain,
clearRefreshCookie, res.status responses) behaves correctly.
- Around line 1212-1213: The controller currently returns raw { error: ... }
when checkUserSoftDeleted(user) yields a message; replace these raw responses
with the standardized AppError flow and envelope: instead of
res.status(403).json({ error: deletedMsg }) call next(new AppError(deletedMsg,
403)) (or throw new AppError(deletedMsg, 403) if controller uses async error
handling), so the global error middleware returns the { success, data, message }
envelope; update every occurrence that checks checkUserSoftDeleted (including
the other spots you flagged) to use AppError and not direct res.json.

In `@sdks/urbackend-sdk/package.json`:
- Line 3: The package.json version was accidentally rolled back to 0.1.0; update
"version" in sdks/urbackend-sdk/package.json to the correct published/expected
semver (e.g., 0.4.1 or the current 0.4.x) and ensure the runtime User-Agent set
in sdks/urbackend-sdk/src/client.ts (which currently reports 0.4.1) matches that
package.json value so package.json and the User-Agent stay in sync before
publishing.

---

Outside diff comments:
In `@sdks/urbackend-react/tests/context.test.tsx`:
- Around line 65-81: The test temporarily overwrites window.location and
window.history (using originalLocation and originalHistory and setting
history.replaceState to vi.fn()) but does not guarantee restoration on failure;
wrap the override block in a try/finally so the finally always restores
window.location = originalLocation and window.history = originalHistory (and any
mutated properties) to prevent leaks into other tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e63fae2d-e211-4c2d-98ad-59d019dfafad

📥 Commits

Reviewing files that changed from the base of the PR and between 498d041 and 6b68eb5.

📒 Files selected for processing (16)
  • apps/public-api/src/__tests__/userAuth.refresh.test.js
  • apps/public-api/src/__tests__/userAuth.social.test.js
  • apps/public-api/src/controllers/userAuth.controller.js
  • apps/web-dashboard/src/index.css
  • apps/web-dashboard/src/pages/ProjectDetails.jsx
  • examples/react-sdk-demo/src/App.tsx
  • examples/react-sdk-demo/src/main.tsx
  • sdks/urbackend-python/README.md
  • sdks/urbackend-python/src/urbackend/auth.py
  • sdks/urbackend-react/package.json
  • sdks/urbackend-react/src/components/Toast.tsx
  • sdks/urbackend-react/src/components/UrAuth.tsx
  • sdks/urbackend-react/src/context.tsx
  • sdks/urbackend-react/tests/context.test.tsx
  • sdks/urbackend-sdk/package.json
  • sdks/urbackend-sdk/src/client.ts
💤 Files with no reviewable changes (1)
  • apps/web-dashboard/src/index.css
✅ Files skipped from review due to trivial changes (1)
  • sdks/urbackend-python/README.md
🚧 Files skipped from review as they are similar to previous changes (5)
  • sdks/urbackend-react/package.json
  • examples/react-sdk-demo/src/main.tsx
  • sdks/urbackend-react/src/components/Toast.tsx
  • examples/react-sdk-demo/src/App.tsx
  • sdks/urbackend-react/src/context.tsx

Comment thread apps/public-api/src/controllers/userAuth.controller.js Outdated
Comment thread apps/public-api/src/controllers/userAuth.controller.js
Comment thread sdks/urbackend-sdk/package.json Outdated
@yash-pouranik
Copy link
Copy Markdown
Collaborator Author

mergeable?? @coderabbitai

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check PR mergeability, checks, and review state
gh pr view 242 --repo geturbackend/urBackend --json mergeable,mergeStateStatus,reviewDecision,statusCheckRollup,reviews 2>&1 | jq '.'

Length of output: 41529


🏁 Script executed:

#!/bin/bash
# Check open/unresolved review comments
gh api repos/geturbackend/urBackend/pulls/242/reviews 2>&1 | jq '[.[] | {id: .id, user: .user.login, state: .state, submitted_at: .submitted_at}]'

Length of output: 662


🏁 Script executed:

#!/bin/bash
# Check review comments count
gh api repos/geturbackend/urBackend/pulls/242/comments 2>&1 | jq 'length'

Length of output: 163



@yash-pouranik: Here's the current status:

Check Status
GitHub mergeability MERGEABLE / CLEAN
CI (all jobs) ✅ All passing
Required approvals ✅ None configured
Open review comments ⚠️ 16 unresolved

Technically GitHub will let you merge, but I'd recommend addressing the open comments first — especially these higher-priority ones:

  1. exchangeSocialRefreshToken — error branches leak raw err.message and don't return the standard { success, data, message } envelope (security + contract issue)
  2. context.tsx (socialExchange catch) — errors are silently swallowed, allowing a misleading "logged in until reload" state
  3. sdks/urbackend-react/package.json@urbackend/sdk is pinned to a local file: path, which breaks consumers outside the monorepo
  4. userAuth.controller.js — soft-delete check in the refresh path is missing deletedAt in the projection, so the deletion deadline message is wrong
  5. Python README.md / auth.py — example shows server-side fragment parsing, which is impossible (URL fragments are never sent to the server)

Once those are resolved, the PR would be in good shape to merge. 🐇

@yash-pouranik
Copy link
Copy Markdown
Collaborator Author

every single comment has been addressed in this last commit
u can check against code @coderabbitai

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== 1. exchangeSocialRefreshToken error branches ==="
rg -n "err.message|catch.*err|socialExchange\|getdel" apps/public-api/src/controllers/userAuth.controller.js -A3 -B1 | head -80

echo ""
echo "=== 2. context.tsx socialExchange catch ==="
cat sdks/urbackend-react/src/context.tsx

echo ""
echo "=== 3. urbackend-react package.json ==="
cat sdks/urbackend-react/package.json

echo ""
echo "=== 4. refreshToken projection in controller ==="
rg -n "refreshToken|deletedAt|isDeleted" apps/public-api/src/controllers/userAuth.controller.js -A5 -B2 | head -100

echo ""
echo "=== 5. Python README fragment parsing ==="
cat sdks/urbackend-python/README.md

echo ""
echo "=== 6. Python auth.py docstring ==="
cat sdks/urbackend-python/src/urbackend/auth.py | head -80

Length of output: 23465



@yash-pouranik: Verified! Here's the per-item status after checking the latest code:

# Issue Status
1 exchangeSocialRefreshToken outer catch — now returns { success: false, data: {}, message: ... } envelope ✅ Fixed
2 context.tsxsocialExchange errors now call setError(...) and re-throw to the outer handler ✅ Fixed
3 sdks/urbackend-react/package.json@urbackend/sdk still uses file:../urbackend-sdk ⚠️ Unchanged
4 refreshToken projection — now correctly includes deletedAt: 1 alongside isDeleted: 1 ✅ Fixed
5 Python README.md — example now correctly shows frontend-posting the fragment token via json.loads(request.body) ✅ Fixed

4 out of 5 are confirmed fixed. The one remaining item (#3) is the file: reference for @urbackend/sdk in the React SDK's package.json. Since this is a monorepo and the package isn't being published to npm independently yet, it's acceptable to leave as-is — just worth noting that consumers outside the monorepo won't be able to install it from npm until it's swapped to a version range (e.g. "^0.4.2") post-publish.

The PR looks good to merge! 🚀

🐇 /(•ᴗ•)\

@yash-pouranik yash-pouranik temporarily deployed to feature/auth-fixes-and-react-sdk-tests - urBackend-frankfrut PR #242 May 31, 2026 14:29 — with Render Destroyed
@yash-pouranik
Copy link
Copy Markdown
Collaborator Author

ok its fixed now
@coderabbitai

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== sdks/urbackend-react/package.json ==="
cat sdks/urbackend-react/package.json

Length of output: 938



@yash-pouranik: Confirmed! @urbackend/sdk is now pinned to "^0.4.2" — the file: reference is gone. All 5 flagged issues are resolved. ✅

# Issue Status
1 exchangeSocialRefreshToken error envelope ✅ Fixed
2 context.tsx socialExchange catch ✅ Fixed
3 @urbackend/sdk file: reference ✅ Fixed
4 refreshToken projection missing deletedAt ✅ Fixed
5 Python README.md fragment parsing ✅ Fixed

The PR is good to go! 🚀

🐇 /(•ᴗ•)\


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@yash-pouranik yash-pouranik added the feature to add a new feature label May 31, 2026
@yash-pouranik yash-pouranik merged commit 4ecc9f9 into main May 31, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature to add a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants