Initial toot-worker implementation

This commit is contained in:
浪子
2026-05-14 09:59:58 +08:00
commit 01880d39a0
19 changed files with 4952 additions and 0 deletions
+167
View File
@@ -0,0 +1,167 @@
export type Json = Record<string, unknown>;
export type User = {
id: string;
username: string;
display_name: string;
note: string;
password_hash: string;
private_key_jwk: string;
public_key_jwk: string;
created_at: string;
};
export type OAuthApp = {
id: string;
client_id: string;
client_secret: string;
name: string;
redirect_uri: string;
scopes: string;
website: string | null;
created_at: string;
};
export type OAuthCode = {
code: string;
app_id: string;
user_id: string;
redirect_uri: string;
scopes: string;
expires_at: number;
};
export type Status = {
id: string;
user_id: string;
content: string;
summary: string;
sensitive: number;
language: string;
visibility: string;
in_reply_to_id: string | null;
activity_id: string;
object_id: string;
created_at: string;
url: string;
};
export type DeletedStatus = {
id: string;
user_id: string;
object_id: string;
url: string;
deleted_at: string;
};
export type Media = {
id: string;
user_id: string;
status_id: string | null;
r2_key: string;
mime_type: string;
description: string | null;
size: number;
created_at: string;
};
export type Follow = {
id: string;
follower_actor: string;
local_user_id: string;
inbox: string;
accepted: number;
created_at: string;
};
export type OutgoingFollow = {
id: string;
local_user_id: string;
target_actor: string;
target_inbox: string;
activity_id: string;
accepted: number;
created_at: string;
};
export type Notification = {
id: string;
user_id: string;
type: string;
actor: string;
status_id: string | null;
read: number;
created_at: string;
};
export type Favourite = {
id: string;
status_id: string;
actor: string;
activity_id: string;
created_at: string;
};
export type Reblog = {
id: string;
status_id: string;
actor: string;
activity_id: string;
created_at: string;
};
export type Mention = {
status_id: string;
actor: string;
acct: string;
url: string;
};
export type Hashtag = {
status_id: string;
tag: string;
};
export type ActorCache = {
id: string;
inbox: string;
shared_inbox: string | null;
preferred_username: string | null;
name: string | null;
summary: string | null;
icon_url: string | null;
public_key_id: string | null;
public_key_pem: string | null;
fetched_at: string;
};
export type RemoteActor = {
id: string;
type?: string;
inbox?: string;
endpoints?: { sharedInbox?: string };
preferredUsername?: string;
name?: string;
summary?: string;
icon?: { url?: string } | string;
publicKey?: {
id?: string;
owner?: string;
publicKeyPem?: string;
};
};
export type Session = {
userId: string;
appId: string;
scopes: string;
};
export const ACTIVITY_CONTEXT = "https://www.w3.org/ns/activitystreams";
export const SECURITY_CONTEXT = "https://w3id.org/security/v1";
export const PUBLIC_COLLECTION = "https://www.w3.org/ns/activitystreams#Public";
export const ACTOR_CACHE_TTL_MS = 1000 * 60 * 60 * 24;
export const SIGNATURE_MAX_SKEW_MS = 1000 * 60 * 60 * 12;
export const AVATAR_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160"><rect width="160" height="160" fill="#d8e1e8"/><circle cx="80" cy="56" r="28" fill="#6b7c8f"/><path d="M30 136c10-28 34-42 50-42s40 14 50 42" fill="#6b7c8f"/></svg>`;
export const HEADER_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1500 500"><defs><linearGradient id="g" x1="0" x2="1"><stop stop-color="#d8e1e8"/><stop offset="1" stop-color="#8aa0b6"/></linearGradient></defs><rect width="1500" height="500" fill="url(#g)"/><circle cx="220" cy="120" r="90" fill="#f7fbff" fill-opacity=".35"/><circle cx="1280" cy="380" r="120" fill="#f7fbff" fill-opacity=".2"/></svg>`;