2020-10-24 04:05:11 -06:00
|
|
|
/*
|
2020-10-24 07:11:14 -06:00
|
|
|
Copyright 2020 Yarmo Mackenbach
|
2020-10-24 04:05:11 -06:00
|
|
|
|
2020-10-24 07:11:14 -06:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
2020-10-24 04:05:11 -06:00
|
|
|
|
2020-10-24 07:11:14 -06:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2020-10-24 04:05:11 -06:00
|
|
|
|
2020-10-24 07:11:14 -06:00
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
2020-10-24 04:05:11 -06:00
|
|
|
*/
|
2020-11-08 04:22:36 -07:00
|
|
|
const utils = require('../utils')
|
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:20:34 -06:00
|
|
|
const processURI = (uri, opts) => {
|
2020-11-07 18:07:02 -07:00
|
|
|
if (!opts) {
|
|
|
|
opts = {}
|
|
|
|
}
|
2020-10-24 03:18:06 -06:00
|
|
|
const match = uri.match(reURI)
|
2020-10-23 14:35:53 -06:00
|
|
|
|
|
|
|
return {
|
2020-10-24 08:42:22 -06:00
|
|
|
serviceprovider: {
|
|
|
|
type: 'communication',
|
2020-11-07 18:07:02 -07:00
|
|
|
name: 'xmpp',
|
2020-10-24 08:42:22 -06:00
|
|
|
},
|
2020-10-23 14:35:53 -06:00
|
|
|
profile: {
|
|
|
|
display: `${match[1]}@${match[2]}`,
|
2020-11-05 18:27:56 -07:00
|
|
|
uri: uri,
|
2020-11-07 18:07:02 -07:00
|
|
|
qr: uri,
|
2020-10-23 14:35:53 -06:00
|
|
|
},
|
|
|
|
proof: {
|
2020-11-08 04:22:36 -07:00
|
|
|
uri: utils.generateProxyURL('xmpp', `${match[1]}@${match[2]}`, opts),
|
2020-10-24 08:42:22 -06:00
|
|
|
fetch: null,
|
2020-10-24 09:30:22 -06:00
|
|
|
useProxy: false,
|
2020-11-07 18:07:02 -07:00
|
|
|
format: 'json',
|
2020-10-24 08:42:22 -06:00
|
|
|
},
|
|
|
|
claim: {
|
|
|
|
fingerprint: null,
|
|
|
|
format: 'message',
|
2020-10-24 15:35:54 -06:00
|
|
|
path: [],
|
2020-11-07 18:07:02 -07:00
|
|
|
relation: 'contains',
|
2020-10-23 14:35:53 -06:00
|
|
|
},
|
2020-11-07 18:07:02 -07:00
|
|
|
customRequestHandler: null,
|
2020-10-23 14:35:53 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-23 17:06:46 -06:00
|
|
|
const tests = [
|
|
|
|
{
|
2020-10-24 03:18:06 -06:00
|
|
|
uri: 'xmpp:alice@domain.org',
|
2020-11-07 18:07:02 -07:00
|
|
|
shouldMatch: true,
|
2020-10-23 17:06:46 -06:00
|
|
|
},
|
|
|
|
{
|
2020-10-24 03:18:06 -06:00
|
|
|
uri: 'xmpp:alice@domain.org?omemo-sid-123456789=A1B2C3D4E5F6G7H8I9',
|
2020-11-07 18:07:02 -07:00
|
|
|
shouldMatch: true,
|
2020-10-23 17:06:46 -06:00
|
|
|
},
|
|
|
|
{
|
2020-10-24 03:18:06 -06:00
|
|
|
uri: 'https://domain.org',
|
2020-11-07 18:07:02 -07:00
|
|
|
shouldMatch: false,
|
|
|
|
},
|
2020-10-23 17:06:46 -06:00
|
|
|
]
|
2020-10-23 14:35:53 -06:00
|
|
|
|
2020-10-24 03:18:06 -06:00
|
|
|
exports.reURI = reURI
|
2020-10-24 03:20:34 -06:00
|
|
|
exports.processURI = processURI
|
2020-10-23 14:35:53 -06:00
|
|
|
exports.tests = tests
|