fix: fix compliance with spec by including fetcher

This commit is contained in:
Yarmo Mackenbach 2023-07-10 10:40:06 +02:00
parent decda24d26
commit 128c9bf682
No known key found for this signature in database
GPG key ID: 3C57D093219103A3
25 changed files with 32 additions and 32 deletions

View file

@ -261,7 +261,7 @@ export class Claim {
this._fingerprint
)
verificationResult.proof = {
protocol: proofData.fetcher,
fetcher: proofData.fetcher,
viaProxy: proofData.viaProxy
}

View file

@ -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

View file

@ -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}

View file

@ -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

View file

@ -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`,

View file

@ -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]

View file

@ -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]}`,

View file

@ -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]}`,

View file

@ -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]}`,

View file

@ -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]}`,

View file

@ -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`,

View file

@ -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`,

View file

@ -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],

View file

@ -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]}`,

View file

@ -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`,

View file

@ -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]}`,

View file

@ -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`,

View file

@ -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,

View file

@ -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',

View file

@ -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`,

View file

@ -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`,

View file

@ -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`,

View file

@ -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],

View file

@ -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

View file

@ -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]}`