diff --git a/package.json b/package.json index cc2048f..2ea6233 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sky-follower-bridge", "displayName": "Sky Follower Bridge", - "version": "0.9.4", + "version": "0.9.5", "description": "Instantly find and follow the same users from your Twitter follows on Bluesky.", "author": "kawamataryou", "scripts": { diff --git a/src/contents/App.tsx b/src/contents/App.tsx index 75682e2..98d1c8b 100644 --- a/src/contents/App.tsx +++ b/src/contents/App.tsx @@ -46,6 +46,7 @@ const App = () => { body: { identifier: string; password: string; + authFactorToken?: string; }; }, _sender: chrome.runtime.MessageSender, @@ -56,6 +57,9 @@ const App = () => { identifier: message.body.identifier, password: message.body.password, messageName: message.name, + ...(message.body.authFactorToken && { + authFactorToken: message.body.authFactorToken, + }), }) .then(() => { sendResponse({ hasError: false }); diff --git a/src/lib/bskyServiceWorkerClient.ts b/src/lib/bskyServiceWorkerClient.ts index 1554e0f..b99b4bc 100644 --- a/src/lib/bskyServiceWorkerClient.ts +++ b/src/lib/bskyServiceWorkerClient.ts @@ -4,6 +4,7 @@ import { sendToBackground } from "@plasmohq/messaging"; export type BskyLoginParams = { identifier: string; password: string; + authFactorToken?: string; }; export class BskyServiceWorkerClient { @@ -14,6 +15,7 @@ export class BskyServiceWorkerClient { public static async createAgent({ identifier, password, + authFactorToken, }: BskyLoginParams): Promise { const client = new BskyServiceWorkerClient(); const { session, error } = await sendToBackground({ @@ -21,6 +23,7 @@ export class BskyServiceWorkerClient { body: { identifier, password, + ...(authFactorToken && { authFactorToken: authFactorToken }), }, }); if (error) throw new Error(error.message); diff --git a/src/lib/hooks/useRetrieveBskyUsers.ts b/src/lib/hooks/useRetrieveBskyUsers.ts index 65f061e..b2b7543 100644 --- a/src/lib/hooks/useRetrieveBskyUsers.ts +++ b/src/lib/hooks/useRetrieveBskyUsers.ts @@ -196,10 +196,12 @@ export const useRetrieveBskyUsers = () => { identifier, password, messageName, + authFactorToken, }: { identifier: string; password: string; messageName: (typeof MESSAGE_NAMES)[keyof typeof MESSAGE_NAMES]; + authFactorToken?: string; }) => { setRetrievalParams({ identifier, @@ -210,6 +212,7 @@ export const useRetrieveBskyUsers = () => { bskyClient.current = await BskyServiceWorkerClient.createAgent({ identifier, password, + ...(authFactorToken && { authFactorToken: authFactorToken }), }); setActionMode(MESSAGE_NAME_TO_ACTION_MODE_MAP[messageName]); diff --git a/src/popup.tsx b/src/popup.tsx index ec91182..92dbd4c 100644 --- a/src/popup.tsx +++ b/src/popup.tsx @@ -109,7 +109,7 @@ function IndexPopup() { }, }); if (res.hasError) { - if (res.message === AUTH_FACTOR_TOKEN_REQUIRED_ERROR_MESSAGE) { + if (res.message.includes(AUTH_FACTOR_TOKEN_REQUIRED_ERROR_MESSAGE)) { setIsShowAuthFactorTokenInput(true); } else { setErrorMessage(res.message); @@ -130,7 +130,6 @@ function IndexPopup() { setErrorMessage( "Error: Something went wrong. Please reload the web page and try again.", ); - console.error(e); } } finally { setIsLoading(false);