Compare commits
No commits in common. "3afda89dfcc71f29b508f82272982a5daae860e0" and "3ae9cffba8a33da016991e988182376f94fd1624" have entirely different histories.
3afda89dfc
...
3ae9cffba8
3 changed files with 43 additions and 28 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
26
package.json
26
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/package",
|
||||
"name": "tutu",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.5",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
@ -14,35 +14,35 @@
|
|||
"author": "Rubicon",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@suid/vite-plugin": "^0.3.0",
|
||||
"@suid/vite-plugin": "^0.2.0",
|
||||
"@types/hammerjs": "^2.0.45",
|
||||
"postcss": "^8.4.45",
|
||||
"postcss": "^8.4.41",
|
||||
"prettier": "^3.3.3",
|
||||
"typescript": "^5.6.2",
|
||||
"vite": "^5.4.5",
|
||||
"typescript": "^5.5.4",
|
||||
"vite": "^5.4.0",
|
||||
"vite-plugin-package-version": "^1.1.0",
|
||||
"vite-plugin-pwa": "^0.20.5",
|
||||
"vite-plugin-pwa": "^0.20.1",
|
||||
"vite-plugin-solid": "^2.10.2",
|
||||
"vite-plugin-solid-styled": "^0.11.1",
|
||||
"wrangler": "^3.78.2"
|
||||
"wrangler": "^3.70.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nanostores/persistent": "^0.10.2",
|
||||
"@nanostores/persistent": "^0.9.1",
|
||||
"@nanostores/solid": "^0.4.2",
|
||||
"@solid-primitives/event-listener": "^2.3.3",
|
||||
"@solid-primitives/intersection-observer": "^2.1.6",
|
||||
"@solid-primitives/resize-observer": "^2.0.26",
|
||||
"@solidjs/router": "^0.14.5",
|
||||
"@suid/icons-material": "^0.8.0",
|
||||
"@suid/material": "^0.17.0",
|
||||
"@solidjs/router": "^0.11.5",
|
||||
"@suid/icons-material": "^0.7.0",
|
||||
"@suid/material": "^0.16.0",
|
||||
"blurhash": "^2.0.5",
|
||||
"colorjs.io": "^0.5.2",
|
||||
"date-fns": "^3.6.0",
|
||||
"fast-average-color": "^9.4.0",
|
||||
"hammerjs": "^2.0.8",
|
||||
"masto": "^6.8.0",
|
||||
"nanostores": "^0.11.3",
|
||||
"solid-js": "^1.8.22",
|
||||
"nanostores": "^0.9.5",
|
||||
"solid-js": "^1.8.20",
|
||||
"solid-styled": "^0.11.1",
|
||||
"stacktrace-js": "^2.0.2",
|
||||
"web-animations-js": "^2.3.2"
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
createRestAPIClient,
|
||||
type mastodon,
|
||||
} from "masto";
|
||||
import { action } from "nanostores";
|
||||
import { createMastoClientFor } from "../masto/clients";
|
||||
|
||||
export type Account = {
|
||||
|
@ -56,9 +57,11 @@ async function oauth2TokenViaAuthCode(app: RegisteredApp, authCode: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function acceptAccountViaAuthCode(site: string, authCode: string) {
|
||||
const $store = $accounts;
|
||||
const app = $registeredApps.get()[site];
|
||||
export const acceptAccountViaAuthCode = action(
|
||||
$accounts,
|
||||
"acceptAccount",
|
||||
async ($store, site: string, authCode: string) => {
|
||||
const app = $registeredApps.get()[site];
|
||||
if (!app) {
|
||||
throw TypeError("application not found");
|
||||
}
|
||||
|
@ -76,20 +79,29 @@ export async function acceptAccountViaAuthCode(site: string, authCode: string) {
|
|||
$store.set(all);
|
||||
|
||||
return acct;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export async function updateAcctInf(idx: number) {
|
||||
const o = $accounts.get();
|
||||
export const updateAcctInf = action(
|
||||
$accounts,
|
||||
"updateAcctInf",
|
||||
async ($store, idx: number) => {
|
||||
const o = $store.get();
|
||||
const client = createMastoClientFor(o[idx]);
|
||||
const inf = await client.v1.accounts.verifyCredentials();
|
||||
o[idx].inf = inf;
|
||||
$accounts.set(o);
|
||||
$store.set(o);
|
||||
return inf;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export function signOut(predicate: (acct: Account) => boolean) {
|
||||
$accounts.set($accounts.get().filter((a) => !predicate(a)));
|
||||
}
|
||||
export const signOut = action(
|
||||
$accounts,
|
||||
"signOut",
|
||||
($store, predicate: (acct: Account) => boolean) => {
|
||||
$store.set($store.get().filter((a) => !predicate(a)));
|
||||
},
|
||||
);
|
||||
|
||||
export type RegisteredApp = {
|
||||
site: string;
|
||||
|
@ -128,9 +140,11 @@ async function getAppAccessToken(app: RegisteredApp) {
|
|||
return dict.access_token;
|
||||
}
|
||||
|
||||
export async function getOrRegisterApp(site: string, redirectUrl: string) {
|
||||
const $store = $registeredApps;
|
||||
const all = $store.get();
|
||||
export const getOrRegisterApp = action(
|
||||
$registeredApps,
|
||||
"getOrRegisterApp",
|
||||
async ($store, site: string, redirectUrl: string) => {
|
||||
const all = $store.get();
|
||||
const savedApp = all[site];
|
||||
if (savedApp && savedApp.redirectUrl === redirectUrl) {
|
||||
const appAccessToken = await getAppAccessToken(savedApp);
|
||||
|
@ -184,4 +198,5 @@ export async function getOrRegisterApp(site: string, redirectUrl: string) {
|
|||
};
|
||||
$store.set(all);
|
||||
return all[site];
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue