forked from Mirrors/doipjs
feat: tweaks to examples, use new classes
This commit is contained in:
parent
00d646e2b2
commit
0546cc1e49
10 changed files with 48 additions and 50 deletions
|
@ -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()
|
|
|
@ -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()
|
|
|
@ -3,7 +3,6 @@ import * as doip from '../src/index.js'
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
// Fetch the profile using ASPE
|
// Fetch the profile using ASPE
|
||||||
const profile = await doip.asp.fetchASPE("aspe:keyoxide.org:6WJK26YKF6WUVPIZTS2I2BIT64")
|
const profile = await doip.asp.fetchASPE("aspe:keyoxide.org:6WJK26YKF6WUVPIZTS2I2BIT64")
|
||||||
console.log(profile);
|
|
||||||
|
|
||||||
// Process every claim for every persona
|
// Process every claim for every persona
|
||||||
profile.personas[0].claims.forEach(async claim => {
|
profile.personas[0].claims.forEach(async claim => {
|
||||||
|
|
20
examples/fetch-profile-hkp.js
Normal file
20
examples/fetch-profile-hkp.js
Normal file
|
@ -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()
|
|
@ -28,14 +28,11 @@ fCRSXrr7SZxIu7I8jfQrxc0k9XhpPI/gdlgRqoEG2lMyqFaWzyoI9dyoVwji78rg
|
||||||
=Csr+
|
=Csr+
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`
|
-----END PGP PUBLIC KEY BLOCK-----`
|
||||||
|
|
||||||
// Fetch the key using WKD
|
// Use the plaintext key to get a profile
|
||||||
const key = await doip.keys.fetchPlaintext(pubKeyPlaintext)
|
const profile = await doip.openpgp.fetchPlaintext(pubKeyPlaintext)
|
||||||
|
|
||||||
// Process it to extract the UIDs and their claims
|
|
||||||
const obj = await doip.keys.process(key)
|
|
||||||
|
|
||||||
// Log the claims of the first UID
|
// Log the claims of the first UID
|
||||||
console.log(obj.users[0].claims)
|
console.log(profile.personas[0].claims)
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
11
examples/fetch-profile-wkd.js
Normal file
11
examples/fetch-profile-wkd.js
Normal file
|
@ -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()
|
|
@ -25,10 +25,10 @@ cXbjvHSGniZ7M3S9S8knAfIquPvTp7+L7wWgSSB5VObPp1r+96n87hyFZUp7PCvl
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
// Process the OpenPGP signature
|
// Process the OpenPGP signature
|
||||||
const sigProfile = await doip.signatures.process(signature)
|
const profile = await doip.signatures.process(signature)
|
||||||
|
|
||||||
// Log the processed signature profile
|
// Log the claims of the first persona
|
||||||
console.log(sigProfile.users[0].claims)
|
console.log(profile.users[0].claims)
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
9
examples/test-service-provider.js
Normal file
9
examples/test-service-provider.js
Normal file
|
@ -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()
|
|
@ -44,7 +44,6 @@ describe('asp.parseProfileJws', () => {
|
||||||
})
|
})
|
||||||
it('should return a valid Profile object when provided a valid JWS', async () => {
|
it('should return a valid Profile object when provided a valid JWS', async () => {
|
||||||
let profile = await asp.parseProfileJws(asp25519ProfileJws, asp25519Uri)
|
let profile = await asp.parseProfileJws(asp25519ProfileJws, asp25519Uri)
|
||||||
console.log(profile);
|
|
||||||
|
|
||||||
expect(profile).to.be.instanceOf(Profile)
|
expect(profile).to.be.instanceOf(Profile)
|
||||||
expect(profile.personas).to.be.length(1)
|
expect(profile.personas).to.be.length(1)
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { expect, use } from 'chai'
|
||||||
import chaiAsPromised from 'chai-as-promised'
|
import chaiAsPromised from 'chai-as-promised'
|
||||||
use(chaiAsPromised)
|
use(chaiAsPromised)
|
||||||
|
|
||||||
import { claimDefinitions, verifications } from '../src/index.js'
|
import { ServiceProviderDefinitions, verifications } from '../src/index.js'
|
||||||
|
|
||||||
const fingerprint = '3637202523e7c1309ab79e99ef2dc5827b445f4b'
|
const fingerprint = '3637202523e7c1309ab79e99ef2dc5827b445f4b'
|
||||||
const plaintextCorrectProofData = [
|
const plaintextCorrectProofData = [
|
||||||
|
@ -44,7 +44,7 @@ const bcryptIncorrectProofData = [
|
||||||
const bcryptCostlyProofData = [
|
const bcryptCostlyProofData = [
|
||||||
'$2y$16$4Knuu11ZyPXa1qxEbEsKQemKY6ZHM8Bk7WElYfL8q5kmzNjY1Ty8W'
|
'$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', () => {
|
describe('verifications.run', () => {
|
||||||
it('should verify a plaintext proof', async () => {
|
it('should verify a plaintext proof', async () => {
|
||||||
|
|
Loading…
Reference in a new issue