diff --git a/keyserver/src/services/blob.js b/keyserver/src/services/blob.js --- a/keyserver/src/services/blob.js +++ b/keyserver/src/services/blob.js @@ -107,8 +107,11 @@ const headers = await createRequestHeaders(); const blobResult = await downloadBlob(hash, headers); - if (blobResult.result !== 'success') { + if (blobResult.result === 'error') { return { found: false, status: blobResult.status }; + } else if (blobResult.result === 'invalid_csat') { + await clearIdentityInfo(); + return { found: false, status: 401 }; } const blob = await blobResult.response.blob(); return { found: true, blob }; diff --git a/lib/actions/upload-actions.js b/lib/actions/upload-actions.js --- a/lib/actions/upload-actions.js +++ b/lib/actions/upload-actions.js @@ -33,7 +33,6 @@ import { getMessageForException } from '../utils/errors.js'; import { useDispatch } from '../utils/redux-utils.js'; import { createDefaultHTTPRequestHeaders } from '../utils/services-utils.js'; -import { responseIsInvalidCSAT } from '../utils/services-utils'; export type MultimediaUploadCallbacks = Partial<{ +onProgress: (percent: number) => void, diff --git a/lib/components/base-auto-join-community-handler.react.js b/lib/components/base-auto-join-community-handler.react.js --- a/lib/components/base-auto-join-community-handler.react.js +++ b/lib/components/base-auto-join-community-handler.react.js @@ -4,6 +4,7 @@ import _pickBy from 'lodash/fp/pickBy.js'; import * as React from 'react'; +import { useInvalidCSATLogOut } from '../actions/user-actions.js'; import { NeynarClientContext } from '../components/neynar-client-provider.react.js'; import { useIsLoggedInToIdentityAndAuthoritativeKeyserver } from '../hooks/account-hooks.js'; import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; @@ -80,6 +81,8 @@ const prevCanQueryRef = React.useRef(); const canQuery = loggedIn && !!fid; + const invalidTokenLogOut = useInvalidCSATLogOut(); + React.useEffect(() => { if (canQuery === prevCanQueryRef.current) { return; @@ -123,6 +126,9 @@ const blobHash = farcasterChannelTagBlobHash(channelID); const blobResult = await downloadBlob(blobHash, headers); if (blobResult.result !== 'success') { + if (blobResult.result === 'invalid_csat') { + void invalidTokenLogOut(); + } return null; } @@ -176,6 +182,7 @@ getAuthMetadata, keyserverInfos, canQuery, + invalidTokenLogOut, ]); const potentiallyIncrementBatch: ( diff --git a/lib/utils/blob-service.js b/lib/utils/blob-service.js --- a/lib/utils/blob-service.js +++ b/lib/utils/blob-service.js @@ -87,6 +87,7 @@ export type BlobDownloadResult = | { +result: 'success', response: Response } + | { +result: 'invalid_csat' } | { +result: 'error', +status: number, +statusText: string }; async function downloadBlob( @@ -100,7 +101,9 @@ headers, }); - if (response.status !== 200) { + if (responseIsInvalidCSAT(response)) { + return { result: 'invalid_csat' }; + } else if (response.status !== 200) { const { status, statusText } = response; return { result: 'error', status, statusText }; }