Use fetch instead

This commit is contained in:
Yarmo Mackenbach 2022-09-10 16:21:14 +02:00
parent b8f5ec7c1e
commit de1ce5c46b
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -13,8 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const axios = require('axios')
const { URL } = require('url')
const utils = require('./utils') const utils = require('./utils')
const E = require('./enums') const E = require('./enums')
@ -51,14 +49,19 @@ const containsProof = async (data, target) => {
continue continue
} }
const response = await axios.head(candidate, { // Using fetch -> axios doesn't find the ariadne-identity-proof header
maxRedirects: 1 const response = await fetch(candidate, { // eslint-disable-line
method: 'HEAD'
})
.catch(e => {
return false
}) })
if (!response) continue
if (response.status !== 200) continue if (response.status !== 200) continue
if (!response.headers['ariadne-identity-proof']) continue if (!response.headers.get('ariadne-identity-proof')) continue
result = response.headers['ariadne-identity-proof'] result = response.headers.get('ariadne-identity-proof')
.toLowerCase() .toLowerCase()
.indexOf(target.toLowerCase()) !== -1 .indexOf(target.toLowerCase()) !== -1
} }