This PR fixes two issues when verifying ActivityPub profiles: using posts as proofs and nodeinfo support
Posts as proof
It was already possible to use posts as proof for Keyoxide, but the code never fully made a distinction between post data and profile data. The issue is that post data usually doesn't contain (much) profile data, so it's not feasible to obtain important things like preferredUsername from post data.
With this PR, the code checks if the user used a post as proof and if so, makes an additional HTTP request to get the profile data.
NodeInfo support
Quite a while ago, all ActivityPub-compatible projects were unified into a single "service provider" to solve a lot of issues:
- if API is the same, how would doipjs know if a server is Peertube, Mastodon, Friendica...?
- all AP-compatible services use identical configs inside the library
- a new AP service appears? doip-js needs to be updated to support it
With a unified service provider, we diminish the config complexity and automatically support all future AP services.
However, doip-js was still unable to distinguish the different AP software.
With this PR, additional HTTP requests are made to determine whether the instance being queried supports nodeinfo and if it does, get the necessary data to make the distinction.
As demonstrated in the example data below, doip-js now reflects that a Mastodon server is mastodon, a Friendica server is friendica, etc.
Servers without nodeinfo support will still be called activitypub servers.
Example data
Claim {
_uri: 'https://fosstodon.org/@yarmo',
_fingerprint: '9f0048ac0b23301e1f77e994909f6bd6f80f485d',
_status: 200,
_matches: [
ServiceProvider {
about: {
id: 'mastodon',
name: 'mastodon',
homepage: 'https://activitypub.rocks'
},
profile: {
display: '@yarmo@fosstodon.org',
uri: 'https://fosstodon.org/@yarmo',
qr: null
},
claim: {
uriRegularExpression: '/^https:\\/\\/(.*)\\/?/',
uriIsAmbiguous: true
},
proof: {
request: {
uri: 'https://fosstodon.org/@yarmo',
fetcher: 'activitypub',
accessRestriction: 'none',
data: { url: 'https://fosstodon.org/@yarmo' }
},
response: { format: 'json' },
target: [
{
format: 'uri',
encoding: 'plain',
relation: 'contains',
path: [ 'summary', [length]: 1 ]
},
{
format: 'uri',
encoding: 'plain',
relation: 'contains',
path: [ 'attachment', 'value', [length]: 2 ]
},
{
format: 'uri',
encoding: 'plain',
relation: 'contains',
path: [ 'content', [length]: 1 ]
},
[length]: 3
]
}
},
[length]: 1
],
}