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 this._fingerprint
) )
verificationResult.proof = { verificationResult.proof = {
protocol: proofData.fetcher, fetcher: proofData.fetcher,
viaProxy: proofData.viaProxy viaProxy: proofData.viaProxy
} }

View file

@ -112,14 +112,14 @@ const handleNodeRequests = (data, opts) => {
*/ */
const createDefaultRequestPromise = (data, opts) => { const createDefaultRequestPromise = (data, opts) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!(data.proof.request.protocol in fetcher)) { if (!(data.proof.request.fetcher in fetcher)) {
reject(new Error(`fetcher for ${data.proof.request.protocol} not found`)) 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) .fn(data.proof.request.data, opts)
.then((res) => { .then((res) => {
return resolve({ return resolve({
protocol: data.proof.request.protocol, fetcher: data.proof.request.fetcher,
data, data,
viaProxy: false, viaProxy: false,
result: res result: res
@ -141,7 +141,7 @@ const createProxyRequestPromise = (data, opts) => {
let proxyUrl let proxyUrl
try { try {
proxyUrl = generateProxyURL( proxyUrl = generateProxyURL(
data.proof.request.protocol, data.proof.request.fetcher,
data.proof.request.data, data.proof.request.data,
opts opts
) )
@ -152,13 +152,13 @@ const createProxyRequestPromise = (data, opts) => {
const requestData = { const requestData = {
url: proxyUrl, url: proxyUrl,
format: data.proof.request.format, format: data.proof.request.format,
fetcherTimeout: fetcher[data.proof.request.protocol].timeout fetcherTimeout: fetcher[data.proof.request.fetcher].timeout
} }
fetcher.http fetcher.http
.fn(requestData, opts) .fn(requestData, opts)
.then((res) => { .then((res) => {
return resolve({ return resolve({
protocol: 'http', fetcher: 'http',
data, data,
viaProxy: true, viaProxy: true,
result: res result: res

View file

@ -98,10 +98,10 @@ export class ServiceProvider {
*/ */
uri: spObj.proof.request.uri, uri: spObj.proof.request.uri,
/** /**
* Protocol to be used to request the proof * Fetcher to be used to request the proof
* @type {string} * @type {string}
*/ */
protocol: spObj.proof.request.protocol, fetcher: spObj.proof.request.fetcher,
/** /**
* Type of access restriction * Type of access restriction
* @type {import('./enums.js').ProofAccessRestriction} * @type {import('./enums.js').ProofAccessRestriction}

View file

@ -42,7 +42,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.ACTIVITYPUB, fetcher: E.Fetcher.ACTIVITYPUB,
accessRestriction: E.ProofAccessRestriction.NONE, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: uri url: uri

View file

@ -44,7 +44,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://${match[1]}/u/${match[2]}.json`, url: `https://${match[1]}/u/${match[2]}.json`,

View file

@ -42,7 +42,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: null, uri: null,
protocol: E.Fetcher.DNS, fetcher: E.Fetcher.DNS,
accessRestriction: E.ProofAccessRestriction.SERVER, accessRestriction: E.ProofAccessRestriction.SERVER,
data: { data: {
domain: match[1] domain: match[1]

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://${match[1]}/api/articles/${match[2]}/${match[3]}`, url: `https://${match[1]}/api/articles/${match[2]}/${match[3]}`,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`, url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`, url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NONE, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://api.github.com/gists/${match[2]}`, url: `https://api.github.com/gists/${match[2]}`,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
uri, uri,
request: { request: {
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NONE, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://${match[1]}/api/v4/projects/${match[2]}%2Fgitlab_proof`, url: `https://${match[1]}/api/v4/projects/${match[2]}%2Fgitlab_proof`,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`, uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`, url: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,

View file

@ -42,7 +42,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: null, uri: null,
protocol: E.Fetcher.IRC, fetcher: E.Fetcher.IRC,
accessRestriction: E.ProofAccessRestriction.SERVER, accessRestriction: E.ProofAccessRestriction.SERVER,
data: { data: {
domain: match[1], domain: match[1],

View file

@ -42,7 +42,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`, 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, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`, url: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NONE, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://liberapay.com/${match[1]}/public.json`, url: `https://liberapay.com/${match[1]}/public.json`,

View file

@ -42,7 +42,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: `https://lichess.org/api/user/${match[1]}`, uri: `https://lichess.org/api/user/${match[1]}`,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NONE, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://lichess.org/api/user/${match[1]}`, url: `https://lichess.org/api/user/${match[1]}`,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: `https://lobste.rs/u/${match[1]}.json`, uri: `https://lobste.rs/u/${match[1]}.json`,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://lobste.rs/u/${match[1]}.json`, url: `https://lobste.rs/u/${match[1]}.json`,

View file

@ -59,7 +59,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: eventUrl, uri: eventUrl,
protocol: E.Fetcher.MATRIX, fetcher: E.Fetcher.MATRIX,
accessRestriction: E.ProofAccessRestriction.GRANTED, accessRestriction: E.ProofAccessRestriction.GRANTED,
data: { data: {
eventId: paramEventId, eventId: paramEventId,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.GRAPHQL, fetcher: E.Fetcher.GRAPHQL,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: 'https://api.opencollective.com/graphql/v2', url: 'https://api.opencollective.com/graphql/v2',

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: `${uri}/api/config`, uri: `${uri}/api/config`,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NONE, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `${uri}/api/config`, url: `${uri}/api/config`,

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://www.reddit.com/user/${match[1]}/comments/${match[2]}.json`, url: `https://www.reddit.com/user/${match[1]}/comments/${match[2]}.json`,

View file

@ -45,7 +45,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: `https://${domain}.com/users/${id}?tab=profile`, uri: `https://${domain}.com/users/${id}?tab=profile`,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NONE, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://api.stackexchange.com/2.3/users/${id}?site=${site}&filter=!AH)b5JqVyImf`, 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: { proof: {
request: { request: {
uri: `https://t.me/${match[2]}`, uri: `https://t.me/${match[2]}`,
protocol: E.Fetcher.TELEGRAM, fetcher: E.Fetcher.TELEGRAM,
accessRestriction: E.ProofAccessRestriction.GRANTED, accessRestriction: E.ProofAccessRestriction.GRANTED,
data: { data: {
user: match[1], user: match[1],

View file

@ -47,7 +47,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri, uri,
protocol: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
// Returns an oembed json object with the tweet content in html form // Returns an oembed json object with the tweet content in html form

View file

@ -43,7 +43,7 @@ export function processURI (uri) {
proof: { proof: {
request: { request: {
uri: null, uri: null,
protocol: E.Fetcher.XMPP, fetcher: E.Fetcher.XMPP,
accessRestriction: E.ProofAccessRestriction.SERVER, accessRestriction: E.ProofAccessRestriction.SERVER,
data: { data: {
id: `${match[1]}@${match[2]}` id: `${match[1]}@${match[2]}`