Cleaning up data no longer necessary

This commit is contained in:
Yarmo Mackenbach 2022-11-17 21:26:15 +01:00
parent 31ea2c0002
commit d75df95c6b
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -116,6 +116,8 @@ const apiProfileSchema = {
} }
}, },
claim: { claim: {
type: 'array',
items: {
type: 'object', type: 'object',
properties: { properties: {
format: { type: 'string' }, format: { type: 'string' },
@ -130,6 +132,7 @@ const apiProfileSchema = {
} }
} }
} }
}
}, },
verification: { verification: {
type: 'object' type: 'object'
@ -222,36 +225,6 @@ const doVerification = async (data) => {
} }
const sanitize = (data) => { const sanitize = (data) => {
const dataClone = JSON.parse(JSON.stringify(data))
for (let iUser = 0; iUser < dataClone.keyData.users.length; iUser++) {
const user = dataClone.keyData.users[iUser]
for (let iClaim = 0; iClaim < user.claims.length; iClaim++) {
const claim = user.claims[iClaim]
// TODO Fix upstream
for (let iMatch = 0; iMatch < claim.matches.length; iMatch++) {
const match = claim.matches[iMatch]
if (Array.isArray(match.claim)) {
match.claim = match.claim[0]
}
}
// TODO Fix upstream
if (!claim.verification) {
claim.verification = {}
}
// TODO Fix upstream
claim.matches.forEach(match => {
match.proof.request.access = ['generic', 'nocors', 'granted', 'server'][match.proof.request.access]
match.claim.format = ['uri', 'fingerprint', 'message'][match.claim.format]
match.claim.relation = ['contains', 'equals', 'oneof'][match.claim.relation]
})
data.keyData.users[iUser].claims[iClaim] = claim
}
}
const valid = apiProfileValidate(data) const valid = apiProfileValidate(data)
if (!valid) { if (!valid) {
throw new Error('Profile data sanitization error') throw new Error('Profile data sanitization error')