mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49: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)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "domain",
|
serviceprovider: {
|
||||||
|
type: 'web',
|
||||||
|
name: 'domain'
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: `https://${match[1]}`
|
uri: `https://${match[1]}`
|
||||||
},
|
},
|
||||||
proof: {
|
proof: {
|
||||||
uri: `https://dns.shivering-isles.com/dns-query?name=${match[1]}&type=TXT`,
|
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
|
qr: null
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,24 @@ const processURI = (uri, opts) => {
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "hackernews",
|
serviceprovider: {
|
||||||
|
type: 'web',
|
||||||
|
name: 'hackernews'
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: uri
|
uri: uri
|
||||||
},
|
},
|
||||||
proof: {
|
proof: {
|
||||||
uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
|
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
|
qr: null
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,24 @@ const processURI = (uri, opts) => {
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "twitter",
|
serviceprovider: {
|
||||||
|
type: 'web',
|
||||||
|
name: 'twitter'
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `@${match[1]}`,
|
display: `@${match[1]}`,
|
||||||
uri: `https://twitter.com/${match[1]}`
|
uri: `https://twitter.com/${match[1]}`
|
||||||
},
|
},
|
||||||
proof: {
|
proof: {
|
||||||
uri: uri,
|
uri: uri,
|
||||||
fetch: 'DOIP_PROXY_SERVER_DOMAIN' in opts
|
fetch: `https://mobile.twitter.com/${match[1]}/status/${match[2]}`,
|
||||||
? `${opts.DOIP_PROXY_SERVER_DOMAIN}/server/verify/twitter
|
useProxy: false
|
||||||
?tweetId=${encodeURIComponent(match[2])}
|
},
|
||||||
&account=${encodeURIComponent(match[1])}
|
claim: {
|
||||||
&fingerprint=${fingerprint}`
|
fingerprint: null,
|
||||||
: null
|
format: 'message',
|
||||||
|
path: null,
|
||||||
|
relation: 'contains'
|
||||||
},
|
},
|
||||||
qr: null
|
qr: null
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,10 @@ const processURI = (uri, opts) => {
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "xmpp",
|
serviceprovider: {
|
||||||
|
type: 'communication',
|
||||||
|
name: 'xmpp'
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `${match[1]}@${match[2]}`,
|
display: `${match[1]}@${match[2]}`,
|
||||||
uri: uri
|
uri: uri
|
||||||
|
@ -29,7 +32,14 @@ const processURI = (uri, opts) => {
|
||||||
uri: 'XMPP_VCARD_SERVER_DOMAIN' in opts
|
uri: 'XMPP_VCARD_SERVER_DOMAIN' in opts
|
||||||
? `https://${opts.XMPP_VCARD_SERVER_DOMAIN}/api/vcard/${output.display}/DESC`
|
? `https://${opts.XMPP_VCARD_SERVER_DOMAIN}/api/vcard/${output.display}/DESC`
|
||||||
: null,
|
: null,
|
||||||
fetch: null
|
fetch: null,
|
||||||
|
useProxy: false
|
||||||
|
},
|
||||||
|
claim: {
|
||||||
|
fingerprint: null,
|
||||||
|
format: 'message',
|
||||||
|
path: null,
|
||||||
|
relation: 'contains'
|
||||||
},
|
},
|
||||||
qr: null
|
qr: null
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,24 +31,24 @@ describe('verify', () => {
|
||||||
const matches = doipjs.verify('dns:domain.org', null, {returnMatchesOnly: true})
|
const matches = doipjs.verify('dns:domain.org', null, {returnMatchesOnly: true})
|
||||||
expect(matches).to.be.a('array')
|
expect(matches).to.be.a('array')
|
||||||
expect(matches).to.be.length(1)
|
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', () => {
|
it('should match "xmpp:alice@domain.org" to the XMPP service provider', () => {
|
||||||
const matches = doipjs.verify('xmpp:alice@domain.org', null, {returnMatchesOnly: true})
|
const matches = doipjs.verify('xmpp:alice@domain.org', null, {returnMatchesOnly: true})
|
||||||
expect(matches).to.be.a('array')
|
expect(matches).to.be.a('array')
|
||||||
expect(matches).to.be.length(1)
|
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', () => {
|
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})
|
const matches = doipjs.verify('https://twitter.com/alice/status/1234567890123456789', null, {returnMatchesOnly: true})
|
||||||
expect(matches).to.be.a('array')
|
expect(matches).to.be.a('array')
|
||||||
expect(matches).to.be.length(1)
|
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', () => {
|
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})
|
const matches = doipjs.verify('https://news.ycombinator.com/user?id=Alice', null, {returnMatchesOnly: true})
|
||||||
expect(matches).to.be.a('array')
|
expect(matches).to.be.a('array')
|
||||||
expect(matches).to.be.length(1)
|
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