@oxy.so/federation 2.15.0 → 2.16.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/dist/cjs/apUri.js +16 -0
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/node/actorResolver.js +11 -11
- package/dist/esm/apUri.js +15 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/node/actorResolver.js +12 -12
- package/dist/types/apUri.d.ts +7 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/actorCollectionCounts.test.ts +29 -0
- package/src/apUri.ts +15 -0
- package/src/index.ts +1 -0
- package/src/node/actorResolver.ts +12 -12
package/dist/cjs/apUri.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.canonicalFederationHost = canonicalFederationHost;
|
|
15
15
|
exports.isSameFederationHost = isSameFederationHost;
|
|
16
|
+
exports.apIri = apIri;
|
|
16
17
|
exports.extractActorUriFromActivityId = extractActorUriFromActivityId;
|
|
17
18
|
exports.createDomainPolicy = createDomainPolicy;
|
|
18
19
|
/** Path segments that typically separate an actor path from a post ID in ActivityPub URIs. */
|
|
@@ -75,6 +76,21 @@ function isSameFederationHost(a, b) {
|
|
|
75
76
|
return false;
|
|
76
77
|
return canonicalA === canonicalFederationHost(b);
|
|
77
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* The IRI a JSON-LD node reference names: the string itself, or the `id` of an
|
|
81
|
+
* embedded object. ActivityStreams lets a server embed a referenced node (an
|
|
82
|
+
* actor's `followers` collection with its `totalItems`, an `endpoints` value)
|
|
83
|
+
* instead of linking it, and both mean the same node. Anything else names none.
|
|
84
|
+
*/
|
|
85
|
+
function apIri(value) {
|
|
86
|
+
if (typeof value === 'string')
|
|
87
|
+
return value || undefined;
|
|
88
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
89
|
+
const id = value.id;
|
|
90
|
+
return typeof id === 'string' && id ? id : undefined;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
78
94
|
/**
|
|
79
95
|
* Given an ActivityPub activity/object ID (URL), extract the actor URI by
|
|
80
96
|
* trimming everything from the first recognised post-path segment onward.
|
package/dist/cjs/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* knowledge of any app's post shape.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.groupFollowersCollection = exports.groupOutboxCollection = exports.isGroupActorKind = exports.GROUP_OUTBOX_SIZE = exports.LOCAL_ACTOR_TYPE_BY_ACCOUNT_KIND = exports.AP_ACTOR_TYPES = exports.isApActorType = exports.accountKindForActor = exports.localActorTypeForAccountKind = exports.normalizeAlsoKnownAs = exports.createLocalActorBuilder = exports.createDomainPolicy = exports.extractActorUriFromActivityId = exports.isSameFederationHost = exports.canonicalFederationHost = exports.AP_CONTEXT = exports.readProxyDeclarations = exports.upstreamHandleFromProxyOf = exports.upstreamHandleFromPreferredUsername = exports.upstreamHandleFromAutomatedActor = exports.upstreamHandleFromAlsoKnownAs = exports.upstreamHandleFromProfileField = exports.federatedUsernameFromUpstreamUrl = exports.parseUpstreamProfileUrl = exports.upstreamProfileUrl = exports.stripBridgeBoilerplate = exports.createBridgeRelabeller = exports.atprotoIdentityHandle = exports.isUnresolvedAtprotoHandle = exports.UNRESOLVED_ATPROTO_HANDLE = exports.blueskyHandleFromUsername = exports.blueskyUsernameFromHandle = exports.BSKY_NETWORK_DOMAIN = exports.FEDERATION_NETWORKS = exports.INSTANCE_ACTOR_USERNAME = exports.normalizeActorUsername = exports.createUrlBuilders = exports.DEFAULT_SIGNED_CONTENT_TYPE = exports.HTTP_SIGNATURE_ALGORITHM = exports.verifyHttpSignature = exports.signRequest = void 0;
|
|
25
|
+
exports.groupFollowersCollection = exports.groupOutboxCollection = exports.isGroupActorKind = exports.GROUP_OUTBOX_SIZE = exports.LOCAL_ACTOR_TYPE_BY_ACCOUNT_KIND = exports.AP_ACTOR_TYPES = exports.isApActorType = exports.accountKindForActor = exports.localActorTypeForAccountKind = exports.normalizeAlsoKnownAs = exports.createLocalActorBuilder = exports.createDomainPolicy = exports.apIri = exports.extractActorUriFromActivityId = exports.isSameFederationHost = exports.canonicalFederationHost = exports.AP_CONTEXT = exports.readProxyDeclarations = exports.upstreamHandleFromProxyOf = exports.upstreamHandleFromPreferredUsername = exports.upstreamHandleFromAutomatedActor = exports.upstreamHandleFromAlsoKnownAs = exports.upstreamHandleFromProfileField = exports.federatedUsernameFromUpstreamUrl = exports.parseUpstreamProfileUrl = exports.upstreamProfileUrl = exports.stripBridgeBoilerplate = exports.createBridgeRelabeller = exports.atprotoIdentityHandle = exports.isUnresolvedAtprotoHandle = exports.UNRESOLVED_ATPROTO_HANDLE = exports.blueskyHandleFromUsername = exports.blueskyUsernameFromHandle = exports.BSKY_NETWORK_DOMAIN = exports.FEDERATION_NETWORKS = exports.INSTANCE_ACTOR_USERNAME = exports.normalizeActorUsername = exports.createUrlBuilders = exports.DEFAULT_SIGNED_CONTENT_TYPE = exports.HTTP_SIGNATURE_ALGORITHM = exports.verifyHttpSignature = exports.signRequest = void 0;
|
|
26
26
|
/**
|
|
27
27
|
* HTTP Signatures (draft-cavage) — the pure sign/verify crypto every Oxy app's
|
|
28
28
|
* ActivityPub federation shares. Private-key custody is injected; the key never
|
|
@@ -89,6 +89,7 @@ var apUri_1 = require("./apUri");
|
|
|
89
89
|
Object.defineProperty(exports, "canonicalFederationHost", { enumerable: true, get: function () { return apUri_1.canonicalFederationHost; } });
|
|
90
90
|
Object.defineProperty(exports, "isSameFederationHost", { enumerable: true, get: function () { return apUri_1.isSameFederationHost; } });
|
|
91
91
|
Object.defineProperty(exports, "extractActorUriFromActivityId", { enumerable: true, get: function () { return apUri_1.extractActorUriFromActivityId; } });
|
|
92
|
+
Object.defineProperty(exports, "apIri", { enumerable: true, get: function () { return apUri_1.apIri; } });
|
|
92
93
|
Object.defineProperty(exports, "createDomainPolicy", { enumerable: true, get: function () { return apUri_1.createDomainPolicy; } });
|
|
93
94
|
/**
|
|
94
95
|
* The single builder of a LOCAL user's ActivityPub actor document —
|
|
@@ -265,7 +265,7 @@ class ActorResolver {
|
|
|
265
265
|
}
|
|
266
266
|
const actor = await readBoundedJson(res, ACTOR_BODY_MAX_BYTES);
|
|
267
267
|
const actorId = asString(actor.id);
|
|
268
|
-
const actorInbox =
|
|
268
|
+
const actorInbox = (0, apUri_1.apIri)(actor.inbox);
|
|
269
269
|
if (!actorId || !actorInbox) {
|
|
270
270
|
this.config.logger.info(`[FedSync] fetchRemoteActor missing fields for ${currentUri}: id=${!!actor.id} inbox=${!!actor.inbox} type=${String(actor.type)} keys=${Object.keys(actor).join(',')}`);
|
|
271
271
|
return null;
|
|
@@ -306,9 +306,9 @@ class ActorResolver {
|
|
|
306
306
|
const actorPublicKey = asRecord(actor.publicKey);
|
|
307
307
|
// Fetch collection counts (followers, following, posts) in parallel
|
|
308
308
|
const [followersCount, followingCount, postsCount] = await Promise.all([
|
|
309
|
-
this.fetchCollectionCount(
|
|
310
|
-
this.fetchCollectionCount(
|
|
311
|
-
this.fetchCollectionCount(
|
|
309
|
+
this.fetchCollectionCount((0, apUri_1.apIri)(actor.followers)),
|
|
310
|
+
this.fetchCollectionCount((0, apUri_1.apIri)(actor.following)),
|
|
311
|
+
this.fetchCollectionCount((0, apUri_1.apIri)(actor.outbox)),
|
|
312
312
|
]);
|
|
313
313
|
// Extract profile fields (PropertyValue attachments). Sanitize BEFORE
|
|
314
314
|
// normalizing: the canonical normalizer collapses whitespace, it never
|
|
@@ -345,7 +345,7 @@ class ActorResolver {
|
|
|
345
345
|
? actor.alsoKnownAs.filter((v) => typeof v === 'string')
|
|
346
346
|
: undefined;
|
|
347
347
|
// A move target is an actor URL; anything else is not one.
|
|
348
|
-
const movedToValue =
|
|
348
|
+
const movedToValue = (0, apUri_1.apIri)(actor.movedTo);
|
|
349
349
|
const movedTo = movedToValue && /^https?:\/\//.test(movedToValue) ? movedToValue : undefined;
|
|
350
350
|
// The IDENTITY the actor is stored under in Oxy, which is not necessarily the
|
|
351
351
|
// host it was fetched from — see `DeriveNetworkIdentity`. Everything below
|
|
@@ -385,10 +385,10 @@ class ActorResolver {
|
|
|
385
385
|
avatarUrl,
|
|
386
386
|
headerUrl,
|
|
387
387
|
inboxUrl: actorInbox,
|
|
388
|
-
outboxUrl:
|
|
389
|
-
sharedInboxUrl:
|
|
390
|
-
followersUrl:
|
|
391
|
-
followingUrl:
|
|
388
|
+
outboxUrl: (0, apUri_1.apIri)(actor.outbox),
|
|
389
|
+
sharedInboxUrl: (0, apUri_1.apIri)(actorEndpoints?.sharedInbox),
|
|
390
|
+
followersUrl: (0, apUri_1.apIri)(actor.followers),
|
|
391
|
+
followingUrl: (0, apUri_1.apIri)(actor.following),
|
|
392
392
|
publicKeyPem: asString(actorPublicKey?.publicKeyPem) || undefined,
|
|
393
393
|
publicKeyId: asString(actorPublicKey?.id) || undefined,
|
|
394
394
|
type: asString(actor.type) || 'Person',
|
|
@@ -398,8 +398,8 @@ class ActorResolver {
|
|
|
398
398
|
memorial: actor.memorial === true,
|
|
399
399
|
suspended: actor.suspended === true,
|
|
400
400
|
fields,
|
|
401
|
-
featuredUrl:
|
|
402
|
-
featuredTagsUrl:
|
|
401
|
+
featuredUrl: (0, apUri_1.apIri)(actor.featured),
|
|
402
|
+
featuredTagsUrl: (0, apUri_1.apIri)(actor.featuredTags),
|
|
403
403
|
alsoKnownAs,
|
|
404
404
|
...(movedTo && { movedTo }),
|
|
405
405
|
networkAcct: networkIdentity?.federatedUsername,
|
package/dist/esm/apUri.js
CHANGED
|
@@ -69,6 +69,21 @@ export function isSameFederationHost(a, b) {
|
|
|
69
69
|
return false;
|
|
70
70
|
return canonicalA === canonicalFederationHost(b);
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* The IRI a JSON-LD node reference names: the string itself, or the `id` of an
|
|
74
|
+
* embedded object. ActivityStreams lets a server embed a referenced node (an
|
|
75
|
+
* actor's `followers` collection with its `totalItems`, an `endpoints` value)
|
|
76
|
+
* instead of linking it, and both mean the same node. Anything else names none.
|
|
77
|
+
*/
|
|
78
|
+
export function apIri(value) {
|
|
79
|
+
if (typeof value === 'string')
|
|
80
|
+
return value || undefined;
|
|
81
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
82
|
+
const id = value.id;
|
|
83
|
+
return typeof id === 'string' && id ? id : undefined;
|
|
84
|
+
}
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
72
87
|
/**
|
|
73
88
|
* Given an ActivityPub activity/object ID (URL), extract the actor URI by
|
|
74
89
|
* trimming everything from the first recognised post-path segment onward.
|
package/dist/esm/index.js
CHANGED
|
@@ -56,7 +56,7 @@ export { FEDERATION_NETWORKS, BSKY_NETWORK_DOMAIN, blueskyUsernameFromHandle, bl
|
|
|
56
56
|
* built from — not a parallel implementation that agrees today.
|
|
57
57
|
*/
|
|
58
58
|
export { AP_CONTEXT } from './apContext.js';
|
|
59
|
-
export { canonicalFederationHost, isSameFederationHost, extractActorUriFromActivityId, createDomainPolicy, } from './apUri.js';
|
|
59
|
+
export { canonicalFederationHost, isSameFederationHost, extractActorUriFromActivityId, apIri, createDomainPolicy, } from './apUri.js';
|
|
60
60
|
/**
|
|
61
61
|
* The single builder of a LOCAL user's ActivityPub actor document —
|
|
62
62
|
* byte-identical across apps, with media resolution injected. The actor `type`
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* e.g. Mention's `IFederatedActor`) so callers keep full typing on the returned
|
|
19
19
|
* document.
|
|
20
20
|
*/
|
|
21
|
-
import { isSameFederationHost } from '../apUri.js';
|
|
21
|
+
import { apIri, isSameFederationHost } from '../apUri.js';
|
|
22
22
|
import { readProxyDeclarations, } from '../networkIdentity.js';
|
|
23
23
|
import { readBodyChunks, ResponseBodyTooLargeError } from './boundedBody.js';
|
|
24
24
|
/**
|
|
@@ -261,7 +261,7 @@ export class ActorResolver {
|
|
|
261
261
|
}
|
|
262
262
|
const actor = await readBoundedJson(res, ACTOR_BODY_MAX_BYTES);
|
|
263
263
|
const actorId = asString(actor.id);
|
|
264
|
-
const actorInbox =
|
|
264
|
+
const actorInbox = apIri(actor.inbox);
|
|
265
265
|
if (!actorId || !actorInbox) {
|
|
266
266
|
this.config.logger.info(`[FedSync] fetchRemoteActor missing fields for ${currentUri}: id=${!!actor.id} inbox=${!!actor.inbox} type=${String(actor.type)} keys=${Object.keys(actor).join(',')}`);
|
|
267
267
|
return null;
|
|
@@ -302,9 +302,9 @@ export class ActorResolver {
|
|
|
302
302
|
const actorPublicKey = asRecord(actor.publicKey);
|
|
303
303
|
// Fetch collection counts (followers, following, posts) in parallel
|
|
304
304
|
const [followersCount, followingCount, postsCount] = await Promise.all([
|
|
305
|
-
this.fetchCollectionCount(
|
|
306
|
-
this.fetchCollectionCount(
|
|
307
|
-
this.fetchCollectionCount(
|
|
305
|
+
this.fetchCollectionCount(apIri(actor.followers)),
|
|
306
|
+
this.fetchCollectionCount(apIri(actor.following)),
|
|
307
|
+
this.fetchCollectionCount(apIri(actor.outbox)),
|
|
308
308
|
]);
|
|
309
309
|
// Extract profile fields (PropertyValue attachments). Sanitize BEFORE
|
|
310
310
|
// normalizing: the canonical normalizer collapses whitespace, it never
|
|
@@ -341,7 +341,7 @@ export class ActorResolver {
|
|
|
341
341
|
? actor.alsoKnownAs.filter((v) => typeof v === 'string')
|
|
342
342
|
: undefined;
|
|
343
343
|
// A move target is an actor URL; anything else is not one.
|
|
344
|
-
const movedToValue =
|
|
344
|
+
const movedToValue = apIri(actor.movedTo);
|
|
345
345
|
const movedTo = movedToValue && /^https?:\/\//.test(movedToValue) ? movedToValue : undefined;
|
|
346
346
|
// The IDENTITY the actor is stored under in Oxy, which is not necessarily the
|
|
347
347
|
// host it was fetched from — see `DeriveNetworkIdentity`. Everything below
|
|
@@ -381,10 +381,10 @@ export class ActorResolver {
|
|
|
381
381
|
avatarUrl,
|
|
382
382
|
headerUrl,
|
|
383
383
|
inboxUrl: actorInbox,
|
|
384
|
-
outboxUrl:
|
|
385
|
-
sharedInboxUrl:
|
|
386
|
-
followersUrl:
|
|
387
|
-
followingUrl:
|
|
384
|
+
outboxUrl: apIri(actor.outbox),
|
|
385
|
+
sharedInboxUrl: apIri(actorEndpoints?.sharedInbox),
|
|
386
|
+
followersUrl: apIri(actor.followers),
|
|
387
|
+
followingUrl: apIri(actor.following),
|
|
388
388
|
publicKeyPem: asString(actorPublicKey?.publicKeyPem) || undefined,
|
|
389
389
|
publicKeyId: asString(actorPublicKey?.id) || undefined,
|
|
390
390
|
type: asString(actor.type) || 'Person',
|
|
@@ -394,8 +394,8 @@ export class ActorResolver {
|
|
|
394
394
|
memorial: actor.memorial === true,
|
|
395
395
|
suspended: actor.suspended === true,
|
|
396
396
|
fields,
|
|
397
|
-
featuredUrl:
|
|
398
|
-
featuredTagsUrl:
|
|
397
|
+
featuredUrl: apIri(actor.featured),
|
|
398
|
+
featuredTagsUrl: apIri(actor.featuredTags),
|
|
399
399
|
alsoKnownAs,
|
|
400
400
|
...(movedTo && { movedTo }),
|
|
401
401
|
networkAcct: networkIdentity?.federatedUsername,
|
package/dist/types/apUri.d.ts
CHANGED
|
@@ -59,6 +59,13 @@ export declare function canonicalFederationHost(host: string): string;
|
|
|
59
59
|
* that is not named is not in any set.
|
|
60
60
|
*/
|
|
61
61
|
export declare function isSameFederationHost(a: string, b: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The IRI a JSON-LD node reference names: the string itself, or the `id` of an
|
|
64
|
+
* embedded object. ActivityStreams lets a server embed a referenced node (an
|
|
65
|
+
* actor's `followers` collection with its `totalItems`, an `endpoints` value)
|
|
66
|
+
* instead of linking it, and both mean the same node. Anything else names none.
|
|
67
|
+
*/
|
|
68
|
+
export declare function apIri(value: unknown): string | undefined;
|
|
62
69
|
/**
|
|
63
70
|
* Given an ActivityPub activity/object ID (URL), extract the actor URI by
|
|
64
71
|
* trimming everything from the first recognised post-path segment onward.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export { FEDERATION_NETWORKS, BSKY_NETWORK_DOMAIN, blueskyUsernameFromHandle, bl
|
|
|
56
56
|
* built from — not a parallel implementation that agrees today.
|
|
57
57
|
*/
|
|
58
58
|
export { AP_CONTEXT } from './apContext';
|
|
59
|
-
export { canonicalFederationHost, isSameFederationHost, extractActorUriFromActivityId, createDomainPolicy, type DomainPolicy, type DomainPolicyConfig, } from './apUri';
|
|
59
|
+
export { canonicalFederationHost, isSameFederationHost, extractActorUriFromActivityId, apIri, createDomainPolicy, type DomainPolicy, type DomainPolicyConfig, } from './apUri';
|
|
60
60
|
/**
|
|
61
61
|
* The single builder of a LOCAL user's ActivityPub actor document —
|
|
62
62
|
* byte-identical across apps, with media resolution injected. The actor `type`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/federation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "Oxy Federation — the app-agnostic ActivityPub identity + follow engine substrate: the network-connector contract, normalized cross-network DTOs, HTTP signatures, actor resolution, the outbound delivery transport + follow lifecycle, the inbound dispatcher, and the webfinger/actor/inbox Express routers. Domain-parameterized so every Oxy app backend federates under its own domain.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -118,6 +118,35 @@ describe('fetchRemoteActor — search opt-in and moves', () => {
|
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
+
describe('fetchRemoteActor — embedded node references', () => {
|
|
122
|
+
it('reads an embedded collection or endpoint by its id, as it reads a linked one', async () => {
|
|
123
|
+
const embed = (id: string) => ({ id, type: 'OrderedCollection', totalItems: 9 });
|
|
124
|
+
const { upserts } = await resolveWith({
|
|
125
|
+
actor: actorDocument({
|
|
126
|
+
inbox: { id: 'https://remote.example/users/bob/inbox' },
|
|
127
|
+
followers: embed(FOLLOWERS),
|
|
128
|
+
following: embed(FOLLOWING),
|
|
129
|
+
outbox: embed(OUTBOX),
|
|
130
|
+
featured: embed('https://remote.example/users/bob/featured'),
|
|
131
|
+
featuredTags: embed('https://remote.example/users/bob/tags'),
|
|
132
|
+
endpoints: { sharedInbox: { id: 'https://remote.example/inbox' } },
|
|
133
|
+
}),
|
|
134
|
+
followers: collection(12),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
expect(upserts[0]).toMatchObject({
|
|
138
|
+
inboxUrl: 'https://remote.example/users/bob/inbox',
|
|
139
|
+
followersUrl: FOLLOWERS,
|
|
140
|
+
followingUrl: FOLLOWING,
|
|
141
|
+
outboxUrl: OUTBOX,
|
|
142
|
+
featuredUrl: 'https://remote.example/users/bob/featured',
|
|
143
|
+
featuredTagsUrl: 'https://remote.example/users/bob/tags',
|
|
144
|
+
sharedInboxUrl: 'https://remote.example/inbox',
|
|
145
|
+
followersCount: 12,
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
121
150
|
describe('fetchRemoteActor — remote collection counts', () => {
|
|
122
151
|
it('stores reported totals, and a real 0 stays 0', async () => {
|
|
123
152
|
const { upserts } = await resolveWith({
|
package/src/apUri.ts
CHANGED
|
@@ -72,6 +72,21 @@ export function isSameFederationHost(a: string, b: string): boolean {
|
|
|
72
72
|
return canonicalA === canonicalFederationHost(b);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* The IRI a JSON-LD node reference names: the string itself, or the `id` of an
|
|
77
|
+
* embedded object. ActivityStreams lets a server embed a referenced node (an
|
|
78
|
+
* actor's `followers` collection with its `totalItems`, an `endpoints` value)
|
|
79
|
+
* instead of linking it, and both mean the same node. Anything else names none.
|
|
80
|
+
*/
|
|
81
|
+
export function apIri(value: unknown): string | undefined {
|
|
82
|
+
if (typeof value === 'string') return value || undefined;
|
|
83
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
84
|
+
const id = (value as { id?: unknown }).id;
|
|
85
|
+
return typeof id === 'string' && id ? id : undefined;
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
/**
|
|
76
91
|
* Given an ActivityPub activity/object ID (URL), extract the actor URI by
|
|
77
92
|
* trimming everything from the first recognised post-path segment onward.
|
package/src/index.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* document.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import { canonicalFederationHost, isSameFederationHost } from '../apUri';
|
|
22
|
+
import { apIri, canonicalFederationHost, isSameFederationHost } from '../apUri';
|
|
23
23
|
import {
|
|
24
24
|
readProxyDeclarations,
|
|
25
25
|
type DeriveNetworkIdentity,
|
|
@@ -507,7 +507,7 @@ export class ActorResolver<TActor extends FederatedActorRecordBase> {
|
|
|
507
507
|
|
|
508
508
|
const actor = await readBoundedJson(res, ACTOR_BODY_MAX_BYTES);
|
|
509
509
|
const actorId = asString(actor.id);
|
|
510
|
-
const actorInbox =
|
|
510
|
+
const actorInbox = apIri(actor.inbox);
|
|
511
511
|
if (!actorId || !actorInbox) {
|
|
512
512
|
this.config.logger.info(
|
|
513
513
|
`[FedSync] fetchRemoteActor missing fields for ${currentUri}: id=${!!actor.id} inbox=${!!actor.inbox} type=${String(actor.type)} keys=${Object.keys(actor).join(',')}`,
|
|
@@ -564,9 +564,9 @@ export class ActorResolver<TActor extends FederatedActorRecordBase> {
|
|
|
564
564
|
|
|
565
565
|
// Fetch collection counts (followers, following, posts) in parallel
|
|
566
566
|
const [followersCount, followingCount, postsCount] = await Promise.all([
|
|
567
|
-
this.fetchCollectionCount(
|
|
568
|
-
this.fetchCollectionCount(
|
|
569
|
-
this.fetchCollectionCount(
|
|
567
|
+
this.fetchCollectionCount(apIri(actor.followers)),
|
|
568
|
+
this.fetchCollectionCount(apIri(actor.following)),
|
|
569
|
+
this.fetchCollectionCount(apIri(actor.outbox)),
|
|
570
570
|
]);
|
|
571
571
|
|
|
572
572
|
// Extract profile fields (PropertyValue attachments). Sanitize BEFORE
|
|
@@ -606,7 +606,7 @@ export class ActorResolver<TActor extends FederatedActorRecordBase> {
|
|
|
606
606
|
? actor.alsoKnownAs.filter((v): v is string => typeof v === 'string')
|
|
607
607
|
: undefined;
|
|
608
608
|
// A move target is an actor URL; anything else is not one.
|
|
609
|
-
const movedToValue =
|
|
609
|
+
const movedToValue = apIri(actor.movedTo);
|
|
610
610
|
const movedTo = movedToValue && /^https?:\/\//.test(movedToValue) ? movedToValue : undefined;
|
|
611
611
|
|
|
612
612
|
// The IDENTITY the actor is stored under in Oxy, which is not necessarily the
|
|
@@ -648,10 +648,10 @@ export class ActorResolver<TActor extends FederatedActorRecordBase> {
|
|
|
648
648
|
avatarUrl,
|
|
649
649
|
headerUrl,
|
|
650
650
|
inboxUrl: actorInbox,
|
|
651
|
-
outboxUrl:
|
|
652
|
-
sharedInboxUrl:
|
|
653
|
-
followersUrl:
|
|
654
|
-
followingUrl:
|
|
651
|
+
outboxUrl: apIri(actor.outbox),
|
|
652
|
+
sharedInboxUrl: apIri(actorEndpoints?.sharedInbox),
|
|
653
|
+
followersUrl: apIri(actor.followers),
|
|
654
|
+
followingUrl: apIri(actor.following),
|
|
655
655
|
publicKeyPem: asString(actorPublicKey?.publicKeyPem) || undefined,
|
|
656
656
|
publicKeyId: asString(actorPublicKey?.id) || undefined,
|
|
657
657
|
type: asString(actor.type) || 'Person',
|
|
@@ -661,8 +661,8 @@ export class ActorResolver<TActor extends FederatedActorRecordBase> {
|
|
|
661
661
|
memorial: actor.memorial === true,
|
|
662
662
|
suspended: actor.suspended === true,
|
|
663
663
|
fields,
|
|
664
|
-
featuredUrl:
|
|
665
|
-
featuredTagsUrl:
|
|
664
|
+
featuredUrl: apIri(actor.featured),
|
|
665
|
+
featuredTagsUrl: apIri(actor.featuredTags),
|
|
666
666
|
alsoKnownAs,
|
|
667
667
|
...(movedTo && { movedTo }),
|
|
668
668
|
networkAcct: networkIdentity?.federatedUsername,
|