mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
Run prettier
This commit is contained in:
parent
de5d358b31
commit
347c48ff4e
4 changed files with 74 additions and 55 deletions
|
@ -213,39 +213,60 @@ const verify = async (input, fingerprint, opts) => {
|
|||
case 'adaptive':
|
||||
if (spData.proof.useProxy) {
|
||||
try {
|
||||
proofData = await serviceproviders.proxyRequestHandler(spData, opts)
|
||||
} catch(er) {}
|
||||
proofData = await serviceproviders.proxyRequestHandler(
|
||||
spData,
|
||||
opts
|
||||
)
|
||||
} catch (er) {}
|
||||
} else {
|
||||
try {
|
||||
proofData = await serviceproviders.directRequestHandler(spData, opts)
|
||||
} catch(er) {}
|
||||
proofData = await serviceproviders.directRequestHandler(
|
||||
spData,
|
||||
opts
|
||||
)
|
||||
} catch (er) {}
|
||||
if (!proofData) {
|
||||
try {
|
||||
proofData = await serviceproviders.proxyRequestHandler(spData, opts)
|
||||
} catch(er) {}
|
||||
proofData = await serviceproviders.proxyRequestHandler(
|
||||
spData,
|
||||
opts
|
||||
)
|
||||
} catch (er) {}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break
|
||||
case 'fallback':
|
||||
try {
|
||||
proofData = await serviceproviders.directRequestHandler(spData, opts)
|
||||
} catch(er) {}
|
||||
proofData = await serviceproviders.directRequestHandler(
|
||||
spData,
|
||||
opts
|
||||
)
|
||||
} catch (er) {}
|
||||
if (!proofData) {
|
||||
try {
|
||||
proofData = await serviceproviders.proxyRequestHandler(spData, opts)
|
||||
} catch(er) {}
|
||||
proofData = await serviceproviders.proxyRequestHandler(
|
||||
spData,
|
||||
opts
|
||||
)
|
||||
} catch (er) {}
|
||||
}
|
||||
break;
|
||||
break
|
||||
case 'always':
|
||||
try {
|
||||
proofData = await serviceproviders.proxyRequestHandler(spData, opts)
|
||||
} catch(er) {}
|
||||
break;
|
||||
proofData = await serviceproviders.proxyRequestHandler(
|
||||
spData,
|
||||
opts
|
||||
)
|
||||
} catch (er) {}
|
||||
break
|
||||
case 'never':
|
||||
try {
|
||||
proofData = await serviceproviders.directRequestHandler(spData, opts)
|
||||
} catch(er) {}
|
||||
break;
|
||||
proofData = await serviceproviders.directRequestHandler(
|
||||
spData,
|
||||
opts
|
||||
)
|
||||
} catch (er) {}
|
||||
break
|
||||
default:
|
||||
objResult.errors.push('invalid_proxy_policy')
|
||||
}
|
||||
|
|
|
@ -120,7 +120,9 @@ const fetchURI = (uri) => {
|
|||
|
||||
switch (match[1]) {
|
||||
case 'hkp':
|
||||
resolve(fetchHKP(match[3] ? match[3] : match[2], match[3] ? match[2] : null))
|
||||
resolve(
|
||||
fetchHKP(match[3] ? match[3] : match[2], match[3] ? match[2] : null)
|
||||
)
|
||||
break
|
||||
case 'wkd':
|
||||
resolve(fetchWKD(match[2]))
|
||||
|
|
|
@ -76,27 +76,27 @@ const directRequestHandler = (spData, opts) => {
|
|||
Accept: 'application/json',
|
||||
'User-Agent': `doipjs/${require('../package.json').version}`,
|
||||
})
|
||||
.then(async (res) => {
|
||||
return await res.json()
|
||||
})
|
||||
.then((res) => {
|
||||
resolve(res)
|
||||
})
|
||||
.catch((e) => {
|
||||
reject(e)
|
||||
})
|
||||
.then(async (res) => {
|
||||
return await res.json()
|
||||
})
|
||||
.then((res) => {
|
||||
resolve(res)
|
||||
})
|
||||
.catch((e) => {
|
||||
reject(e)
|
||||
})
|
||||
break
|
||||
case 'text':
|
||||
req(url)
|
||||
.then(async (res) => {
|
||||
return await res.text()
|
||||
})
|
||||
.then((res) => {
|
||||
resolve(res)
|
||||
})
|
||||
.catch((e) => {
|
||||
reject(e)
|
||||
})
|
||||
.then(async (res) => {
|
||||
return await res.text()
|
||||
})
|
||||
.then((res) => {
|
||||
resolve(res)
|
||||
})
|
||||
.catch((e) => {
|
||||
reject(e)
|
||||
})
|
||||
break
|
||||
default:
|
||||
reject('No specified proof data format')
|
||||
|
@ -108,20 +108,18 @@ const directRequestHandler = (spData, opts) => {
|
|||
const proxyRequestHandler = (spData, opts) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri
|
||||
req(
|
||||
utils.generateProxyURL(spData.proof.format, url, opts),
|
||||
null,
|
||||
{ Accept: 'application/json' }
|
||||
)
|
||||
.then(async (res) => {
|
||||
return await res.json()
|
||||
})
|
||||
.then((res) => {
|
||||
resolve(res.content)
|
||||
})
|
||||
.catch((e) => {
|
||||
reject(e)
|
||||
req(utils.generateProxyURL(spData.proof.format, url, opts), null, {
|
||||
Accept: 'application/json',
|
||||
})
|
||||
.then(async (res) => {
|
||||
return await res.json()
|
||||
})
|
||||
.then((res) => {
|
||||
resolve(res.content)
|
||||
})
|
||||
.catch((e) => {
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,9 @@ const customRequestHandler = async (spData, opts) => {
|
|||
try {
|
||||
resUser = await req(urlUser, null, { Accept: 'application/json' })
|
||||
} catch (e) {
|
||||
resUser = await req(
|
||||
utils.generateProxyURL('web', urlUser, opts),
|
||||
null,
|
||||
{ Accept: 'application/json' }
|
||||
)
|
||||
resUser = await req(utils.generateProxyURL('web', urlUser, opts), null, {
|
||||
Accept: 'application/json',
|
||||
})
|
||||
}
|
||||
const jsonUser = await resUser.json()
|
||||
|
||||
|
|
Loading…
Reference in a new issue