Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33317269
D10578.1768831577.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D10578.1768831577.diff
View Options
diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js
--- a/lib/utils/action-utils.js
+++ b/lib/utils/action-utils.js
@@ -13,6 +13,7 @@
import { getConfig } from './config.js';
import { promiseAll } from './promises.js';
import { useSelector, useDispatch } from './redux-utils.js';
+import { usingCommServicesAccessToken } from './services-utils.js';
import { ashoatKeyserverID } from './validation-utils.js';
import { serverCallStateSelector } from '../selectors/server-calls.js';
import {
@@ -185,6 +186,23 @@
});
}
+// This function is a shortcut that tells us whether it's worth even trying to
+// call resolveKeyserverSessionInvalidation
+function canResolveKeyserverSessionInvalidation() {
+ if (usingCommServicesAccessToken) {
+ // We can always try to resolve a keyserver session invalidation
+ // automatically using the Olm auth responder
+ return true;
+ }
+ const { resolveKeyserverSessionInvalidationUsingNativeCredentials } =
+ getConfig();
+ // If we can't use the Olm auth responder, then we can only resolve a
+ // keyserver session invalidation on native, where we have access to the
+ // user's native credentials. Note that we can't do this for ETH users, but we
+ // don't know if the user is an ETH user from this function
+ return !!resolveKeyserverSessionInvalidationUsingNativeCredentials;
+}
+
// This function attempts to resolve an invalid keyserver session. A session can
// become invalid when a keyserver invalidates it, or due to inconsistent client
// state. If the client is usingCommServicesAccessToken, then the invalidation
@@ -330,15 +348,13 @@
undefined,
keyserverID,
);
- const { resolveKeyserverSessionInvalidationUsingNativeCredentials } =
- getConfig();
+ const canResolveInvalidation = canResolveKeyserverSessionInvalidation();
// This function gets called before callServerEndpoint sends a request,
// to make sure that we're not in the middle of trying to recover
// an invalidated cookie
const waitIfCookieInvalidated = () => {
- if (!resolveKeyserverSessionInvalidationUsingNativeCredentials) {
- // If there is no
- // resolveKeyserverSessionInvalidationUsingNativeCredentials function,
+ if (!canResolveInvalidation) {
+ // If there is no way to resolve the session invalidation,
// just let the caller callServerEndpoint instance continue
return Promise.resolve(null);
}
@@ -385,9 +401,8 @@
// its cookie, and is wondering if it should just like... give up?
// Or if there's a chance at redemption
const cookieInvalidationRecovery = (sessionChange: ClientSessionChange) => {
- if (!resolveKeyserverSessionInvalidationUsingNativeCredentials) {
- // If there is no
- // resolveKeyserverSessionInvalidationUsingNativeCredentials function,
+ if (!canResolveInvalidation) {
+ // If there is no way to resolve the session invalidation,
// just let the caller callServerEndpoint instance continue
return Promise.resolve(null);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 2:06 PM (10 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5956769
Default Alt Text
D10578.1768831577.diff (2 KB)
Attached To
Mode
D10578: [lib] Introduce canResolveKeyserverSessionInvalidation
Attached
Detach File
Event Timeline
Log In to Comment