mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 23:09:29 -07:00
Attempt both WKD and HKP if no protocol specified
This commit is contained in:
parent
b0ca9e7bd0
commit
b2b1a1a8d0
2 changed files with 28 additions and 7 deletions
|
@ -29,7 +29,7 @@ more information on this, and how to apply and follow the GNU AGPL, see <https:/
|
|||
*/
|
||||
import express from 'express'
|
||||
import bodyParserImport from 'body-parser'
|
||||
import { generateSignatureProfile, utils, generateWKDProfile, generateHKPProfile, generateKeybaseProfile } from '../server/index.js'
|
||||
import { generateSignatureProfile, utils, generateWKDProfile, generateHKPProfile, generateAutoProfile, generateKeybaseProfile } from '../server/index.js'
|
||||
|
||||
const router = express.Router()
|
||||
const bodyParser = bodyParserImport.urlencoded({ extended: false })
|
||||
|
@ -74,12 +74,7 @@ router.get('/keybase/:username/:fingerprint', async (req, res) => {
|
|||
})
|
||||
|
||||
router.get('/:id', async (req, res) => {
|
||||
let data
|
||||
if (req.params.id.includes('@')) {
|
||||
data = await generateWKDProfile(req.params.id)
|
||||
} else {
|
||||
data = await generateHKPProfile(req.params.id)
|
||||
}
|
||||
const data = await generateAutoProfile(req.params.id)
|
||||
const title = utils.generatePageTitle('profile', data)
|
||||
res.set('ariadne-identity-proof', data.keyData.openpgp4fpr)
|
||||
res.render('profile', { title: title, data: data })
|
||||
|
|
|
@ -99,6 +99,31 @@ const generateHKPProfile = async (id, keyserverDomain) => {
|
|||
})
|
||||
}
|
||||
|
||||
const generateAutoProfile = async (id) => {
|
||||
let result
|
||||
|
||||
if (id.includes('@')) {
|
||||
result = await generateWKDProfile(id)
|
||||
|
||||
if (result && result.errors.length === 0) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
result = await generateHKPProfile(id)
|
||||
if (result && result.errors.length === 0) {
|
||||
return result
|
||||
}
|
||||
|
||||
return {
|
||||
key: {},
|
||||
keyData: {},
|
||||
keyoxide: {},
|
||||
extra: {},
|
||||
errors: ["No public keys could be found"]
|
||||
}
|
||||
}
|
||||
|
||||
const generateSignatureProfile = async (signature) => {
|
||||
return fetchSignature(signature)
|
||||
.then(async key => {
|
||||
|
@ -203,6 +228,7 @@ const computeExtraData = async (key, keyData) => {
|
|||
|
||||
export { generateWKDProfile }
|
||||
export { generateHKPProfile }
|
||||
export { generateAutoProfile }
|
||||
export { generateKeybaseProfile }
|
||||
export { generateSignatureProfile }
|
||||
|
||||
|
|
Loading…
Reference in a new issue