mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49: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
|
// Post process the data
|
||||||
if (claimData.functions && claimData.functions.postprocess) {
|
const def = claimDefinitions.data[claimData.serviceprovider.name]
|
||||||
|
if (def.functions && def.functions.postprocess) {
|
||||||
try {
|
try {
|
||||||
({ claimData, proofData } = claimData.functions.postprocess(claimData, proofData))
|
({ claimData, proofData } = def.functions.postprocess(claimData, proofData))
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -54,14 +54,15 @@ const processURI = (uri) => {
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['attachment', 'value']
|
path: ['attachment', 'value']
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
functions: {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const functions = {
|
||||||
postprocess: (claimData, proofData) => {
|
postprocess: (claimData, proofData) => {
|
||||||
claimData.profile.display = `${proofData.result.preferredUsername}@${new URL(proofData.result.url).hostname}`
|
claimData.profile.display = `${proofData.result.preferredUsername}@${new URL(proofData.result.url).hostname}`
|
||||||
return { claimData, proofData }
|
return { claimData, proofData }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
|
@ -93,4 +94,5 @@ const tests = [
|
||||||
|
|
||||||
exports.reURI = reURI
|
exports.reURI = reURI
|
||||||
exports.processURI = processURI
|
exports.processURI = processURI
|
||||||
|
exports.functions = functions
|
||||||
exports.tests = tests
|
exports.tests = tests
|
||||||
|
|
Loading…
Reference in a new issue