diff --git a/examples/fetch-key-hkp.js b/examples/fetch-key-hkp.js deleted file mode 100644 index 2875b0d..0000000 --- a/examples/fetch-key-hkp.js +++ /dev/null @@ -1,23 +0,0 @@ -import * as doip from '../src/index.js' - -const main = async () => { - // Fetch the key using HKP - const key = await doip.keys.fetchHKP("test@doip.rocks") - - // Process it to extract the UIDs and their claims - const obj = await doip.keys.process(key) - - // Process every claim for every user - obj.users.forEach(async user => { - user.claims.forEach(async claim => { - // Match the claim - await claim.match() - - // Verify the claim - await claim.verify() - console.log(claim) - }) - }) -} - -main() \ No newline at end of file diff --git a/examples/fetch-key-wkd.js b/examples/fetch-key-wkd.js deleted file mode 100644 index 2fdfe1e..0000000 --- a/examples/fetch-key-wkd.js +++ /dev/null @@ -1,14 +0,0 @@ -import * as doip from '../src/index.js' - -const main = async () => { - // Fetch the key using WKD - const key = await doip.keys.fetchWKD("test@doip.rocks") - - // Process it to extract the UIDs and their claims - const obj = await doip.keys.process(key) - - // Log the claims of the first UID - console.log(obj.users[0].claims) -} - -main() \ No newline at end of file diff --git a/examples/fetch-profile-aspe.js b/examples/fetch-profile-aspe.js index a7474f7..8b43765 100644 --- a/examples/fetch-profile-aspe.js +++ b/examples/fetch-profile-aspe.js @@ -3,7 +3,6 @@ import * as doip from '../src/index.js' const main = async () => { // Fetch the profile using ASPE const profile = await doip.asp.fetchASPE("aspe:keyoxide.org:6WJK26YKF6WUVPIZTS2I2BIT64") - console.log(profile); // Process every claim for every persona profile.personas[0].claims.forEach(async claim => { diff --git a/examples/fetch-profile-hkp.js b/examples/fetch-profile-hkp.js new file mode 100644 index 0000000..baf2c86 --- /dev/null +++ b/examples/fetch-profile-hkp.js @@ -0,0 +1,20 @@ +import * as doip from '../src/index.js' + +const main = async () => { + // Fetch the profile using HKP + const profile = await doip.openpgp.fetchHKP("test@doip.rocks") + + // Process every claim for every persona + profile.personas.forEach(async persona => { + persona.claims.forEach(async claim => { + // Match the claim + await claim.match() + + // Verify the claim + await claim.verify() + console.log(claim) + }) + }) +} + +main() \ No newline at end of file diff --git a/examples/fetch-key-plaintext.js b/examples/fetch-profile-plaintext.js similarity index 87% rename from examples/fetch-key-plaintext.js rename to examples/fetch-profile-plaintext.js index 1790179..9993602 100644 --- a/examples/fetch-key-plaintext.js +++ b/examples/fetch-profile-plaintext.js @@ -28,14 +28,11 @@ fCRSXrr7SZxIu7I8jfQrxc0k9XhpPI/gdlgRqoEG2lMyqFaWzyoI9dyoVwji78rg =Csr+ -----END PGP PUBLIC KEY BLOCK-----` - // Fetch the key using WKD - const key = await doip.keys.fetchPlaintext(pubKeyPlaintext) - - // Process it to extract the UIDs and their claims - const obj = await doip.keys.process(key) + // Use the plaintext key to get a profile + const profile = await doip.openpgp.fetchPlaintext(pubKeyPlaintext) // Log the claims of the first UID - console.log(obj.users[0].claims) + console.log(profile.personas[0].claims) } main() \ No newline at end of file diff --git a/examples/fetch-profile-wkd.js b/examples/fetch-profile-wkd.js new file mode 100644 index 0000000..53b94ed --- /dev/null +++ b/examples/fetch-profile-wkd.js @@ -0,0 +1,11 @@ +import * as doip from '../src/index.js' + +const main = async () => { + // Fetch the profile using WKD + const profile = await doip.openpgp.fetchWKD("test@doip.rocks") + + // Log the claims of the first persona + console.log(profile.personas[0].claims) +} + +main() \ No newline at end of file diff --git a/examples/process-signature-profile.js b/examples/process-signature-profile.js index dc6af9c..6a26ea2 100644 --- a/examples/process-signature-profile.js +++ b/examples/process-signature-profile.js @@ -25,10 +25,10 @@ cXbjvHSGniZ7M3S9S8knAfIquPvTp7+L7wWgSSB5VObPp1r+96n87hyFZUp7PCvl const main = async () => { // Process the OpenPGP signature - const sigProfile = await doip.signatures.process(signature) + const profile = await doip.signatures.process(signature) - // Log the processed signature profile - console.log(sigProfile.users[0].claims) + // Log the claims of the first persona + console.log(profile.users[0].claims) } main() \ No newline at end of file diff --git a/examples/test-service-provider.js b/examples/test-service-provider.js new file mode 100644 index 0000000..c8db228 --- /dev/null +++ b/examples/test-service-provider.js @@ -0,0 +1,9 @@ +import * as doip from '../src/index.js' + +const main = async () => { + // const sp = doip.ServiceProviderDefinitions.data['activitypub'].processURI('https://fosstodon.org/@yarmo') + const sp = doip.ServiceProviderDefinitions.data['discourse'].processURI('https://domain.org/u/alice') + console.log(sp); +} + +main() \ No newline at end of file diff --git a/test/asp.test.js b/test/asp.test.js index e78f0ef..7b1a5f7 100644 --- a/test/asp.test.js +++ b/test/asp.test.js @@ -44,7 +44,6 @@ describe('asp.parseProfileJws', () => { }) it('should return a valid Profile object when provided a valid JWS', async () => { let profile = await asp.parseProfileJws(asp25519ProfileJws, asp25519Uri) - console.log(profile); expect(profile).to.be.instanceOf(Profile) expect(profile.personas).to.be.length(1) diff --git a/test/verifications.test.js b/test/verifications.test.js index a34be2d..77cfd48 100644 --- a/test/verifications.test.js +++ b/test/verifications.test.js @@ -17,7 +17,7 @@ import { expect, use } from 'chai' import chaiAsPromised from 'chai-as-promised' use(chaiAsPromised) -import { claimDefinitions, verifications } from '../src/index.js' +import { ServiceProviderDefinitions, verifications } from '../src/index.js' const fingerprint = '3637202523e7c1309ab79e99ef2dc5827b445f4b' const plaintextCorrectProofData = [ @@ -44,7 +44,7 @@ const bcryptIncorrectProofData = [ const bcryptCostlyProofData = [ '$2y$16$4Knuu11ZyPXa1qxEbEsKQemKY6ZHM8Bk7WElYfL8q5kmzNjY1Ty8W' ] -const claimData = claimDefinitions.data.irc.processURI('irc://domain.tld/test') +const claimData = ServiceProviderDefinitions.data.irc.processURI('irc://domain.tld/test') describe('verifications.run', () => { it('should verify a plaintext proof', async () => {