mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
Fix implementation of postprocess function
This commit is contained in:
parent
e6b824bcf8
commit
13e20fe6fb
2 changed files with 12 additions and 9 deletions
|
@ -250,9 +250,10 @@ class Claim {
|
|||
}
|
||||
|
||||
// Post process the data
|
||||
if (claimData.functions && claimData.functions.postprocess) {
|
||||
const def = claimDefinitions.data[claimData.serviceprovider.name]
|
||||
if (def.functions && def.functions.postprocess) {
|
||||
try {
|
||||
({ claimData, proofData } = claimData.functions.postprocess(claimData, proofData))
|
||||
({ claimData, proofData } = def.functions.postprocess(claimData, proofData))
|
||||
} catch (_) {}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -54,13 +54,14 @@ const processURI = (uri) => {
|
|||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['attachment', 'value']
|
||||
}
|
||||
],
|
||||
functions: {
|
||||
postprocess: (claimData, proofData) => {
|
||||
claimData.profile.display = `${proofData.result.preferredUsername}@${new URL(proofData.result.url).hostname}`
|
||||
return { claimData, proofData }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
const functions = {
|
||||
postprocess: (claimData, proofData) => {
|
||||
claimData.profile.display = `${proofData.result.preferredUsername}@${new URL(proofData.result.url).hostname}`
|
||||
return { claimData, proofData }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,4 +94,5 @@ const tests = [
|
|||
|
||||
exports.reURI = reURI
|
||||
exports.processURI = processURI
|
||||
exports.functions = functions
|
||||
exports.tests = tests
|
||||
|
|
Loading…
Reference in a new issue