Skip to content

refactor(client): replace Accounts.storageLocation with SDK storage helper - #40479

Merged
ggazzo merged 1 commit into
developfrom
refactor/sdk-storage-helper
May 11, 2026
Merged

refactor(client): replace Accounts.storageLocation with SDK storage helper#40479
ggazzo merged 1 commit into
developfrom
refactor/sdk-storage-helper

Conversation

@ggazzo

@ggazzo ggazzo commented May 11, 2026

Copy link
Copy Markdown
Member

Summary

Accounts.storageLocation is just window.localStorage with a Meteor alias. Replace the four direct consumers with a small helper in apps/meteor/client/lib/sdk/storage.ts so no client code outside the Meteor bridges has to import from meteor/accounts-base for storage access.

  • New STORAGE_KEYS (mirrors the existing Meteor key names so sessions persist across the migration) and getStoredItem / setStoredItem / removeStoredItem helpers.
  • RestApiClient.getCredentials() reads USER_ID / LOGIN_TOKEN through the helper instead of Accounts.storageLocation.getItem.
  • rocketchat.e2e.ts swaps its 12 Accounts.storageLocation.* calls (public_key, private_key, e2e.randomPassword) for the helper. The Accounts import stays for Accounts.onLogout, which is migrated separately in refactor(client): migrate Accounts.on* event handlers to sdk.account #40442.
  • saml.ts replaces the lone Accounts.storageLocation.removeItem(USER_ID_KEY).
  • ddpSdk.ts collapses its private readStoredLoginToken into getStoredItem(STORAGE_KEYS.LOGIN_TOKEN) so there's only one definition of the token key path.

