mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
Make keys.process get notations from all users
This commit is contained in:
parent
45cb9918e5
commit
33f4b5c882
1 changed files with 27 additions and 12 deletions
39
src/keys.js
39
src/keys.js
|
@ -144,11 +144,33 @@ const fetchURI = async (uri) => {
|
|||
const process = async (publicKey) => {
|
||||
try {
|
||||
const fingerprint = await publicKey.primaryKey.getFingerprint()
|
||||
const user = await publicKey.getPrimaryUser()
|
||||
const primaryUser = await publicKey.getPrimaryUser()
|
||||
const users = publicKey.users
|
||||
let primaryUserIndex, usersOutput = []
|
||||
|
||||
users.forEach((user, i) => {
|
||||
usersOutput[i] = {
|
||||
userData: {
|
||||
id: user.userId.userid,
|
||||
name: user.userId.name,
|
||||
email: user.userId.email,
|
||||
comment: user.userId.comment,
|
||||
isPrimary: primaryUser.index === i
|
||||
}
|
||||
}
|
||||
|
||||
const notations = user.selfCertifications[0].rawNotations
|
||||
usersOutput[i].notations = notations.map(({ name, value, humanReadable }) => {
|
||||
if (humanReadable && name === 'proof@metacode.biz') {
|
||||
return openpgp.util.decode_utf8(value)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return {
|
||||
fingerprint: fingerprint,
|
||||
user: user,
|
||||
users: usersOutput,
|
||||
primaryUserIndex: primaryUser.index,
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
@ -156,18 +178,11 @@ const process = async (publicKey) => {
|
|||
}
|
||||
}
|
||||
|
||||
const getClaims = async (publicKey) => {
|
||||
const getUserData = async (publicKey) => {
|
||||
try {
|
||||
const keyData = await process(publicKey)
|
||||
let notations = keyData.user.selfCertification.rawNotations
|
||||
|
||||
notations = notations.map(({ name, value, humanReadable }) => {
|
||||
if (humanReadable && name === 'proof@metacode.biz') {
|
||||
return openpgp.util.decode_utf8(value)
|
||||
}
|
||||
})
|
||||
|
||||
return notations
|
||||
return keyData.users
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return undefined
|
||||
|
@ -194,5 +209,5 @@ exports.fetch = {
|
|||
signature: fetchSignature,
|
||||
}
|
||||
exports.process = process
|
||||
exports.getClaims = getClaims
|
||||
exports.getUserData = getUserData
|
||||
exports.getFingerprint = getFingerprint
|
||||
|
|
Loading…
Reference in a new issue