From 8e73360d4695e76cce3ffa676b1ae56c87768750 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sun, 8 Nov 2020 12:22:36 +0100 Subject: [PATCH] Support xmpp via doip-proxy --- src/serviceproviders/xmpp.js | 6 ++---- src/utils.js | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/serviceproviders/xmpp.js b/src/serviceproviders/xmpp.js index 477e863..24f509f 100644 --- a/src/serviceproviders/xmpp.js +++ b/src/serviceproviders/xmpp.js @@ -13,6 +13,7 @@ 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. */ +const utils = require('../utils') const reURI = /^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/ const processURI = (uri, opts) => { @@ -32,10 +33,7 @@ const processURI = (uri, opts) => { qr: uri, }, proof: { - uri: - 'xmppVcardServerDomain' in opts - ? `https://${opts.xmppVcardServerDomain}/api/vcard/${match[1]}@${match[2]}/DESC` - : null, + uri: utils.generateProxyURL('xmpp', `${match[1]}@${match[2]}`, opts), fetch: null, useProxy: false, format: 'json', diff --git a/src/utils.js b/src/utils.js index 9050f7d..bf35084 100644 --- a/src/utils.js +++ b/src/utils.js @@ -2,9 +2,13 @@ const generateProxyURL = (type, url, opts) => { if (!opts || !opts.doipProxyHostname) { return null } + let addParam = '' + if (type == 'xmpp') { + addParam += '/DESC' + } return `https://${ opts.doipProxyHostname - }/api/1/get/${type}/${encodeURIComponent(url)}` + }/api/1/get/${type}/${encodeURIComponent(url)}${addParam}` } const generateClaim = (fingerprint, format) => {