Add simple WKD validation

This commit is contained in:
Yarmo Mackenbach 2021-05-04 11:51:59 +02:00
parent 0195420448
commit cca12a2237
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -39,7 +39,14 @@ const fetchWKD = (id) => {
fetchURL: null
}
if (!id.includes('@')) {
reject(new Error(`The WKD identifier "${id}" is invalid`));
}
const [, localPart, domain] = /([^\@]*)@(.*)/.exec(id)
if (!localPart || !domain) {
reject(new Error(`The WKD identifier "${id}" is invalid`));
}
const localEncoded = await utils.computeWKDLocalPart(localPart)
const urlAdvanced = `https://openpgpkey.${domain}/.well-known/openpgpkey/${domain}/hu/${localEncoded}`
const urlDirect = `https://${domain}/.well-known/openpgpkey/hu/${localEncoded}`