support 2FA auth

This commit is contained in:
kawamataryo
2024-10-18 09:14:45 +09:00
parent f7e2c58c72
commit 9544a7f67c
4 changed files with 67 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ const clientCache = new Map<string, BskyClient>();
export type BskyLoginParams = {
identifier: string;
password: string;
authFactorToken?: string;
};
export class BskyClient {
@@ -49,11 +50,13 @@ export class BskyClient {
public static async createAgent({
identifier,
password,
authFactorToken,
}: BskyLoginParams): Promise<BskyClient> {
const client = new BskyClient();
const { data } = await client.agent.login({
identifier,
password,
...(authFactorToken && { authFactorToken }),
});
client.me = {
did: data.did,

View File

@@ -73,3 +73,5 @@ export const MATCH_TYPE_LABEL_AND_COLOR = {
color: "secondary",
},
};
export const AUTH_FACTOR_TOKEN_REQUIRED_ERROR_MESSAGE = "AuthFactorTokenRequiredError";