@takosjp/yurucommu-core 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -0
- package/README.md +82 -0
- package/migrations/0001_init.sql +495 -0
- package/migrations/0002_social_remote_actor_edges.sql +92 -0
- package/migrations/0003_activity_remote_object_edges.sql +68 -0
- package/migrations/0004_blocklist.sql +26 -0
- package/migrations/0005_story_community_scope.sql +13 -0
- package/migrations/0006_dm_community_read_status.sql +19 -0
- package/migrations/0007_moderation_reports.sql +22 -0
- package/migrations/0008_actor_fields_aka.sql +18 -0
- package/migrations/0009_object_tags.sql +13 -0
- package/migrations/0010_object_recipients_drop_actor_fk.sql +34 -0
- package/migrations/0011_drop_remote_actor_fks.sql +205 -0
- package/migrations/0012_objects_content_fts.sql +39 -0
- package/migrations/0013_efficiency_indexes.sql +13 -0
- package/migrations/0014_inbox_actor_created_idx.sql +15 -0
- package/migrations/0015_community_bans.sql +16 -0
- package/migrations/0016_namespace_takos_oidc_subject.sql +19 -0
- package/migrations/0017_mobile_push_registrations.sql +22 -0
- package/migrations/README.md +122 -0
- package/package.json +75 -0
- package/packages/api/LICENSE +16 -0
- package/packages/api/package.json +30 -0
- package/packages/api/src/index.ts +4 -0
- package/packages/api/src/lib/api/account.ts +20 -0
- package/packages/api/src/lib/api/actors.ts +149 -0
- package/packages/api/src/lib/api/auth.ts +46 -0
- package/packages/api/src/lib/api/communities.ts +329 -0
- package/packages/api/src/lib/api/dm.test.ts +67 -0
- package/packages/api/src/lib/api/dm.ts +236 -0
- package/packages/api/src/lib/api/fetch.ts +111 -0
- package/packages/api/src/lib/api/follow.ts +30 -0
- package/packages/api/src/lib/api/media.ts +100 -0
- package/packages/api/src/lib/api/moderation.ts +98 -0
- package/packages/api/src/lib/api/normalize.ts +71 -0
- package/packages/api/src/lib/api/notifications.test.ts +63 -0
- package/packages/api/src/lib/api/notifications.ts +61 -0
- package/packages/api/src/lib/api/posts.test.ts +110 -0
- package/packages/api/src/lib/api/posts.ts +181 -0
- package/packages/api/src/lib/api/recommendations.ts +22 -0
- package/packages/api/src/lib/api/search.ts +88 -0
- package/packages/api/src/lib/api/stories.ts +80 -0
- package/packages/api/src/lib/api.ts +15 -0
- package/packages/api/src/lib/fetch-with-timeout.ts +42 -0
- package/packages/api/src/lib/transport.ts +40 -0
- package/packages/api/src/social-server.ts +47 -0
- package/packages/api/src/types/index.ts +185 -0
- package/scripts/apply-takosumi-migrations.ts +621 -0
- package/src/backend/federation-helpers.ts +36 -0
- package/src/backend/index.ts +872 -0
- package/src/backend/lib/account-migration.ts +106 -0
- package/src/backend/lib/activitypub-actor-cache.ts +238 -0
- package/src/backend/lib/activitypub-helpers.ts +131 -0
- package/src/backend/lib/activitypub-validators.ts +323 -0
- package/src/backend/lib/ap-context.ts +16 -0
- package/src/backend/lib/ap-ids.ts +101 -0
- package/src/backend/lib/ap-response.ts +30 -0
- package/src/backend/lib/ap-signing.ts +87 -0
- package/src/backend/lib/ap-verify.ts +670 -0
- package/src/backend/lib/auth-lockout.ts +230 -0
- package/src/backend/lib/backend-paths.ts +34 -0
- package/src/backend/lib/base64.ts +30 -0
- package/src/backend/lib/blocklist-purge.ts +109 -0
- package/src/backend/lib/blocklist.ts +279 -0
- package/src/backend/lib/chunk.ts +33 -0
- package/src/backend/lib/client-ip.ts +169 -0
- package/src/backend/lib/community-visibility.ts +230 -0
- package/src/backend/lib/crypto.ts +424 -0
- package/src/backend/lib/delivery/circuit.ts +265 -0
- package/src/backend/lib/delivery/metrics.ts +30 -0
- package/src/backend/lib/delivery/planner.ts +190 -0
- package/src/backend/lib/delivery/queue-batching.ts +626 -0
- package/src/backend/lib/delivery/queue-delivery.ts +641 -0
- package/src/backend/lib/delivery/queue.ts +576 -0
- package/src/backend/lib/delivery/transformers.ts +56 -0
- package/src/backend/lib/delivery/types.ts +139 -0
- package/src/backend/lib/errors.ts +114 -0
- package/src/backend/lib/federation-fetch.ts +296 -0
- package/src/backend/lib/feed-cursor.ts +57 -0
- package/src/backend/lib/feed-exclude.ts +48 -0
- package/src/backend/lib/hex.ts +8 -0
- package/src/backend/lib/log-mask.ts +213 -0
- package/src/backend/lib/logger.ts +285 -0
- package/src/backend/lib/mobile-contract.ts +137 -0
- package/src/backend/lib/oauth-providers.ts +324 -0
- package/src/backend/lib/oauth-utils.ts +148 -0
- package/src/backend/lib/oidc-id-token.ts +151 -0
- package/src/backend/lib/parse-helpers.ts +31 -0
- package/src/backend/lib/post-visibility.ts +190 -0
- package/src/backend/lib/session-actor.ts +61 -0
- package/src/backend/lib/ssrf.ts +428 -0
- package/src/backend/lib/strip-image-metadata.ts +191 -0
- package/src/backend/middleware/bearer-auth.ts +70 -0
- package/src/backend/middleware/body-limit.ts +212 -0
- package/src/backend/middleware/cache.ts +429 -0
- package/src/backend/middleware/csrf.ts +130 -0
- package/src/backend/middleware/error-handler.ts +77 -0
- package/src/backend/middleware/rate-limit.ts +308 -0
- package/src/backend/public.ts +21 -0
- package/src/backend/routes/account-teardown.ts +430 -0
- package/src/backend/routes/activitypub/handlers/actor-inbox-handlers.ts +354 -0
- package/src/backend/routes/activitypub/handlers/inbound-timestamp.ts +29 -0
- package/src/backend/routes/activitypub/handlers/inbox-content-handlers.ts +1634 -0
- package/src/backend/routes/activitypub/handlers/inbox-follow-handlers.ts +547 -0
- package/src/backend/routes/activitypub/handlers/inbox-interaction-handlers.ts +497 -0
- package/src/backend/routes/activitypub/handlers/inbox-shared-helpers.ts +262 -0
- package/src/backend/routes/activitypub/handlers/user-inbox-handlers.ts +35 -0
- package/src/backend/routes/activitypub/inbox-types.ts +74 -0
- package/src/backend/routes/activitypub/inbox.ts +1191 -0
- package/src/backend/routes/activitypub/outbox.ts +0 -0
- package/src/backend/routes/activitypub/query-helpers.ts +227 -0
- package/src/backend/routes/activitypub.ts +616 -0
- package/src/backend/routes/actors-helpers.ts +487 -0
- package/src/backend/routes/actors.ts +1311 -0
- package/src/backend/routes/apps.ts +313 -0
- package/src/backend/routes/auth-helpers.ts +566 -0
- package/src/backend/routes/auth.ts +615 -0
- package/src/backend/routes/communities/membership-invites.ts +208 -0
- package/src/backend/routes/communities/membership-join.ts +335 -0
- package/src/backend/routes/communities/membership-members.ts +539 -0
- package/src/backend/routes/communities/membership-requests.ts +296 -0
- package/src/backend/routes/communities/membership-shared.ts +364 -0
- package/src/backend/routes/communities/messages.ts +479 -0
- package/src/backend/routes/communities/routes.ts +624 -0
- package/src/backend/routes/communities.ts +21 -0
- package/src/backend/routes/dm/contacts.ts +525 -0
- package/src/backend/routes/dm/conversations-helpers.ts +197 -0
- package/src/backend/routes/dm/conversations.ts +25 -0
- package/src/backend/routes/dm/messages.ts +658 -0
- package/src/backend/routes/dm/query-helpers.ts +85 -0
- package/src/backend/routes/dm/read-archive.ts +228 -0
- package/src/backend/routes/dm/requests.ts +222 -0
- package/src/backend/routes/dm/typing.ts +81 -0
- package/src/backend/routes/dm.ts +15 -0
- package/src/backend/routes/follow-helpers.ts +370 -0
- package/src/backend/routes/follow.ts +588 -0
- package/src/backend/routes/media.ts +692 -0
- package/src/backend/routes/mobile.ts +159 -0
- package/src/backend/routes/moderation.ts +373 -0
- package/src/backend/routes/notifications.ts +757 -0
- package/src/backend/routes/posts/delete-cascade.ts +330 -0
- package/src/backend/routes/posts/interactions.ts +795 -0
- package/src/backend/routes/posts/post-helpers.ts +847 -0
- package/src/backend/routes/posts/queries.ts +537 -0
- package/src/backend/routes/posts/routes.ts +865 -0
- package/src/backend/routes/posts/transformers.ts +161 -0
- package/src/backend/routes/posts.ts +17 -0
- package/src/backend/routes/recommendations.ts +88 -0
- package/src/backend/routes/search.ts +730 -0
- package/src/backend/routes/stories/interactions.ts +576 -0
- package/src/backend/routes/stories/query-helpers.ts +482 -0
- package/src/backend/routes/stories/routes.ts +906 -0
- package/src/backend/routes/stories.ts +13 -0
- package/src/backend/routes/takos-tools/dm.ts +249 -0
- package/src/backend/routes/takos-tools/follows.ts +225 -0
- package/src/backend/routes/takos-tools/posts.ts +292 -0
- package/src/backend/routes/takos-tools/search.ts +228 -0
- package/src/backend/routes/takos-tools/timeline.ts +132 -0
- package/src/backend/routes/takos-tools/types.ts +10 -0
- package/src/backend/routes/takos-tools-response.ts +178 -0
- package/src/backend/routes/takos-tools.ts +153 -0
- package/src/backend/routes/timeline.ts +755 -0
- package/src/backend/runtime/bun.ts +620 -0
- package/src/backend/runtime/cloudflare.ts +202 -0
- package/src/backend/runtime/compat-bun/types.ts +44 -0
- package/src/backend/runtime/memory-kv.ts +104 -0
- package/src/backend/runtime/shared.ts +142 -0
- package/src/backend/runtime/types.ts +205 -0
- package/src/backend/server.ts +636 -0
- package/src/backend/types.ts +143 -0
- package/src/db/index.ts +97 -0
- package/src/db/schema/actors.ts +129 -0
- package/src/db/schema/communities.ts +133 -0
- package/src/db/schema/date-utils.ts +17 -0
- package/src/db/schema/index.ts +17 -0
- package/src/db/schema/messaging.ts +241 -0
- package/src/db/schema/mobile.ts +37 -0
- package/src/db/schema/posts.ts +150 -0
- package/src/db/schema/relations.ts +266 -0
- package/src/db/schema/reports.ts +33 -0
- package/src/db/schema/social.ts +106 -0
- package/src/db/schema/stories.ts +70 -0
- package/src/db/schema.ts +15 -0
- package/src/plugin/public.ts +7 -0
- package/src/runtime/site-worker.ts +10 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// ===== Yurucommu AP-Native Types =====
|
|
2
|
+
|
|
3
|
+
// Actor represents a user (Person) in ActivityPub
|
|
4
|
+
export interface Actor {
|
|
5
|
+
ap_id: string; // Primary key: https://domain/ap/users/username
|
|
6
|
+
username: string; // Formatted: user@domain
|
|
7
|
+
preferred_username: string;
|
|
8
|
+
name: string | null;
|
|
9
|
+
summary: string | null;
|
|
10
|
+
icon_url: string | null;
|
|
11
|
+
header_url: string | null;
|
|
12
|
+
follower_count: number;
|
|
13
|
+
following_count: number;
|
|
14
|
+
post_count: number;
|
|
15
|
+
is_private?: boolean;
|
|
16
|
+
role?: "owner" | "moderator" | "member";
|
|
17
|
+
created_at: string;
|
|
18
|
+
is_following?: boolean;
|
|
19
|
+
is_followed_by?: boolean;
|
|
20
|
+
// Structured PropertyValue profile fields (Mastodon-parity, capped at 4 on
|
|
21
|
+
// the backend). Rendered as a small label/value list on the profile.
|
|
22
|
+
fields?: { name: string; value: string }[];
|
|
23
|
+
// Account-migration markers: `moved_to` is the AP id this account moved to,
|
|
24
|
+
// `also_known_as` is the set of declared aliases. Migration *authoring* lives
|
|
25
|
+
// in Settings; the profile only surfaces the moved-to banner.
|
|
26
|
+
moved_to?: string | null;
|
|
27
|
+
also_known_as?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Community (AP Group)
|
|
31
|
+
export interface Community {
|
|
32
|
+
ap_id: string;
|
|
33
|
+
preferred_username: string;
|
|
34
|
+
name: string;
|
|
35
|
+
summary: string | null;
|
|
36
|
+
icon_url: string | null;
|
|
37
|
+
visibility?: "public" | "private";
|
|
38
|
+
member_count?: number;
|
|
39
|
+
created_at: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Media attachment
|
|
43
|
+
export interface MediaAttachment {
|
|
44
|
+
url?: string;
|
|
45
|
+
r2_key: string;
|
|
46
|
+
content_type: string;
|
|
47
|
+
// ActivityPub-standard alt text for the attachment (`name` on a Document).
|
|
48
|
+
name?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Post author info
|
|
52
|
+
export interface PostAuthor {
|
|
53
|
+
ap_id: string;
|
|
54
|
+
username: string;
|
|
55
|
+
preferred_username: string;
|
|
56
|
+
name: string | null;
|
|
57
|
+
icon_url: string | null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Post (AP Note)
|
|
61
|
+
export interface Post {
|
|
62
|
+
ap_id: string;
|
|
63
|
+
type: string;
|
|
64
|
+
author: PostAuthor;
|
|
65
|
+
content: string;
|
|
66
|
+
summary: string | null;
|
|
67
|
+
attachments: MediaAttachment[];
|
|
68
|
+
in_reply_to: string | null;
|
|
69
|
+
visibility: "public" | "unlisted" | "followers" | "direct";
|
|
70
|
+
community_ap_id: string | null;
|
|
71
|
+
like_count: number;
|
|
72
|
+
reply_count: number;
|
|
73
|
+
announce_count: number;
|
|
74
|
+
published: string;
|
|
75
|
+
// Set to the post's `updated` timestamp when it has been edited (else null).
|
|
76
|
+
edited_at: string | null;
|
|
77
|
+
liked: boolean;
|
|
78
|
+
bookmarked: boolean;
|
|
79
|
+
reposted: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// DM participant
|
|
83
|
+
export interface DMParticipant {
|
|
84
|
+
ap_id: string;
|
|
85
|
+
username: string;
|
|
86
|
+
preferred_username: string;
|
|
87
|
+
name: string | null;
|
|
88
|
+
icon_url: string | null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// DM message sender
|
|
92
|
+
export interface DMSender {
|
|
93
|
+
ap_id: string;
|
|
94
|
+
username: string;
|
|
95
|
+
preferred_username: string;
|
|
96
|
+
name: string | null;
|
|
97
|
+
icon_url: string | null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// DM message
|
|
101
|
+
export interface DMMessage {
|
|
102
|
+
id: string;
|
|
103
|
+
sender: DMSender;
|
|
104
|
+
content: string;
|
|
105
|
+
created_at: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Notification actor
|
|
109
|
+
export interface NotificationActor {
|
|
110
|
+
ap_id: string;
|
|
111
|
+
username: string;
|
|
112
|
+
preferred_username: string;
|
|
113
|
+
name: string | null;
|
|
114
|
+
icon_url: string | null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Notification
|
|
118
|
+
export interface Notification {
|
|
119
|
+
id: string;
|
|
120
|
+
type: "follow" | "follow_request" | "like" | "announce" | "reply" | "mention";
|
|
121
|
+
actor: NotificationActor;
|
|
122
|
+
object_ap_id: string | null;
|
|
123
|
+
read: boolean;
|
|
124
|
+
created_at: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Story attachment (image or video)
|
|
128
|
+
export interface StoryAttachment {
|
|
129
|
+
type: string; // "Document" or "Video"
|
|
130
|
+
mediaType: string; // "image/jpeg", "video/mp4", etc.
|
|
131
|
+
url: string;
|
|
132
|
+
r2_key: string;
|
|
133
|
+
width?: number;
|
|
134
|
+
height?: number;
|
|
135
|
+
duration?: string; // For video: ISO 8601 duration
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Overlay position (relative coordinates 0.0-1.0)
|
|
139
|
+
export interface OverlayPosition {
|
|
140
|
+
x: number; // Center X (0=left, 1=right)
|
|
141
|
+
y: number; // Center Y (0=top, 1=bottom)
|
|
142
|
+
width: number; // Width relative to canvas
|
|
143
|
+
height: number; // Height relative to canvas
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Story overlay (any AS2 object with position)
|
|
147
|
+
export interface StoryOverlay {
|
|
148
|
+
type: string; // "Question", "Note", "Link", etc.
|
|
149
|
+
position: OverlayPosition;
|
|
150
|
+
// Question-specific
|
|
151
|
+
name?: string; // Question text
|
|
152
|
+
oneOf?: Array<{ type: string; name: string }>; // Options
|
|
153
|
+
closed?: string; // Close time
|
|
154
|
+
// Link-specific
|
|
155
|
+
href?: string;
|
|
156
|
+
// Generic
|
|
157
|
+
[key: string]: unknown; // Allow any AS2 properties
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Story (v2: 1 Story = 1 Media)
|
|
161
|
+
export interface Story {
|
|
162
|
+
ap_id: string;
|
|
163
|
+
author: PostAuthor;
|
|
164
|
+
attachment: StoryAttachment;
|
|
165
|
+
caption?: string; // Optional caption/text shown over the story
|
|
166
|
+
displayDuration: string; // ISO 8601 duration (e.g., "PT5S")
|
|
167
|
+
overlays?: StoryOverlay[]; // Optional interactive overlays
|
|
168
|
+
published: string;
|
|
169
|
+
end_time: string;
|
|
170
|
+
viewed: boolean;
|
|
171
|
+
like_count?: number;
|
|
172
|
+
share_count?: number;
|
|
173
|
+
liked?: boolean;
|
|
174
|
+
// Poll/Question voting results
|
|
175
|
+
votes?: { [key: number]: number }; // Index -> vote count
|
|
176
|
+
votes_total?: number; // Total vote count
|
|
177
|
+
user_vote?: number; // Current user's vote index (if voted)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Actor with stories grouped
|
|
181
|
+
export interface ActorStories {
|
|
182
|
+
actor: PostAuthor;
|
|
183
|
+
stories: Story[];
|
|
184
|
+
has_unviewed: boolean;
|
|
185
|
+
}
|