mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
fix: fix compliance with spec by including fetcher
This commit is contained in:
parent
decda24d26
commit
128c9bf682
25 changed files with 32 additions and 32 deletions
|
@ -261,7 +261,7 @@ export class Claim {
|
|||
this._fingerprint
|
||||
)
|
||||
verificationResult.proof = {
|
||||
protocol: proofData.fetcher,
|
||||
fetcher: proofData.fetcher,
|
||||
viaProxy: proofData.viaProxy
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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]}`,
|
||||
|
|
|
@ -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]}`,
|
||||
|
|
|
@ -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]}`,
|
||||
|
|
|
@ -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]}`,
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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]}`,
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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]}`,
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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`,
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]}`
|
||||
|
|
Loading…
Reference in a new issue