mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2025-01-10 14:39:28 -07:00
Change serviceproviders to claimDefinitions
This commit is contained in:
parent
1bbf6511e4
commit
be0f660e85
18 changed files with 142 additions and 132 deletions
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/dev\.to\/(.*)\/(.*)\/?/
|
const reURI = /^https:\/\/dev\.to\/(.*)\/(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'devto',
|
name: 'devto',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: `https://dev.to/${match[1]}`,
|
uri: `https://dev.to/${match[1]}`,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['body_markdown'],
|
path: ['body_markdown'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/(.*)\/u\/(.*)\/?/
|
const reURI = /^https:\/\/(.*)\/u\/(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'discourse',
|
name: 'discourse',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: true,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `${match[2]}@${match[1]}`,
|
display: `${match[2]}@${match[1]}`,
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['user', 'bio_raw'],
|
path: ['user', 'bio_raw'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
|
const reURI = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'dns',
|
name: 'dns',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: `https://${match[1]}`,
|
uri: `https://${match[1]}`,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.URI,
|
format: E.ClaimFormat.URI,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['records', 'txt'],
|
path: ['records', 'txt'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/(.*)\/users\/(.*)\/?/
|
const reURI = /^https:\/\/(.*)\/users\/(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'fediverse',
|
name: 'fediverse',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: true,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `@${match[2]}@${match[1]}`,
|
display: `@${match[2]}@${match[1]}`,
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.FINGERPRINT,
|
format: E.ClaimFormat.FINGERPRINT,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['summary'],
|
path: ['summary'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/(.*)\/(.*)\/gitea_proof\/?/
|
const reURI = /^https:\/\/(.*)\/(.*)\/gitea_proof\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'gitea',
|
name: 'gitea',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: true,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `${match[2]}@${match[1]}`,
|
display: `${match[2]}@${match[1]}`,
|
||||||
uri: `https://${match[1]}/${match[2]}`,
|
uri: `https://${match[1]}/${match[2]}`,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.EQUALS,
|
relation: E.ClaimRelation.EQUALS,
|
||||||
path: ['description'],
|
path: ['description'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/
|
const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'github',
|
name: 'github',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: `https://github.com/${match[1]}`,
|
uri: `https://github.com/${match[1]}`,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['files', 'openpgp.md', 'content'],
|
path: ['files', 'openpgp.md', 'content'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/(.*)\/(.*)\/gitlab_proof\/?/
|
const reURI = /^https:\/\/(.*)\/(.*)\/gitlab_proof\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'gitlab',
|
name: 'gitlab',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: true,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `${match[2]}@${match[1]}`,
|
display: `${match[2]}@${match[1]}`,
|
||||||
uri: `https://${match[1]}/${match[2]}`,
|
uri: `https://${match[1]}/${match[2]}`,
|
||||||
|
@ -46,7 +47,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.EQUALS,
|
relation: E.ClaimRelation.EQUALS,
|
||||||
path: ['description'],
|
path: ['description'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/news\.ycombinator\.com\/user\?id=(.*)\/?/
|
const reURI = /^https:\/\/news\.ycombinator\.com\/user\?id=(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'hackernews',
|
name: 'hackernews',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.URI,
|
format: E.ClaimFormat.URI,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['about'],
|
path: ['about'],
|
57
src/claimDefinitions/index.js
Normal file
57
src/claimDefinitions/index.js
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
Copyright 2021 Yarmo Mackenbach
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
const list = [
|
||||||
|
'dns',
|
||||||
|
'irc',
|
||||||
|
'xmpp',
|
||||||
|
'matrix',
|
||||||
|
'twitter',
|
||||||
|
'reddit',
|
||||||
|
'liberapay',
|
||||||
|
'hackernews',
|
||||||
|
'lobsters',
|
||||||
|
'devto',
|
||||||
|
'gitea',
|
||||||
|
'gitlab',
|
||||||
|
'github',
|
||||||
|
'mastodon',
|
||||||
|
'fediverse',
|
||||||
|
'discourse',
|
||||||
|
'owncast',
|
||||||
|
]
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
dns: require('./dns'),
|
||||||
|
irc: require('./irc'),
|
||||||
|
xmpp: require('./xmpp'),
|
||||||
|
matrix: require('./matrix'),
|
||||||
|
twitter: require('./twitter'),
|
||||||
|
reddit: require('./reddit'),
|
||||||
|
liberapay: require('./liberapay'),
|
||||||
|
hackernews: require('./hackernews'),
|
||||||
|
lobsters: require('./lobsters'),
|
||||||
|
devto: require('./devto'),
|
||||||
|
gitea: require('./gitea'),
|
||||||
|
gitlab: require('./gitlab'),
|
||||||
|
github: require('./github'),
|
||||||
|
mastodon: require('./mastodon'),
|
||||||
|
fediverse: require('./fediverse'),
|
||||||
|
discourse: require('./discourse'),
|
||||||
|
owncast: require('./owncast'),
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.list = list
|
||||||
|
exports.data = data
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^irc\:\/\/(.*)\/([a-zA-Z0-9]*)/
|
const reURI = /^irc\:\/\/(.*)\/([a-zA-Z0-9]*)/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'communication',
|
type: 'communication',
|
||||||
name: 'irc',
|
name: 'irc',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `irc://${match[1]}/${match[2]}`,
|
display: `irc://${match[1]}/${match[2]}`,
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -46,7 +47,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.URI,
|
format: E.ClaimFormat.URI,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: [],
|
path: [],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/
|
const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'liberapay',
|
name: 'liberapay',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['statements', 'content'],
|
path: ['statements', 'content'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/
|
const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'lobsters',
|
name: 'lobsters',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['about'],
|
path: ['about'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/(.*)\/@(.*)\/?/
|
const reURI = /^https:\/\/(.*)\/@(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'mastodon',
|
name: 'mastodon',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: true,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `@${match[2]}@${match[1]}`,
|
display: `@${match[2]}@${match[1]}`,
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.FINGERPRINT,
|
format: E.ClaimFormat.FINGERPRINT,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['attachment', 'value'],
|
path: ['attachment', 'value'],
|
|
@ -18,10 +18,7 @@ const queryString = require('query-string')
|
||||||
|
|
||||||
const reURI = /^matrix\:u\/(?:\@)?([^@:]*\:[^?]*)(\?.*)?/
|
const reURI = /^matrix\:u\/(?:\@)?([^@:]*\:[^?]*)(\?.*)?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
if (!match[2]) {
|
if (!match[2]) {
|
||||||
|
@ -42,6 +39,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'communication',
|
type: 'communication',
|
||||||
name: 'matrix',
|
name: 'matrix',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `@${match[1]}`,
|
display: `@${match[1]}`,
|
||||||
uri: profileUrl,
|
uri: profileUrl,
|
||||||
|
@ -60,7 +61,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['data', 'content', 'body'],
|
path: ['data', 'content', 'body'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/(.*)/
|
const reURI = /^https:\/\/(.*)/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'owncast',
|
name: 'owncast',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: true,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.FINGERPRINT,
|
format: E.ClaimFormat.FINGERPRINT,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['socialHandles', 'url'],
|
path: ['socialHandles', 'url'],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^https:\/\/(?:www\.)?reddit\.com\/user\/(.*)\/comments\/(.*)\/(.*)\/?/
|
const reURI = /^https:\/\/(?:www\.)?reddit\.com\/user\/(.*)\/comments\/(.*)\/(.*)\/?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'reddit',
|
name: 'reddit',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
uri: `https://www.reddit.com/user/${match[1]}`,
|
uri: `https://www.reddit.com/user/${match[1]}`,
|
||||||
|
@ -45,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: ['data', 'children', 'data', 'selftext'],
|
path: ['data', 'children', 'data', 'selftext'],
|
|
@ -14,60 +14,10 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
const E = require('../enums')
|
const E = require('../enums')
|
||||||
const bent = require('bent')
|
|
||||||
const req = bent('GET')
|
|
||||||
const serviceproviders = require('../serviceproviders')
|
|
||||||
const utils = require('../utils')
|
|
||||||
|
|
||||||
const reURI = /^https:\/\/twitter\.com\/(.*)\/status\/([0-9]*)(?:\?.*)?/
|
const reURI = /^https:\/\/twitter\.com\/(.*)\/status\/([0-9]*)(?:\?.*)?/
|
||||||
|
|
||||||
const customRequestHandler = async (spData, opts) => {
|
const processURI = (uri) => {
|
||||||
const match = spData.proof.uri.match(reURI)
|
|
||||||
|
|
||||||
// Attempt direct verification if policy allows it
|
|
||||||
if (opts.proxyPolicy !== 'always') {
|
|
||||||
if ('twitterBearerToken' in opts && opts.twitterBearerToken) {
|
|
||||||
const res = await req(
|
|
||||||
`https://api.twitter.com/1.1/statuses/show.json?id=${match[2]}`,
|
|
||||||
null,
|
|
||||||
{
|
|
||||||
Accept: 'application/json',
|
|
||||||
Authorization: `Bearer ${opts.twitterBearerToken}`,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
const json = await res.json()
|
|
||||||
return json.text
|
|
||||||
} else if ('nitterInstance' in opts && opts.nitterInstance) {
|
|
||||||
spData.proof.fetch = `https://${opts.nitterInstance}/${match[1]}/status/${match[2]}`
|
|
||||||
const res = await serviceproviders.proxyRequestHandler(spData, opts)
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt proxy verification if policy allows it
|
|
||||||
if (opts.proxyPolicy !== 'never' && spData.proof.fetch) {
|
|
||||||
return req(utils.generateProxyURL('twitter', match[2], opts), null, {
|
|
||||||
Accept: 'application/json',
|
|
||||||
})
|
|
||||||
.then(async (res) => {
|
|
||||||
return await res.json()
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
return res.data.text
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
reject(e)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// No verification
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -75,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'web',
|
type: 'web',
|
||||||
name: 'twitter',
|
name: 'twitter',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `@${match[1]}`,
|
display: `@${match[1]}`,
|
||||||
uri: `https://twitter.com/${match[1]}`,
|
uri: `https://twitter.com/${match[1]}`,
|
||||||
|
@ -92,7 +46,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: [],
|
path: [],
|
|
@ -17,10 +17,7 @@ const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
|
const reURI = /^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
|
||||||
|
|
||||||
const processURI = (uri, opts) => {
|
const processURI = (uri) => {
|
||||||
if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +25,10 @@ const processURI = (uri, opts) => {
|
||||||
type: 'communication',
|
type: 'communication',
|
||||||
name: 'xmpp',
|
name: 'xmpp',
|
||||||
},
|
},
|
||||||
|
match: {
|
||||||
|
regularExpression: reURI,
|
||||||
|
isAmbiguous: false,
|
||||||
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `${match[1]}@${match[2]}`,
|
display: `${match[1]}@${match[2]}`,
|
||||||
uri: uri,
|
uri: uri,
|
||||||
|
@ -46,7 +47,6 @@ const processURI = (uri, opts) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
fingerprint: null,
|
|
||||||
format: E.ClaimFormat.MESSAGE,
|
format: E.ClaimFormat.MESSAGE,
|
||||||
relation: E.ClaimRelation.CONTAINS,
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
path: [],
|
path: [],
|
Loading…
Reference in a new issue