@openpeepshq/core 0.2.0 → 0.2.2
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 +674 -0
- package/dist/accounts/mutations.js +9 -0
- package/dist/analytics/cache.js +1 -1
- package/dist/config/index.d.ts +3 -336
- package/dist/db/explorer/index.d.ts +1 -1
- package/dist/db/explorer/index.js +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/pg/map/registry.js +3 -2
- package/dist/federation/actors.d.ts +32 -0
- package/dist/federation/actors.js +136 -0
- package/dist/federation/identity.d.ts +11 -0
- package/dist/federation/identity.js +11 -0
- package/dist/federation/index.d.ts +8 -1
- package/dist/federation/index.js +5 -1
- package/dist/federation/ingest.d.ts +9 -0
- package/dist/federation/ingest.js +60 -0
- package/dist/federation/notes.d.ts +8 -0
- package/dist/federation/notes.js +30 -0
- package/dist/federation/peers.d.ts +3 -0
- package/dist/federation/peers.js +24 -0
- package/dist/jams/export.d.ts +2 -0
- package/dist/jams/export.js +5 -0
- package/dist/jams/finders.d.ts +1 -0
- package/dist/jams/finders.js +1 -0
- package/dist/jams/health.d.ts +23 -0
- package/dist/jams/health.js +79 -7
- package/dist/jams/index.d.ts +1 -1
- package/dist/jams/index.js +10 -3
- package/dist/jams/token.js +6 -2
- package/dist/jams/waitingRoom.js +3 -1
- package/dist/media/garbageCollection.d.ts +109 -0
- package/dist/media/garbageCollection.js +603 -0
- package/dist/media/garbageCollectionJobs.d.ts +14 -0
- package/dist/media/garbageCollectionJobs.js +55 -0
- package/dist/media/index.d.ts +10 -0
- package/dist/media/index.js +39 -15
- package/dist/media/streaming.d.ts +2 -0
- package/dist/media/streaming.js +8 -0
- package/dist/notifications/defaultNotifications/index.js +2 -0
- package/dist/notifications/defaultNotifications/jamStarted/index.d.ts +1 -0
- package/dist/notifications/defaultNotifications/jamStarted/index.js +61 -13
- package/dist/notifications/defaultNotifications/waitlistOffer/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/waitlistOffer/index.js +40 -0
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/plugins/pluginAuth.js +1 -0
- package/dist/posts/conversationQueries.d.ts +31 -0
- package/dist/posts/conversationQueries.js +150 -24
- package/dist/posts/finders.d.ts +9 -0
- package/dist/posts/finders.js +23 -3
- package/dist/posts/helpers/index.d.ts +10 -2
- package/dist/posts/helpers/index.js +6 -0
- package/dist/posts/index.d.ts +3 -1
- package/dist/posts/index.js +3 -1
- package/dist/posts/mapping.d.ts +14 -0
- package/dist/posts/mutations.d.ts +13 -6
- package/dist/posts/mutations.js +271 -72
- package/dist/posts/rsvpExport.d.ts +47 -0
- package/dist/posts/rsvpExport.js +178 -0
- package/dist/posts/unseenCounts.d.ts +6 -0
- package/dist/posts/unseenCounts.js +51 -1
- package/dist/posts/waitlist.d.ts +13 -0
- package/dist/posts/waitlist.js +75 -0
- package/dist/posts/waitlistOfferJobs.d.ts +10 -0
- package/dist/posts/waitlistOfferJobs.js +91 -0
- package/dist/profiles/index.js +6 -1
- package/dist/profiles/mutations.js +6 -3
- package/dist/reports/mapping.d.ts +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/stats/mapping.d.ts +1 -0
- package/dist/stripe/connection.js +1 -1
- package/dist/stripe/helpers.js +7 -3
- package/package.json +11 -10
|
@@ -140,6 +140,15 @@ export const updateAccount = async (accountData) => {
|
|
|
140
140
|
}
|
|
141
141
|
const previousEmail = accountData.account.email;
|
|
142
142
|
const updatedEmail = normalizeEmailAddress(accountData.email);
|
|
143
|
+
if (updatedEmail && updatedEmail !== previousEmail) {
|
|
144
|
+
const existing = await findAccountByEmail(updatedEmail);
|
|
145
|
+
if (existing && existing.id !== accountData.account.id) {
|
|
146
|
+
throw conflict({
|
|
147
|
+
errorKey: 'emailAlreadyTaken',
|
|
148
|
+
parameters: { email: updatedEmail },
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
143
152
|
const account = await accountsMapping.update(db, accountData.account.id, {
|
|
144
153
|
email: updatedEmail,
|
|
145
154
|
passwordHash: accountData.password
|
package/dist/analytics/cache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSharedConnection } from '../redis/index.js';
|
|
2
|
-
const KEY_PREFIX = 'analytics:
|
|
2
|
+
const KEY_PREFIX = 'analytics:v5:';
|
|
3
3
|
const OPEN_DAY_TTL_SEC = 60 * 60;
|
|
4
4
|
const CLOSED_RANGE_TTL_SEC = 60 * 60 * 6;
|
|
5
5
|
export const analyticsCacheKey = (section, from, to) => `${KEY_PREFIX}${section}:${from}:${to}`;
|
package/dist/config/index.d.ts
CHANGED
|
@@ -14,174 +14,7 @@ export declare const refreshConfig: (namespace?: string, name?: string) => void;
|
|
|
14
14
|
* admin UI forms and pin/unpin all send partial trees.
|
|
15
15
|
*/
|
|
16
16
|
export declare const updateConfigValues: (configValues: unknown, namespace?: string, name?: string) => Promise<void>;
|
|
17
|
-
export declare const config: <T =
|
|
18
|
-
version: string;
|
|
19
|
-
environment: string;
|
|
20
|
-
server: {
|
|
21
|
-
host: string;
|
|
22
|
-
signUpsOpen: boolean;
|
|
23
|
-
publicContent: boolean;
|
|
24
|
-
maxProfiles?: number | undefined;
|
|
25
|
-
};
|
|
26
|
-
db: {
|
|
27
|
-
databaseUrl: string;
|
|
28
|
-
url?: string | undefined;
|
|
29
|
-
databaseName?: string | undefined;
|
|
30
|
-
};
|
|
31
|
-
redis: {
|
|
32
|
-
host: string;
|
|
33
|
-
};
|
|
34
|
-
email: {
|
|
35
|
-
service: string;
|
|
36
|
-
defaultTemplatePath: string;
|
|
37
|
-
transportConfig: {
|
|
38
|
-
host: string;
|
|
39
|
-
port: number;
|
|
40
|
-
secure: boolean;
|
|
41
|
-
auth?: {
|
|
42
|
-
user?: string | undefined;
|
|
43
|
-
pass?: string | undefined;
|
|
44
|
-
} | undefined;
|
|
45
|
-
};
|
|
46
|
-
defaultFrom?: string | undefined;
|
|
47
|
-
};
|
|
48
|
-
logs: {
|
|
49
|
-
local: {
|
|
50
|
-
path: string;
|
|
51
|
-
};
|
|
52
|
-
retention: {
|
|
53
|
-
zipAfterDays: number;
|
|
54
|
-
deleteAfterDays: number;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
media: {
|
|
58
|
-
maxUploadMb: number;
|
|
59
|
-
storage: {
|
|
60
|
-
driver: "openpeeps";
|
|
61
|
-
params: {
|
|
62
|
-
path: string;
|
|
63
|
-
prefix: string;
|
|
64
|
-
host?: string | undefined;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
network: {
|
|
69
|
-
port: number;
|
|
70
|
-
};
|
|
71
|
-
plugins: {
|
|
72
|
-
path: string;
|
|
73
|
-
rootPackageJsonPath: string;
|
|
74
|
-
};
|
|
75
|
-
secrets: {
|
|
76
|
-
jwt: string;
|
|
77
|
-
};
|
|
78
|
-
jams: {
|
|
79
|
-
livekit: {
|
|
80
|
-
url: string;
|
|
81
|
-
apiKey?: string | undefined;
|
|
82
|
-
apiSecret?: string | undefined;
|
|
83
|
-
recordingEnabled?: boolean | undefined;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
vapid: {
|
|
87
|
-
privateKey?: string | undefined;
|
|
88
|
-
publicKey?: string | undefined;
|
|
89
|
-
};
|
|
90
|
-
federation: {
|
|
91
|
-
active: boolean;
|
|
92
|
-
allowedHosts: string[];
|
|
93
|
-
};
|
|
94
|
-
activityPub: {
|
|
95
|
-
defaultDomain: string;
|
|
96
|
-
itemsPerPage: number;
|
|
97
|
-
threadDepth: number;
|
|
98
|
-
federation: {
|
|
99
|
-
requestTimeout: number;
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
sso: {
|
|
103
|
-
generic: {
|
|
104
|
-
id: string;
|
|
105
|
-
name: string;
|
|
106
|
-
userProfileRequest: {
|
|
107
|
-
url: string;
|
|
108
|
-
authHeader?: string | undefined;
|
|
109
|
-
};
|
|
110
|
-
userProfilePaths: {
|
|
111
|
-
email: string;
|
|
112
|
-
handle?: string | undefined;
|
|
113
|
-
avatar?: string | undefined;
|
|
114
|
-
displayName?: string | undefined;
|
|
115
|
-
};
|
|
116
|
-
loginLink?: string | undefined;
|
|
117
|
-
createAccounts?: boolean | undefined;
|
|
118
|
-
createProfiles?: boolean | undefined;
|
|
119
|
-
}[];
|
|
120
|
-
oidc: {
|
|
121
|
-
id: string;
|
|
122
|
-
name: string;
|
|
123
|
-
authorizationUrl: string;
|
|
124
|
-
tokenUrl: string;
|
|
125
|
-
userinfoUrl: string;
|
|
126
|
-
clientId: string;
|
|
127
|
-
kind?: "oidc" | "github" | "gitlab" | "gitlab-selfhosted" | "google" | "entra" | "auth0" | "keycloak" | "authentik" | "okta" | "discord" | "pocketid" | undefined;
|
|
128
|
-
instanceUrl?: string | undefined;
|
|
129
|
-
tenant?: string | undefined;
|
|
130
|
-
emailsUrl?: string | undefined;
|
|
131
|
-
jwksUri?: string | undefined;
|
|
132
|
-
clientSecret?: string | undefined;
|
|
133
|
-
scope?: string | undefined;
|
|
134
|
-
claimMapping?: {
|
|
135
|
-
email?: string | undefined;
|
|
136
|
-
handle?: string | undefined;
|
|
137
|
-
displayName?: string | undefined;
|
|
138
|
-
avatar?: string | undefined;
|
|
139
|
-
} | undefined;
|
|
140
|
-
approvalRequired?: boolean | undefined;
|
|
141
|
-
}[];
|
|
142
|
-
onlySSO?: boolean | undefined;
|
|
143
|
-
};
|
|
144
|
-
services: {
|
|
145
|
-
sentry: {
|
|
146
|
-
enabled: boolean;
|
|
147
|
-
dsn?: string | undefined;
|
|
148
|
-
replayEnabled?: boolean | undefined;
|
|
149
|
-
};
|
|
150
|
-
location: {
|
|
151
|
-
type: string;
|
|
152
|
-
url: string;
|
|
153
|
-
apiKey?: string | undefined;
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
apps: {
|
|
157
|
-
ios: {
|
|
158
|
-
url?: string | undefined;
|
|
159
|
-
bundleIdentifier?: string | undefined;
|
|
160
|
-
teamId?: string | undefined;
|
|
161
|
-
appId?: string | undefined;
|
|
162
|
-
apnKeyId?: string | undefined;
|
|
163
|
-
apnSigningKey?: string | undefined;
|
|
164
|
-
};
|
|
165
|
-
android: {
|
|
166
|
-
url?: string | undefined;
|
|
167
|
-
packageName?: string | undefined;
|
|
168
|
-
appId?: string | undefined;
|
|
169
|
-
fcmCredentials?: string | undefined;
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
payments: {
|
|
173
|
-
stripe: {
|
|
174
|
-
paidMembership?: {
|
|
175
|
-
enabled: boolean;
|
|
176
|
-
productId?: string | undefined;
|
|
177
|
-
trialPeriodDays?: number | undefined;
|
|
178
|
-
} | undefined;
|
|
179
|
-
publishableKey?: string | undefined;
|
|
180
|
-
secretKey?: string | undefined;
|
|
181
|
-
webhookSecret?: string | undefined;
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
}>(namespace?: string, name?: string) => Promise<T>;
|
|
17
|
+
export declare const config: <T = CoreConfig>(namespace?: string, name?: string) => Promise<T>;
|
|
185
18
|
export declare const communityConfig: () => Promise<{
|
|
186
19
|
theme: {
|
|
187
20
|
base: string;
|
|
@@ -239,6 +72,7 @@ export declare const communityConfig: () => Promise<{
|
|
|
239
72
|
defaultTimeZone?: string | undefined;
|
|
240
73
|
defaultFeedFormat?: "threaded" | "linear" | undefined;
|
|
241
74
|
indexProfiles?: boolean | undefined;
|
|
75
|
+
additionalForbiddenHandles?: string[] | undefined;
|
|
242
76
|
};
|
|
243
77
|
roles: {
|
|
244
78
|
onRegistration: {
|
|
@@ -260,174 +94,7 @@ export declare const communityConfig: () => Promise<{
|
|
|
260
94
|
} | undefined;
|
|
261
95
|
}>;
|
|
262
96
|
export declare const capabilitiesConfig: () => Promise<CapabilitiesConfig>;
|
|
263
|
-
export declare const sanitizedConfigWithDefaults: <T = {
|
|
264
|
-
version: string;
|
|
265
|
-
environment: string;
|
|
266
|
-
server: {
|
|
267
|
-
host: string;
|
|
268
|
-
signUpsOpen: boolean;
|
|
269
|
-
publicContent: boolean;
|
|
270
|
-
maxProfiles?: number | undefined;
|
|
271
|
-
};
|
|
272
|
-
db: {
|
|
273
|
-
databaseUrl: string;
|
|
274
|
-
url?: string | undefined;
|
|
275
|
-
databaseName?: string | undefined;
|
|
276
|
-
};
|
|
277
|
-
redis: {
|
|
278
|
-
host: string;
|
|
279
|
-
};
|
|
280
|
-
email: {
|
|
281
|
-
service: string;
|
|
282
|
-
defaultTemplatePath: string;
|
|
283
|
-
transportConfig: {
|
|
284
|
-
host: string;
|
|
285
|
-
port: number;
|
|
286
|
-
secure: boolean;
|
|
287
|
-
auth?: {
|
|
288
|
-
user?: string | undefined;
|
|
289
|
-
pass?: string | undefined;
|
|
290
|
-
} | undefined;
|
|
291
|
-
};
|
|
292
|
-
defaultFrom?: string | undefined;
|
|
293
|
-
};
|
|
294
|
-
logs: {
|
|
295
|
-
local: {
|
|
296
|
-
path: string;
|
|
297
|
-
};
|
|
298
|
-
retention: {
|
|
299
|
-
zipAfterDays: number;
|
|
300
|
-
deleteAfterDays: number;
|
|
301
|
-
};
|
|
302
|
-
};
|
|
303
|
-
media: {
|
|
304
|
-
maxUploadMb: number;
|
|
305
|
-
storage: {
|
|
306
|
-
driver: "openpeeps";
|
|
307
|
-
params: {
|
|
308
|
-
path: string;
|
|
309
|
-
prefix: string;
|
|
310
|
-
host?: string | undefined;
|
|
311
|
-
};
|
|
312
|
-
};
|
|
313
|
-
};
|
|
314
|
-
network: {
|
|
315
|
-
port: number;
|
|
316
|
-
};
|
|
317
|
-
plugins: {
|
|
318
|
-
path: string;
|
|
319
|
-
rootPackageJsonPath: string;
|
|
320
|
-
};
|
|
321
|
-
secrets: {
|
|
322
|
-
jwt: string;
|
|
323
|
-
};
|
|
324
|
-
jams: {
|
|
325
|
-
livekit: {
|
|
326
|
-
url: string;
|
|
327
|
-
apiKey?: string | undefined;
|
|
328
|
-
apiSecret?: string | undefined;
|
|
329
|
-
recordingEnabled?: boolean | undefined;
|
|
330
|
-
};
|
|
331
|
-
};
|
|
332
|
-
vapid: {
|
|
333
|
-
privateKey?: string | undefined;
|
|
334
|
-
publicKey?: string | undefined;
|
|
335
|
-
};
|
|
336
|
-
federation: {
|
|
337
|
-
active: boolean;
|
|
338
|
-
allowedHosts: string[];
|
|
339
|
-
};
|
|
340
|
-
activityPub: {
|
|
341
|
-
defaultDomain: string;
|
|
342
|
-
itemsPerPage: number;
|
|
343
|
-
threadDepth: number;
|
|
344
|
-
federation: {
|
|
345
|
-
requestTimeout: number;
|
|
346
|
-
};
|
|
347
|
-
};
|
|
348
|
-
sso: {
|
|
349
|
-
generic: {
|
|
350
|
-
id: string;
|
|
351
|
-
name: string;
|
|
352
|
-
userProfileRequest: {
|
|
353
|
-
url: string;
|
|
354
|
-
authHeader?: string | undefined;
|
|
355
|
-
};
|
|
356
|
-
userProfilePaths: {
|
|
357
|
-
email: string;
|
|
358
|
-
handle?: string | undefined;
|
|
359
|
-
avatar?: string | undefined;
|
|
360
|
-
displayName?: string | undefined;
|
|
361
|
-
};
|
|
362
|
-
loginLink?: string | undefined;
|
|
363
|
-
createAccounts?: boolean | undefined;
|
|
364
|
-
createProfiles?: boolean | undefined;
|
|
365
|
-
}[];
|
|
366
|
-
oidc: {
|
|
367
|
-
id: string;
|
|
368
|
-
name: string;
|
|
369
|
-
authorizationUrl: string;
|
|
370
|
-
tokenUrl: string;
|
|
371
|
-
userinfoUrl: string;
|
|
372
|
-
clientId: string;
|
|
373
|
-
kind?: "oidc" | "github" | "gitlab" | "gitlab-selfhosted" | "google" | "entra" | "auth0" | "keycloak" | "authentik" | "okta" | "discord" | "pocketid" | undefined;
|
|
374
|
-
instanceUrl?: string | undefined;
|
|
375
|
-
tenant?: string | undefined;
|
|
376
|
-
emailsUrl?: string | undefined;
|
|
377
|
-
jwksUri?: string | undefined;
|
|
378
|
-
clientSecret?: string | undefined;
|
|
379
|
-
scope?: string | undefined;
|
|
380
|
-
claimMapping?: {
|
|
381
|
-
email?: string | undefined;
|
|
382
|
-
handle?: string | undefined;
|
|
383
|
-
displayName?: string | undefined;
|
|
384
|
-
avatar?: string | undefined;
|
|
385
|
-
} | undefined;
|
|
386
|
-
approvalRequired?: boolean | undefined;
|
|
387
|
-
}[];
|
|
388
|
-
onlySSO?: boolean | undefined;
|
|
389
|
-
};
|
|
390
|
-
services: {
|
|
391
|
-
sentry: {
|
|
392
|
-
enabled: boolean;
|
|
393
|
-
dsn?: string | undefined;
|
|
394
|
-
replayEnabled?: boolean | undefined;
|
|
395
|
-
};
|
|
396
|
-
location: {
|
|
397
|
-
type: string;
|
|
398
|
-
url: string;
|
|
399
|
-
apiKey?: string | undefined;
|
|
400
|
-
};
|
|
401
|
-
};
|
|
402
|
-
apps: {
|
|
403
|
-
ios: {
|
|
404
|
-
url?: string | undefined;
|
|
405
|
-
bundleIdentifier?: string | undefined;
|
|
406
|
-
teamId?: string | undefined;
|
|
407
|
-
appId?: string | undefined;
|
|
408
|
-
apnKeyId?: string | undefined;
|
|
409
|
-
apnSigningKey?: string | undefined;
|
|
410
|
-
};
|
|
411
|
-
android: {
|
|
412
|
-
url?: string | undefined;
|
|
413
|
-
packageName?: string | undefined;
|
|
414
|
-
appId?: string | undefined;
|
|
415
|
-
fcmCredentials?: string | undefined;
|
|
416
|
-
};
|
|
417
|
-
};
|
|
418
|
-
payments: {
|
|
419
|
-
stripe: {
|
|
420
|
-
paidMembership?: {
|
|
421
|
-
enabled: boolean;
|
|
422
|
-
productId?: string | undefined;
|
|
423
|
-
trialPeriodDays?: number | undefined;
|
|
424
|
-
} | undefined;
|
|
425
|
-
publishableKey?: string | undefined;
|
|
426
|
-
secretKey?: string | undefined;
|
|
427
|
-
webhookSecret?: string | undefined;
|
|
428
|
-
};
|
|
429
|
-
};
|
|
430
|
-
}>(namespace?: string, name?: string) => Promise<{
|
|
97
|
+
export declare const sanitizedConfigWithDefaults: <T = CoreConfig>(namespace?: string, name?: string) => Promise<{
|
|
431
98
|
config: unknown;
|
|
432
99
|
defaults: unknown;
|
|
433
100
|
}>;
|
|
@@ -2,5 +2,5 @@ export { listExplorerTables, getExplorerTable, describeExplorerTable, quoteIdent
|
|
|
2
2
|
export { listExplorerRows, DEFAULT_ROW_LIMIT, MAX_ROW_LIMIT, MAX_EXPORT_LIMIT, clampLimit, buildFilterClause, } from './query';
|
|
3
3
|
export type { ListRowsInput } from './query';
|
|
4
4
|
export { updateExplorerRow } from './mutate';
|
|
5
|
-
export { runExplorerSql, SQL_STATEMENT_TIMEOUT_MS, SQL_MAX_ROWS, SQL_HARD_MAX_ROWS, SQL_DEFAULT_MAX_ROWS } from './sql';
|
|
5
|
+
export { runExplorerSql, SQL_STATEMENT_TIMEOUT_MS, SQL_MAX_ROWS, SQL_HARD_MAX_ROWS, SQL_DEFAULT_MAX_ROWS, } from './sql';
|
|
6
6
|
export { rowsToCsv } from './csv';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { listExplorerTables, getExplorerTable, describeExplorerTable, quoteIdent, assertKnownColumns, primaryKeyColumns, } from './tables.js';
|
|
2
2
|
export { listExplorerRows, DEFAULT_ROW_LIMIT, MAX_ROW_LIMIT, MAX_EXPORT_LIMIT, clampLimit, buildFilterClause, } from './query.js';
|
|
3
3
|
export { updateExplorerRow } from './mutate.js';
|
|
4
|
-
export { runExplorerSql, SQL_STATEMENT_TIMEOUT_MS, SQL_MAX_ROWS, SQL_HARD_MAX_ROWS, SQL_DEFAULT_MAX_ROWS } from './sql.js';
|
|
4
|
+
export { runExplorerSql, SQL_STATEMENT_TIMEOUT_MS, SQL_MAX_ROWS, SQL_HARD_MAX_ROWS, SQL_DEFAULT_MAX_ROWS, } from './sql.js';
|
|
5
5
|
export { rowsToCsv } from './csv.js';
|
package/dist/db/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from './explorer';
|
|
|
5
5
|
export { map } from './pg/map';
|
|
6
6
|
export { collectionInfos } from './pg/collections';
|
|
7
7
|
export type { CollectionInfoKey } from './pg/collections';
|
|
8
|
-
export { closePostgres, type PgDb } from './pg/client';
|
|
8
|
+
export { closePostgres, pgConnectionString, type PgDb } from './pg/client';
|
|
9
9
|
export type { PgFilter, SqlFilter } from './pg/map/queryTypes';
|
|
10
10
|
export { combine, createdAtBetween, documentKeyAfter, documentKeyBefore, edgeFilters, eventTimeFilters, groupFilters, isSqlFilter, notificationFilters, pgSql, postFilters, profileFilters, } from './pg/filters';
|
|
11
11
|
export { computedFields, sorts } from './pg/queries';
|
package/dist/db/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { empty } from './examples.js';
|
|
|
3
3
|
export * from './explorer/index.js';
|
|
4
4
|
export { map } from './pg/map/index.js';
|
|
5
5
|
export { collectionInfos } from './pg/collections.js';
|
|
6
|
-
export { closePostgres } from './pg/client.js';
|
|
6
|
+
export { closePostgres, pgConnectionString } from './pg/client.js';
|
|
7
7
|
export { combine, createdAtBetween, documentKeyAfter, documentKeyBefore, edgeFilters, eventTimeFilters, groupFilters, isSqlFilter, notificationFilters, pgSql, postFilters, profileFilters, } from './pg/filters/index.js';
|
|
8
8
|
export { computedFields, sorts } from './pg/queries/index.js';
|
|
9
9
|
let dbPromise;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withDeletedProfileIdentity } from '@openpeepshq/common/lib';
|
|
1
2
|
import * as documents from '../schema/documents.js';
|
|
2
3
|
import * as edges from '../schema/edges.js';
|
|
3
4
|
import { modelTimestampsFromRow, normalizeIsoDatetime, rowToModel, } from '../mappers.js';
|
|
@@ -402,7 +403,7 @@ export const rowToDocument = (collection, row, keepMetadata = false) => {
|
|
|
402
403
|
guest: row.guest ?? undefined,
|
|
403
404
|
}, timestamps);
|
|
404
405
|
case 'profiles':
|
|
405
|
-
return rowToModel(row.id, {
|
|
406
|
+
return withDeletedProfileIdentity(rowToModel(row.id, {
|
|
406
407
|
handle: row.handle,
|
|
407
408
|
type: row.type,
|
|
408
409
|
...(row.activityPubDomain
|
|
@@ -424,7 +425,7 @@ export const rowToDocument = (collection, row, keepMetadata = false) => {
|
|
|
424
425
|
...(typeof row.fetchedAt === 'string'
|
|
425
426
|
? { fetchedAt: normalizeIsoDatetime(row.fetchedAt) }
|
|
426
427
|
: {}),
|
|
427
|
-
}, timestamps);
|
|
428
|
+
}, timestamps));
|
|
428
429
|
case 'posts': {
|
|
429
430
|
const lastActivityAt = row.lastActivityAt
|
|
430
431
|
? normalizeIsoDatetime(row.lastActivityAt)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ProfileWithMeta } from '@openpeepshq/common/types';
|
|
2
|
+
export type LocalActor = {
|
|
3
|
+
id: string;
|
|
4
|
+
handle: string;
|
|
5
|
+
displayName?: string;
|
|
6
|
+
bio?: string;
|
|
7
|
+
avatar?: string | null;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
deleted: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type LocalActorKeys = {
|
|
12
|
+
id: string;
|
|
13
|
+
publicKeyPem: string;
|
|
14
|
+
privateKeyPem: string;
|
|
15
|
+
keyId: string | null;
|
|
16
|
+
};
|
|
17
|
+
export type RemoteActorInput = {
|
|
18
|
+
uri: string;
|
|
19
|
+
handle: string;
|
|
20
|
+
domain: string;
|
|
21
|
+
inboxUrl?: string | null;
|
|
22
|
+
sharedInboxUrl?: string | null;
|
|
23
|
+
publicKeyPem?: string | null;
|
|
24
|
+
displayName?: string;
|
|
25
|
+
bio?: string;
|
|
26
|
+
avatar?: string | null;
|
|
27
|
+
};
|
|
28
|
+
export declare const federatedHandleFrom: (preferred: string | null | undefined, uri: string) => string;
|
|
29
|
+
export declare const loadLocalActor: (profileId: string) => Promise<LocalActor | null>;
|
|
30
|
+
export declare const findLocalActorIdByHandle: (handle: string) => Promise<string | null>;
|
|
31
|
+
export declare const loadLocalActorKeys: (profileId: string) => Promise<LocalActorKeys | null>;
|
|
32
|
+
export declare const upsertRemoteActor: (input: RemoteActorInput) => Promise<ProfileWithMeta | undefined>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { and, eq, isNull } from 'drizzle-orm';
|
|
2
|
+
import { uuidv7 } from 'uuidv7';
|
|
3
|
+
import { allpeepDb } from '../db/index.js';
|
|
4
|
+
import { pgDb } from '../db/pg/client.js';
|
|
5
|
+
import { nowIso } from '../db/pg/mappers.js';
|
|
6
|
+
import { profiles } from '../db/pg/schema/documents.js';
|
|
7
|
+
import { profilesMapping } from '../profiles/mapping.js';
|
|
8
|
+
import { findProfileByHandleAndDomain, findProfileByUri } from './profiles.js';
|
|
9
|
+
export const federatedHandleFrom = (preferred, uri) => {
|
|
10
|
+
const fromName = (preferred ?? '')
|
|
11
|
+
.replace(/[^a-zA-Z0-9_.-]/g, '')
|
|
12
|
+
.slice(0, 64);
|
|
13
|
+
if (fromName.length >= 1)
|
|
14
|
+
return fromName;
|
|
15
|
+
const fromUri = uri.replace(/[^a-zA-Z0-9]/g, '').slice(-16);
|
|
16
|
+
return `actor-${fromUri || 'remote'}`;
|
|
17
|
+
};
|
|
18
|
+
const clipDisplayName = (name) => name ? name.slice(0, 30) : undefined;
|
|
19
|
+
const bodyOf = (row) => (row.body ?? {});
|
|
20
|
+
export const loadLocalActor = async (profileId) => {
|
|
21
|
+
const db = pgDb();
|
|
22
|
+
// The Fedify actor dispatcher passes the username from the URL path (e.g.
|
|
23
|
+
// "alice" from /ap/users/alice), not a UUID. Resolve it to a profile ID
|
|
24
|
+
// via findLocalActorIdByHandle, falling back to the original value which
|
|
25
|
+
// may already be a UUID from internal callers.
|
|
26
|
+
const resolvedId = (await findLocalActorIdByHandle(profileId)) ?? profileId;
|
|
27
|
+
const [row] = await db
|
|
28
|
+
.select({
|
|
29
|
+
id: profiles.id,
|
|
30
|
+
handle: profiles.handle,
|
|
31
|
+
type: profiles.type,
|
|
32
|
+
body: profiles.body,
|
|
33
|
+
createdAt: profiles.createdAt,
|
|
34
|
+
deletedAt: profiles.deletedAt,
|
|
35
|
+
})
|
|
36
|
+
.from(profiles)
|
|
37
|
+
.where(eq(profiles.id, resolvedId))
|
|
38
|
+
.limit(1);
|
|
39
|
+
if (!row || row.type !== 'local')
|
|
40
|
+
return null;
|
|
41
|
+
const body = bodyOf(row);
|
|
42
|
+
return {
|
|
43
|
+
id: row.id,
|
|
44
|
+
handle: row.handle,
|
|
45
|
+
displayName: body.displayName,
|
|
46
|
+
bio: body.bio,
|
|
47
|
+
avatar: body.avatar,
|
|
48
|
+
createdAt: row.createdAt,
|
|
49
|
+
deleted: row.deletedAt != null,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export const findLocalActorIdByHandle = async (handle) => {
|
|
53
|
+
const db = pgDb();
|
|
54
|
+
const [row] = await db
|
|
55
|
+
.select({ id: profiles.id })
|
|
56
|
+
.from(profiles)
|
|
57
|
+
.where(and(eq(profiles.handle, handle), eq(profiles.type, 'local'), isNull(profiles.deletedAt)))
|
|
58
|
+
.limit(1);
|
|
59
|
+
return row?.id ?? null;
|
|
60
|
+
};
|
|
61
|
+
export const loadLocalActorKeys = async (profileId) => {
|
|
62
|
+
const db = pgDb();
|
|
63
|
+
const resolvedId = (await findLocalActorIdByHandle(profileId)) ?? profileId;
|
|
64
|
+
const [row] = await db
|
|
65
|
+
.select({
|
|
66
|
+
id: profiles.id,
|
|
67
|
+
type: profiles.type,
|
|
68
|
+
publicKeyPem: profiles.publicKeyPem,
|
|
69
|
+
privateKeyPem: profiles.privateKeyPem,
|
|
70
|
+
keyId: profiles.keyId,
|
|
71
|
+
deletedAt: profiles.deletedAt,
|
|
72
|
+
})
|
|
73
|
+
.from(profiles)
|
|
74
|
+
.where(eq(profiles.id, resolvedId))
|
|
75
|
+
.limit(1);
|
|
76
|
+
if (!row ||
|
|
77
|
+
row.type !== 'local' ||
|
|
78
|
+
row.deletedAt != null ||
|
|
79
|
+
!row.publicKeyPem ||
|
|
80
|
+
!row.privateKeyPem) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
id: row.id,
|
|
85
|
+
publicKeyPem: row.publicKeyPem,
|
|
86
|
+
privateKeyPem: row.privateKeyPem,
|
|
87
|
+
keyId: row.keyId,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export const upsertRemoteActor = async (input) => {
|
|
91
|
+
const existing = await findProfileByUri(input.uri);
|
|
92
|
+
const displayName = clipDisplayName(input.displayName);
|
|
93
|
+
const db = pgDb();
|
|
94
|
+
if (existing) {
|
|
95
|
+
await db
|
|
96
|
+
.update(profiles)
|
|
97
|
+
.set({
|
|
98
|
+
inboxUrl: input.inboxUrl ?? existing.inboxUrl,
|
|
99
|
+
sharedInboxUrl: input.sharedInboxUrl ?? existing.sharedInboxUrl,
|
|
100
|
+
publicKeyPem: input.publicKeyPem ?? existing.publicKeyPem,
|
|
101
|
+
fetchedAt: nowIso(),
|
|
102
|
+
})
|
|
103
|
+
.where(eq(profiles.id, existing.id));
|
|
104
|
+
if (displayName || input.bio || input.avatar) {
|
|
105
|
+
await profilesMapping.update(await allpeepDb().then((d) => d.db), existing.id, {
|
|
106
|
+
...(displayName ? { displayName } : {}),
|
|
107
|
+
...(input.bio ? { bio: input.bio } : {}),
|
|
108
|
+
...(input.avatar ? { avatar: input.avatar } : {}),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return findProfileByUri(input.uri);
|
|
112
|
+
}
|
|
113
|
+
const handleTaken = await findProfileByHandleAndDomain(input.handle, input.domain);
|
|
114
|
+
const handle = handleTaken
|
|
115
|
+
? federatedHandleFrom(null, input.uri)
|
|
116
|
+
: input.handle;
|
|
117
|
+
const id = uuidv7();
|
|
118
|
+
const actorFields = {
|
|
119
|
+
uri: input.uri,
|
|
120
|
+
inboxUrl: input.inboxUrl,
|
|
121
|
+
sharedInboxUrl: input.sharedInboxUrl,
|
|
122
|
+
publicKeyPem: input.publicKeyPem,
|
|
123
|
+
fetchedAt: nowIso(),
|
|
124
|
+
};
|
|
125
|
+
await profilesMapping.create(await allpeepDb().then((d) => d.db), {
|
|
126
|
+
id,
|
|
127
|
+
handle,
|
|
128
|
+
type: 'federated',
|
|
129
|
+
activityPub: { domain: input.domain },
|
|
130
|
+
displayName,
|
|
131
|
+
bio: input.bio,
|
|
132
|
+
avatar: input.avatar ?? undefined,
|
|
133
|
+
...actorFields,
|
|
134
|
+
});
|
|
135
|
+
return findProfileByUri(input.uri);
|
|
136
|
+
};
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
/** Fedify URI templates; must stay aligned with `actorUri` / `objectUri`. */
|
|
2
|
+
export declare const ACTOR_PATH: "/ap/users/{identifier}";
|
|
3
|
+
export declare const ACTOR_INBOX_PATH: "/ap/users/{identifier}/inbox";
|
|
4
|
+
export declare const SHARED_INBOX_PATH: "/ap/inbox";
|
|
5
|
+
export declare const FOLLOWERS_PATH: "/ap/users/{identifier}/followers";
|
|
6
|
+
export declare const NOTE_PATH: "/ap/objects/{id}";
|
|
7
|
+
export declare const CREATE_PATH: "/ap/create/{id}";
|
|
8
|
+
export declare const ACCEPT_PATH: "/ap/accept/{id}";
|
|
9
|
+
export declare const federationOrigin: (domain: string) => string;
|
|
1
10
|
export declare const actorUri: (domain: string, profileId: string) => string;
|
|
2
11
|
export declare const objectUri: (domain: string, postId: string) => string;
|
|
12
|
+
export declare const createActivityUri: (domain: string, activityId: string) => string;
|
|
13
|
+
export declare const acceptActivityUri: (domain: string, activityId: string) => string;
|
|
3
14
|
export declare const generateActorKeyPair: () => import("crypto").KeyPairSyncResult<string, string>;
|
|
4
15
|
export declare const localActorScalars: (profileId: string, domain: string) => {
|
|
5
16
|
uri: string;
|
|
@@ -2,8 +2,19 @@ import { generateKeyPairSync } from 'node:crypto';
|
|
|
2
2
|
import { and, eq, isNull, sql } from 'drizzle-orm';
|
|
3
3
|
import { pgDb } from '../db/pg/client.js';
|
|
4
4
|
import { profiles } from '../db/pg/schema/documents.js';
|
|
5
|
+
/** Fedify URI templates; must stay aligned with `actorUri` / `objectUri`. */
|
|
6
|
+
export const ACTOR_PATH = '/ap/users/{identifier}';
|
|
7
|
+
export const ACTOR_INBOX_PATH = '/ap/users/{identifier}/inbox';
|
|
8
|
+
export const SHARED_INBOX_PATH = '/ap/inbox';
|
|
9
|
+
export const FOLLOWERS_PATH = '/ap/users/{identifier}/followers';
|
|
10
|
+
export const NOTE_PATH = '/ap/objects/{id}';
|
|
11
|
+
export const CREATE_PATH = '/ap/create/{id}';
|
|
12
|
+
export const ACCEPT_PATH = '/ap/accept/{id}';
|
|
13
|
+
export const federationOrigin = (domain) => `https://${domain}`;
|
|
5
14
|
export const actorUri = (domain, profileId) => `https://${domain}/ap/users/${profileId}`;
|
|
6
15
|
export const objectUri = (domain, postId) => `https://${domain}/ap/objects/${postId}`;
|
|
16
|
+
export const createActivityUri = (domain, activityId) => `https://${domain}/ap/create/${activityId}`;
|
|
17
|
+
export const acceptActivityUri = (domain, activityId) => `https://${domain}/ap/accept/${activityId}`;
|
|
7
18
|
export const generateActorKeyPair = () => generateKeyPairSync('rsa', {
|
|
8
19
|
modulusLength: 2048,
|
|
9
20
|
publicKeyEncoding: { type: 'spki', format: 'pem' },
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export { findApActivityByUri, recordApActivity } from './activities';
|
|
2
2
|
export type { ApActivity, ApActivityDirection } from './activities';
|
|
3
|
-
export {
|
|
3
|
+
export { federatedHandleFrom, findLocalActorIdByHandle, loadLocalActor, loadLocalActorKeys, upsertRemoteActor, } from './actors';
|
|
4
|
+
export type { LocalActor, LocalActorKeys, RemoteActorInput } from './actors';
|
|
5
|
+
export { ACCEPT_PATH, ACTOR_INBOX_PATH, ACTOR_PATH, CREATE_PATH, FOLLOWERS_PATH, NOTE_PATH, SHARED_INBOX_PATH, acceptActivityUri, actorUri, backfillLocalFederationIdentities, createActivityUri, federationOrigin, generateActorKeyPair, localActorScalars, localObjectScalars, objectUri, } from './identity';
|
|
6
|
+
export { ingestIncomingFollow, ingestIncomingUnfollow, listFederatedFollowerRecipients, } from './ingest';
|
|
7
|
+
export type { FollowerRecipient } from './ingest';
|
|
8
|
+
export { loadPublicNote } from './notes';
|
|
9
|
+
export type { PublicNote } from './notes';
|
|
10
|
+
export { federationIsActive, hostnameOf, peerHostAllowed } from './peers';
|
|
4
11
|
export { findProfileByHandleAndDomain, findProfileByUri } from './profiles';
|
package/dist/federation/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { findApActivityByUri, recordApActivity } from './activities.js';
|
|
2
|
-
export {
|
|
2
|
+
export { federatedHandleFrom, findLocalActorIdByHandle, loadLocalActor, loadLocalActorKeys, upsertRemoteActor, } from './actors.js';
|
|
3
|
+
export { ACCEPT_PATH, ACTOR_INBOX_PATH, ACTOR_PATH, CREATE_PATH, FOLLOWERS_PATH, NOTE_PATH, SHARED_INBOX_PATH, acceptActivityUri, actorUri, backfillLocalFederationIdentities, createActivityUri, federationOrigin, generateActorKeyPair, localActorScalars, localObjectScalars, objectUri, } from './identity.js';
|
|
4
|
+
export { ingestIncomingFollow, ingestIncomingUnfollow, listFederatedFollowerRecipients, } from './ingest.js';
|
|
5
|
+
export { loadPublicNote } from './notes.js';
|
|
6
|
+
export { federationIsActive, hostnameOf, peerHostAllowed } from './peers.js';
|
|
3
7
|
export { findProfileByHandleAndDomain, findProfileByUri } from './profiles.js';
|