Skip to content

Commit

Permalink
Fix session validation error in WebKit browsers (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelhoral committed Jun 23, 2024
1 parent 0ec6976 commit bc37909
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Portions copyright 2024 Wren Security.
*/

import $ from "jquery";
import _ from "lodash";

import { sessionAddInfo } from "store/actions/creators";
Expand All @@ -37,11 +38,22 @@ const getSessionInfo = (options) => {
};

export const getTimeLeft = () => {
// Number of seconds to indicate in case of network error (see WrenSecurity/wrenam#176)
const NETWORK_ERROR_EXPIRATION_SECONDS = 30;

return getSessionInfo({ suppressSpinner: true }).then((sessionInfo) => {
const idleExpiration = moment(sessionInfo.maxIdleExpirationTime).diff(moment(), "seconds");
const maxExpiration = moment(sessionInfo.maxSessionExpirationTime).diff(moment(), "seconds");
return _.min([idleExpiration, maxExpiration]);
});
}).then(
null,
(jqXhr, textStatus, errorThrown) => {
if (jqXhr.status === 0) { // ignore network error
return $.Deferred().resolve(NETWORK_ERROR_EXPIRATION_SECONDS);
}
return $.Deferred().reject(jqXhr, textStatus, errorThrown);
}
);
};

export const updateSessionInfo = (options) => {
Expand Down

0 comments on commit bc37909

Please sign in to comment.