From 1e37969dc62cc2ec502610c4fe6a27da28e86921 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Wed, 16 Nov 2022 22:25:32 +0100 Subject: [PATCH] Make data structure uniform --- src/claimDefinitions/devto.js | 4 ++-- src/claimDefinitions/discourse.js | 4 ++-- src/claimDefinitions/dns.js | 4 ++-- src/claimDefinitions/gitea.js | 4 ++-- src/claimDefinitions/github.js | 4 ++-- src/claimDefinitions/gitlab.js | 4 ++-- src/claimDefinitions/hackernews.js | 4 ++-- src/claimDefinitions/irc.js | 4 ++-- src/claimDefinitions/liberapay.js | 4 ++-- src/claimDefinitions/lichess.js | 4 ++-- src/claimDefinitions/lobsters.js | 4 ++-- src/claimDefinitions/matrix.js | 4 ++-- src/claimDefinitions/owncast.js | 4 ++-- src/claimDefinitions/reddit.js | 4 ++-- src/claimDefinitions/stackexchange.js | 4 ++-- src/claimDefinitions/telegram.js | 4 ++-- src/claimDefinitions/twitter.js | 4 ++-- src/claimDefinitions/xmpp.js | 4 ++-- src/verifications.js | 12 ++++-------- 19 files changed, 40 insertions(+), 44 deletions(-) diff --git a/src/claimDefinitions/devto.js b/src/claimDefinitions/devto.js index 81f4656..e5faa85 100644 --- a/src/claimDefinitions/devto.js +++ b/src/claimDefinitions/devto.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['body_markdown'] - } + }] } } diff --git a/src/claimDefinitions/discourse.js b/src/claimDefinitions/discourse.js index e2c376b..03910e5 100644 --- a/src/claimDefinitions/discourse.js +++ b/src/claimDefinitions/discourse.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['user', 'bio_raw'] - } + }] } } diff --git a/src/claimDefinitions/dns.js b/src/claimDefinitions/dns.js index 8487335..cde2f61 100644 --- a/src/claimDefinitions/dns.js +++ b/src/claimDefinitions/dns.js @@ -45,11 +45,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['records', 'txt'] - } + }] } } diff --git a/src/claimDefinitions/gitea.js b/src/claimDefinitions/gitea.js index cf2ad16..cc8110e 100644 --- a/src/claimDefinitions/gitea.js +++ b/src/claimDefinitions/gitea.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.EQUALS, path: ['description'] - } + }] } } diff --git a/src/claimDefinitions/github.js b/src/claimDefinitions/github.js index 3849596..2e4bc02 100644 --- a/src/claimDefinitions/github.js +++ b/src/claimDefinitions/github.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['files', 'openpgp.md', 'content'] - } + }] } } diff --git a/src/claimDefinitions/gitlab.js b/src/claimDefinitions/gitlab.js index e4a2923..f4af8e6 100644 --- a/src/claimDefinitions/gitlab.js +++ b/src/claimDefinitions/gitlab.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.EQUALS, path: ['description'] - } + }] } } diff --git a/src/claimDefinitions/hackernews.js b/src/claimDefinitions/hackernews.js index c2f7d0a..4381884 100644 --- a/src/claimDefinitions/hackernews.js +++ b/src/claimDefinitions/hackernews.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['about'] - } + }] } } diff --git a/src/claimDefinitions/irc.js b/src/claimDefinitions/irc.js index 289f074..18338c9 100644 --- a/src/claimDefinitions/irc.js +++ b/src/claimDefinitions/irc.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: [] - } + }] } } diff --git a/src/claimDefinitions/liberapay.js b/src/claimDefinitions/liberapay.js index 2feb1f8..be2907d 100644 --- a/src/claimDefinitions/liberapay.js +++ b/src/claimDefinitions/liberapay.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['statements', 'content'] - } + }] } } diff --git a/src/claimDefinitions/lichess.js b/src/claimDefinitions/lichess.js index 992cfe1..0ba74d6 100644 --- a/src/claimDefinitions/lichess.js +++ b/src/claimDefinitions/lichess.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.FINGERPRINT, relation: E.ClaimRelation.CONTAINS, path: ['profile', 'links'] - } + }] } } diff --git a/src/claimDefinitions/lobsters.js b/src/claimDefinitions/lobsters.js index 020a9de..b3e7eb0 100644 --- a/src/claimDefinitions/lobsters.js +++ b/src/claimDefinitions/lobsters.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['about'] - } + }] } } diff --git a/src/claimDefinitions/matrix.js b/src/claimDefinitions/matrix.js index 62d94aa..a15f1ed 100644 --- a/src/claimDefinitions/matrix.js +++ b/src/claimDefinitions/matrix.js @@ -60,11 +60,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['content', 'body'] - } + }] } } diff --git a/src/claimDefinitions/owncast.js b/src/claimDefinitions/owncast.js index bdedef3..16de454 100644 --- a/src/claimDefinitions/owncast.js +++ b/src/claimDefinitions/owncast.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.FINGERPRINT, relation: E.ClaimRelation.CONTAINS, path: ['socialHandles', 'url'] - } + }] } } diff --git a/src/claimDefinitions/reddit.js b/src/claimDefinitions/reddit.js index 859f970..c54eaf0 100644 --- a/src/claimDefinitions/reddit.js +++ b/src/claimDefinitions/reddit.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['data', 'children', 'data', 'selftext'] - } + }] } } diff --git a/src/claimDefinitions/stackexchange.js b/src/claimDefinitions/stackexchange.js index 478a7f3..1316476 100644 --- a/src/claimDefinitions/stackexchange.js +++ b/src/claimDefinitions/stackexchange.js @@ -48,11 +48,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: ['items', 'about_me'] - } + }] } } diff --git a/src/claimDefinitions/telegram.js b/src/claimDefinitions/telegram.js index f9c0b4c..08d6e66 100644 --- a/src/claimDefinitions/telegram.js +++ b/src/claimDefinitions/telegram.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.EQUALS, path: ['text'] - } + }] } } diff --git a/src/claimDefinitions/twitter.js b/src/claimDefinitions/twitter.js index 7101585..c2753dc 100644 --- a/src/claimDefinitions/twitter.js +++ b/src/claimDefinitions/twitter.js @@ -45,11 +45,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: [] - } + }] } } diff --git a/src/claimDefinitions/xmpp.js b/src/claimDefinitions/xmpp.js index 29c9cb3..a702af6 100644 --- a/src/claimDefinitions/xmpp.js +++ b/src/claimDefinitions/xmpp.js @@ -46,11 +46,11 @@ const processURI = (uri) => { } } }, - claim: { + claim: [{ format: E.ClaimFormat.URI, relation: E.ClaimRelation.CONTAINS, path: [] - } + }] } } diff --git a/src/verifications.js b/src/verifications.js index e24ddd7..5059ab1 100644 --- a/src/verifications.js +++ b/src/verifications.js @@ -200,14 +200,10 @@ const run = async (proofData, claimData, fingerprint) => { errors: [] } - const claimMethods = Array.isArray(claimData.claim) - ? claimData.claim - : [claimData.claim] - switch (claimData.proof.request.format) { case E.ProofFormat.JSON: - for (let index = 0; index < claimMethods.length; index++) { - const claimMethod = claimMethods[index] + for (let index = 0; index < claimData.claim.length; index++) { + const claimMethod = claimData.claim[index] try { res.result = res.result || await runJSON( proofData, @@ -223,8 +219,8 @@ const run = async (proofData, claimData, fingerprint) => { res.completed = true break case E.ProofFormat.TEXT: - for (let index = 0; index < claimMethods.length; index++) { - const claimMethod = claimMethods[index] + for (let index = 0; index < claimData.claim.length; index++) { + const claimMethod = claimData.claim[index] try { res.result = res.result || await containsProof( proofData,