From 128c9bf682ac9feb020f999b7398baf4dfd3b792 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Mon, 10 Jul 2023 10:40:06 +0200 Subject: [PATCH] fix: fix compliance with spec by including fetcher --- src/claim.js | 2 +- src/proofs.js | 14 +++++++------- src/serviceProvider.js | 4 ++-- src/serviceProviders/activitypub.js | 2 +- src/serviceProviders/discourse.js | 2 +- src/serviceProviders/dns.js | 2 +- src/serviceProviders/forem.js | 2 +- src/serviceProviders/forgejo.js | 2 +- src/serviceProviders/gitea.js | 2 +- src/serviceProviders/github.js | 2 +- src/serviceProviders/gitlab.js | 2 +- src/serviceProviders/hackernews.js | 2 +- src/serviceProviders/irc.js | 2 +- src/serviceProviders/keybase.js | 2 +- src/serviceProviders/liberapay.js | 2 +- src/serviceProviders/lichess.js | 2 +- src/serviceProviders/lobsters.js | 2 +- src/serviceProviders/matrix.js | 2 +- src/serviceProviders/opencollective.js | 2 +- src/serviceProviders/owncast.js | 2 +- src/serviceProviders/reddit.js | 2 +- src/serviceProviders/stackexchange.js | 2 +- src/serviceProviders/telegram.js | 2 +- src/serviceProviders/twitter.js | 2 +- src/serviceProviders/xmpp.js | 2 +- 25 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/claim.js b/src/claim.js index f0e879b..29e3439 100644 --- a/src/claim.js +++ b/src/claim.js @@ -261,7 +261,7 @@ export class Claim { this._fingerprint ) verificationResult.proof = { - protocol: proofData.fetcher, + fetcher: proofData.fetcher, viaProxy: proofData.viaProxy } diff --git a/src/proofs.js b/src/proofs.js index deee758..4cc8c16 100644 --- a/src/proofs.js +++ b/src/proofs.js @@ -112,14 +112,14 @@ const handleNodeRequests = (data, opts) => { */ const createDefaultRequestPromise = (data, opts) => { return new Promise((resolve, reject) => { - if (!(data.proof.request.protocol in fetcher)) { - reject(new Error(`fetcher for ${data.proof.request.protocol} not found`)) + if (!(data.proof.request.fetcher in fetcher)) { + reject(new Error(`fetcher for ${data.proof.request.fetcher} not found`)) } - fetcher[data.proof.request.protocol] + fetcher[data.proof.request.fetcher] .fn(data.proof.request.data, opts) .then((res) => { return resolve({ - protocol: data.proof.request.protocol, + fetcher: data.proof.request.fetcher, data, viaProxy: false, result: res @@ -141,7 +141,7 @@ const createProxyRequestPromise = (data, opts) => { let proxyUrl try { proxyUrl = generateProxyURL( - data.proof.request.protocol, + data.proof.request.fetcher, data.proof.request.data, opts ) @@ -152,13 +152,13 @@ const createProxyRequestPromise = (data, opts) => { const requestData = { url: proxyUrl, format: data.proof.request.format, - fetcherTimeout: fetcher[data.proof.request.protocol].timeout + fetcherTimeout: fetcher[data.proof.request.fetcher].timeout } fetcher.http .fn(requestData, opts) .then((res) => { return resolve({ - protocol: 'http', + fetcher: 'http', data, viaProxy: true, result: res diff --git a/src/serviceProvider.js b/src/serviceProvider.js index 3ef5d99..91e1835 100644 --- a/src/serviceProvider.js +++ b/src/serviceProvider.js @@ -98,10 +98,10 @@ export class ServiceProvider { */ uri: spObj.proof.request.uri, /** - * Protocol to be used to request the proof + * Fetcher to be used to request the proof * @type {string} */ - protocol: spObj.proof.request.protocol, + fetcher: spObj.proof.request.fetcher, /** * Type of access restriction * @type {import('./enums.js').ProofAccessRestriction} diff --git a/src/serviceProviders/activitypub.js b/src/serviceProviders/activitypub.js index ab18166..21394db 100644 --- a/src/serviceProviders/activitypub.js +++ b/src/serviceProviders/activitypub.js @@ -42,7 +42,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.ACTIVITYPUB, + fetcher: E.Fetcher.ACTIVITYPUB, accessRestriction: E.ProofAccessRestriction.NONE, data: { url: uri diff --git a/src/serviceProviders/discourse.js b/src/serviceProviders/discourse.js index ed60b89..3a30f77 100644 --- a/src/serviceProviders/discourse.js +++ b/src/serviceProviders/discourse.js @@ -44,7 +44,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: `https://${match[1]}/u/${match[2]}.json`, diff --git a/src/serviceProviders/dns.js b/src/serviceProviders/dns.js index e5135c5..fb9cde7 100644 --- a/src/serviceProviders/dns.js +++ b/src/serviceProviders/dns.js @@ -42,7 +42,7 @@ export function processURI (uri) { proof: { request: { uri: null, - protocol: E.Fetcher.DNS, + fetcher: E.Fetcher.DNS, accessRestriction: E.ProofAccessRestriction.SERVER, data: { domain: match[1] diff --git a/src/serviceProviders/forem.js b/src/serviceProviders/forem.js index e9fb420..de75630 100644 --- a/src/serviceProviders/forem.js +++ b/src/serviceProviders/forem.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: `https://${match[1]}/api/articles/${match[2]}/${match[3]}`, diff --git a/src/serviceProviders/forgejo.js b/src/serviceProviders/forgejo.js index 7fb7c07..7996462 100644 --- a/src/serviceProviders/forgejo.js +++ b/src/serviceProviders/forgejo.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`, diff --git a/src/serviceProviders/gitea.js b/src/serviceProviders/gitea.js index 10fb641..38841cc 100644 --- a/src/serviceProviders/gitea.js +++ b/src/serviceProviders/gitea.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`, diff --git a/src/serviceProviders/github.js b/src/serviceProviders/github.js index 312b5c5..75953ea 100644 --- a/src/serviceProviders/github.js +++ b/src/serviceProviders/github.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NONE, data: { url: `https://api.github.com/gists/${match[2]}`, diff --git a/src/serviceProviders/gitlab.js b/src/serviceProviders/gitlab.js index a390732..1c568b0 100644 --- a/src/serviceProviders/gitlab.js +++ b/src/serviceProviders/gitlab.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { uri, request: { - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NONE, data: { url: `https://${match[1]}/api/v4/projects/${match[2]}%2Fgitlab_proof`, diff --git a/src/serviceProviders/hackernews.js b/src/serviceProviders/hackernews.js index dcbc030..2f3a6cb 100644 --- a/src/serviceProviders/hackernews.js +++ b/src/serviceProviders/hackernews.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`, diff --git a/src/serviceProviders/irc.js b/src/serviceProviders/irc.js index 7db6c13..64b7411 100644 --- a/src/serviceProviders/irc.js +++ b/src/serviceProviders/irc.js @@ -42,7 +42,7 @@ export function processURI (uri) { proof: { request: { uri: null, - protocol: E.Fetcher.IRC, + fetcher: E.Fetcher.IRC, accessRestriction: E.ProofAccessRestriction.SERVER, data: { domain: match[1], diff --git a/src/serviceProviders/keybase.js b/src/serviceProviders/keybase.js index 8814edf..b90b368 100644 --- a/src/serviceProviders/keybase.js +++ b/src/serviceProviders/keybase.js @@ -42,7 +42,7 @@ export function processURI (uri) { proof: { request: { uri: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`, diff --git a/src/serviceProviders/liberapay.js b/src/serviceProviders/liberapay.js index 222a2ac..c44e223 100644 --- a/src/serviceProviders/liberapay.js +++ b/src/serviceProviders/liberapay.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NONE, data: { url: `https://liberapay.com/${match[1]}/public.json`, diff --git a/src/serviceProviders/lichess.js b/src/serviceProviders/lichess.js index fb665d5..d70b6a3 100644 --- a/src/serviceProviders/lichess.js +++ b/src/serviceProviders/lichess.js @@ -42,7 +42,7 @@ export function processURI (uri) { proof: { request: { uri: `https://lichess.org/api/user/${match[1]}`, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NONE, data: { url: `https://lichess.org/api/user/${match[1]}`, diff --git a/src/serviceProviders/lobsters.js b/src/serviceProviders/lobsters.js index ed730f9..5fa9904 100644 --- a/src/serviceProviders/lobsters.js +++ b/src/serviceProviders/lobsters.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri: `https://lobste.rs/u/${match[1]}.json`, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: `https://lobste.rs/u/${match[1]}.json`, diff --git a/src/serviceProviders/matrix.js b/src/serviceProviders/matrix.js index a57ab38..eeb6153 100644 --- a/src/serviceProviders/matrix.js +++ b/src/serviceProviders/matrix.js @@ -59,7 +59,7 @@ export function processURI (uri) { proof: { request: { uri: eventUrl, - protocol: E.Fetcher.MATRIX, + fetcher: E.Fetcher.MATRIX, accessRestriction: E.ProofAccessRestriction.GRANTED, data: { eventId: paramEventId, diff --git a/src/serviceProviders/opencollective.js b/src/serviceProviders/opencollective.js index 2b64aec..3d14692 100644 --- a/src/serviceProviders/opencollective.js +++ b/src/serviceProviders/opencollective.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.GRAPHQL, + fetcher: E.Fetcher.GRAPHQL, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: 'https://api.opencollective.com/graphql/v2', diff --git a/src/serviceProviders/owncast.js b/src/serviceProviders/owncast.js index 77b1f76..6abf042 100644 --- a/src/serviceProviders/owncast.js +++ b/src/serviceProviders/owncast.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri: `${uri}/api/config`, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NONE, data: { url: `${uri}/api/config`, diff --git a/src/serviceProviders/reddit.js b/src/serviceProviders/reddit.js index 89e9814..15f61cf 100644 --- a/src/serviceProviders/reddit.js +++ b/src/serviceProviders/reddit.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { url: `https://www.reddit.com/user/${match[1]}/comments/${match[2]}.json`, diff --git a/src/serviceProviders/stackexchange.js b/src/serviceProviders/stackexchange.js index ec1ee15..16eec02 100644 --- a/src/serviceProviders/stackexchange.js +++ b/src/serviceProviders/stackexchange.js @@ -45,7 +45,7 @@ export function processURI (uri) { proof: { request: { uri: `https://${domain}.com/users/${id}?tab=profile`, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NONE, data: { url: `https://api.stackexchange.com/2.3/users/${id}?site=${site}&filter=!AH)b5JqVyImf`, diff --git a/src/serviceProviders/telegram.js b/src/serviceProviders/telegram.js index 048b200..8bc0c2f 100644 --- a/src/serviceProviders/telegram.js +++ b/src/serviceProviders/telegram.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri: `https://t.me/${match[2]}`, - protocol: E.Fetcher.TELEGRAM, + fetcher: E.Fetcher.TELEGRAM, accessRestriction: E.ProofAccessRestriction.GRANTED, data: { user: match[1], diff --git a/src/serviceProviders/twitter.js b/src/serviceProviders/twitter.js index fe0de0f..aba21a4 100644 --- a/src/serviceProviders/twitter.js +++ b/src/serviceProviders/twitter.js @@ -47,7 +47,7 @@ export function processURI (uri) { proof: { request: { uri, - protocol: E.Fetcher.HTTP, + fetcher: E.Fetcher.HTTP, accessRestriction: E.ProofAccessRestriction.NOCORS, data: { // Returns an oembed json object with the tweet content in html form diff --git a/src/serviceProviders/xmpp.js b/src/serviceProviders/xmpp.js index 0043495..56d55f8 100644 --- a/src/serviceProviders/xmpp.js +++ b/src/serviceProviders/xmpp.js @@ -43,7 +43,7 @@ export function processURI (uri) { proof: { request: { uri: null, - protocol: E.Fetcher.XMPP, + fetcher: E.Fetcher.XMPP, accessRestriction: E.ProofAccessRestriction.SERVER, data: { id: `${match[1]}@${match[2]}`