mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
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 () => {
|
||||
// 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 => {
|
||||
|
|
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+
|
||||
-----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()
|
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 () => {
|
||||
// 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()
|
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 () => {
|
||||
let profile = await asp.parseProfileJws(asp25519ProfileJws, asp25519Uri)
|
||||
console.log(profile);
|
||||
|
||||
expect(profile).to.be.instanceOf(Profile)
|
||||
expect(profile.personas).to.be.length(1)
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
Loading…
Reference in a new issue