feat: apply ServiceProvider class, update tests

This commit is contained in:
Yarmo Mackenbach 2023-07-09 11:31:25 +02:00
parent b674f113c7
commit fd8c760689
No known key found for this signature in database
GPG key ID: 3C57D093219103A3
26 changed files with 613 additions and 563 deletions

View file

@ -46,7 +46,6 @@
"@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-node-resolve": "^15.1.0",
"chai": "^4.2.0", "chai": "^4.2.0",
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"chai-match-pattern": "^1.2.0",
"clean-jsdoc-theme": "^3.2.4", "clean-jsdoc-theme": "^3.2.4",
"eslint": "^8.39.0", "eslint": "^8.39.0",
"eslint-config-standard": "^17.0.0", "eslint-config-standard": "^17.0.0",

View file

@ -14,60 +14,65 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(.*)\/?/ export const reURI = /^https:\/\/(.*)\/?/
/** /**
* @function * @function
* @param {string} uri * @param {string} uri
* @returns {ServiceProvider}
*/ */
export function processURI (uri) { export function processURI (uri) {
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'activitypub',
name: 'activitypub' name: 'ActivityPub',
}, homepage: 'https://activitypub.rocks'
match: {
regularExpression: reURI,
isAmbiguous: true
}, },
profile: { profile: {
display: uri, display: uri,
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString().toString(),
uriIsAmbiguous: true
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.ACTIVITYPUB, uri,
access: E.ProofAccess.GENERIC, protocol: E.Fetcher.ACTIVITYPUB,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: uri url: uri
} }
}
},
claim: [
{
format: E.ClaimFormat.FINGERPRINT,
encoding: E.EntityEncodingFormat.PLAIN,
relation: E.ClaimRelation.CONTAINS,
path: ['summary']
}, },
{ response: {
format: E.ClaimFormat.FINGERPRINT, format: E.ProofFormat.JSON
encoding: E.EntityEncodingFormat.PLAIN,
relation: E.ClaimRelation.CONTAINS,
path: ['attachment', 'value']
}, },
{ target: [
format: E.ClaimFormat.FINGERPRINT, {
encoding: E.EntityEncodingFormat.PLAIN, format: E.ClaimFormat.URI,
relation: E.ClaimRelation.CONTAINS, encoding: E.EntityEncodingFormat.PLAIN,
path: ['content'] 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 = { export const functions = {

View file

@ -14,49 +14,54 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(.*)\/u\/(.*)\/?/ export const reURI = /^https:\/\/(.*)\/u\/(.*)\/?/
/** /**
* @function * @function
* @param {string} uri * @param {string} uri
* @returns {ServiceProvider}
*/ */
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'discourse',
name: 'discourse' name: 'Discourse',
}, homepage: 'https://www.discourse.org'
match: {
regularExpression: reURI,
isAmbiguous: true
}, },
profile: { profile: {
display: `${match[2]}@${match[1]}`, display: `${match[2]}@${match[1]}`,
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString().toString(),
uriIsAmbiguous: true
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.HTTP, uri,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://${match[1]}/u/${match[2]}.json`, url: `https://${match[1]}/u/${match[2]}.json`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['user', 'bio_raw'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['user', 'bio_raw']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^dns:([a-zA-Z0-9.\-_]*)(?:\?(.*))?/ export const reURI = /^dns:([a-zA-Z0-9.\-_]*)(?:\?(.*))?/
@ -24,38 +25,40 @@ export const reURI = /^dns:([a-zA-Z0-9.\-_]*)(?:\?(.*))?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'dns',
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]}`,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: null,
request: { request: {
fetcher: E.Fetcher.DNS, uri: null,
access: E.ProofAccess.SERVER, protocol: E.Fetcher.DNS,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.SERVER,
data: { data: {
domain: match[1] domain: match[1]
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['records', 'txt'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['records', 'txt']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'forem',
name: 'forem' name: 'Forem',
}, homepage: 'https://www.forem.com'
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]}`,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString().toString(),
uriIsAmbiguous: true
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.HTTP, uri,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://${match[1]}/api/articles/${match[2]}/${match[3]}`, url: `https://${match[1]}/api/articles/${match[2]}/${match[3]}`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['body_markdown'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['body_markdown']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'forgejo',
name: 'forgejo' name: 'Forgejo',
}, homepage: 'https://forgejo.org'
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]}`,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: true
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.HTTP, uri,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`, url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.EQUALS, format: E.ClaimFormat.URI,
path: ['description'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.EQUALS,
} path: ['description']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'gitea',
name: 'gitea' name: 'Gitea',
}, homepage: 'https://about.gitea.com'
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]}`,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: true
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.HTTP, uri,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`, url: `https://${match[1]}/api/v1/repos/${match[2]}/${match[3]}`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.EQUALS, format: E.ClaimFormat.URI,
path: ['description'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.EQUALS,
} path: ['description']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/ export const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'github',
name: 'github' name: 'GitHub',
}, homepage: 'https://github.com'
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]}`,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.HTTP, uri,
access: E.ProofAccess.GENERIC, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://api.github.com/gists/${match[2]}`, url: `https://api.github.com/gists/${match[2]}`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['files', 'openpgp.md', 'content'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['files', 'openpgp.md', 'content']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(.*)\/(.*)\/gitlab_proof\/?/ export const reURI = /^https:\/\/(.*)\/(.*)\/gitlab_proof\/?/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)\/(.*)\/gitlab_proof\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'gitlab',
name: 'gitlab' name: 'GitLab',
}, homepage: 'https://about.gitlab.com'
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]}`,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: true
},
proof: { proof: {
uri, uri,
request: { request: {
fetcher: E.Fetcher.HTTP, protocol: E.Fetcher.HTTP,
access: E.ProofAccess.GENERIC, accessRestriction: E.ProofAccessRestriction.NONE,
format: E.ProofFormat.JSON,
data: { data: {
url: `https://${match[1]}/api/v4/projects/${match[2]}%2Fgitlab_proof`, url: `https://${match[1]}/api/v4/projects/${match[2]}%2Fgitlab_proof`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.EQUALS, format: E.ClaimFormat.URI,
path: ['description'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.EQUALS,
} path: ['description']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/news\.ycombinator\.com\/user\?id=(.*)\/?/ 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) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'hackernews',
name: 'hackernews' name: 'Hacker News',
}, homepage: 'https://news.ycombinator.com'
match: {
regularExpression: reURI,
isAmbiguous: false
}, },
profile: { profile: {
display: match[1], display: match[1],
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
request: { request: {
fetcher: E.Fetcher.HTTP, uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`, url: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.HTML, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['about'] encoding: E.EntityEncodingFormat.HTML,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['about']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^irc:\/\/(.*)\/([a-zA-Z0-9\-[\]\\`_^{|}]*)/ export const reURI = /^irc:\/\/(.*)\/([a-zA-Z0-9\-[\]\\`_^{|}]*)/
@ -24,39 +25,41 @@ export const reURI = /^irc:\/\/(.*)\/([a-zA-Z0-9\-[\]\\`_^{|}]*)/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'communication', id: 'irc',
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,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: null,
request: { request: {
fetcher: E.Fetcher.IRC, uri: null,
access: E.ProofAccess.SERVER, protocol: E.Fetcher.IRC,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.SERVER,
data: { data: {
domain: match[1], domain: match[1],
nick: match[2] nick: match[2]
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: [] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: []
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/keybase.io\/(.*)\/?/ export const reURI = /^https:\/\/keybase.io\/(.*)\/?/
@ -24,39 +25,41 @@ export const reURI = /^https:\/\/keybase.io\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'web',
name: 'keybase' name: 'keybase'
}, },
match: {
regularExpression: reURI,
isAmbiguous: false
},
profile: { profile: {
display: match[1], display: match[1],
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`,
request: { request: {
fetcher: E.Fetcher.HTTP, uri: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`, url: `https://keybase.io/_/api/1.0/user/lookup.json?username=${match[1]}`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.FINGERPRINT, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.FINGERPRINT,
path: ['them', 'public_keys', 'primary', 'key_fingerprint'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['them', 'public_keys', 'primary', 'key_fingerprint']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/ export const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'liberapay',
name: 'liberapay' name: 'Liberapay',
}, homepage: 'https://liberapay.com'
match: {
regularExpression: reURI,
isAmbiguous: false
}, },
profile: { profile: {
display: match[1], display: match[1],
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.HTTP, uri,
access: E.ProofAccess.GENERIC, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://liberapay.com/${match[1]}/public.json`, url: `https://liberapay.com/${match[1]}/public.json`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['statements', 'content'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['statements', 'content']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/lichess\.org\/@\/(.*)\/?/ export const reURI = /^https:\/\/lichess\.org\/@\/(.*)\/?/
@ -24,39 +25,41 @@ export const reURI = /^https:\/\/lichess\.org\/@\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'web',
name: 'lichess' name: 'lichess'
}, },
match: {
regularExpression: reURI,
isAmbiguous: false
},
profile: { profile: {
display: match[1], display: match[1],
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: `https://lichess.org/api/user/${match[1]}`,
request: { request: {
fetcher: E.Fetcher.HTTP, uri: `https://lichess.org/api/user/${match[1]}`,
access: E.ProofAccess.GENERIC, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://lichess.org/api/user/${match[1]}`, url: `https://lichess.org/api/user/${match[1]}`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.FINGERPRINT, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.FINGERPRINT,
path: ['profile', 'links'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['profile', 'links']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/ export const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'lobsters',
name: 'lobsters' name: 'Lobsters',
}, homepage: 'https://lobste.rs'
match: {
regularExpression: reURI,
isAmbiguous: false
}, },
profile: { profile: {
display: match[1], display: match[1],
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: `https://lobste.rs/u/${match[1]}.json`,
request: { request: {
fetcher: E.Fetcher.HTTP, uri: `https://lobste.rs/u/${match[1]}.json`,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://lobste.rs/u/${match[1]}.json`, url: `https://lobste.rs/u/${match[1]}.json`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['about'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['about']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^matrix:u\/(?:@)?([^@:]*:[^?]*)(\?.*)?/ export const reURI = /^matrix:u\/(?:@)?([^@:]*:[^?]*)(\?.*)?/
@ -40,39 +41,42 @@ export function processURI (uri) {
const profileUrl = `https://matrix.to/#/@${match[1]}` const profileUrl = `https://matrix.to/#/@${match[1]}`
const eventUrl = `https://matrix.to/#/${paramRoomId}/${paramEventId}` const eventUrl = `https://matrix.to/#/${paramRoomId}/${paramEventId}`
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'communication', id: 'matrix',
name: 'matrix' name: 'Matrix',
}, homepage: 'https://matrix.org'
match: {
regularExpression: reURI,
isAmbiguous: false
}, },
profile: { profile: {
display: `@${match[1]}`, display: `@${match[1]}`,
uri: profileUrl, uri: profileUrl,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: eventUrl,
request: { request: {
fetcher: E.Fetcher.MATRIX, uri: eventUrl,
access: E.ProofAccess.GRANTED, protocol: E.Fetcher.MATRIX,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.GRANTED,
data: { data: {
eventId: paramEventId, eventId: paramEventId,
roomId: paramRoomId roomId: paramRoomId
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['content', 'body'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['content', 'body']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/opencollective\.com\/(.*)\/?/ export const reURI = /^https:\/\/opencollective\.com\/(.*)\/?/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/opencollective\.com\/(.*)\/?/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'opencollective',
name: 'opencollective' name: 'Open Collective',
}, homepage: 'https://opencollective.com'
match: {
regularExpression: reURI,
isAmbiguous: false
}, },
profile: { profile: {
display: match[1], display: match[1],
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.GRAPHQL, uri,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.GRAPHQL,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: 'https://api.opencollective.com/graphql/v2', url: 'https://api.opencollective.com/graphql/v2',
query: `{ "query": "query { collective(slug: \\"${match[1]}\\") { longDescription } }" }` query: `{ "query": "query { collective(slug: \\"${match[1]}\\") { longDescription } }" }`
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['data', 'collective', 'longDescription'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['data', 'collective', 'longDescription']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(.*)/ export const reURI = /^https:\/\/(.*)/
@ -24,39 +25,42 @@ export const reURI = /^https:\/\/(.*)/
export function processURI (uri) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'owncast',
name: 'owncast' name: 'Owncast',
}, homepage: 'https://owncast.online'
match: {
regularExpression: reURI,
isAmbiguous: true
}, },
profile: { profile: {
display: match[1], display: match[1],
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: true
},
proof: { proof: {
uri: `${uri}/api/config`,
request: { request: {
fetcher: E.Fetcher.HTTP, uri: `${uri}/api/config`,
access: E.ProofAccess.GENERIC, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `${uri}/api/config`, url: `${uri}/api/config`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.FINGERPRINT, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.FINGERPRINT,
path: ['socialHandles', 'url'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['socialHandles', 'url']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(?:www\.)?reddit\.com\/user\/(.*)\/comments\/(.*)\/(.*)\/?/ 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) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'reddit',
name: 'reddit' name: 'Reddit',
}, homepage: 'https://reddit.com'
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]}`,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.HTTP, uri,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://www.reddit.com/user/${match[1]}/comments/${match[2]}.json`, url: `https://www.reddit.com/user/${match[1]}/comments/${match[2]}.json`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['data', 'children', 'data', 'selftext'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['data', 'children', 'data', 'selftext']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' 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+)/ export const reURI = /^https:\/\/(.*(?:askubuntu|mathoverflow|serverfault|stackapps|stackoverflow|superuser)|.+\.stackexchange)\.com\/users\/(\d+)/
const reStackExchange = /\.stackexchange$/ const reStackExchange = /\.stackexchange$/
@ -26,39 +27,42 @@ export function processURI (uri) {
const [, domain, id] = uri.match(reURI) const [, domain, id] = uri.match(reURI)
const site = domain.replace(reStackExchange, '') const site = domain.replace(reStackExchange, '')
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'stackexchange',
name: 'stackexchange' name: 'Stack Exchange',
}, homepage: 'https://stackexchange.com'
match: {
regularExpression: reURI,
isAmbiguous: false
}, },
profile: { profile: {
display: `${id}@${site}`, display: `${id}@${site}`,
uri, uri,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: `https://${domain}.com/users/${id}?tab=profile`,
request: { request: {
fetcher: E.Fetcher.HTTP, uri: `https://${domain}.com/users/${id}?tab=profile`,
access: E.ProofAccess.GENERIC, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NONE,
data: { data: {
url: `https://api.stackexchange.com/2.3/users/${id}?site=${site}&filter=!AH)b5JqVyImf`, url: `https://api.stackexchange.com/2.3/users/${id}?site=${site}&filter=!AH)b5JqVyImf`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['items', 'about_me'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['items', 'about_me']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' 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})/ 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) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'communication', id: 'telegram',
name: 'telegram' name: 'Telegram',
}, homepage: 'https://telegram.org'
match: {
regularExpression: reURI,
isAmbiguous: false
}, },
profile: { profile: {
display: `@${match[1]}`, display: `@${match[1]}`,
uri: `https://t.me/${match[1]}`, uri: `https://t.me/${match[1]}`,
qr: `https://t.me/${match[1]}` qr: `https://t.me/${match[1]}`
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: `https://t.me/${match[2]}`,
request: { request: {
fetcher: E.Fetcher.TELEGRAM, uri: `https://t.me/${match[2]}`,
access: E.ProofAccess.GRANTED, protocol: E.Fetcher.TELEGRAM,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.GRANTED,
data: { data: {
user: match[1], user: match[1],
chat: match[2] chat: match[2]
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.EQUALS, format: E.ClaimFormat.URI,
path: ['text'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.EQUALS,
} path: ['text']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/twitter\.com\/(.*)\/status\/([0-9]*)(?:\?.*)?/ export const reURI = /^https:\/\/twitter\.com\/(.*)\/status\/([0-9]*)(?:\?.*)?/
@ -28,40 +29,43 @@ export function processURI (uri) {
urlsp.set('url', match[0]) urlsp.set('url', match[0])
urlsp.set('omit_script', '1') urlsp.set('omit_script', '1')
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'web', id: 'twitter',
name: 'twitter' name: 'Twitter',
}, homepage: 'https://twitter.com'
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]}`,
qr: null qr: null
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri,
request: { request: {
fetcher: E.Fetcher.HTTP, uri,
access: E.ProofAccess.NOCORS, protocol: E.Fetcher.HTTP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
// Returns an oembed json object with the tweet content in html form // Returns an oembed json object with the tweet content in html form
url: `https://publish.twitter.com/oembed?${urlsp}`, url: `https://publish.twitter.com/oembed?${urlsp}`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: ['html'] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: ['html']
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^xmpp:([a-zA-Z0-9.\-_]*)@([a-zA-Z0-9.\-_]*)(?:\?(.*))?/ 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) { export function processURI (uri) {
const match = uri.match(reURI) const match = uri.match(reURI)
return { return new ServiceProvider({
serviceprovider: { about: {
type: 'communication', id: 'xmpp',
name: 'xmpp' name: 'XMPP',
}, homepage: 'https://xmpp.org'
match: {
regularExpression: reURI,
isAmbiguous: false
}, },
profile: { profile: {
display: `${match[1]}@${match[2]}`, display: `${match[1]}@${match[2]}`,
uri, uri,
qr: uri qr: uri
}, },
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: { proof: {
uri: null,
request: { request: {
fetcher: E.Fetcher.XMPP, uri: null,
access: E.ProofAccess.SERVER, protocol: E.Fetcher.XMPP,
format: E.ProofFormat.JSON, accessRestriction: E.ProofAccessRestriction.SERVER,
data: { data: {
id: `${match[1]}@${match[2]}` id: `${match[1]}@${match[2]}`
} }
} },
}, response: {
claim: [{ format: E.ProofFormat.JSON
format: E.ClaimFormat.URI, },
encoding: E.EntityEncodingFormat.PLAIN, target: [{
relation: E.ClaimRelation.CONTAINS, format: E.ClaimFormat.URI,
path: [] encoding: E.EntityEncodingFormat.PLAIN,
}] relation: E.ClaimRelation.CONTAINS,
} path: []
}]
}
})
} }
export const tests = [ export const tests = [

View file

@ -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
})
}
})
})
})

View 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
})
}
})
})
})