Unfollow tool for Bluesky

fix app password login

Changed files
+7 -5
src
+7 -5
src/App.tsx
···
resolveFromIdentity,
type Session,
} from "@atcute/oauth-browser-client";
-
import { $type, Did, Handle } from "@atcute/lexicons";
import { ComAtprotoRepoApplyWrites } from "@atcute/atproto";
import { AppBskyGraphFollow } from "@atcute/bluesky";
···
let rpc: Client;
let agent: OAuthUserAgent;
let manager: CredentialManager;
const resolveDid = async (did: string) => {
const res = await fetch(
···
if (session) {
agent = new OAuthUserAgent(session);
rpc = new Client({ handler: agent });
setLoginState(true);
setHandle(await resolveDid(agent.sub));
···
const loginBsky = async (login: string) => {
if (password()) {
-
const agentDID = login.startsWith("did:") ? login : await resolveHandle(login);
manager = new CredentialManager({ service: await getPDS(agentDID) });
rpc = new Client({ handler: manager });
···
const fetchPage = async (cursor?: string) => {
return await rpc.get("com.atproto.repo.listRecords", {
params: {
-
repo: agent.sub,
collection: "app.bsky.graph.follow",
limit: PAGE_LIMIT,
cursor: cursor,
···
viewer.blocking || viewer.blockingByList ?
RepoStatus.BLOCKEDBY | RepoStatus.BLOCKING
: RepoStatus.BLOCKEDBY;
-
} else if (res.data.did.includes(agent.sub)) {
status = RepoStatus.YOURSELF;
} else if (viewer.blocking || viewer.blockingByList) {
status = RepoStatus.BLOCKING;
···
for (let i = 0; i < writes.length; i += BATCHSIZE) {
await rpc.post("com.atproto.repo.applyWrites", {
input: {
-
repo: agent.sub,
writes: writes.slice(i, i + BATCHSIZE),
},
});
···
resolveFromIdentity,
type Session,
} from "@atcute/oauth-browser-client";
+
import { $type, ActorIdentifier, Did, Handle } from "@atcute/lexicons";
import { ComAtprotoRepoApplyWrites } from "@atcute/atproto";
import { AppBskyGraphFollow } from "@atcute/bluesky";
···
let rpc: Client;
let agent: OAuthUserAgent;
let manager: CredentialManager;
+
let agentDID: string;
const resolveDid = async (did: string) => {
const res = await fetch(
···
if (session) {
agent = new OAuthUserAgent(session);
rpc = new Client({ handler: agent });
+
agentDID = agent.sub;
setLoginState(true);
setHandle(await resolveDid(agent.sub));
···
const loginBsky = async (login: string) => {
if (password()) {
+
agentDID = login.startsWith("did:") ? login : await resolveHandle(login);
manager = new CredentialManager({ service: await getPDS(agentDID) });
rpc = new Client({ handler: manager });
···
const fetchPage = async (cursor?: string) => {
return await rpc.get("com.atproto.repo.listRecords", {
params: {
+
repo: agentDID as ActorIdentifier,
collection: "app.bsky.graph.follow",
limit: PAGE_LIMIT,
cursor: cursor,
···
viewer.blocking || viewer.blockingByList ?
RepoStatus.BLOCKEDBY | RepoStatus.BLOCKING
: RepoStatus.BLOCKEDBY;
+
} else if (res.data.did.includes(agentDID)) {
status = RepoStatus.YOURSELF;
} else if (viewer.blocking || viewer.blockingByList) {
status = RepoStatus.BLOCKING;
···
for (let i = 0; i < writes.length; i += BATCHSIZE) {
await rpc.post("com.atproto.repo.applyWrites", {
input: {
+
repo: agentDID as ActorIdentifier,
writes: writes.slice(i, i + BATCHSIZE),
},
});