2020-12-26 05:52:49 -07:00
|
|
|
/*
|
2021-01-13 05:20:33 -07:00
|
|
|
Copyright 2021 Yarmo Mackenbach
|
2020-12-26 05:52:49 -07: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
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2021-04-12 07:59:03 -06:00
|
|
|
const E = require('../enums')
|
2020-12-26 05:52:49 -07:00
|
|
|
|
|
|
|
const reURI = /^https:\/\/(.*)/
|
|
|
|
|
2021-04-15 02:19:24 -06:00
|
|
|
const processURI = (uri) => {
|
2020-12-26 05:52:49 -07:00
|
|
|
const match = uri.match(reURI)
|
|
|
|
|
|
|
|
return {
|
|
|
|
serviceprovider: {
|
|
|
|
type: 'web',
|
2021-07-09 15:44:52 -06:00
|
|
|
name: 'owncast'
|
2020-12-26 05:52:49 -07:00
|
|
|
},
|
2021-04-15 02:19:24 -06:00
|
|
|
match: {
|
|
|
|
regularExpression: reURI,
|
2021-07-09 15:44:52 -06:00
|
|
|
isAmbiguous: true
|
2021-04-15 02:19:24 -06:00
|
|
|
},
|
2020-12-26 05:52:49 -07:00
|
|
|
profile: {
|
|
|
|
display: match[1],
|
|
|
|
uri: uri,
|
2021-07-09 15:44:52 -06:00
|
|
|
qr: null
|
2020-12-26 05:52:49 -07:00
|
|
|
},
|
|
|
|
proof: {
|
|
|
|
uri: `${uri}/api/config`,
|
2021-04-12 07:59:03 -06:00
|
|
|
request: {
|
|
|
|
fetcher: E.Fetcher.HTTP,
|
|
|
|
access: E.ProofAccess.GENERIC,
|
|
|
|
format: E.ProofFormat.JSON,
|
|
|
|
data: {
|
|
|
|
url: `${uri}/api/config`,
|
2021-07-09 15:44:52 -06:00
|
|
|
format: E.ProofFormat.JSON
|
|
|
|
}
|
|
|
|
}
|
2020-12-26 05:52:49 -07:00
|
|
|
},
|
2022-11-16 14:25:32 -07:00
|
|
|
claim: [{
|
2021-04-12 07:59:03 -06:00
|
|
|
format: E.ClaimFormat.FINGERPRINT,
|
2023-03-12 14:44:32 -06:00
|
|
|
encoding: E.EntityEncodingFormat.PLAIN,
|
2021-04-12 07:59:03 -06:00
|
|
|
relation: E.ClaimRelation.CONTAINS,
|
2021-07-09 15:44:52 -06:00
|
|
|
path: ['socialHandles', 'url']
|
2022-11-16 14:25:32 -07:00
|
|
|
}]
|
2020-12-26 05:52:49 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const tests = [
|
|
|
|
{
|
|
|
|
uri: 'https://live.domain.org',
|
2021-07-09 15:44:52 -06:00
|
|
|
shouldMatch: true
|
2020-12-26 05:52:49 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
uri: 'https://live.domain.org/',
|
2021-07-09 15:44:52 -06:00
|
|
|
shouldMatch: true
|
2020-12-26 05:52:49 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
uri: 'https://domain.org/live',
|
2021-07-09 15:44:52 -06:00
|
|
|
shouldMatch: true
|
2020-12-26 05:52:49 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
uri: 'https://domain.org/live/',
|
2021-07-09 15:44:52 -06:00
|
|
|
shouldMatch: true
|
|
|
|
}
|
2020-12-26 05:52:49 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
exports.reURI = reURI
|
|
|
|
exports.processURI = processURI
|
|
|
|
exports.tests = tests
|