mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
feat: apply ServiceProvider class, update tests
This commit is contained in:
parent
b674f113c7
commit
fd8c760689
26 changed files with 613 additions and 563 deletions
|
@ -46,7 +46,6 @@
|
|||
"@rollup/plugin-node-resolve": "^15.1.0",
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-match-pattern": "^1.2.0",
|
||||
"clean-jsdoc-theme": "^3.2.4",
|
||||
"eslint": "^8.39.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
|
|
|
@ -14,60 +14,65 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(.*)\/?/
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @param {string} uri
|
||||
* @returns {ServiceProvider}
|
||||
*/
|
||||
export function processURI (uri) {
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'activitypub'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: true
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'activitypub',
|
||||
name: 'ActivityPub',
|
||||
homepage: 'https://activitypub.rocks'
|
||||
},
|
||||
profile: {
|
||||
display: uri,
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString().toString(),
|
||||
uriIsAmbiguous: true
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.ACTIVITYPUB,
|
||||
access: E.ProofAccess.GENERIC,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.ACTIVITYPUB,
|
||||
accessRestriction: E.ProofAccessRestriction.NONE,
|
||||
data: {
|
||||
url: uri
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [
|
||||
{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['summary']
|
||||
},
|
||||
{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['attachment', 'value']
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['content']
|
||||
}
|
||||
]
|
||||
}
|
||||
target: [
|
||||
{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['summary']
|
||||
},
|
||||
{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['attachment', 'value']
|
||||
},
|
||||
{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['content']
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const functions = {
|
|
@ -14,49 +14,54 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(.*)\/u\/(.*)\/?/
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @param {string} uri
|
||||
* @returns {ServiceProvider}
|
||||
*/
|
||||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'discourse'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: true
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'discourse',
|
||||
name: 'Discourse',
|
||||
homepage: 'https://www.discourse.org'
|
||||
},
|
||||
profile: {
|
||||
display: `${match[2]}@${match[1]}`,
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString().toString(),
|
||||
uriIsAmbiguous: true
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: `https://${match[1]}/u/${match[2]}.json`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['user', 'bio_raw']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['user', 'bio_raw']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^dns:([a-zA-Z0-9.\-_]*)(?:\?(.*))?/
|
||||
|
||||
|
@ -24,38 +25,40 @@ export const reURI = /^dns:([a-zA-Z0-9.\-_]*)(?:\?(.*))?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'dns'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'dns',
|
||||
name: 'DNS'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri: `https://${match[1]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: null,
|
||||
request: {
|
||||
fetcher: E.Fetcher.DNS,
|
||||
access: E.ProofAccess.SERVER,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: null,
|
||||
protocol: E.Fetcher.DNS,
|
||||
accessRestriction: E.ProofAccessRestriction.SERVER,
|
||||
data: {
|
||||
domain: match[1]
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['records', 'txt']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['records', 'txt']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'forem'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: true
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'forem',
|
||||
name: 'Forem',
|
||||
homepage: 'https://www.forem.com'
|
||||
},
|
||||
profile: {
|
||||
display: `${match[2]}@${match[1]}`,
|
||||
uri: `https://${match[1]}/${match[2]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString().toString(),
|
||||
uriIsAmbiguous: true
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: `https://${match[1]}/api/articles/${match[2]}/${match[3]}`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['body_markdown']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['body_markdown']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'forgejo'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: true
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'forgejo',
|
||||
name: 'Forgejo',
|
||||
homepage: 'https://forgejo.org'
|
||||
},
|
||||
profile: {
|
||||
display: `${match[2]}@${match[1]}`,
|
||||
uri: `https://${match[1]}/${match[2]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: true
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.EQUALS,
|
||||
path: ['description']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.EQUALS,
|
||||
path: ['description']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'gitea'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: true
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'gitea',
|
||||
name: 'Gitea',
|
||||
homepage: 'https://about.gitea.com'
|
||||
},
|
||||
profile: {
|
||||
display: `${match[2]}@${match[1]}`,
|
||||
uri: `https://${match[1]}/${match[2]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: true
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.EQUALS,
|
||||
path: ['description']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.EQUALS,
|
||||
path: ['description']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'github'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'github',
|
||||
name: 'GitHub',
|
||||
homepage: 'https://github.com'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri: `https://github.com/${match[1]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.GENERIC,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NONE,
|
||||
data: {
|
||||
url: `https://api.github.com/gists/${match[2]}`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['files', 'openpgp.md', 'content']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['files', 'openpgp.md', 'content']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(.*)\/(.*)\/gitlab_proof\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)\/(.*)\/gitlab_proof\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'gitlab'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: true
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'gitlab',
|
||||
name: 'GitLab',
|
||||
homepage: 'https://about.gitlab.com'
|
||||
},
|
||||
profile: {
|
||||
display: `${match[2]}@${match[1]}`,
|
||||
uri: `https://${match[1]}/${match[2]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: true
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.GENERIC,
|
||||
format: E.ProofFormat.JSON,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NONE,
|
||||
data: {
|
||||
url: `https://${match[1]}/api/v4/projects/${match[2]}%2Fgitlab_proof`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.EQUALS,
|
||||
path: ['description']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.EQUALS,
|
||||
path: ['description']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/news\.ycombinator\.com\/user\?id=(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/news\.ycombinator\.com\/user\?id=(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'hackernews'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'hackernews',
|
||||
name: 'Hacker News',
|
||||
homepage: 'https://news.ycombinator.com'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.HTML,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['about']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.HTML,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['about']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^irc:\/\/(.*)\/([a-zA-Z0-9\-[\]\\`_^{|}]*)/
|
||||
|
||||
|
@ -24,39 +25,41 @@ export const reURI = /^irc:\/\/(.*)\/([a-zA-Z0-9\-[\]\\`_^{|}]*)/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'communication',
|
||||
name: 'irc'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'irc',
|
||||
name: 'IRC'
|
||||
},
|
||||
profile: {
|
||||
display: `irc://${match[1]}/${match[2]}`,
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: null,
|
||||
request: {
|
||||
fetcher: E.Fetcher.IRC,
|
||||
access: E.ProofAccess.SERVER,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: null,
|
||||
protocol: E.Fetcher.IRC,
|
||||
accessRestriction: E.ProofAccessRestriction.SERVER,
|
||||
data: {
|
||||
domain: match[1],
|
||||
nick: match[2]
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: []
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: []
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/keybase.io\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,41 @@ export const reURI = /^https:\/\/keybase.io\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'web',
|
||||
name: 'keybase'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['them', 'public_keys', 'primary', 'key_fingerprint']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['them', 'public_keys', 'primary', 'key_fingerprint']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'liberapay'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'liberapay',
|
||||
name: 'Liberapay',
|
||||
homepage: 'https://liberapay.com'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.GENERIC,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NONE,
|
||||
data: {
|
||||
url: `https://liberapay.com/${match[1]}/public.json`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['statements', 'content']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['statements', 'content']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/lichess\.org\/@\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,41 @@ export const reURI = /^https:\/\/lichess\.org\/@\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'web',
|
||||
name: 'lichess'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: `https://lichess.org/api/user/${match[1]}`,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.GENERIC,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: `https://lichess.org/api/user/${match[1]}`,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NONE,
|
||||
data: {
|
||||
url: `https://lichess.org/api/user/${match[1]}`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['profile', 'links']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['profile', 'links']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'lobsters'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'lobsters',
|
||||
name: 'Lobsters',
|
||||
homepage: 'https://lobste.rs'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: `https://lobste.rs/u/${match[1]}.json`,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: `https://lobste.rs/u/${match[1]}.json`,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: `https://lobste.rs/u/${match[1]}.json`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['about']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['about']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^matrix:u\/(?:@)?([^@:]*:[^?]*)(\?.*)?/
|
||||
|
||||
|
@ -40,39 +41,42 @@ export function processURI (uri) {
|
|||
const profileUrl = `https://matrix.to/#/@${match[1]}`
|
||||
const eventUrl = `https://matrix.to/#/${paramRoomId}/${paramEventId}`
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'communication',
|
||||
name: 'matrix'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'matrix',
|
||||
name: 'Matrix',
|
||||
homepage: 'https://matrix.org'
|
||||
},
|
||||
profile: {
|
||||
display: `@${match[1]}`,
|
||||
uri: profileUrl,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: eventUrl,
|
||||
request: {
|
||||
fetcher: E.Fetcher.MATRIX,
|
||||
access: E.ProofAccess.GRANTED,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: eventUrl,
|
||||
protocol: E.Fetcher.MATRIX,
|
||||
accessRestriction: E.ProofAccessRestriction.GRANTED,
|
||||
data: {
|
||||
eventId: paramEventId,
|
||||
roomId: paramRoomId
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['content', 'body']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['content', 'body']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/opencollective\.com\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/opencollective\.com\/(.*)\/?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'opencollective'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'opencollective',
|
||||
name: 'Open Collective',
|
||||
homepage: 'https://opencollective.com'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.GRAPHQL,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.GRAPHQL,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: 'https://api.opencollective.com/graphql/v2',
|
||||
query: `{ "query": "query { collective(slug: \\"${match[1]}\\") { longDescription } }" }`
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['data', 'collective', 'longDescription']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['data', 'collective', 'longDescription']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(.*)/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'owncast'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: true
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'owncast',
|
||||
name: 'Owncast',
|
||||
homepage: 'https://owncast.online'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: true
|
||||
},
|
||||
proof: {
|
||||
uri: `${uri}/api/config`,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.GENERIC,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: `${uri}/api/config`,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NONE,
|
||||
data: {
|
||||
url: `${uri}/api/config`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['socialHandles', 'url']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.FINGERPRINT,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['socialHandles', 'url']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(?:www\.)?reddit\.com\/user\/(.*)\/comments\/(.*)\/(.*)\/?/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(?:www\.)?reddit\.com\/user\/(.*)\/comments\/(.
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'reddit'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'reddit',
|
||||
name: 'Reddit',
|
||||
homepage: 'https://reddit.com'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri: `https://www.reddit.com/user/${match[1]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: `https://www.reddit.com/user/${match[1]}/comments/${match[2]}.json`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['data', 'children', 'data', 'selftext']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['data', 'children', 'data', 'selftext']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/(.*(?:askubuntu|mathoverflow|serverfault|stackapps|stackoverflow|superuser)|.+\.stackexchange)\.com\/users\/(\d+)/
|
||||
const reStackExchange = /\.stackexchange$/
|
||||
|
@ -26,39 +27,42 @@ export function processURI (uri) {
|
|||
const [, domain, id] = uri.match(reURI)
|
||||
const site = domain.replace(reStackExchange, '')
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'stackexchange'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'stackexchange',
|
||||
name: 'Stack Exchange',
|
||||
homepage: 'https://stackexchange.com'
|
||||
},
|
||||
profile: {
|
||||
display: `${id}@${site}`,
|
||||
uri,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: `https://${domain}.com/users/${id}?tab=profile`,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.GENERIC,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: `https://${domain}.com/users/${id}?tab=profile`,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NONE,
|
||||
data: {
|
||||
url: `https://api.stackexchange.com/2.3/users/${id}?site=${site}&filter=!AH)b5JqVyImf`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['items', 'about_me']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['items', 'about_me']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /https:\/\/t.me\/([A-Za-z0-9_]{5,32})\?proof=([A-Za-z0-9_]{5,32})/
|
||||
|
||||
|
@ -24,39 +25,42 @@ export const reURI = /https:\/\/t.me\/([A-Za-z0-9_]{5,32})\?proof=([A-Za-z0-9_]{
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'communication',
|
||||
name: 'telegram'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'telegram',
|
||||
name: 'Telegram',
|
||||
homepage: 'https://telegram.org'
|
||||
},
|
||||
profile: {
|
||||
display: `@${match[1]}`,
|
||||
uri: `https://t.me/${match[1]}`,
|
||||
qr: `https://t.me/${match[1]}`
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: `https://t.me/${match[2]}`,
|
||||
request: {
|
||||
fetcher: E.Fetcher.TELEGRAM,
|
||||
access: E.ProofAccess.GRANTED,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: `https://t.me/${match[2]}`,
|
||||
protocol: E.Fetcher.TELEGRAM,
|
||||
accessRestriction: E.ProofAccessRestriction.GRANTED,
|
||||
data: {
|
||||
user: match[1],
|
||||
chat: match[2]
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.EQUALS,
|
||||
path: ['text']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.EQUALS,
|
||||
path: ['text']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/twitter\.com\/(.*)\/status\/([0-9]*)(?:\?.*)?/
|
||||
|
||||
|
@ -28,40 +29,43 @@ export function processURI (uri) {
|
|||
urlsp.set('url', match[0])
|
||||
urlsp.set('omit_script', '1')
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'web',
|
||||
name: 'twitter'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'twitter',
|
||||
name: 'Twitter',
|
||||
homepage: 'https://twitter.com'
|
||||
},
|
||||
profile: {
|
||||
display: `@${match[1]}`,
|
||||
uri: `https://twitter.com/${match[1]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri,
|
||||
request: {
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
access: E.ProofAccess.NOCORS,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri,
|
||||
protocol: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
// Returns an oembed json object with the tweet content in html form
|
||||
url: `https://publish.twitter.com/oembed?${urlsp}`,
|
||||
format: E.ProofFormat.JSON
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['html']
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: ['html']
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^xmpp:([a-zA-Z0-9.\-_]*)@([a-zA-Z0-9.\-_]*)(?:\?(.*))?/
|
||||
|
||||
|
@ -24,38 +25,41 @@ export const reURI = /^xmpp:([a-zA-Z0-9.\-_]*)@([a-zA-Z0-9.\-_]*)(?:\?(.*))?/
|
|||
export function processURI (uri) {
|
||||
const match = uri.match(reURI)
|
||||
|
||||
return {
|
||||
serviceprovider: {
|
||||
type: 'communication',
|
||||
name: 'xmpp'
|
||||
},
|
||||
match: {
|
||||
regularExpression: reURI,
|
||||
isAmbiguous: false
|
||||
return new ServiceProvider({
|
||||
about: {
|
||||
id: 'xmpp',
|
||||
name: 'XMPP',
|
||||
homepage: 'https://xmpp.org'
|
||||
},
|
||||
profile: {
|
||||
display: `${match[1]}@${match[2]}`,
|
||||
uri,
|
||||
qr: uri
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
uri: null,
|
||||
request: {
|
||||
fetcher: E.Fetcher.XMPP,
|
||||
access: E.ProofAccess.SERVER,
|
||||
format: E.ProofFormat.JSON,
|
||||
uri: null,
|
||||
protocol: E.Fetcher.XMPP,
|
||||
accessRestriction: E.ProofAccessRestriction.SERVER,
|
||||
data: {
|
||||
id: `${match[1]}@${match[2]}`
|
||||
}
|
||||
}
|
||||
},
|
||||
claim: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: []
|
||||
}]
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.JSON
|
||||
},
|
||||
target: [{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: []
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
import { expect, use } from 'chai'
|
||||
import chaiAsPromised from 'chai-as-promised'
|
||||
import chaiMatchPattern from 'chai-match-pattern'
|
||||
use(chaiAsPromised)
|
||||
use(chaiMatchPattern)
|
||||
|
||||
const _ = chaiMatchPattern.getLodashModule()
|
||||
|
||||
import { claimDefinitions } from '../src/index.js'
|
||||
|
||||
const pattern = {
|
||||
serviceprovider: {
|
||||
type: _.isString,
|
||||
name: _.isString,
|
||||
},
|
||||
match: {
|
||||
regularExpression: _.isRegExp,
|
||||
isAmbiguous: _.isBoolean,
|
||||
},
|
||||
profile: {
|
||||
display: _.isString,
|
||||
uri: _.isString,
|
||||
qr: (x) => {
|
||||
return _.isString(x) || _.isNull(x)
|
||||
},
|
||||
},
|
||||
proof: {
|
||||
uri: (x) => {
|
||||
return _.isString(x) || _.isNull(x)
|
||||
},
|
||||
request: {
|
||||
fetcher: _.isString,
|
||||
access: _.isString,
|
||||
format: _.isString,
|
||||
data: _.isObject,
|
||||
},
|
||||
},
|
||||
claim: _.isArray
|
||||
}
|
||||
|
||||
claimDefinitions.list.forEach((claimDefName, i) => {
|
||||
const claimDef = claimDefinitions.data[claimDefName]
|
||||
|
||||
describe(`claimDefinitions.${claimDefName}`, () => {
|
||||
it('should be an object', () => {
|
||||
expect(typeof claimDef).to.equal('object')
|
||||
})
|
||||
it('should have a RegExp instance named "reURI"', () => {
|
||||
expect(claimDef.reURI).to.be.instanceof(RegExp)
|
||||
})
|
||||
it('should have a function named "processURI" (1 argument)', () => {
|
||||
expect(claimDef.processURI).to.be.a('function')
|
||||
expect(claimDef.processURI).to.have.length(1)
|
||||
})
|
||||
it('should have an array named "tests"', () => {
|
||||
expect(claimDef.tests).to.be.instanceof(Array)
|
||||
})
|
||||
|
||||
claimDef.tests.forEach((test, j) => {
|
||||
if (test.shouldMatch) {
|
||||
it(`should match "${test.uri}"`, () => {
|
||||
expect(claimDef.reURI.test(test.uri)).to.be.true
|
||||
})
|
||||
it(`should return a valid object for "${test.uri}"`, async () => {
|
||||
const obj = claimDef.processURI(claimDef.tests[0].uri)
|
||||
expect(obj).to.be.a('object')
|
||||
expect(obj).to.matchPattern(pattern)
|
||||
})
|
||||
} else {
|
||||
it(`should not match "${test.uri}"`, () => {
|
||||
expect(claimDef.reURI.test(test.uri)).to.be.false
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
56
test/serviceProviderDefinitions.test.js
Normal file
56
test/serviceProviderDefinitions.test.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
import { expect, use } from 'chai'
|
||||
import chaiAsPromised from 'chai-as-promised'
|
||||
use(chaiAsPromised)
|
||||
|
||||
import { ServiceProviderDefinitions, ServiceProvider } from '../src/index.js'
|
||||
|
||||
ServiceProviderDefinitions.list.forEach((spDefName, i) => {
|
||||
const spDef = ServiceProviderDefinitions.data[spDefName]
|
||||
|
||||
describe(`ServiceProviderDefinitions.${spDefName}`, () => {
|
||||
it('should be an object', () => {
|
||||
expect(typeof spDef).to.equal('object')
|
||||
})
|
||||
it('should have a RegExp instance named "reURI"', () => {
|
||||
expect(spDef.reURI).to.be.instanceof(RegExp)
|
||||
})
|
||||
it('should have a function named "processURI" (1 argument)', () => {
|
||||
expect(spDef.processURI).to.be.a('function')
|
||||
expect(spDef.processURI).to.have.length(1)
|
||||
})
|
||||
it('should have an array named "tests"', () => {
|
||||
expect(spDef.tests).to.be.instanceof(Array)
|
||||
})
|
||||
|
||||
spDef.tests.forEach((test, j) => {
|
||||
if (test.shouldMatch) {
|
||||
it(`should match "${test.uri}"`, () => {
|
||||
expect(spDef.reURI.test(test.uri)).to.be.true
|
||||
})
|
||||
it(`should return a valid object for "${test.uri}"`, async () => {
|
||||
const obj = spDef.processURI(spDef.tests[0].uri)
|
||||
expect(obj).to.be.instanceOf(ServiceProvider)
|
||||
})
|
||||
} else {
|
||||
it(`should not match "${test.uri}"`, () => {
|
||||
expect(spDef.reURI.test(test.uri)).to.be.false
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue