mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2025-01-10 14:39: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) => {
|
const process = async (publicKey) => {
|
||||||
try {
|
try {
|
||||||
const fingerprint = await publicKey.primaryKey.getFingerprint()
|
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 {
|
return {
|
||||||
fingerprint: fingerprint,
|
fingerprint: fingerprint,
|
||||||
user: user,
|
users: usersOutput,
|
||||||
|
primaryUserIndex: primaryUser.index,
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
@ -156,18 +178,11 @@ const process = async (publicKey) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getClaims = async (publicKey) => {
|
const getUserData = async (publicKey) => {
|
||||||
try {
|
try {
|
||||||
const keyData = await process(publicKey)
|
const keyData = await process(publicKey)
|
||||||
let notations = keyData.user.selfCertification.rawNotations
|
|
||||||
|
|
||||||
notations = notations.map(({ name, value, humanReadable }) => {
|
return keyData.users
|
||||||
if (humanReadable && name === 'proof@metacode.biz') {
|
|
||||||
return openpgp.util.decode_utf8(value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return notations
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
return undefined
|
return undefined
|
||||||
|
@ -194,5 +209,5 @@ exports.fetch = {
|
||||||
signature: fetchSignature,
|
signature: fetchSignature,
|
||||||
}
|
}
|
||||||
exports.process = process
|
exports.process = process
|
||||||
exports.getClaims = getClaims
|
exports.getUserData = getUserData
|
||||||
exports.getFingerprint = getFingerprint
|
exports.getFingerprint = getFingerprint
|
||||||
|
|
Loading…
Reference in a new issue