Changeset View
Changeset View
Standalone View
Standalone View
lib/utils/action-utils.js
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | |||||
// here, on the assumption that only native clients will call this. (Native | // here, on the assumption that only native clients will call this. (Native | ||||
// clients don't specify a sessionID, indicating to the server that it should | // clients don't specify a sessionID, indicating to the server that it should | ||||
// use the cookieID as the sessionID.) | // use the cookieID as the sessionID.) | ||||
async function fetchNewCookieFromNativeCredentials( | async function fetchNewCookieFromNativeCredentials( | ||||
dispatch: Dispatch, | dispatch: Dispatch, | ||||
cookie: ?string, | cookie: ?string, | ||||
urlPrefix: string, | urlPrefix: string, | ||||
logInActionSource: LogInActionSource, | logInActionSource: LogInActionSource, | ||||
getInitialNotificationsEncryptedMessage?: () => Promise<string>, | |||||
): Promise<?ClientSessionChange> { | ): Promise<?ClientSessionChange> { | ||||
const resolveInvalidatedCookie = getConfig().resolveInvalidatedCookie; | const resolveInvalidatedCookie = getConfig().resolveInvalidatedCookie; | ||||
if (!resolveInvalidatedCookie) { | if (!resolveInvalidatedCookie) { | ||||
return null; | return null; | ||||
} | } | ||||
let newSessionChange = null; | let newSessionChange = null; | ||||
let callServerEndpointCallback = null; | let callServerEndpointCallback = null; | ||||
const boundCallServerEndpoint = async ( | const boundCallServerEndpoint = async ( | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | ) => { | ||||
const startingPayload = { ...inputStartingPayload, logInActionSource }; | const startingPayload = { ...inputStartingPayload, logInActionSource }; | ||||
dispatch(wrapActionPromise(actionTypes, promise, null, startingPayload)); | dispatch(wrapActionPromise(actionTypes, promise, null, startingPayload)); | ||||
return new Promise(r => (callServerEndpointCallback = r)); | return new Promise(r => (callServerEndpointCallback = r)); | ||||
}; | }; | ||||
await resolveInvalidatedCookie( | await resolveInvalidatedCookie( | ||||
boundCallServerEndpoint, | boundCallServerEndpoint, | ||||
dispatchRecoveryAttempt, | dispatchRecoveryAttempt, | ||||
logInActionSource, | logInActionSource, | ||||
getInitialNotificationsEncryptedMessage, | |||||
); | ); | ||||
return newSessionChange; | return newSessionChange; | ||||
} | } | ||||
// Third param is optional and gets called with newCookie if we get a new cookie | // Third param is optional and gets called with newCookie if we get a new cookie | ||||
// Necessary to propagate cookie in cookieInvalidationRecovery below | // Necessary to propagate cookie in cookieInvalidationRecovery below | ||||
function bindCookieAndUtilsIntoCallServerEndpoint( | function bindCookieAndUtilsIntoCallServerEndpoint( | ||||
params: BindServerCallsParams, | params: BindServerCallsParams, | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |