diff --git a/src/claims.js b/src/claims.js index c85b1da..cec7530 100644 --- a/src/claims.js +++ b/src/claims.js @@ -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') } diff --git a/src/keys.js b/src/keys.js index 4d95fb6..84f8dac 100644 --- a/src/keys.js +++ b/src/keys.js @@ -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])) diff --git a/src/serviceproviders.js b/src/serviceproviders.js index e6433a2..ce231d7 100644 --- a/src/serviceproviders.js +++ b/src/serviceproviders.js @@ -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) + }) }) } diff --git a/src/serviceproviders/gitlab.js b/src/serviceproviders/gitlab.js index f64afcb..45c6ce1 100644 --- a/src/serviceproviders/gitlab.js +++ b/src/serviceproviders/gitlab.js @@ -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()