Out of scope: Accounts.onLogin/onLogout/onPageLoadLogin/onEmailVerificationLink (#40442), Accounts._unstoreLoginToken / _storedLoginToken, Accounts.LoginCancelledError, Accounts.registerClientLoginFunction, Accounts.oauth.credentialRequestCompleteHandler. The AuthorizationFormPage.tsx usage is handled by #40477's useLoginToken hook.

No behaviour change: same window.localStorage backend, same key names.

Test plan

  • Fresh login persists across page reload: Meteor.userId and Meteor.loginToken keys still appear in DevTools › Application › Local Storage, and the app stays logged in after refresh.
  • E2EE flow: enable E2EE on an account, reload, confirm public_key / private_key are read back correctly and rooms decrypt; change password and confirm e2e.randomPassword updates.
  • REST credentials: any authenticated REST call (e.g. send a message) still carries the correct X-User-Id / X-Auth-Token headers.
  • SAML SLO logout: with a SAML provider configured for SLO, click Logout and verify the user id is cleared and the SLO redirect happens.

Summary by CodeRabbit

  • Refactor
    • Centralized client-side storage for authentication tokens, session identifiers, and end-to-end encryption keys/passwords.
    • Updated login/token handling to read from the centralized storage.
    • E2EE key saving/clearing now uses the new storage layer.
    • SAML logout now cleans up the locally stored user identifier via the centralized storage.

Review Change Stack

Task: ARCH-2133

@ggazzo
ggazzo requested a review from a team as a code owner May 11, 2026 16:38
@dionisio-bot

dionisio-bot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented May 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6752370

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09a7cd48-70d6-4408-b3e1-8e1ac2f2dec0

📥 Commits

Reviewing files that changed from the base of the PR and between 58568fc and 6752370.

📒 Files selected for processing (5)
  • apps/meteor/app/utils/client/lib/RestApiClient.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/meteor/login/saml.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/app/utils/client/lib/RestApiClient.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build

Walkthrough

This PR introduces a centralized client-side storage module and replaces direct Accounts.storageLocation usage across five modules. The new storage API provides type-safe key constants and helper functions that safely abstract localStorage access for browser and non-browser environments.

Changes

Storage Centralization Refactor

Layer / File(s) Summary
Storage Module Definition
apps/meteor/client/lib/sdk/storage.ts
New module exports STORAGE_KEYS constant, StorageKey type, and helper functions getStoredItem, setStoredItem, removeStoredItem that centralize localStorage operations with safe browser-environment checks.
RestApiClient Credentials Retrieval
apps/meteor/app/utils/client/lib/RestApiClient.ts
getCredentials() now retrieves uid and token via getStoredItem() with the new STORAGE_KEYS constants instead of Accounts.storageLocation.
DDP SDK Login Token
apps/meteor/client/lib/sdk/ddpSdk.ts
readStoredLoginToken() now calls getStoredItem(STORAGE_KEYS.LOGIN_TOKEN) instead of directly reading window.localStorage.
SAML Logout User ID Cleanup
apps/meteor/client/meteor/login/saml.ts
Post-logout user ID removal now uses removeStoredItem(STORAGE_KEYS.USER_ID) instead of Accounts.storageLocation.removeItem().
E2EE Key Material and Password Persistence
apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
All E2EE storage operations—loading/saving public and private keys, storing random passwords, and client lifecycle cleanup—now use the centralized storage API instead of Accounts.storageLocation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

type: chore, area: authentication

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing Accounts.storageLocation with a new SDK storage helper module, which is the core objective of this refactoring PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ARCH-2133: Request failed with status code 401

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.

@ggazzo

ggazzo commented May 11, 2026

Copy link
Copy Markdown
Member Author

/jira ARCH-2116

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (2)
apps/meteor/client/lib/sdk/storage.ts (2)

14-22: ⚡ Quick win

Type the helper API as StorageKey.

StorageKey is defined here, but the exported helpers still accept any string, so key typos in auth/E2EE call sites won't be caught at compile time. Tightening the signatures here keeps the abstraction aligned with the intent of STORAGE_KEYS.

Suggested diff
 export type StorageKey = (typeof STORAGE_KEYS)[keyof typeof STORAGE_KEYS];
 
 const getStorage = (): Storage | undefined => (typeof window !== 'undefined' ? window.localStorage : undefined);
 
-export const getStoredItem = (key: string): string | null => getStorage()?.getItem(key) ?? null;
+export const getStoredItem = (key: StorageKey): string | null => getStorage()?.getItem(key) ?? null;
 
-export const setStoredItem = (key: string, value: string): void => getStorage()?.setItem(key, value);
+export const setStoredItem = (key: StorageKey, value: string): void => getStorage()?.setItem(key, value);
 
-export const removeStoredItem = (key: string): void => getStorage()?.removeItem(key);
+export const removeStoredItem = (key: StorageKey): void => getStorage()?.removeItem(key);
🤖 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/meteor/client/lib/sdk/storage.ts` around lines 14 - 22, The exported
helpers accept plain strings but should use the exported StorageKey type to
prevent key typos; update the function signatures of getStoredItem,
setStoredItem, and removeStoredItem to take key: StorageKey (and keep their
return/types the same), leaving getStorage() unchanged; ensure callers using
these helpers pass a STORAGE_KEYS member (or cast) so the compiler enforces
valid keys.

1-4: ⚡ Quick win

Remove the module header comments.

This helper is small enough to be self-explanatory, and the new inline comments conflict with the repo rule for TS/JS implementation files.

As per coding guidelines, **/*.{ts,tsx,js}: Avoid code comments in the implementation.

🤖 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/meteor/client/lib/sdk/storage.ts` around lines 1 - 4, Remove the module
header comment block at the top of the file (the multi-line comment describing
purpose and storage behavior); delete those lines so the file contains only the
implementation code, and ensure there are no other TS/JS implementation comments
remaining to comply with the repository rule for /*.{ts,tsx,js} files.
🤖 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.

Nitpick comments:
In `@apps/meteor/client/lib/sdk/storage.ts`:
- Around line 14-22: The exported helpers accept plain strings but should use
the exported StorageKey type to prevent key typos; update the function
signatures of getStoredItem, setStoredItem, and removeStoredItem to take key:
StorageKey (and keep their return/types the same), leaving getStorage()
unchanged; ensure callers using these helpers pass a STORAGE_KEYS member (or
cast) so the compiler enforces valid keys.
- Around line 1-4: Remove the module header comment block at the top of the file
(the multi-line comment describing purpose and storage behavior); delete those
lines so the file contains only the implementation code, and ensure there are no
other TS/JS implementation comments remaining to comply with the repository rule
for /*.{ts,tsx,js} files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cb696dc8-58a2-42a4-9dab-1db92471d3e3

📥 Commits

Reviewing files that changed from the base of the PR and between 8c9868c and 58568fc.

📒 Files selected for processing (5)
  • apps/meteor/app/utils/client/lib/RestApiClient.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/meteor/login/saml.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/utils/client/lib/RestApiClient.ts
  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
🧠 Learnings (4)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/app/utils/client/lib/RestApiClient.ts
  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/app/utils/client/lib/RestApiClient.ts
  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/app/utils/client/lib/RestApiClient.ts
  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/client/lib/sdk/ddpSdk.ts
  • apps/meteor/client/lib/sdk/storage.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
🔇 Additional comments (4)
apps/meteor/client/lib/sdk/ddpSdk.ts (1)

70-70: Nice consolidation of the resume-token lookup.

This keeps the existing auth path intact while removing another direct storage dependency from the SDK bridge.

apps/meteor/app/utils/client/lib/RestApiClient.ts (1)

15-23: Looks good.

Reading both headers through the shared helper keeps this client aligned with the same legacy key names the rest of the migration is using.

apps/meteor/client/meteor/login/saml.ts (1)

77-77: This migration is clean.

It preserves the current SLO behavior while removing one more direct Accounts.storageLocation dependency from the login layer.

apps/meteor/client/lib/e2ee/rocketchat.e2e.ts (1)

318-319: Good storage migration for the E2EE state.

All of the persisted key material now goes through the shared helper without changing the legacy key names, which is exactly what this refactor needs.

Also applies to: 338-338, 406-406, 425-426, 441-442, 467-473, 497-521

@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.59459% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.64%. Comparing base (5183306) to head (6752370).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40479      +/-   ##
===========================================
- Coverage    69.64%   69.64%   -0.01%     
===========================================
  Files         3317     3318       +1     
  Lines       121897   121973      +76     
  Branches     21831    21825       -6     
===========================================
+ Hits         84901    84948      +47     
- Misses       33678    33704      +26     
- Partials      3318     3321       +3     
Flag Coverage Δ
e2e 59.05% <84.21%> (-0.03%) ⬇️
e2e-api 46.32% <ø> (+0.08%) ⬆️
unit 70.43% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…elper

Accounts.storageLocation is just an alias for window.localStorage but couples
every consumer to meteor/accounts-base. Centralize the persistent client
storage behind apps/meteor/client/lib/sdk/storage.ts, which exposes
STORAGE_KEYS (the Meteor key names we already write) and thin
get/set/removeStoredItem helpers.

Consumers migrated:
- RestApiClient.getCredentials() reads USER_ID / LOGIN_TOKEN through the
  helper instead of Accounts.storageLocation.getItem.
- rocketchat.e2e.ts swaps 12 Accounts.storageLocation.* calls (public_key,
  private_key, e2e.randomPassword) for the helper. The Accounts import stays
  for Accounts.onLogout, which is out of scope here (#40442).
- saml.ts replaces the lone Accounts.storageLocation.removeItem with the
  helper.
- ddpSdk.ts collapses its local readStoredLoginToken into getStoredItem so
  there is only one definition of the LOGIN_TOKEN key path.

No behaviour change: same window.localStorage backend, same key names.
@ggazzo
ggazzo force-pushed the refactor/sdk-storage-helper branch from 58568fc to 6752370 Compare May 11, 2026 18:12
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label May 11, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 11, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue May 11, 2026
@ggazzo
ggazzo removed this pull request from the merge queue due to a manual request May 11, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue May 11, 2026
@ggazzo
ggazzo removed this pull request from the merge queue due to a manual request May 11, 2026
@ggazzo
ggazzo merged commit 1acd37a into develop May 11, 2026
46 checks passed
@ggazzo
ggazzo deleted the refactor/sdk-storage-helper branch May 11, 2026 19:53
ggazzo added a commit that referenced this pull request May 11, 2026
The remaining client-side Accounts._unstoreLoginToken calls fell into two
roles: a monkey-patch that piggybacked on Meteor's token-clear hook to run
side effects on logout, and direct calls used to manually wipe the stored
credentials. Both are replaceable now that #40442 landed sdk.account.onLogout
and #40479 landed the SDK storage helper.

- Delete apps/meteor/client/meteor/overrides/unstoreLoginToken.ts (and its
  barrel entry). CachedStoresManager.ts registers
  clearAllCachesOnLogout via getDdpSdk().account.onLogout at module init,
  which fires on the same uid-undefined transition Meteor's monkey-patch
  was capturing.
- AuthenticationProvider's unstoreLoginToken context method collapses from
  a monkey-patch + restore pair into
  `(callback) => getDdpSdk().account.onLogout(callback)`. Same return shape
  (callback -> unsubscribe), so useUnstoreLoginToken consumers stay intact.
- AuthenticationProvider.wipeLocalAuth and the auth-error branch in
  ddpSdk.ts call removeStoredItem for USER_ID / LOGIN_TOKEN /
  LOGIN_TOKEN_EXPIRES — the three keys Meteor's _unstoreLoginToken clears.
  Adds LOGIN_TOKEN_EXPIRES to STORAGE_KEYS so storage.ts owns the full set.

No behaviour change: same localStorage keys cleared, same logout cleanup
ordering. The Accounts import stays in AuthenticationProvider.tsx and
ddpSdk.ts because callLoginMethod / loggingIn / getLoginToken / the
onEmailVerificationLink + onPageLoadLogin bridges still use it.
ggazzo added a commit that referenced this pull request May 14, 2026
The remaining client-side Accounts._unstoreLoginToken calls fell into two
roles: a monkey-patch that piggybacked on Meteor's token-clear hook to run
side effects on logout, and direct calls used to manually wipe the stored
credentials. Both are replaceable now that #40442 landed sdk.account.onLogout
and #40479 landed the SDK storage helper.

- Delete apps/meteor/client/meteor/overrides/unstoreLoginToken.ts (and its
  barrel entry). CachedStoresManager.ts registers
  clearAllCachesOnLogout via getDdpSdk().account.onLogout at module init,
  which fires on the same uid-undefined transition Meteor's monkey-patch
  was capturing.
- AuthenticationProvider's unstoreLoginToken context method collapses from
  a monkey-patch + restore pair into
  `(callback) => getDdpSdk().account.onLogout(callback)`. Same return shape
  (callback -> unsubscribe), so useUnstoreLoginToken consumers stay intact.
- AuthenticationProvider.wipeLocalAuth and the auth-error branch in
  ddpSdk.ts call removeStoredItem for USER_ID / LOGIN_TOKEN /
  LOGIN_TOKEN_EXPIRES — the three keys Meteor's _unstoreLoginToken clears.
  Adds LOGIN_TOKEN_EXPIRES to STORAGE_KEYS so storage.ts owns the full set.

No behaviour change: same localStorage keys cleared, same logout cleanup
ordering. The Accounts import stays in AuthenticationProvider.tsx and
ddpSdk.ts because callLoginMethod / loggingIn / getLoginToken / the
onEmailVerificationLink + onPageLoadLogin bridges still use it.
tassoevan pushed a commit that referenced this pull request May 15, 2026
The remaining client-side Accounts._unstoreLoginToken calls fell into two
roles: a monkey-patch that piggybacked on Meteor's token-clear hook to run
side effects on logout, and direct calls used to manually wipe the stored
credentials. Both are replaceable now that #40442 landed sdk.account.onLogout
and #40479 landed the SDK storage helper.

- Delete apps/meteor/client/meteor/overrides/unstoreLoginToken.ts (and its
  barrel entry). CachedStoresManager.ts registers
  clearAllCachesOnLogout via getDdpSdk().account.onLogout at module init,
  which fires on the same uid-undefined transition Meteor's monkey-patch
  was capturing.
- AuthenticationProvider's unstoreLoginToken context method collapses from
  a monkey-patch + restore pair into
  `(callback) => getDdpSdk().account.onLogout(callback)`. Same return shape
  (callback -> unsubscribe), so useUnstoreLoginToken consumers stay intact.
- AuthenticationProvider.wipeLocalAuth and the auth-error branch in
  ddpSdk.ts call removeStoredItem for USER_ID / LOGIN_TOKEN /
  LOGIN_TOKEN_EXPIRES — the three keys Meteor's _unstoreLoginToken clears.
  Adds LOGIN_TOKEN_EXPIRES to STORAGE_KEYS so storage.ts owns the full set.

No behaviour change: same localStorage keys cleared, same logout cleanup
ordering. The Accounts import stays in AuthenticationProvider.tsx and
ddpSdk.ts because callLoginMethod / loggingIn / getLoginToken / the
onEmailVerificationLink + onPageLoadLogin bridges still use it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: authentication stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants