mattermost-mobile-upstream/app/actions/remote
Amy Blais 4a74a5be75
[MM-70605][MM-70607] Scope pre-auth secret storage per server (#10149) (#10278)
* [MM-70605][MM-70607] Scope pre-auth secret storage per server

The pre-auth secret was written with react-native-keychain's generic-password
API using the `server` option, which those calls do not read. Every server
therefore resolved to one shared entry, and a falsy secret argument deleted it,
so ordinary operations such as building a client, refreshing the token header or
removing another server discarded the stored value.

Key the entry per server instead. On Android the alias namespace is shared with
internet credentials, so the service is prefixed to keep it away from the
session token; iOS uses the bare server URL, which is what the native reader in
Gekidou already queries. The account value is renamed to `preauth_secret` on
both sides. Writing the token no longer touches the secret: removal is explicit,
via removePreauthSecret.

A one-time migration adopts the previously shared entry when a single server
makes ownership unambiguous, and discards it otherwise. It only deletes the old
entry once the new one is confirmed stored, and defers when no server is active.

Also forward the secret through the login screen to SSO, and fix loginOptions to
count only enabled providers so the single-provider redirect works. Relands the
`.enabled` filter from #9585 by @pltnm239.

Edit Server now updates the live client's headers rather than invalidating the
session, and validates with the candidate secret so a value the server rejects
cannot be saved.

* [MM-70605] Harden preauth secret flows and fix Edit Server Detox on iOS

Address review feedback around migration markers, credential errors, and
keeping re-login secrets out of nav params. Focus the empty Authentication
secret field via Display Name return so iOS Detox can type into it.



* [MM-70605] Fix lines-around-comment in Edit Server Detox helper



* [MM-70605] Roll back preauth keychain when Edit Server client sync fails

After the secret is stored, header apply or createClient failures left the
new value in secure storage while UI state still held the old baseline.
Restore the previous secret (and live header) before surfacing the error.



* [MM-70605] Preserve exact preauth secret on Edit Server rollback

Avoid trimming during keychain restore so boundary whitespace from the
previously stored value is not altered.



* [MM-70605] Harden preauth migration ownership and secret handoff

Adopt the legacy secret only when a single server exists in the app DB,
keep add-server candidates in EphemeralStore instead of nav params, and
resync the live client to stored credentials when keychain rollback fails.



* [MM-70605] Discard the legacy preauth secret when no server can own it

* [MM-70605] Shorten the preauth migration docblock

* [MM-70605] Skip the Authorization header when there is no bearer token

* [MM-70605] Surface preauth secret rejections with a specific error message

* [MM-70605] Mock clearPendingPreauthSecret in session action tests

* [MM-70605] Remove the unreachable catch from restorePreviousPreauthSecret

setPreauthSecret and removePreauthSecret never reject, and the returned promise was not awaited, so the catch could not run.

* [MM-70605] Use network-client fix for the iOS addHeaders crash

Temporary pin to mattermost/react-native-network-client#175 to check CI. Replace with the released version before merge.

* [MM-70605] Bump react-native-network-client to 1.11.5

1.11.5 gives each recreated iOS session its own delegate in addHeaders, which fixes the SIGTRAP on pre-auth secret changes.

---------


(cherry picked from commit 9ccfa0ebe9)

Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-27 08:32:25 +02:00
..
entry fetch roles during entry to avoid UI observing inconsistent channel s… (#9873) 2026-09-22 14:50:35 +02:00
apps.test.ts MM-59445 + others - Add tests for channel bookmarks, systems, apps and tos files in remote/actions (#8558) 2025-02-07 23:57:17 +08:00
apps.ts Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
category.test.ts [MM-68255] Enable mobile support for Managed Categories (#9683) 2026-04-16 10:01:51 -04:00
category.ts fix: app bugs surfaced by Detox RF migration (#9789) 2026-06-09 13:25:42 +05:30
channel_access_control_attributes.ts Mm 63935 abac end user indicators (#8848) 2025-05-19 15:34:03 +02:00
channel_bookmark.test.ts [MM-69723, MM-69705] Version-gate ChannelBookmarks and CustomProfileAttributes for flag removal (#9916) 2026-07-29 17:14:33 -03:00
channel_bookmark.ts [MM-69723, MM-69705] Version-gate ChannelBookmarks and CustomProfileAttributes for flag removal (#9916) 2026-07-29 17:14:33 -03:00
channel.test.ts [MM-66560] Fix channel links ending in channel IDs (#10158) 2026-09-15 11:28:03 -04:00
channel.ts Mm 70299 channel labels display phase 1 (#10113) 2026-09-17 21:37:43 +02:00
classification.test.ts Mm 70299 channel labels display phase 1 (#10113) 2026-09-17 21:37:43 +02:00
classification.ts Mm 70299 channel labels display phase 1 (#10113) 2026-09-17 21:37:43 +02:00
command.test.ts Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
command.ts Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
custom_emoji.test.ts feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
custom_emoji.ts Improve emoji picker performance introducing flashList (#8650) 2025-03-11 22:09:46 +08:00
custom_profile.test.ts [MM-62700] User Attribute types (#8903) 2025-06-12 10:59:13 +02:00
custom_profile.ts [MM-62700] User Attribute types (#8903) 2025-06-12 10:59:13 +02:00
ephemeral_mode.test.ts Mm 68296 audit ephemeral mode events (#10139) 2026-09-23 13:48:14 +02:00
ephemeral_mode.ts Mm 68296 audit ephemeral mode events (#10139) 2026-09-23 13:48:14 +02:00
file.test.ts MM-69122: Add file element support to interactive dialogs (#9898) 2026-10-07 14:43:26 -05:00
file.ts MM-69122: Add file element support to interactive dialogs (#9898) 2026-10-07 14:43:26 -05:00
general.test.ts Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
general.ts [MM-70605][MM-70607] Scope pre-auth secret storage per server (#10149) (#10278) 2026-10-27 08:32:25 +02:00
groups.test.ts Add tests to actions/remote/groups (#8303) 2024-11-04 19:24:01 +08:00
groups.ts Request metrics improvements (#8420) 2025-01-16 13:55:29 -07:00
integrations.test.ts Mattermost Blocks (#9764) 2026-06-29 18:42:16 +02:00
integrations.ts Mattermost Blocks (#9764) 2026-06-29 18:42:16 +02:00
license.test.ts Mm 68293 ephemeral mode warnings (#10140) 2026-10-01 18:13:22 +02:00
license.ts [MM-63728] Add license load metric to About screen (#8769) 2025-04-17 17:29:47 -03:00
notifications.test.ts Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
notifications.ts Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
performance.test.ts Add Accept Header on ClientTracking (#8895) 2025-06-06 12:42:09 +02:00
performance.ts Add performance metrics to the app (#7953) 2024-06-12 09:45:27 +02:00
permalink.ts Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
post.auxiliary.test.ts [MM-66467] Missing messages (#9827) 2026-06-15 11:20:58 +02:00
post.auxiliary.ts Mm 68219 show placeholder for redacted files (#9719) 2026-10-15 15:59:13 -07:00
post.test.ts MM-70693: Hide burn-on-read quick action when ABAC policy denies it (#10239) (#10260) 2026-10-20 09:01:17 +03:00
post.ts MM-70693: Hide burn-on-read quick action when ABAC policy denies it (#10239) (#10260) 2026-10-20 09:01:17 +03:00
preference.test.ts Revert "e2e(detox): Rainforest to Detox migration (#9790)" (#9834) 2026-06-15 17:57:01 +02:00
preference.ts fix: app bugs surfaced by Detox RF migration (#9789) 2026-06-09 13:25:42 +05:30
reactions.test.ts Fix team sidebar not showing thread unreads (#8624) 2025-03-18 13:33:15 +01:00
reactions.ts [MM-42586] Reaction toggle behavior (#7674) 2023-11-22 21:05:58 +08:00
refresh.test.ts Mm 68293 ephemeral mode warnings (#10140) 2026-10-01 18:13:22 +02:00
refresh.ts Mm 68293 ephemeral mode warnings (#10140) 2026-10-01 18:13:22 +02:00
render_permissions.test.ts Mm 68219 show placeholder for redacted files (#9719) 2026-10-15 15:59:13 -07:00
render_permissions.ts Mm 68219 show placeholder for redacted files (#9719) 2026-10-15 15:59:13 -07:00
restore_server.test.ts Fix deeplink handler (#9919) 2026-08-19 01:35:52 +08:00
restore_server.ts Fix deeplink handler (#9919) 2026-08-19 01:35:52 +08:00
retry.test.ts MM-59433 Add unit tests to actions/remote/retry (#8445) 2025-01-08 12:30:16 -05:00
retry.ts Refactor errors around the app (#7306) 2023-05-03 13:08:55 +02:00
role.ts Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
scheduled_post.test.ts feat(MM-63937): fetch initial team data only on entry (#8894) 2025-08-18 10:06:15 -06:00
scheduled_post.ts Unlicensed server should not show the tooltip on channel send button (#8806) 2025-04-29 17:21:09 +05:30
search.test.ts Fix team sidebar not showing thread unreads (#8624) 2025-03-18 13:33:15 +01:00
search.ts Mm 68219 show placeholder for redacted files (#9719) 2026-10-15 15:59:13 -07:00
session_attributes.test.ts [MM-68986][MM-69203] Add module to collect Session Attributes from Mobile App (#9830) 2026-08-18 18:03:20 +00:00
session_attributes.ts [MM-68986][MM-69203] Add module to collect Session Attributes from Mobile App (#9830) 2026-08-18 18:03:20 +00:00
session.test.ts [MM-70605][MM-70607] Scope pre-auth secret storage per server (#10149) (#10278) 2026-10-27 08:32:25 +02:00
session.ts [MM-70605][MM-70607] Scope pre-auth secret storage per server (#10149) (#10278) 2026-10-27 08:32:25 +02:00
systems.test.ts Mm 68767 zero persistence (#9803) 2026-07-16 13:55:45 +02:00
systems.ts Mm 68767 zero persistence (#9803) 2026-07-16 13:55:45 +02:00
team.test.ts MM-68575: Use server getMyTeams for canJoinOtherTeams check (#9736) 2026-05-13 10:23:21 -07:00
team.ts MM-68575: Use server getMyTeams for canJoinOtherTeams check (#9736) 2026-05-13 10:23:21 -07:00
terms_of_service.test.ts MM-59445 + others - Add tests for channel bookmarks, systems, apps and tos files in remote/actions (#8558) 2025-02-07 23:57:17 +08:00
terms_of_service.ts fix critical crashes on Android (#9871) 2026-06-23 02:40:21 +08:00
thread.test.ts Revert "e2e(detox): Rainforest to Detox migration (#9790)" (#9834) 2026-06-15 17:57:01 +02:00
thread.ts Mm 70299 channel labels display phase 1 (#10113) 2026-09-17 21:37:43 +02:00
user.test.ts Mm 68767 zero persistence (#9803) 2026-07-16 13:55:45 +02:00
user.ts Mm 68767 zero persistence (#9803) 2026-07-16 13:55:45 +02:00