doipjs/src/serviceproviders/xmpp.js

38 lines
726 B
JavaScript
Raw Normal View History

2020-10-24 03:18:06 -06:00
const reURI = /^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
2020-10-23 14:35:53 -06:00
2020-10-24 03:18:06 -06:00
const processURL = (uri, opts) => {
const match = uri.match(reURI)
2020-10-23 14:35:53 -06:00
return {
type: "xmpp",
profile: {
display: `${match[1]}@${match[2]}`,
2020-10-24 03:18:06 -06:00
uri: uri
2020-10-23 14:35:53 -06:00
},
proof: {
2020-10-24 03:18:06 -06:00
uri: `https://${opts.XMPP_VCARD_SERVER_DOMAIN}/api/vcard/${output.display}/DESC`,
2020-10-23 14:35:53 -06:00
fetch: null
},
qr: null
}
}
2020-10-23 17:06:46 -06:00
const tests = [
{
2020-10-24 03:18:06 -06:00
uri: 'xmpp:alice@domain.org',
2020-10-23 17:06:46 -06:00
shouldMatch: true
},
{
2020-10-24 03:18:06 -06:00
uri: 'xmpp:alice@domain.org?omemo-sid-123456789=A1B2C3D4E5F6G7H8I9',
2020-10-23 17:06:46 -06:00
shouldMatch: true
},
{
2020-10-24 03:18:06 -06:00
uri: 'https://domain.org',
2020-10-23 17:06:46 -06:00
shouldMatch: false
}
]
2020-10-23 14:35:53 -06:00
2020-10-24 03:18:06 -06:00
exports.reURI = reURI
2020-10-23 14:35:53 -06:00
exports.processURL = processURL
exports.tests = tests