Skip to content

Commit

Permalink
avoid password
Browse files Browse the repository at this point in the history
  • Loading branch information
amay077 committed May 6, 2024
1 parent 5ced1f2 commit 3abd3fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/lib/BlueSkyConnection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
let bskyServer = 'https://bsky.social';
let postSettings = loadPostSetting('bluesky');
let user = postSettings?.data?.user ?? '';
let password = postSettings?.data?.password ?? '';
let user = postSettings?.data?.sessionData?.email ?? '';
let password = '';
const onApplyBSkySettings = async () => {
console.log(`onApplyBSkySettings -> user:`, user);
Expand All @@ -30,8 +30,9 @@
alert('BlueSky に接続できませんでした。');
return;
}
postSettings = { type: 'bluesky', title: 'BlueSky', enabled: true, data: { user, password } };
const sessionData = res.data;
postSettings = { type: 'bluesky', title: 'BlueSky', enabled: true, data: { sessionData } };
savePostSetting(postSettings);
dispatch('onChange');
alert('BlueSky に接続しました。');
Expand Down
12 changes: 5 additions & 7 deletions src/lib/MainContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,12 @@
const postToBlueSky = async (text: string): Promise<boolean> => {
try {
const agent = new BskyAgent({
service: 'https://bsky.social'
service: 'https://bsky.social',
});
// resume session
agent.resumeSession(postSettings.bluesky?.data?.sessionData!);
// creating richtext
const rt = new RichText({
text,
Expand All @@ -213,12 +216,7 @@
text: rt.text,
facets: rt.facets,
createdAt: new Date().toISOString(),
};
await agent.login({
identifier: '[email protected]',
password: 'k36i-nsi2-in2j-mg34'
});
};
await agent.post(postRecord);
return true;
Expand Down
5 changes: 3 additions & 2 deletions src/lib/func.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { AtpSessionData } from "@atproto/api";

export type SettingDataMastodon = {
type: 'mastodon',
title: 'Mastodon',
Expand All @@ -16,8 +18,7 @@ export type SettingDataBluesky = {
title: 'BlueSky',
enabled: boolean,
data: {
user: string,
password: string,
sessionData: AtpSessionData,
}
};

Expand Down

0 comments on commit 3abd3fa

Please sign in to comment.