mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49: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
|
this._fingerprint
|
||||||
)
|
)
|
||||||
verificationResult.proof = {
|
verificationResult.proof = {
|
||||||
protocol: proofData.fetcher,
|
fetcher: proofData.fetcher,
|
||||||
viaProxy: proofData.viaProxy
|
viaProxy: proofData.viaProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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`,
|
||||||
|
|
|
@ -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]
|
||||||
|
|
|
@ -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]}`,
|
||||||
|
|
|
@ -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]}`,
|
||||||
|
|
|
@ -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]}`,
|
||||||
|
|
|
@ -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]}`,
|
||||||
|
|
|
@ -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`,
|
||||||
|
|
|
@ -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`,
|
||||||
|
|
|
@ -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],
|
||||||
|
|
|
@ -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]}`,
|
||||||
|
|
|
@ -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`,
|
||||||
|
|
|
@ -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]}`,
|
||||||
|
|
|
@ -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`,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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',
|
||||||
|
|
|
@ -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`,
|
||||||
|
|
|
@ -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`,
|
||||||
|
|
|
@ -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`,
|
||||||
|
|
|
@ -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],
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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]}`
|
||||||
|
|
Loading…
Reference in a new issue