From d75df95c6b356286f210c6eddc88f5f9c9e9dd26 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Thu, 17 Nov 2022 21:26:15 +0100 Subject: [PATCH] Cleaning up data no longer necessary --- src/api/v2/keyoxide_profile.js | 49 ++++++++-------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/src/api/v2/keyoxide_profile.js b/src/api/v2/keyoxide_profile.js index 63a2e6a..704e02f 100644 --- a/src/api/v2/keyoxide_profile.js +++ b/src/api/v2/keyoxide_profile.js @@ -116,14 +116,17 @@ const apiProfileSchema = { } }, claim: { - type: 'object', - properties: { - format: { type: 'string' }, - relation: { type: 'string' }, - path: { - type: 'array', - items: { - type: 'string' + type: 'array', + items: { + type: 'object', + properties: { + format: { type: 'string' }, + relation: { type: 'string' }, + path: { + type: 'array', + items: { + type: 'string' + } } } } @@ -222,36 +225,6 @@ const doVerification = async (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) if (!valid) { throw new Error('Profile data sanitization error')