Run prettier

This commit is contained in:
Yarmo Mackenbach 2020-12-20 23:19:07 +01:00
parent de5d358b31
commit 347c48ff4e
4 changed files with 74 additions and 55 deletions

View file

@ -213,39 +213,60 @@ const verify = async (input, fingerprint, opts) => {
case 'adaptive': case 'adaptive':
if (spData.proof.useProxy) { if (spData.proof.useProxy) {
try { try {
proofData = await serviceproviders.proxyRequestHandler(spData, opts) proofData = await serviceproviders.proxyRequestHandler(
} catch(er) {} spData,
opts
)
} catch (er) {}
} else { } else {
try { try {
proofData = await serviceproviders.directRequestHandler(spData, opts) proofData = await serviceproviders.directRequestHandler(
} catch(er) {} spData,
opts
)
} catch (er) {}
if (!proofData) { if (!proofData) {
try { try {
proofData = await serviceproviders.proxyRequestHandler(spData, opts) proofData = await serviceproviders.proxyRequestHandler(
} catch(er) {} spData,
opts
)
} catch (er) {}
} }
} }
break; break
case 'fallback': case 'fallback':
try { try {
proofData = await serviceproviders.directRequestHandler(spData, opts) proofData = await serviceproviders.directRequestHandler(
} catch(er) {} spData,
opts
)
} catch (er) {}
if (!proofData) { if (!proofData) {
try { try {
proofData = await serviceproviders.proxyRequestHandler(spData, opts) proofData = await serviceproviders.proxyRequestHandler(
} catch(er) {} spData,
opts
)
} catch (er) {}
} }
break; break
case 'always': case 'always':
try { try {
proofData = await serviceproviders.proxyRequestHandler(spData, opts) proofData = await serviceproviders.proxyRequestHandler(
} catch(er) {} spData,
break; opts
)
} catch (er) {}
break
case 'never': case 'never':
try { try {
proofData = await serviceproviders.directRequestHandler(spData, opts) proofData = await serviceproviders.directRequestHandler(
} catch(er) {} spData,
break; opts
)
} catch (er) {}
break
default: default:
objResult.errors.push('invalid_proxy_policy') objResult.errors.push('invalid_proxy_policy')
} }

View file

@ -120,7 +120,9 @@ const fetchURI = (uri) => {
switch (match[1]) { switch (match[1]) {
case 'hkp': 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 break
case 'wkd': case 'wkd':
resolve(fetchWKD(match[2])) resolve(fetchWKD(match[2]))

View file

@ -108,11 +108,9 @@ const directRequestHandler = (spData, opts) => {
const proxyRequestHandler = (spData, opts) => { const proxyRequestHandler = (spData, opts) => {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri
req( req(utils.generateProxyURL(spData.proof.format, url, opts), null, {
utils.generateProxyURL(spData.proof.format, url, opts), Accept: 'application/json',
null, })
{ Accept: 'application/json' }
)
.then(async (res) => { .then(async (res) => {
return await res.json() return await res.json()
}) })

View file

@ -26,11 +26,9 @@ const customRequestHandler = async (spData, opts) => {
try { try {
resUser = await req(urlUser, null, { Accept: 'application/json' }) resUser = await req(urlUser, null, { Accept: 'application/json' })
} catch (e) { } catch (e) {
resUser = await req( resUser = await req(utils.generateProxyURL('web', urlUser, opts), null, {
utils.generateProxyURL('web', urlUser, opts), Accept: 'application/json',
null, })
{ Accept: 'application/json' }
)
} }
const jsonUser = await resUser.json() const jsonUser = await resUser.json()