mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 23:09:29 -07:00
Cleaning up data no longer necessary
This commit is contained in:
parent
31ea2c0002
commit
d75df95c6b
1 changed files with 11 additions and 38 deletions
|
@ -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')
|
||||||
|
|
Loading…
Reference in a new issue