mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
Update the data structure used by service providers
This commit is contained in:
parent
03fa420298
commit
81edf64046
5 changed files with 52 additions and 17 deletions
|
@ -20,14 +20,24 @@ const processURI = (uri, opts) => {
|
|||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
type: "domain",
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'domain'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri: `https://${match[1]}`
|
||||
},
|
||||
proof: {
|
||||
uri: `https://dns.shivering-isles.com/dns-query?name=${match[1]}&type=TXT`,
|
||||
fetch: null
|
||||
fetch: null,
|
||||
useProxy: false
|
||||
},
|
||||
claim: {
|
||||
fingerprint: null,
|
||||
format: 'uri',
|
||||
path: 'Answer',
|
||||
relation: 'equals'
|
||||
},
|
||||
qr: null
|
||||
}
|
||||
|
|
|
@ -20,14 +20,24 @@ const processURI = (uri, opts) => {
|
|||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
type: "hackernews",
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'hackernews'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri: uri
|
||||
},
|
||||
proof: {
|
||||
uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
|
||||
fetch: null
|
||||
fetch: null,
|
||||
useProxy: true
|
||||
},
|
||||
claim: {
|
||||
fingerprint: null,
|
||||
format: 'uri',
|
||||
path: 'about',
|
||||
relation: 'contains'
|
||||
},
|
||||
qr: null
|
||||
}
|
||||
|
|
|
@ -20,19 +20,24 @@ const processURI = (uri, opts) => {
|
|||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
type: "twitter",
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'twitter'
|
||||
},
|
||||
profile: {
|
||||
display: `@${match[1]}`,
|
||||
uri: `https://twitter.com/${match[1]}`
|
||||
},
|
||||
proof: {
|
||||
uri: uri,
|
||||
fetch: 'DOIP_PROXY_SERVER_DOMAIN' in opts
|
||||
? `${opts.DOIP_PROXY_SERVER_DOMAIN}/server/verify/twitter
|
||||
?tweetId=${encodeURIComponent(match[2])}
|
||||
&account=${encodeURIComponent(match[1])}
|
||||
&fingerprint=${fingerprint}`
|
||||
: null
|
||||
fetch: `https://mobile.twitter.com/${match[1]}/status/${match[2]}`,
|
||||
useProxy: false
|
||||
},
|
||||
claim: {
|
||||
fingerprint: null,
|
||||
format: 'message',
|
||||
path: null,
|
||||
relation: 'contains'
|
||||
},
|
||||
qr: null
|
||||
}
|
||||
|
|
|
@ -20,7 +20,10 @@ const processURI = (uri, opts) => {
|
|||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
type: "xmpp",
|
||||
serviceprovider: {
|
||||
type: 'communication',
|
||||
name: 'xmpp'
|
||||
},
|
||||
profile: {
|
||||
display: `${match[1]}@${match[2]}`,
|
||||
uri: uri
|
||||
|
@ -29,7 +32,14 @@ const processURI = (uri, opts) => {
|
|||
uri: 'XMPP_VCARD_SERVER_DOMAIN' in opts
|
||||
? `https://${opts.XMPP_VCARD_SERVER_DOMAIN}/api/vcard/${output.display}/DESC`
|
||||
: null,
|
||||
fetch: null
|
||||
fetch: null,
|
||||
useProxy: false
|
||||
},
|
||||
claim: {
|
||||
fingerprint: null,
|
||||
format: 'message',
|
||||
path: null,
|
||||
relation: 'contains'
|
||||
},
|
||||
qr: null
|
||||
}
|
||||
|
|
|
@ -31,24 +31,24 @@ describe('verify', () => {
|
|||
const matches = doipjs.verify('dns:domain.org', null, {returnMatchesOnly: true})
|
||||
expect(matches).to.be.a('array')
|
||||
expect(matches).to.be.length(1)
|
||||
expect(matches[0].type).to.be.equal('domain')
|
||||
expect(matches[0].serviceprovider.name).to.be.equal('domain')
|
||||
})
|
||||
it('should match "xmpp:alice@domain.org" to the XMPP service provider', () => {
|
||||
const matches = doipjs.verify('xmpp:alice@domain.org', null, {returnMatchesOnly: true})
|
||||
expect(matches).to.be.a('array')
|
||||
expect(matches).to.be.length(1)
|
||||
expect(matches[0].type).to.be.equal('xmpp')
|
||||
expect(matches[0].serviceprovider.name).to.be.equal('xmpp')
|
||||
})
|
||||
it('should match "https://twitter.com/alice/status/1234567890123456789" to the Twitter service provider', () => {
|
||||
const matches = doipjs.verify('https://twitter.com/alice/status/1234567890123456789', null, {returnMatchesOnly: true})
|
||||
expect(matches).to.be.a('array')
|
||||
expect(matches).to.be.length(1)
|
||||
expect(matches[0].type).to.be.equal('twitter')
|
||||
expect(matches[0].serviceprovider.name).to.be.equal('twitter')
|
||||
})
|
||||
it('should match "https://news.ycombinator.com/user?id=Alice" to the Hackernews service provider', () => {
|
||||
const matches = doipjs.verify('https://news.ycombinator.com/user?id=Alice', null, {returnMatchesOnly: true})
|
||||
expect(matches).to.be.a('array')
|
||||
expect(matches).to.be.length(1)
|
||||
expect(matches[0].type).to.be.equal('hackernews')
|
||||
expect(matches[0].serviceprovider.name).to.be.equal('hackernews')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue